Skip to content
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

Multiple subheadings in same fenced div don't appear in the TOC #8518

Open
ulrichb opened this issue Jan 3, 2023 · 4 comments
Open

Multiple subheadings in same fenced div don't appear in the TOC #8518

ulrichb opened this issue Jan 3, 2023 · 4 comments

Comments

@ulrichb
Copy link

ulrichb commented Jan 3, 2023

Explain the problem.

Render the following markdown with pandoc/core Input.md --self-contained --toc --output=Output.html.

# Heading with subheading in individual fenced divs (good)

::: Fenced1

## A1

Content of a1.

:::

::: Fenced2

## A2

Content of a2.

:::

# Heading with subheading in same fenced div (bad)

::: Fenced3

## B1

Content of b1.


## B2

Content of b2.

:::

Result:

image

So it seams that when a fenced div contains more than one subheading the contained subheadings aren't rendered in the TOC.

Pandoc version?

pandoc 2.19.2
Compiled with pandoc-types 1.22.2.1, texmath 0.12.5.2, skylighting 0.13,
citeproc 0.8.0.1, ipynb 0.2, hslua 2.1.0
Scripting engine: Lua 5.3
@ulrichb ulrichb added the bug label Jan 3, 2023
@jgm
Copy link
Owner

jgm commented Jan 4, 2023

That's true. Originally we didn't include any of the headings inside fenced divs; the thought was that these created isolated environments which might be used, e.g., for callouts.

A problem with this was that round-trip got broken in certain cases, since in some formats pandoc will add the section divs around headings. So we supported this case only: a div starting with a heading with no other headings in it.

I'm not sure we want to support the other case, for the reasons mentioned above.

@ulrichb
Copy link
Author

ulrichb commented Jan 4, 2023

Okay, I understand. Let me tell my scenario, where the fenced divs are not "isolated environments": We're using the class name of the fenced divs in combination with a Lua filter to implement conditional sections (i.e. the rendered output's sections depend on metadata flags). Here we of course also want all the "enabled sections" to be part of the TOC.

Maybe implement the TOC inclusion of fenced div headings behind a flag to support both scenarios?

@jgm
Copy link
Owner

jgm commented Jan 4, 2023

That makes sense. Have you thought of using a class on the headers to be enabled/omitted instead?

@ulrichb
Copy link
Author

ulrichb commented Jan 5, 2023

This wouldn't work because we're using these "conditional fenced divs" in all kind of ways: Conditional div blocks within a heading; all subheadings conditional within a heading; only parts of the subheadings conditional within a heading, ...

And here the instrument of these fenced divs plus the filter works really great in the body text, just the TOC has the mentioned issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants