Add option to disable section wrapping in HTML output - #266
Merged
Conversation
Document-level headings are wrapped in section elements by default, with the heading id hoisted onto the wrapper. Stylesheets that assume a flat heading structure, such as sibling selectors like `.stack > * + *`, break when migrating from Markdown, and there was no way to opt out short of post-processing the HTML. Add `HtmlRenderer::setSections(false)`, a `sections` constructor option on DjotConverter, and a `--no-sections` CLI flag. The default is unchanged. With sections disabled, document-level headings render through the existing `renderHeading()` path already used for headings nested inside divs and blockquotes, so they keep their id inline and no attributes are dropped. The explicit id reservation pass still runs first, so generated ids and their dedup suffixes are identical in both modes. Section wrapping is an HTML concern only. The footnote endnotes section, the round-trip abbreviation metadata, and the plain text, Markdown and ANSI renderers are all unaffected.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #266 +/- ##
============================================
+ Coverage 92.39% 92.40% +0.01%
- Complexity 3668 3673 +5
============================================
Files 109 109
Lines 10407 10421 +14
============================================
+ Hits 9616 9630 +14
Misses 791 791 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Document-level headings are wrapped in
<section>elements by default, with the heading id hoisted onto the wrapper. There was no way to turn this off short of post-processing the HTML.That is a real migration blocker: stylesheets written against a flat Markdown heading structure break silently. The motivating case is sibling selectors such as
.stack > * + *, which stop matching once every heading and its content sit in their own wrapper. Raised in markup-carve/carve#427 and before in jgm/djot#221 .What this adds
An opt-out. The default is unchanged.
<section id="install">/<h2 class="featured">Setup</h2>sections: false<h2 id="install" class="featured">Setup</h2>Why it is small
renderHeading()already emits exactly this shape. It is the path used today for headings nested inside divs and blockquotes. Disabling section wrapping routes document-level headings through that same path, so the behavior is one that already existed and was already covered, just not reachable at document level.Two things worth calling out:
Docs
Added to
docs/guide/parser-options.md,docs/guide/converters.md,docs/reference/api.md,docs/reference/cli.md, and a migration note indocs/cookbook/markdown.md, which is where someone hitting this problem is most likely to look.