git.iko.soy/typeable/pandoc
on master help sign in
Improve detection of headings in Divs by hierarchicalize.

The structure ``` <h1>one</h1> <div> <h1>two</h1> </div> ``` should create two coordinate sections, not a section with a subsection. Now it does. Extends #3057.

commit6e2cfd6c97b1b8657f1f3e2b66090a2c3ba8d887 authorJohn MacFarlane <jgm@berkeley.edu> dateFri 6 Sep 2019, 08:44 (7 years ago) parent345b337
2 files changed+9−6
src/Text/Pandoc/Shared.hs+2−1 test/command/3057.md+7−5
src/Text/Pandoc/Shared.hs+2−1
@@ -544,7 +544,8 @@ hierarchicalizeWithIds (x:rest) = do
544544
545545headerLtEq :: Int -> Block -> Bool
546546headerLtEq level (Header l _ _) = l <= level
547−headerLtEq level (Div ("",["references"],[]) (Header l _ _ : _)) = l <= level
547+headerLtEq level (Div ("",classes,[]) (Header l _ _ : _)) =
548+ l <= level && "column" `notElem` classes && "columns" `notElem` classes
548549headerLtEq _ _ = False
549550
550551-- | Generate a unique identifier from a list of inlines.
test/command/3057.md+7−5
@@ -45,10 +45,12 @@
4545^D
4646<section xml:id="one">
4747 <title>one</title>
48− <section>
49− <title>two</title>
50− <para>
51− </para>
52− </section>
48+ <para>
49+ </para>
50+</section>
51+<section>
52+ <title>two</title>
53+ <para>
54+ </para>
5355</section>
5456```