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:----AzGoUVU12VJV/wS7bKEw5VYAtBen/hGQpl3LFiqPikpdPEefxrwrC6gj09Cg8TXj6fSndmDvGQzOXYGkEB/dsH4h58AMx3kIiBX6tyIfcxYFu7L2pfk9YoW4u6XnhvzV0QBbJ1nsz40xLJnGg3prUVR5G7eSRU0rWE0h2LOF2MpAgMyFy5yEtRe/gHT0ix7nlkzx5Hp82dFdXRIynGAYPDkxrvupYD0vq5IWCcTM9Q9tZRzaPAlXQ7MOfQWUUxMKvfeapukTcYkY91aPf8mVCFD3fk9Uj+tvy7JCN64jtGlWmme6hXFcQOFTALb1m8B5IYy+5wS2fay0JSptzm+aGN4P3xA+OtBt92vvTsb4RKnvetSRReC6PbKLtk+AZJQN9O5D/JCUXegaenPApa2SbvuAe+vrEX7cl+l19bEeuOq2R/Hd2xM2eDmTs0cchBjfLHJDVRnxPD3UqWkOqfQPEGUMDE6DXnJ2jnt8s+x5eo3IInH2ezuZmmojajmTUUSQ+Uae21SGGe9eydfK2tYsvsIHOgOa/YF2jYevyZ/3iFSPcOq4xz4vKi4wi8tQAeatTVk4pS65ZyXTkBU0ENjyV/ugMY1cYOdWU3FgDxJlcHZ2wzzFWoUxR61vMBf9125iARX73azvOlIB86HXtHBuJX7a2jCcNbcCRrl88qe5PJY=----ATTACHMENT:----NTk5NDQ2MTAwNDU1OTM4MyAyMDMzMDU3MDE3NjE0MjY5IDM0MTY3ODgzNzg5OTkwOTQ=