public function generateHeaderId(string $headerText): string
    {

        // $headerText is completely raw markdown input. We need to strip it
        // from all markup, because we are only interested in the actual 'text'
        // part of it.

        // Step 1: Remove html tags.
        $result = strip_tags($headerText);

        // Step 2: Remove all markdown links. To do this, we simply remove
        // everything between ( and ) if the ( occurs right after a ].
        $result = preg_replace('%
            (?<= \\]) # Look behind to find ]
            (
                \\(     # match (
                [^\\)]* # match everything except )
                \\)     # match )
            )

            %x', '', $result);

        // Step 3: Convert spaces to dashes, and remove unwanted special
        // characters.
        $map = [
            ' ' => '-',
            '(' => '',
            ')' => '',
            '[' => '',
            ']' => '',
        ];
        return rawurlencode(strtolower(
            strtr($result, $map)
        ));
    }
public function generateHeaderId(string $headerText): string
    {

        // $headerText is completely raw markdown input. We need to strip it
        // from all markup, because we are only interested in the actual 'text'
        // part of it.

        // Step 1: Remove html tags.
        $result = strip_tags($headerText);

        // Step 2: Remove all markdown links. To do this, we simply remove
        // everything between ( and ) if the ( occurs right after a ].
        $result = preg_replace('%
            (?<= \\]) # Look behind to find ]
            (
                \\(     # match (
                [^\\)]* # match everything except )
                \\)     # match )
            )

            %x', '', $result);

        // Step 3: Convert spaces to dashes, and remove unwanted special
        // characters.
        $map = [
            ' ' => '-',
            '(' => '',
            ')' => '',
            '[' => '',
            ']' => '',
        ];
        return rawurlencode(strtolower(
            strtr($result, $map)
        ));
    }
public function generateHeaderId ( string $ headerText ) : string { // $headerText is completely raw markdown input. We need to strip it // from all markup, because we are only interested in the actual 'text' // part of it. // Step 1: Remove html tags. $ result = strip_tags ( $ headerText ) ; // Step 2: Remove all markdown links. To do this, we simply remove // everything between ( and ) if the ( occurs right after a ]. $ result = preg_replace ( '%
            (?<= \\]) # Look behind to find ]
            (
                \\(     # match (
                [^\\)]* # match everything except )
                \\)     # match )
            )

            %x' , '' , $ result ) ; // Step 3: Convert spaces to dashes, and remove unwanted special // characters. $ map = [ ' ' => '-' , '(' => '' , ')' => '' , '[' => '' , ']' => '' , ] ; return rawurlencode ( strtolower ( strtr ( $ result , $ map ) ) ) ; }
This method is called to generate an id="" attribute for a header.

@internal

@param string $headerText raw markdown input for the header name
This method is called to generate an id = attribute for a header .