Ensure that Nulls are ignored in creating slide shows.

Also ensure that Nulls are ignored in sectionification
by `makeSections`.

Closes #8155.
This commit is contained in:
John MacFarlane 2022-07-04 14:24:57 +02:00
parent f2f9c896ee
commit befa9d1301
3 changed files with 21 additions and 1 deletions

View file

@ -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 []

View file

@ -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"] :

19
test/command/8155.md Normal file
View file

@ -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>
```