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

With --number-offset set, --section-divs gets silently activated with no way to turn it off #8097

Closed
mrzool opened this issue Jun 2, 2022 · 2 comments
Labels

Comments

@mrzool
Copy link

mrzool commented Jun 2, 2022

Noticed while converting from docx to html.

The following command:

pandoc document.docx -t html --number-sections --number-offset=1 --shift-heading-level-by=1

causes document sections to get wrapped in <section> tags, even if --section-divs was not explicitly given.

This doesn't happen when omitting -number-offset.

I couldn't find a way to change this behavior.

pandoc 2.14.2 on macOS 12.4.

See also: my original message on Google Groups

(y'all should really switch to groups.io btw)

@mrzool mrzool added the bug label Jun 2, 2022
@jgm
Copy link
Owner

jgm commented Jun 2, 2022

Thanks for reporting.
Note that we also get incorrect number attributes on the sections:

<section id="one" data-number="1">
<h1 data-number="2"><span class="header-section-number">2</span>
one</h1>
</section>
<section id="two" data-number="2">
<h1 data-number="3"><span class="header-section-number">3</span>
two</h1>
</section>

That is the clue. See the HTML writer at line 852 -- in deciding whether to add the section tag, it checks to see if the surrounding Div and the Header have different attributes. Apparently they do in this case, because --number-offset modifies the attributes on the Header but not the surrounding Div. (See the function adjustNumbers.) We could fix this by having adjustNumbers modify the number on both the Header and the surrounding Div. Or we could avoid putting the number on the Div in the first place: this relates to a bigger issue, #5965.

@mrzool
Copy link
Author

mrzool commented Jun 2, 2022

Wow, that was quick! Thanks @jgm.

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

No branches or pull requests

2 participants