Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Shared:
makeSections
behavior changes.
+ When the optional base level parameter is provided, we no longer ensure that the sequence of heading levels is gapless [behavior change]. Instead, we set the lowest heading level to the specified base level, and adjust the others accordingly. If an author wants to skip a level, e.g. from level 1 to level 3, they can do that. In general, the heading levels specified in the source document are preserved; `makeSections` only puts them into a hierarchical structure. Closes #9398. + Section numbers are now assigned so that the top level gets `1`, no matter what heading level is used. So, even if the top heading level is 2, numbers will be `1`, `2`, etc. rather than `0.1`, `0.2`, as in the past. Closes #5071. + We revert to the old behavior when the `--number-offset` option is used. So, for example, if a document begins with a level-3 heading, and `--number-offset=1,2` is used, the top-level section numbers will be `1.2.1`, `1.2.2`, etc. This is mainly for backwards-compatibility.
- Loading branch information
Showing
4 changed files
with
96 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
``` | ||
% 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.3" id="subhead"><span | ||
class="header-section-number">2.3.3</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.3" id="subhead"><span | ||
class="header-section-number">0.3.3</span> Subhead</h3> | ||
``` |