Sub headings not getting direct linkified
See original GitHub issueI noticed these two <h2>
tags aren’t being highlighted and turned into a direct link like they should be. This is happening on the Using CSS Variables page.
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (6 by maintainers)
Top Results From Across the Web
MS Word - Built in Headings not working - Microsoft Community
I am having a problem with my MS word, I am currently trying to format one of my reports for varsity so that...
Read more >headings not showing up in navigation pane in word - YouTube
Learn how to add title in the navigation bar which is very helpful in navigating to different parts of the word documents.
Read more >Syntax Extensions - MyST-Parser
This extension requires that linkify-it-py is installed. Either directly; pip install linkify-it-py or via pip install myst-parser[linkify] .
Read more >Microsoft Word - Adding Headings to a Document
One of the key ways to make Microsoft Word documents accessible is to use Word's built-in heading styles to format the document.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What’s happening here is that we have HTML looks like this:
What the builder does is that it first breaks it up into sections by looping over the “root level” elements. The first and section section is:
and
But for the next section, yes it starts with a lovely
<h2>
but here’s more than one withinSo it dares not to extract split it by
<h2>
. In fact, to extract the title, it uses:But what happens here on this page is that
h2s.length === 2
so it can’t confidently proceed.The solution is two-fold. First, we need to correct the HTML. That second
<h2>Inheritance of custom properties</h2>
should be moved and appear outside the<div id="sample1">
so it’s at the root level instead. Secondly, because there’s a lot of pages that are like this. We can do a little bit better. So we can change theid
andtitle
extraction to:That, and log it as a flaw (not fixable) where a writer has to go in and move the
<h2>
to the root level.So what’s probably happening is that some invalid HTML gets forgiven by
cheerio
and when serialized back to a HTML string, it adds that<div>
lets see what’s going on.