diff options
author | John MacFarlane <jgm@berkeley.edu> | 2013-01-15 23:02:08 -0800 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2013-01-15 23:02:08 -0800 |
commit | fa71969e81a1c95017f2566ac01fa0562123349d (patch) | |
tree | 3c719fcfdb83c761a162ef7a250e058ceb1663e6 | |
parent | a3381331f82d7a494f51bdac822c3c85a28ad528 (diff) | |
download | pandoc-fa71969e81a1c95017f2566ac01fa0562123349d.tar.gz |
LaTeX writer: Prevent paragraphs containing only linebreaks or spaces.
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 13 |
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 |