Skip to content

Commit

Permalink
Fix regression in section numbering.
Browse files Browse the repository at this point in the history
Starting with pandoc 3.1.12, unnumbered sections incremented
the section number.

Closes #9516.
  • Loading branch information
jgm committed Feb 28, 2024
1 parent 87b07c6 commit cd460ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Text/Pandoc/Shared.hs
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ makeSections numbering mbBaseLevel bs =
| otherwise = 0
let newnum = zipWith adjustNum [minLevel..level]
(lastnum ++ repeat 0)
unless (null newnum) $ S.put newnum
unless (null newnum || "unnumbered" `elem` classes) $ S.put newnum
let (sectionContents, rest) = break (headerLtEq level) xs
sectionContents' <- go sectionContents
rest' <- go rest
Expand Down
17 changes: 17 additions & 0 deletions test/command/9516.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
```
% pandoc --number-sections
# One {-}
# Two
# Three {-}
# Four
^D
<h1 class="unnumbered" id="one">One</h1>
<h1 data-number="1" id="two"><span
class="header-section-number">1</span> Two</h1>
<h1 class="unnumbered" id="three">Three</h1>
<h1 data-number="2" id="four"><span
class="header-section-number">2</span> Four</h1>
```

0 comments on commit cd460ec

Please sign in to comment.