From befa9d130181ff99d155a6df454c40fba0d9736a Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Mon, 4 Jul 2022 14:24:57 +0200 Subject: [PATCH] Ensure that Nulls are ignored in creating slide shows. Also ensure that Nulls are ignored in sectionification by `makeSections`. Closes #8155. --- src/Text/Pandoc/Shared.hs | 1 + src/Text/Pandoc/Slides.hs | 2 +- test/command/8155.md | 19 +++++++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 test/command/8155.md 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 +
+

Header after null

+ +
+```