Skip to content

docs: fix sidebar scaffold on section-less pages#4177

Open
grandixximo wants to merge 1 commit into
LinuxCNC:masterfrom
grandixximo:fix/docs-toc-margin
Open

docs: fix sidebar scaffold on section-less pages#4177
grandixximo wants to merge 1 commit into
LinuxCNC:masterfrom
grandixximo:fix/docs-toc-margin

Conversation

@grandixximo

@grandixximo grandixximo commented Jun 19, 2026

Copy link
Copy Markdown
Contributor

Problem

The example pages examples/pci-parallel-port.html and examples/mpg.html render without the left sidebar margin (page content overlaps the navigation tree).

Cause

These pages have no == sections, so asciidoctor emits no left-TOC and no toc2 toc-left body classes. lang_switcher_postprocess.py scaffolds the sidebar for such pages, but its body-class rewrite used the regex <body class="...">, which requires class immediately 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 and toc2 toc-left was never added. The sidebar div still got inserted (it keys off the <h1>), so the nav showed but padding-left:320px was never applied, leaving the overlap.

Section-ful pages get toc2 toc-left straight from asciidoctor, which masked the bug.

Fix

Match optional attributes before class in the body tag.

Verification

Built make htmldocs locally and rendered both pages: body is now book toc2 toc-left, padding-left is 320px, content clears the sidebar.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant