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:----TtYCRGbTa+xB1YLzXb1tsK2bQNvsaxO9VYSR1Il+NgQKFtThBtxvr8g/HwyfZQI6VyWXcjtQlGKvk5CXqkC+3lcfWGrfsgktYtYWFpNOQWFb2opvJtnCBiUltzaTNK/gy6eKlcUlQzFdZUcwTxE/qKK14Q4VSZCJ70D6fd1mEz0QOU+AB0DStiolJqUljWMdN2l/SLS5w5PtQwHtYzQB/YiJpwF+K0hqrIGUfZzk5QLdyF1Y1t/HEZf0F5jTCDhxujQoBeJuOsK3fIIc8l/XcmSHJURn0CBpAnsXv13+PvJkGy9rnFOsem8LP4ZUMlkt9O7gCo/PlUKpVDgzi5ppMxSkW7NC87na686bWamoFaSCXhHqqrbAfvIvCogU+xYCyjSRQ3KH+TBPXZ/Zd5BCHO2aCjP225sJoKZsPmr5SXF3SoaVXt38WHYuqdplbN8jGrI9RAXPmAfijUunMk8rd30/jkZP6la376mBv0pmF+rwnpCwfVM9ZelswxaRrShJ3nMMNC6T3IdtFIWkWraXzk1Kk4eWsT2j0St46f2xCtaQ+NRNsWudYgwfqnzfj9Vth9G3K3XjSUEysO6b0Ad4E96UhZOJxaanSfc2hUI43+pD1GcqT9GbIVwn3COeGsCco/0MDq+NT9I5hbUV13Efavu3cFtacPh0jcXyuDw4IZY=----ATTACHMENT:----MTcwMDkzMzEzOTQyNDk5NiA5MTAxNzg3MTgyNTgyODkzIDQ2OTg2OTk0MDE3NTUxNDk=