From 03bb426a4a65918bfd6fbd63d5bb32a657df5568 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 3 Feb 2024 22:19:29 -0800 Subject: 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. --- test/command/5071.md | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 test/command/5071.md (limited to 'test/command') diff --git a/test/command/5071.md b/test/command/5071.md new file mode 100644 index 000000000..6bbeb85fc --- /dev/null +++ b/test/command/5071.md @@ -0,0 +1,68 @@ +``` +% pandoc -f markdown -t html --number-sections +## First section + +### Subhead + +##### Subhead with gap + +## Second section +^D +

1 First section

+

1.1 Subhead

+
1.1.0.1 Subhead with gap
+

2 Second section

+ +``` + +``` +% pandoc -f markdown -t html --number-sections +## First section + +### Subhead + +# Higher-level section + +## Sub +^D +

0.1 First section

+

0.1.1 Subhead

+

1 Higher-level section

+

1.1 Sub

+``` + +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 +

2.3 First section

+

2.3.3 Subhead

+ +``` + +``` +% pandoc -f markdown -t html --number-sections --number-offset=0,2,2 +## First section + +### Subhead +^D +

0.3 First section

+

0.3.3 Subhead

+ +``` -- cgit v1.2.3