question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Myst handles HTML anchors in headings in an unexpected way

See original GitHub issue

Describe the bug

context We have documents which have a structure very similar to the C++ Core Guidelines and use HTML anchors in heading the very same way as they do:

## <a name="S-const"></a>Con: Constants and immutability

The documents are from an external source and we cannot change them.

expectation

Linkage in github markdown viewer works:

* [Con: Constants and immutability](#S-const)
* the above produces a valid href to the section heading

Github also produces the “slugs” for a heading anchor, and ignores the HTML tags for it:

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#con-constants-and-immutability

This is what I expect myst-parser to do as well.

Btw., both links work in full URLs, also the custom one: https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#S-const

bug

Instead, myst parser includes the HTML code in the heading anchors slug:

cpp_coding_guidelines.html#a-name-con-a-constants-and-immutability

The manually added anchor slugs also do not work and these links produce nasty warnings (which is related to #564, I assume):

cpp_coding_guidelines.md:2368: warning: 'myst' reference target not found: #Rf-single

problem

This is a problem because it breaks all links and spams lots of warnings during sphinx-build.

Reproduce the bug

  1. Download the cpp_core_guidelines.md and create a little sphinx project around it
  2. generate the HTML docs

List your environment

Sphinx==5.0.2
myst-parser==0.18.0
sphinx-rtd-theme==1.0.0
sphinx_design==0.2.0
mdit-py-plugins==0.3.0

Issue Analytics

  • State:open
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
chrisjsewellcommented, Aug 23, 2022
0reactions
ravindk89commented, Sep 1, 2022

So we’re having a similar sort of issue, where we have docs that are built for GitHub rendering, and it seems to just not enjoy being pulled through Myst.

You can see an example of the issue here

Rendering w/ myst-parser 0.18.0 , I noticed two things:

  • the manual <a name="make_bucket"></a> doesn’t get rendered as an anchor on the page at all - MyST seems to drop it
  • Setting the myst_heading_anchors here would normally work, except for the way we are using those headers (full method descriptions)

Possible answer here is to redo all our reference docs and not have the full method as part of the heading. Which…we can probably do.

But if MyST did render those anchors, then I think the linking might work.

As another issue, I cannot figure out how to suppress the reference warnings in the meantime - we now have hundreds of them. I tried adding


suppress_warnings = [ 
   'myst.reference',
   'myst.target',
   'myst.*',
   'myst'
]

But none of those seemed to take. Any ideas there?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Syntax Extensions - MyST-Parser
Auto-generated header anchors# ... The MyST Parser can automatically generate label “slugs” for header anchors so that you can reference them from markdown...
Read more >
Links in HTML documents - W3C
12 Links. Contents. Introduction to links and anchors. Visiting a linked resource; Other link relationships; Specifying anchors and links; Link titles ...
Read more >
Link to a named anchor - Esri Community
Is there a way you can change the way Open Data handles anchors? The problem we are encountering is that the title bar...
Read more >
Obsidian For Mac - Trailer Eksperten
Obsidian is an electron-based note-taking app that treats links as first class ... removal Not clear what's the right way to remove an...
Read more >
Printable Starfinder Character Sheet - Boutique 17
Sorry if this has already been asked but I can't find it in the forum - is there a way to print character...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found