git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Prevent paragraphs containing only linebreaks or spaces.
commitfa71969e81a1c95017f2566ac01fa0562123349d authorJohn MacFarlane <jgm@berkeley.edu> dateTue 15 Jan 2013, 23:02 (14 years ago) parenta338133
1 file changed+9−4
src/Text/Pandoc/Writers/LaTeX.hs+9−4
src/Text/Pandoc/Writers/LaTeX.hs+9−4
@@ -272,11 +272,17 @@ isListBlock (OrderedList _ _) = True
272272isListBlock (DefinitionList _) = True
273273isListBlock _ = False
274274
275+isLineBreakOrSpace :: Inline -> Bool
276+isLineBreakOrSpace LineBreak = True
277+isLineBreakOrSpace Space = True
278+isLineBreakOrSpace _ = False
279+
275280-- | Convert Pandoc block element to LaTeX.
276281blockToLaTeX :: Block -- ^ Block to convert
277282 -> State WriterState Doc
278283blockToLaTeX Null = return empty
279−blockToLaTeX (Plain lst) = inlineListToLaTeX lst
284+blockToLaTeX (Plain lst) =
285+ inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
280286-- title beginning with fig: indicates that the image is a figure
281287blockToLaTeX (Para [Image txt (src,'f':'i':'g':':':tit)]) = do
282288 capt <- if null txt
@@ -285,9 +291,8 @@ blockToLaTeX (Para [Image txt (src,'f':'i':'g':':':tit)]) = do
285291 img <- inlineToLaTeX (Image txt (src,tit))
286292 return $ "\\begin{figure}[htbp]" $$ "\\centering" $$ img $$
287293 capt $$ "\\end{figure}"
288−blockToLaTeX (Para lst) = do
289− result <- inlineListToLaTeX lst
290− return result
294+blockToLaTeX (Para lst) =
295+ inlineListToLaTeX $ dropWhile isLineBreakOrSpace lst
291296blockToLaTeX (BlockQuote lst) = do
292297 beamer <- writerBeamer `fmap` gets stOptions
293298 case lst of