` / `` 里,浏览器会提前闭合外层,
* 把 sidenote 的结构切断、吞掉后面的正文。
*/
public function inlineSafe(Document $document, RenderContext $ctx): string
{
$previous = $this->inlineOnly;
$this->inlineOnly = true;
try {
if ($document->inline) {
return $this->document($document, $ctx);
}
$blocks = array_map(fn (Node $node) => $this->nodes([$node], $ctx), $document->nodes);
$html = implode(' ['.$note['sn'].'] '.$note['content'].'
', array_filter($blocks, fn (string $html) => $html !== ''));
return $html === '' ? '' : "{$html}";
} finally {
$this->inlineOnly = $previous;
}
}
/**
* @param list
';
}
$class = 'md-'.$element->tag.(isset($element->attrs['class']) ? ' '.e($element->attrs['class'], false) : '');
return ''.$this->nodes($element->children, $ctx).'';
}
if (in_array($element->tag, [...HtmlPolicy::VOID, 'input'], true)) {
return "<{$element->tag}{$attrs} />";
}
return "<{$element->tag}{$attrs}>".$this->nodes($element->children, $ctx)."{$element->tag}>";
}
/**
* 文末的脚注列表(footnote 选项打开时)。
*/
public function footnotes(RenderContext $ctx): string
{
if ($ctx->footnotes === []) {
return '';
}
$html = 'endnote
';
foreach ($ctx->footnotes as $note) {
$html .= '