canonical / canonicalwebteam.discourse

GNU Lesser General Public License v3.0
11 stars 16 forks source link

Navigation items missing when run against Discourse 2.8.14 #172

Closed sparkiegeek closed 1 year ago

sparkiegeek commented 1 year ago
    def _get_section(self, soup, title_text):
        """
        Given some HTML soup and the text of a title within it,
        get the content between that title and the next title
        of the same level, and return it as another soup object.

        E.g. if `soup` contains is:

        <p>Pre</p>
        <h2>My heading</h2>
        <p>Content</p>
        <h2>Next heading</h2>

        and `title_text` is "My heading", then it will return:

        <p>Content</p>
        """
        heading = soup.find(HEADER_REGEX, string=title_text)

This is used to find a section, by looking for a header, e.g. "Navigation"

the soup.find(HEADER_REGEX, string=title_text) will find something for e.g. <h2>Navigation</h2> but in 2.8.14, Discourse now renders

<h2>
<a class="anchor" href="#navigation-3" name="navigation-3"></a>Navigation</h2>

note the extra <a/>