git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: fix a use of `last` that might take empty list.

If you ran with `--biblatex` and have an empty document (metadata but no blocks), pandoc would previously raise an error because of the use of `last` on an empty list.

commit4bc2b7eb5b9e71eef141c3b5022fc3cd18560a80 authorJohn MacFarlane <jgm@berkeley.edu> dateSat 22 Sep 2018, 20:39 (8 years ago) parent0bd2760
1 file changed+3−3
src/Text/Pandoc/Writers/LaTeX.hs+3−3
src/Text/Pandoc/Writers/LaTeX.hs+3−3
@@ -176,9 +176,9 @@ pandocToLaTeX options (Pandoc meta blocks) = do
176176 modify $ \s -> s{stCsquotes = True}
177177 let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
178178 (blocks', [])
179− else case last blocks' of
180− Header 1 _ il -> (init blocks', il)
181− _ -> (blocks', [])
179+ else case reverse blocks' of
180+ Header 1 _ il : _ -> (init blocks', il)
181+ _ -> (blocks', [])
182182 beamer <- gets stBeamer
183183 blocks''' <- if beamer
184184 then toSlides blocks''