Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Less/greater than signs in headings appear as &lt/&gt in TOC #931

Closed

Description

@p-ouellette

screen

That's an mkdocs site with the readthedocs theme. It's using git master HEAD of mkdocs and markdown. The issue was caused by 74c0166. I haven't tested this using just markdown so it might be related to mkdocs.

Activity

  1. facelessuser commented on Apr 5, 2020

    @facelessuser
    Collaborator

    What version of Markdown are you using? I'm not seeing this in the current version.

    chrome_pMDuMrFSF6

  2. waylan commented on Apr 5, 2020

    @waylan
    Member

    I just tested the readthedocs theme with the latest on master and do not see the issue.

    Screen Shot 2020-04-05 at 5 08 23 PM

    Note that in the picture you can see the Markdown text, the TOC and the main body. All appear correct.

  3. p-ouellette commented on Apr 5, 2020

    @p-ouellette
    Author

    Reproduced using just markdown 3.2.1:

    echo -e "[TOC]\n# `<test>`" | python -m markdown -x toc
    <div class="toc">
    <ul>
    <li><a href="#lttestgt">&amp;lt;test&amp;gt;</a></li>
    </ul>
    </div>
    <h1 id="lttestgt"><code>&lt;test&gt;</code></h1>

    With markdown 3.2 the above command outputs:

    <div class="toc">
    <ul>
    <li><a href="#lttestgt">&lt;test&gt;</a></li>
    </ul>
    </div>
    <h1 id="lttestgt"><code>&lt;test&gt;</code></h1>
  4. waylan commented on Apr 5, 2020

    @waylan
    Member

    Ah, I missed that that was a code span. It would appear that code spans were not being considered in this comment. We do need the smart escape after all.

    Sent with GitHawk

  5. added
    bug
    confirmed
    extension
    on Apr 5, 2020
  6. facelessuser commented on Apr 5, 2020

    @facelessuser
    Collaborator

    Okay, I guess my results were different as I'm using pymdownx.inlinehilite. It uses the htmlstash instead of AtomicString. I guess there is a difference in how those get handled...

  7. facelessuser commented on Apr 5, 2020

    @facelessuser
    Collaborator

    I guess htmlstash must work while AtomicString does not due to the fact that the htmlstash placeholders don't get cleaned up until after the toc is generated. I imagine it just duplicates the placeholder, and the placeholders get replaced with the content post toc.

    So yeah, we generally need a solution when handling AtomicStrings. I assume we can just detect AtomicString types and not escape them? I don't think we specifically need a smart escape.

  8. facelessuser commented on Apr 5, 2020

    @facelessuser
    Collaborator

    I'll take a stab at it.

  9. facelessuser commented on Apr 5, 2020

    @facelessuser
    Collaborator

    Yeah, I think all we really need is something like this:

    def get_name(el):
        """Get title name."""
    
        text = []
        for c in el.itertext():
            if isinstance(c, AtomicString):
                text.append(html.unescape(c))
            else:
                text.append(c)
        name = ''.join(text).strip()
        return name

    This prevents us from getting weird ids such as lttestgt Which we previously got from `<text>`. And it returns a string that we can handle sanely. It just unescapes Atomic strings with html.unescape which uses html5 rules for entities (py34+).

  10. added a commit that references this issue on Apr 6, 2020
    ada40c6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugconfirmedextension

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions