fix(remote): keep page markup out of the first TOC entry - #170
Merged
Merged
Conversation
On GitHub file pages the first heading of a document shares a line with the page markup, including the file tree <h2>. The heading grep started its match at that <h2>, so the first entry got the page HTML, a level-2 indent and a link to the repository tree. Match only <h1>..<h6> tags that carry class="heading-element", and re-enable the remote tests that cover this case. Fixes #166
This was referenced Sep 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #166: for a GitHub file URL whose document starts with a heading, the first
TOC entry contained the page HTML, had a level-2 indent and linked to the repository
tree.
gh-md-toc: on file pages the first heading shares a line with the page markup,including the file tree
<h2>. The heading grep started its match at that<h2>.The pattern now matches only
<h1>..<h6>tags that carryclass="heading-element". The same pattern works withgrep -Eand withpcregrepon OS/390.tests/tests.bats: re-enabled the three commented-out remote tests, assertionsunchanged:
TOC for remote README.md,TOC for mixed README.md (remote/local),TOC for remote non-english chars (remote load), #6, #10.Testing
nodeenvwiki page is the same as onmaster.make lintreports the same warnings as onmaster(make lint fails on shellcheck style and info warnings #167), no new ones.The re-enabled tests fetch pages from github.com, so they depend on network access
and on GitHub page markup.