aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2018-09-22 20:39:42 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2018-09-22 20:40:59 -0700
commit4bc2b7eb5b9e71eef141c3b5022fc3cd18560a80 (patch)
tree75ace6253ac33e74644e9d83ea668d61bfc6a3f8
parent0bd27608a6e463a66a9959cda823cd80808d38db (diff)
downloadpandoc-4bc2b7eb5b9e71eef141c3b5022fc3cd18560a80.tar.gz
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.
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 3db643503..6042f2765 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -176,9 +176,9 @@ pandocToLaTeX options (Pandoc meta blocks) = do
modify $ \s -> s{stCsquotes = True}
let (blocks'', lastHeader) = if writerCiteMethod options == Citeproc then
(blocks', [])
- else case last blocks' of
- Header 1 _ il -> (init blocks', il)
- _ -> (blocks', [])
+ else case reverse blocks' of
+ Header 1 _ il : _ -> (init blocks', il)
+ _ -> (blocks', [])
beamer <- gets stBeamer
blocks''' <- if beamer
then toSlides blocks''