mirror of
https://github.com/jgm/pandoc.git
synced 2026-07-11 20:07:22 +00:00
3e6eb1cde2
This is like `makeSections` but has an additional parameter specifying number offsets, for use with the `--number-offset` option. Use `makeSectionsWithOffsets` in HTML writer instead of ad hoc and inefficient number-adjusting code. Clarify MANUAL.txt: the `--number-offset` option should only directly affect numbering of the first section heading in a document; subsequent headings will increment normally. Fix test output for #5071 to reflect this.
1.8 KiB
1.8 KiB
% pandoc -f markdown -t html --number-sections
## First section
### Subhead
##### Subhead with gap
## Second section
^D
<h2 data-number="1" id="first-section"><span
class="header-section-number">1</span> First section</h2>
<h3 data-number="1.1" id="subhead"><span
class="header-section-number">1.1</span> Subhead</h3>
<h5 data-number="1.1.0.1" id="subhead-with-gap"><span
class="header-section-number">1.1.0.1</span> Subhead with gap</h5>
<h2 data-number="2" id="second-section"><span
class="header-section-number">2</span> Second section</h2>
% pandoc -f markdown -t html --number-sections
## First section
### Subhead
# Higher-level section
## Sub
^D
<h2 data-number="0.1" id="first-section"><span
class="header-section-number">0.1</span> First section</h2>
<h3 data-number="0.1.1" id="subhead"><span
class="header-section-number">0.1.1</span> Subhead</h3>
<h1 data-number="1" id="higher-level-section"><span
class="header-section-number">1</span> Higher-level section</h1>
<h2 data-number="1.1" id="sub"><span
class="header-section-number">1.1</span> Sub</h2>
For backwards compatibility, we want it to work the old way,
giving numbers like 0.1, when --number-offset is used:
% pandoc -f markdown -t html --number-sections --number-offset=2,2,2
## First section
### Subhead
^D
<h2 data-number="2.3" id="first-section"><span
class="header-section-number">2.3</span> First section</h2>
<h3 data-number="2.3.1" id="subhead"><span
class="header-section-number">2.3.1</span> Subhead</h3>
% pandoc -f markdown -t html --number-sections --number-offset=0,2,2
## First section
### Subhead
^D
<h2 data-number="0.3" id="first-section"><span
class="header-section-number">0.3</span> First section</h2>
<h3 data-number="0.3.1" id="subhead"><span
class="header-section-number">0.3.1</span> Subhead</h3>