Open dbader opened 7 years ago
Yes, I think we should make this more of a first-class citizen, with an option --secnum-depth
that works in all writers, like --toc-depth
.
As a workaround, just add this sort of thing to your CSS:
h3 > span.header-section-number { display: none; }
Thanks John, the workaround does exactly what I was looking for. I'll use that for now.
Similar situation β I'm generating a PDF where only parts ("modules") and chapters are numbered, everything else isn't. Level 1 headers are part ("Module II"), Level 2 headers are chapters ("Chapter 5"). Now I'm trying to replicate the effect for the EPUB version.
The CSS workaround can hide the numbers on the headers, but doesn't help with the Table of Contents. The chapter numbering also starts off as "1.1" because of the module grouping, as opposed to the more bookish style of picking up numbering from the previous module.
I wrote a filter to throw the .unnumbered
class on every heading below h2 which fixes the table of contents issue:
#!/usr/bin/env node
const pandoc = require('pandoc-filter');
const { Header } = pandoc;
const CHAPTER_LEVEL = 2;
let action = async (type, value, format, meta) => {
if (type === 'Header') {
let [level, [id, classes, keys], text] = value;
if (level > CHAPTER_LEVEL) {
classes = [...classes, 'unnumbered'];
}
return Header(level, [id, classes, keys], text);
}
};
pandoc.stdioAsync(action);
But I'm not sure of a good way to tackle the custom numbering style of Roman numerals for modules and chapter numbering β if I curmudgeon it in a filter by modifying the actual header text, is that going to interfere with the internal numbering system and cross linking?
Have you tried suppressing the section numbers in the TOC using CSS, as well? It should be possible. E.g. to suppress level-3 numbers:
nav#TOC > ul > li > ul > li > ul > li > a > span.toc-section-number { display: none; }
In response to your other question: Changing the numbering should not affect internal cross-linking, since the identifiers don't include the numbers. Try it.
@jgm ^^ Good point. I didn't, I went ahead and suppressed them with the filter β seemed less likely to break since the unnumbered
class works magic.
Good to hear, fingers crossed! If it doesn't have weird side effects, it sounds like a good filter recipe ("Custom Numbering Schemes") β preferred place to submit those?
preferred place to submit those?
pandoc/lua-filters on github
Thanks so much for the great tool. Pandoc is a core part of my ebook workflow now and it's absolutely fantastic. I've been recommending it left and right π
Here's a feature I'd like to suggest:
Currently, the
secnumdepth
variable for limiting the numbering depth on sections will only affect LaTeX and PDF output.It would be great if the same (or a similar) setting was made available for ePub files.
Right now ePub files generated with Pandoc (
1.19.2.1
) include section numbers at least up to level 5.For example, the following Markdown input:
...leads to this result in the ePub export (all section levels are numbered)
I'd love to be able to control section numbering in the ePub output as well.
For example, in my use case I'd like to hide section numbers past level 2. For my LaTeX and PDF exports I'm setting
secnumdepth: 1
and that gets me the desired result. But this only works for LaTeX and PDF files.Thanks for considering it!
pandoc 1.19.2.1