3 || strspn(ltrim($line), $fence[0]) < $mw || !str_ends_with(rtrim($line), $fence[0]) ) { if ($indent > 0 && $leadingSpaces > 0) { if ($leadingSpaces < $indent) { $line = ltrim($line); } else { $line = substr($line, $indent); } } $content[] = $line; } else { break; } } $block = [ 'math', 'content' => implode("\n", $content), ]; return [$block, $i]; } /** * Renders a math expression. */ protected function renderMath($block): string { return '' . $this->escapeHtmlEntities( $block['content'], ENT_COMPAT | ENT_SUBSTITUTE ) . ($block['content'] === '' ? '' : "\n" ) . "\n"; } abstract protected function escapeHtmlEntities($text, $flags = 0); }