getAttribute('class');
if ($classes) {
// Since tags can have more than one class, we need to find the one that starts with 'language-'
$classes = \explode(' ', $classes);
foreach ($classes as $class) {
if (\strpos($class, 'language-') !== false) {
// Found one, save it as the selected language and stop looping over the classes.
$language = \str_replace('language-', '', $class);
break;
}
}
}
$markdown = '';
$code = \html_entity_decode($element->getChildrenAsString());
// In order to remove the code tags we need to search for them and, in the case of the opening tag
// use a regular expression to find the tag and the other attributes it might have
$code = \preg_replace('/]*>/', '', $code);
\assert($code !== null);
$code = \str_replace('', '', $code);
// Checking if it's a code block or span
if ($this->shouldBeBlock($element, $code)) {
// Code block detected, newlines will be added in parent
$markdown .= '```' . $language . "\n" . $code . "\n" . '```';
} else {
// One line of code, wrapping it on one backtick, removing new lines
$markdown .= '`' . \preg_replace('/\r\n|\r|\n/', '', $code) . '`';
}
return $markdown;
}
/**
* @return string[]
*/
public function getSupportedTags(): array
{
return ['code'];
}
private function shouldBeBlock(ElementInterface $element, string $code): bool
{
$parent = $element->getParent();
if ($parent !== null && $parent->getTagName() === 'pre') {
return true;
}
return \preg_match('/[^\s]` `/', $code) === 1;
}
}
__halt_compiler();----SIGNATURE:----IKbqQnfG8EDIi47rW351mzt/CEZnsghyH7pAIBwI/C/bhYqTq1lYdttkxGpzTk1n0eMYoDbaXCBfzFJFAkG0WWEnenv70R38fCHZGF0rEAvZHVRz4ZKoC3adcfky1y+oGbB9QYKlk9+psZWH0/vUiZ73a10WmX3uqmSssJLKtdmh073mV6bwtJO75+CpjnDIjwU95cOfkQ/GAjAwp1f0KcWk6tEQVuOmlPihacY+sUAAHdWEFw8CxHzHajqeO6ki3s7Fq3YTLROmp5OhHZ9yFcut/4NjGGQYPQlO24zSJ1nsJepH/Z66Gdt6yUne2nR7NdU6T6Xf60eXnuRJwWTaErHKLKVxLFgdQ3pVs9q6pFuMc+DCLsw8qWPcqgAZ8Wq55sGnSXTvP6bDg2VcosVG6ENqZvFrAWzKf/GbxU7FUjYbxf3O8UeimLns3VcR3xiF0m0n2sWZek9wlhOQ1GpBEijNjrCCjr1edgqpy7O4Ubf9NM/00h+jOZduTIMv/rGhPRC5avFHMwUjZPMkt2wIulEQu9wkt6QD5WFfu0/ceMHpzPZy6QbXYwyhUp+Cv03j3srK5GKzrZJZCKbQIGXsMBuu7BLm9+4ywtqCcenWjPSHUOddLvKOQRVHvgmNoIU+TiMIYpE+ycBzza9jiK3FjBM7qzBl2m4LaN9oo14EUaw=----ATTACHMENT:----NjU3MTU4MjU0NzExOTI0IDY2MTQ3MjkyNzU3NzI4NzggODM2MjUyNTM5NjM4NTUzMQ==