Markdown to HTML – DIVs and ToC issue (ToC omitted) #10893
-
I am sorry if the following is expected behaviour or has been discussed before, I couldn’t find anything on it in the manual or here. Converting this to HTML: # Heading 1
# Heading 2 …creates a level 1 table of contents, as expected. This: ::: {.foo}
# Heading 1
# Heading 2
::: …creates no ToC at all. ::: {.foo}
# Heading 1
# Heading 2
:::
# Heading 3 … creates a ToC with only Heading 3. And this: # Heading 1
::: {.foo}
# Heading 2
:::
# Heading 3 …creates a document with a full table of contents, but it moves the Heading 2 ID to the generated DIV (which messes with a JavaScript-based navigation feature in my current projects) – this particular edge case was discussed earlier. So – is there a way to use ::: DIVs with Pandoc 3.7 that won’t affect ToC generation as described here, with a full table of contents created no matter where DIVs are applied? Thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 9 replies
-
I am able to reproduce this (running |
Beta Was this translation helpful? Give feedback.
-
You can always use header attributes such as
# Heading 1 {.foo}
# Heading 2 {.foo}
You can expand on this if you need to with this syntax:
{#identifier .class .class key=value key=value}
Then just make a CCS for the .foo class.
… Am 04.06.2025 um 09:47 schrieb PlainMartin ***@***.***>:
OK. I’ll admit I only checked the Q&A section, not the bug tracker.
In your Jan 3, 2014 comment <#997>, you say:
The real issue is the 'hierarchicalize' function from Text.Pandoc.Shared, which creates a nested section structure based on the outer-level headers of the document. It only looks at outer-level headers and does not recurse into other block-level structures (divs, lists, blockquotes, etc.).
Now I obviously respect that decision, but let me just ask: From a HTML perspective, a DIV doesn’t really define a new hierarchy / semantic context. From the MDN page <https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/div>:
“The <div> HTML element is the generic container for flow content. It has no effect on the content or layout until styled in some way using CSS […] As a ‘pure’ container, the <div> element does not inherently represent anything. Instead, it’s used to group content so it can be easily styled using the class or id attributes.”
So while I understand that e.g. a <section> or <article> defines a new context that would justify omitting them from a ToC or other indexes, I don’t see why headings in a <div> (that might just be used for layout/styling) are removed from the document hierarchy.
Again – just asking.
And the reason why I stumbled into this is that I really just wanted to apply a background color and some other styling to a section with headings of a longer HTML page, but it shouldn’t be removed from the ToC. Is there another way to achieve this?
Thank you.
—
Reply to this email directly, view it on GitHub <#10893 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ACZ2I7FFAK6UKDG7PBQNXSL3B2P7VAVCNFSM6AAAAAB6PINFZSVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTGMZWGQ2DGNY>.
You are receiving this because you are subscribed to this thread.
|
Beta Was this translation helpful? Give feedback.
If you use
--section-divs
, then you'll get a<section>
with the specified class and you can use that for styling.