app/Filter.php
public static function expandUrls(string $text, Tree $tree): string
    {
        // If it looks like a URL, turn it into a markdown autolink.
        $text = preg_replace('/' . addcslashes(self::URL_REGEX, '/') . '/', '<$0>', $text);

        // Create a minimal commonmark processor - just add support for autolinks.
        $environment = new Environment();
        $environment->mergeConfig([
            'renderer'           => [
                'block_separator' => "\n",
                'inner_separator' => "\n",
                'soft_break'      => "\n",
            ],
            'html_input'         => Environment::HTML_INPUT_ESCAPE,
            'allow_unsafe_links' => true,
        ]);

        $environment
            ->addBlockRenderer(Document::class, new DocumentRenderer())
            ->addBlockRenderer(Paragraph::class, new ParagraphRenderer())
            ->addInlineRenderer(Text::class, new TextRenderer())
            ->addInlineRenderer(Link::class, new LinkRenderer())
            ->addInlineParser(new AutolinkParser());

        $environment->addExtension(new CensusTableExtension());
        $environment->addExtension(new XrefExtension($tree));

        $converter = new Converter(new DocParser($environment), new HtmlRenderer($environment));

        try {
            return $converter->convertToHtml($text);
        } catch (Throwable $ex) {
            // See issue #1824
            return $text;
        }
    }
public static function expandUrls(string $text, Tree $tree): string
    {
        // If it looks like a URL, turn it into a markdown autolink.
        $text = preg_replace('/' . addcslashes(self::URL_REGEX, '/') . '/', '<$0>', $text);

        // Create a minimal commonmark processor - just add support for autolinks.
        $environment = new Environment();
        $environment->mergeConfig([
            'renderer'           => [
                'block_separator' => "\n",
                'inner_separator' => "\n",
                'soft_break'      => "\n",
            ],
            'html_input'         => Environment::HTML_INPUT_ESCAPE,
            'allow_unsafe_links' => true,
        ]);

        $environment
            ->addBlockRenderer(Document::class, new DocumentRenderer())
            ->addBlockRenderer(Paragraph::class, new ParagraphRenderer())
            ->addInlineRenderer(Text::class, new TextRenderer())
            ->addInlineRenderer(Link::class, new LinkRenderer())
            ->addInlineParser(new AutolinkParser());

        $environment->addExtension(new CensusTableExtension());
        $environment->addExtension(new XrefExtension($tree));

        $converter = new Converter(new DocParser($environment), new HtmlRenderer($environment));

        try {
            return $converter->convertToHtml($text);
        } catch (Throwable $ex) {
            // See issue #1824
            return $text;
        }
    }
public static function expandUrls ( string $ text , Tree $ tree ) : string { // If it looks like a URL, turn it into a markdown autolink. $ text = preg_replace ( '/' . addcslashes ( self :: URL_REGEX , '/' ) . '/' , '<$0>' , $ text ) ; // Create a minimal commonmark processor - just add support for autolinks. $ environment = new Environment ( ) ; $ environment -> mergeConfig ( [ 'renderer' => [ 'block_separator' => "\n" , 'inner_separator' => "\n" , 'soft_break' => "\n" , ] , 'html_input' => Environment :: HTML_INPUT_ESCAPE , 'allow_unsafe_links' => true , ] ) ; $ environment -> addBlockRenderer ( Document :: class , new DocumentRenderer ( ) ) -> addBlockRenderer ( Paragraph :: class , new ParagraphRenderer ( ) ) -> addInlineRenderer ( Text :: class , new TextRenderer ( ) ) -> addInlineRenderer ( Link :: class , new LinkRenderer ( ) ) -> addInlineParser ( new AutolinkParser ( ) ) ; $ environment -> addExtension ( new CensusTableExtension ( ) ) ; $ environment -> addExtension ( new XrefExtension ( $ tree ) ) ; $ converter = new Converter ( new DocParser ( $ environment ) , new HtmlRenderer ( $ environment ) ) ; try { return $ converter -> convertToHtml ( $ text ) ; } catch ( Throwable $ ex ) { // See issue #1824 return $ text ; } }
Format a block of text, expanding URLs and XREFs.

@param string $text
@param Tree   $tree

@return string
Format a block of text expanding URLs and XREFs .