. */ declare(strict_types=1); namespace Fisharebest\Webtrees\CommonMark; use League\CommonMark\Node\Node; use League\CommonMark\Renderer\ChildNodeRendererInterface; use League\CommonMark\Renderer\NodeRendererInterface; use League\CommonMark\Util\HtmlElement; use Stringable; /** * Convert XREFs within markdown text to links */ class XrefRenderer implements NodeRendererInterface { /** * @param Node $node * @param ChildNodeRendererInterface $childRenderer * * @return Stringable */ public function render(Node $node, ChildNodeRendererInterface $childRenderer): Stringable { XrefNode::assertInstanceOf($node); /** @var XrefNode $node */ $href = $node->record()->url(); $html = $node->record()->fullName(); return new HtmlElement('a', ['href' => $href], $html); } }