summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2013-01-15 23:02:08 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2013-01-15 23:02:08 -0800
commitfa71969e81a1c95017f2566ac01fa0562123349d (patch)
tree3c719fcfdb83c761a162ef7a250e058ceb1663e6 /src
parenta3381331f82d7a494f51bdac822c3c85a28ad528 (diff)
LaTeX writer: Prevent paragraphs containing only linebreaks or spaces.
Diffstat (limited to 'src')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 3c0726b3d..12384ca97 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -272,11 +272,17 @@ isListBlock (OrderedList _ _) = True
isListBlock (DefinitionList _) = True
isListBlock _ = False
+isLineBreakOrSpace :: Inline -> Bool
+isLineBreakOrSpace LineBreak = True
+isLineBreakOrSpace Space = True
+isLineBreakOrSpace _ = False
+
-- | Convert Pandoc block element to LaTeX.
blockToLaTeX :: Block -- ^ Block to convert
-> State WriterState Doc
blockToLaTeX Null = return empty
-blockToLaTeX (Plain lst) = inlineListToLaTeX lst
+blockToLaTeX (Plain lst) =
+ inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
-- title beginning with fig: indicates that the image is a figure
blockToLaTeX (Para [Image txt (src,'f':'i':'g':':':tit)]) = do
capt <- if null txt
@@ -285,9 +291,8 @@ blockToLaTeX (Para [Image txt (src,'f':'i':'g':':':tit)]) = do
img <- inlineToLaTeX (Image txt (src,tit))
return $ "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$
capt $$ "\\end{figure}"
-blockToLaTeX (Para lst) = do
- result <- inlineListToLaTeX lst
- return result
+blockToLaTeX (Para lst) =
+ inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
blockToLaTeX (BlockQuote lst) = do
beamer <- writerBeamer `fmap` gets stOptions
case lst of