-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Request support for heading offset #888
Comments
This can be done in a postprocessor (this one only does positive offsets, but you get the idea): fn heading_offset<'a>(
parser: impl Iterator<Item = Event<'a>>,
offset: usize,
) -> impl Iterator<Item = Event<'a>> {
parser.map(move |mut event| {
match &mut event {
Event::Start(Tag::Heading { level, .. }) | Event::End(TagEnd::Heading(level)) => {
*level = (*level as usize + offset)
.try_into()
.unwrap_or(HeadingLevel::H6);
}
_ => {}
}
event
})
} I don't know if we want this in the main crate, but we could have a |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Would you be open to adding a configuration option to allow for offsetting of headings?
For example, adding an offset of
2
would map#
-><h3>
and##
-><h4>
and so on.Why
Hand-editing Markdown levels is often described as a workaround. However, this workaround fails if the same Markdown file gets included by different templates using different nesting levels for headers.
Related Work
For example, this has been implemented in at least one markdown processor; see BlackFriday (GoLang):
The text was updated successfully, but these errors were encountered: