git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1594 from jkr/itemFix
3533218John MacFarlane
src/Text/Pandoc/Writers/LaTeX.hs+12−2
@@ -572,7 +572,13 @@ tableCellToLaTeX header (width, align, blocks) = do
572 $ reverse ns)
572 $ reverse ns)
573
573
574listItemToLaTeX :: [Block] -> State WriterState Doc
574listItemToLaTeX :: [Block] -> State WriterState Doc
575+listItemToLaTeX lst
576+ -- we need to put some text before a header if it's the first
577+ -- element in an item. This will look ugly in LaTeX regardless, but
578+ -- this will keep the typesetter from throwing an error.
579+ | ((Header _ _ _) :_) <- lst =
580+ blockListToLaTeX lst >>= return . (text "\\item ~" $$) . (nest 2)
575−listItemToLaTeX lst = blockListToLaTeX lst >>= return . (text "\\item" $$) .
581+ | otherwise = blockListToLaTeX lst >>= return . (text "\\item" $$) .
576 (nest 2)
582 (nest 2)
577
583
578defListItemToLaTeX :: ([Inline], [[Block]]) -> State WriterState Doc
584defListItemToLaTeX :: ([Inline], [[Block]]) -> State WriterState Doc
@@ -586,7 +592,11 @@ defListItemToLaTeX (term, defs) = do
586 then braces term'
592 then braces term'
587 else term'
593 else term'
588 def' <- liftM vsep $ mapM blockListToLaTeX defs
594 def' <- liftM vsep $ mapM blockListToLaTeX defs
595+ return $ case defs of
596+ (((Header _ _ _) : _) : _) ->
597+ "\\item" <> brackets term'' <> " ~ " $$ def'
598+ _ ->
589− return $ "\\item" <> brackets term'' $$ def'
599+ "\\item" <> brackets term'' $$ def'
590
600
591-- | Craft the section header, inserting the secton reference, if supplied.
601-- | Craft the section header, inserting the secton reference, if supplied.
592sectionHeader :: Bool -- True for unnumbered
602sectionHeader :: Bool -- True for unnumbered
tests/Tests/Writers/LaTeX.hs+7
@@ -53,6 +53,13 @@ tests = [ testGroup "code blocks"
53 headerWith ("foo",["unnumbered"],[]) 1
53 headerWith ("foo",["unnumbered"],[]) 1
54 (text "Header 1" <> note (plain $ text "note")) =?>
54 (text "Header 1" <> note (plain $ text "note")) =?>
55 "\\section*{Header 1\\footnote{note}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n"
55 "\\section*{Header 1\\footnote{note}}\\label{foo}\n\\addcontentsline{toc}{section}{Header 1}\n"
56+ , "in list item" =:
57+ bulletList [header 2 (text "foo")] =?>
58+ "\\begin{itemize}\n\\item ~\n \\subsection{foo}\n\\end{itemize}"
59+ , "in definition list item" =:
60+ definitionList [(text "foo", [header 2 (text "bar"),
61+ para $ text "baz"])] =?>
62+ "\\begin{description}\n\\item[foo] ~ \n\\subsection{bar}\n\nbaz\n\\end{description}"
56 ]
63 ]
57 , testGroup "inline code"
64 , testGroup "inline code"
58 [ "struck out and highlighted" =:
65 [ "struck out and highlighted" =: