. */ declare(strict_types=1); namespace Fisharebest\Webtrees\CommonMark; use Fisharebest\Webtrees\Tree; use League\CommonMark\Environment\EnvironmentBuilderInterface; use League\CommonMark\Extension\ExtensionInterface; /** * Convert XREFs within markdown text to links */ class XrefExtension implements ExtensionInterface { private Tree $tree; /** * MarkdownXrefParser constructor. * * @param Tree $tree Match XREFs in this tree */ public function __construct(Tree $tree) { $this->tree = $tree; } /** * @param EnvironmentBuilderInterface $environment */ public function register(EnvironmentBuilderInterface $environment): void { $environment ->addInlineParser(new XrefParser($this->tree)) ->addRenderer(XrefNode::class, new XrefRenderer); } }