src/Parser.php
/**
     * Parses some HTML for headings and adds anchor links to them.
     *
     * @param string $html The HTML to parse
     * @param string|string[] $tags The tags to add anchor links to.
     * @return string The parsed HTML.
     */
Parses some HTML for headings and adds anchor links to them.
@param string $html The HTML to parse
@param string|string[] $tags The tags to add anchor links to.
@return string The parsed HTML.
Parses some HTML for headings and adds anchor links to them . @param string $html The HTML to parse @param string|string [] $tags The tags to add anchor links to . @return string The parsed HTML .
public function parseHtml($html, $tags = 'h1,h2,h3'): string
    {
        if (is_string($tags)) {
            $tags = StringHelper::split($tags);
        }
        return preg_replace_callback('/<('.implode('|', $tags).')([^>]*)>(.+?)<\/\1>/', [$this, '_addAnchorToTagMatch'], $html);
    }
public function parseHtml ( $ html , $ tags = 'h1,h2,h3' ) : string { if ( is_string ( $ tags ) ) { $ tags = StringHelper :: split ( $ tags ) ; } return preg_replace_callback ( '/<(' . implode ( '|' , $ tags ) . ')([^>]*)>(.+?)<\/\1>/' , [ $ this , '_addAnchorToTagMatch' ] , $ html ) ; }
Parses some HTML for headings and adds anchor links to them.
Parses some HTML for headings and adds anchor links to them .