docs: fix sidebar scaffold on section-less pages#4177
Open
grandixximo wants to merge 1 commit into
Open
Conversation
Body-class regex required class right after <body>, but pages with a title anchor emit <body id=... class=...>, so toc2 toc-left was never added. Section-less pages (pci-parallel-port, mpg) lost the left margin and TOC arrows. Match attrs before class.
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.
Problem
The example pages
examples/pci-parallel-port.htmlandexamples/mpg.htmlrender without the left sidebar margin (page content overlaps the navigation tree).Cause
These pages have no
==sections, so asciidoctor emits no left-TOC and notoc2 toc-leftbody classes.lang_switcher_postprocess.pyscaffolds the sidebar for such pages, but its body-class rewrite used the regex<body class="...">, which requiresclassimmediately after<body. Pages with a title anchor ([[cha:pci-parallel-port]]) emit<body id="cha:pci-parallel-port" class="book">, so the regex never matched andtoc2 toc-leftwas never added. The sidebardivstill got inserted (it keys off the<h1>), so the nav showed butpadding-left:320pxwas never applied, leaving the overlap.Section-ful pages get
toc2 toc-leftstraight from asciidoctor, which masked the bug.Fix
Match optional attributes before
classin the body tag.Verification
Built
make htmldocslocally and rendered both pages: body is nowbook toc2 toc-left,padding-leftis 320px, content clears the sidebar.