diff options
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 10 | ||||
-rw-r--r-- | test/command/5846.md | 170 |
2 files changed, 177 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 59e30feeb..ff97d16fb 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -1,12 +1,13 @@ -{-# LANGUAGE NoImplicitPrelude #-} +{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE CPP #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE ViewPatterns #-} -{-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE TypeSynonymInstances #-} +{-# LANGUAGE LambdaCase #-} {- | Module : Text.Pandoc.Shared Copyright : Copyright (C) 2006-2019 John MacFarlane @@ -533,7 +534,10 @@ makeSections numbering mbBaseLevel bs = return $ Div divattr (Header level' attr title' : sectionContents') : rest' go (Div (dident,dclasses,dkvs) - (Header level (ident,classes,kvs) title':ys) : xs) = do + (Header level (ident,classes,kvs) title':ys) : xs) + | all (\case + Header level' _ _ -> level' > level + _ -> True) ys = do inner <- go (Header level (ident,classes,kvs) title':ys) let inner' = case inner of diff --git a/test/command/5846.md b/test/command/5846.md new file mode 100644 index 000000000..ec00074d3 --- /dev/null +++ b/test/command/5846.md @@ -0,0 +1,170 @@ +``` +% pandoc --section-divs +::: {.mydiv} +# header 1a + +one + +# header 1b + +two +::: +^D +<div class="mydiv"> +<section id="header-1a" class="level1"> +<h1>header 1a</h1> +<p>one</p> +</section> +<section id="header-1b" class="level1"> +<h1>header 1b</h1> +<p>two</p> +</section> +</div> +``` + +``` +% pandoc --section-divs +::: mydiv +# head 1 +## head 1.1 +# head 2 +::: + +## head 2.1 +^D +<div class="mydiv"> +<section id="head-1" class="level1"> +<h1>head 1</h1> +<section id="head-1.1" class="level2"> +<h2>head 1.1</h2> +</section> +</section> +<section id="head-2" class="level1"> +<h1>head 2</h1> +</section> +</div> +<section id="head-2.1" class="level2"> +<h2>head 2.1</h2> +</section> +``` + +``` +% pandoc --section-divs +# One +## One A +::: fence +## One B +# Two +::: +^D +<section id="one" class="level1"> +<h1>One</h1> +<section id="one-a" class="level2"> +<h2>One A</h2> +</section> +<div class="fence"> +<section id="one-b" class="level2"> +<h2>One B</h2> +</section> +<section id="two" class="level1"> +<h1>Two</h1> +</section> +</div> +</section> +``` + +``` +% pandoc --section-divs +# Beginning + +::: exterior + +At first... + +::: + +In the beginning... + +::: interior + +# Middle + +So it continued... + +::: + +# Ending + +::: exterior + +And finally... + +::: +^D +<section id="beginning" class="level1"> +<h1>Beginning</h1> +<div class="exterior"> +<p>At first…</p> +</div> +<p>In the beginning…</p> +</section> +<section id="middle" class="level1 interior"> +<h1>Middle</h1> +<p>So it continued…</p> +</section> +<section id="ending" class="level1"> +<h1>Ending</h1> +<div class="exterior"> +<p>And finally…</p> +</div> +</section> +``` + +``` +% pandoc --section-divs +::: part +# One +# Two +::: +::: part +# Three +# Four +# Five +::: +::: part +# Six +# Seven +# Eight +::: +^D +<div class="part"> +<section id="one" class="level1"> +<h1>One</h1> +</section> +<section id="two" class="level1"> +<h1>Two</h1> +</section> +</div> +<div class="part"> +<section id="three" class="level1"> +<h1>Three</h1> +</section> +<section id="four" class="level1"> +<h1>Four</h1> +</section> +<section id="five" class="level1"> +<h1>Five</h1> +</section> +</div> +<div class="part"> +<section id="six" class="level1"> +<h1>Six</h1> +</section> +<section id="seven" class="level1"> +<h1>Seven</h1> +</section> +<section id="eight" class="level1"> +<h1>Eight</h1> +</section> +</div> +``` |