git.iko.soy/typeable/pandoc
on master help sign in
[Tex] Remove invalid inlines in sections (#3218)
5219599hubertp-lshift
src/Text/Pandoc/Writers/LaTeX.hs+6−4
@@ -743,14 +743,16 @@ sectionHeader :: Bool -- True for unnumbered
743sectionHeader unnumbered ident level lst = do
743sectionHeader unnumbered ident level lst = do
744 txt <- inlineListToLaTeX lst
744 txt <- inlineListToLaTeX lst
745 plain <- stringToLaTeX TextString $ concatMap stringify lst
745 plain <- stringToLaTeX TextString $ concatMap stringify lst
746− let noNote (Note _) = Str ""
746+ let removeInvalidInline (Note _) = []
747− noNote x = x
747+ removeInvalidInline (Span (id', _, _) _) | not (null id') = []
748− let lstNoNotes = walk noNote lst
748+ removeInvalidInline (Image _ _ _) = []
749+ removeInvalidInline x = [x]
750+ let lstNoNotes = foldr (mappend . (\x -> walkM removeInvalidInline x)) mempty lst
749 txtNoNotes <- inlineListToLaTeX lstNoNotes
751 txtNoNotes <- inlineListToLaTeX lstNoNotes
750 -- footnotes in sections don't work (except for starred variants)
752 -- footnotes in sections don't work (except for starred variants)
751 -- unless you specify an optional argument:
753 -- unless you specify an optional argument:
752 -- \section[mysec]{mysec\footnote{blah}}
754 -- \section[mysec]{mysec\footnote{blah}}
753− optional <- if unnumbered || lstNoNotes == lst
755+ optional <- if unnumbered || lstNoNotes == lst || lstNoNotes == []
754 then return empty
756 then return empty
755 else do
757 else do
756 return $ brackets txtNoNotes
758 return $ brackets txtNoNotes