@@ -357,8 +357,10 @@ blockToLaTeX (Div attr@(identifier,"block":dclasses,_)
357357 else (cr <> ) <$> hypertarget identifier
358358 title' <- inlineListToLaTeX ils
359359 contents <- blockListToLaTeX bs
360- wrapDiv attr $ (" \\ begin" <> braces blockname <> braces title' <> anchor) $$
361- contents $$ " \\ end" <> braces blockname
360+ ($$ blankline) <$> wrapDiv attr
361+ ((" \\ begin" <> braces blockname <> braces title' <> anchor) $$
362+ contents $$
363+ " \\ end" <> braces blockname)
362364blockToLaTeX (Div (identifier," slide" : dclasses,dkvs)
363365 (Header _ (_,hclasses,hkvs) ils : bs)) = do
364366 -- note: [fragile] is required or verbatim breaks
@@ -392,7 +394,7 @@ blockToLaTeX (Div (identifier,"slide":dclasses,dkvs)
392394 else (cr <> ) <$> hypertarget identifier
393395 contents <- blockListToLaTeX bs >>= wrapDiv (identifier,classes,kvs)
394396 return $ (" \\ begin{frame}" <> options <> slideTitle <> slideAnchor) $$
395- contents $$ " \\ end{frame}"
397+ contents $$ " \\ end{frame}" $$ blankline
396398blockToLaTeX (Div (identifier@ (T. uncons -> Just (_,_)),dclasses,dkvs)
397399 (Header lvl (" " ,hclasses,hkvs) ils : bs)) =
398400 -- move identifier from div to header
@@ -433,23 +435,24 @@ blockToLaTeX (Div (identifier,classes,kvs) bs) = do
433435 | otherwise = do
434436 linkAnchor <- hypertarget identifier
435437 pure $ linkAnchor $$ txt
436- wrapDiv (identifier,classes,kvs) result >>= wrap
438+ ( $$ blankline) <$> ( wrapDiv (identifier,classes,kvs) result >>= wrap)
437439blockToLaTeX (Plain lst) =
438440 inlineListToLaTeX lst
439- -- . . . indicates pause in beamer slides
441+ -- . . . indicates pause in beamer slides
440442blockToLaTeX (Para [Str " ." ,Space ,Str " ." ,Space ,Str " ." ]) = do
441443 beamer <- gets stBeamer
442444 if beamer
443445 then blockToLaTeX (RawBlock " latex" " \\ pause" )
444- else inlineListToLaTeX [Str " ." ,Space ,Str " ." ,Space ,Str " ." ]
446+ else ($$ blankline) . (blankline $$ )
447+ <$> inlineListToLaTeX [Str " ." ,Space ,Str " ." ,Space ,Str " ." ]
445448blockToLaTeX (Para lst) =
446449 if null lst
447450 then do
448451 opts <- gets stOptions
449452 if isEnabled Ext_empty_paragraphs opts
450- then pure " \\ hfill\\ par"
453+ then pure $ " \\ hfill\\ par" $$ blankline
451454 else pure mempty
452- else inlineListToLaTeX lst
455+ else (blankline $$ ) . ( $$ blankline) <$> inlineListToLaTeX lst
453456blockToLaTeX (LineBlock lns) =
454457 blockToLaTeX $ linesToPara lns
455458blockToLaTeX (BlockQuote lst) = do
@@ -470,7 +473,8 @@ blockToLaTeX (BlockQuote lst) = do
470473 let envname = if csquotes then " displayquote" else " quote"
471474 return $ (" \\ begin" <> braces envname) $$
472475 contents $$
473- (" \\ end" <> braces envname)
476+ (" \\ end" <> braces envname) $$
477+ blankline
474478blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do
475479 opts <- gets stOptions
476480 inNote <- stInNote <$> get
@@ -527,7 +531,8 @@ blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do
527531 when inNote $ modify (\ s -> s{ stVerbInNote = True })
528532 modify (\ s -> s{ stHighlighting = True })
529533 return (flush $ linkAnchor $$ text (T. unpack h))
530- case () of
534+ ($$ blankline) <$>
535+ case () of
531536 _ | isEnabled Ext_literate_haskell opts && " haskell" `elem` classes &&
532537 " literate" `elem` classes -> lhsCodeBlock
533538 | writerListings opts -> listingsCodeBlock
@@ -564,7 +569,8 @@ blockToLaTeX (BulletList lst) = do
564569 spacing $$
565570 -- force list at beginning of definition to start on new line
566571 vcat items $$
567- " \\ end{itemize}"
572+ " \\ end{itemize}" $$
573+ blankline
568574blockToLaTeX (OrderedList _ [] ) = return empty -- otherwise latex error
569575blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
570576 st <- get
@@ -618,6 +624,7 @@ blockToLaTeX (OrderedList (start, numstyle, numdelim) lst) = do
618624 $$ spacing
619625 $$ vcat items
620626 $$ " \\ end{enumerate}"
627+ $$ blankline
621628blockToLaTeX (DefinitionList [] ) = return empty
622629blockToLaTeX (DefinitionList lst) = do
623630 incremental <- gets stIncremental
@@ -628,17 +635,18 @@ blockToLaTeX (DefinitionList lst) = do
628635 then text " \\ tightlist"
629636 else empty
630637 return $ text (" \\ begin{description}" <> inc) $$ spacing $$ vcat items $$
631- " \\ end{description}"
632- blockToLaTeX HorizontalRule =
633- return
634- " \\ begin{center}\\ rule{0.5\\ linewidth}{0.5pt}\\ end{center}"
638+ " \\ end{description}" $$
639+ blankline
640+ blockToLaTeX HorizontalRule = return $
641+ " \\ begin{center}\\ rule{0.5\\ linewidth}{0.5pt}\\ end{center}" $$ blankline
635642blockToLaTeX (Header level (id',classes,_) lst) = do
636643 modify $ \ s -> s{stInHeading = True }
637644 hdr <- sectionHeader classes id' level lst
638645 modify $ \ s -> s{stInHeading = False }
639- return hdr
646+ return $ hdr $$ blankline
640647blockToLaTeX (Table attr blkCapt specs thead tbodies tfoot) =
641- tableToLaTeX inlineListToLaTeX blockListToLaTeX
648+ ($$ blankline) <$>
649+ tableToLaTeX inlineListToLaTeX blockListToLaTeX
642650 (Ann. toTable attr blkCapt specs thead tbodies tfoot)
643651blockToLaTeX (Figure (ident, _, _) captnode body) = do
644652 opts <- gets stOptions
@@ -678,6 +686,7 @@ blockToLaTeX (Figure (ident, _, _) captnode body) = do
678686 innards
679687 _ -> cr <> " \\ begin{figure}" $$ innards $$ " \\ end{figure}" )
680688 $$ footnotes
689+ $$ blankline
681690
682691toSubfigure :: PandocMonad m => Int -> Block -> LW m (Doc Text )
683692toSubfigure nsubfigs blk = do
@@ -696,8 +705,8 @@ toSubfigure nsubfigs blk = do
696705 ]
697706
698707blockListToLaTeX :: PandocMonad m => [Block ] -> LW m (Doc Text )
699- blockListToLaTeX lst =
700- vsep `fmap` mapM (\ b -> setEmptyLine True >> blockToLaTeX b) lst
708+ blockListToLaTeX lst = (nestle . chomp . vcat) <$>
709+ mapM (\ b -> setEmptyLine True >> blockToLaTeX b) lst
701710
702711listItemToLaTeX :: PandocMonad m => Bool -> [Block ] -> LW m (Doc Text )
703712listItemToLaTeX isOrdered lst
@@ -742,7 +751,7 @@ defListItemToLaTeX (term, defs) = do
742751 firstitem <- blockToLaTeX x
743752 modify $ \ s -> s{stIsFirstInDefinition = False }
744753 rest <- blockListToLaTeX xs
745- return $ firstitem $+$ rest
754+ return $ chomp . nestle $ firstitem $+$ rest
746755 return $ case defs of
747756 ((Header {} : _) : _) ->
748757 " \\ item" <> brackets term'' <> " ~ " $$ def'
0 commit comments