summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2022-07-04 14:24:57 +0200
committerJohn MacFarlane <jgm@berkeley.edu>2022-07-04 14:34:14 +0200
commitbefa9d130181ff99d155a6df454c40fba0d9736a (patch)
tree8c58ad92b73918f1e476148d036abae3a72a2023
parentf2f9c896eee80d2f7cb60ed7e5d4d27cf2dacd0b (diff)
Ensure that Nulls are ignored in creating slide shows.
Also ensure that Nulls are ignored in sectionification by `makeSections`. Closes #8155.
-rw-r--r--src/Text/Pandoc/Shared.hs1
-rw-r--r--src/Text/Pandoc/Slides.hs2
-rw-r--r--test/command/8155.md19
3 files changed, 21 insertions, 1 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs
index cc7893511..5c179158f 100644
--- a/src/Text/Pandoc/Shared.hs
+++ b/src/Text/Pandoc/Shared.hs
@@ -589,6 +589,7 @@ makeSections numbering mbBaseLevel bs =
xs' <- go xs
rest' <- go rest
return $ Div attr xs' : rest'
+ go (Null:xs) = go xs
go (x:xs) = (x :) <$> go xs
go [] = return []
diff --git a/src/Text/Pandoc/Slides.hs b/src/Text/Pandoc/Slides.hs
index 2275bcffe..34763ea23 100644
--- a/src/Text/Pandoc/Slides.hs
+++ b/src/Text/Pandoc/Slides.hs
@@ -30,7 +30,7 @@ getSlideLevel = go 6
-- | Prepare a block list to be passed to makeSections.
prepSlides :: Int -> [Block] -> [Block]
-prepSlides slideLevel = ensureStartWithH . splitHrule . extractRefsHeader
+prepSlides slideLevel = ensureStartWithH . splitHrule . extractRefsHeader . filter (/= Null)
where splitHrule (HorizontalRule : Header n attr xs : ys)
| n == slideLevel = Header slideLevel attr xs : splitHrule ys
splitHrule (HorizontalRule : xs) = Header slideLevel nullAttr [Str "\0"] :
diff --git a/test/command/8155.md b/test/command/8155.md
new file mode 100644
index 000000000..966bff871
--- /dev/null
+++ b/test/command/8155.md
@@ -0,0 +1,19 @@
+```
+% pandoc -f native -t revealjs
+[ Null
+, Header
+ 2
+ ( "header-after-null" , [] , [] )
+ [ Str "Header"
+ , Space
+ , Str "after"
+ , Space
+ , Str "null"
+ ]
+]
+^D
+<section id="header-after-null" class="title-slide slide level2">
+<h2>Header after null</h2>
+
+</section>
+```