aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorhubertp-lshift <hubertp@lshift.de>2016-11-26 21:47:51 +0100
committerJohn MacFarlane <jgm@berkeley.edu>2016-11-26 21:47:51 +0100
commit5219599a775b5765d39ddceae4d57223c8eacc41 (patch)
tree2022788a31db2f1b15734ee7837b9b4398c6a1e6 /src/Text/Pandoc/Writers
parent015dead0bb2bb5cea06a0fa366fdd651c8e07889 (diff)
downloadpandoc-5219599a775b5765d39ddceae4d57223c8eacc41.tar.gz
[Tex] Remove invalid inlines in sections (#3218)
Latex doesn't like when hypertargets or images are put in the options list of the section. They are not lost since they were actually duplicated and present also in the second argument list. Note on the implementation: I had to inline the definiton of 'foldMap' since it is not implemented in every version of Haskell that Pandoc supports.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index b75f56cef..3657f3464 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -743,14 +743,16 @@ sectionHeader :: Bool -- True for unnumbered
sectionHeader unnumbered ident level lst = do
txt <- inlineListToLaTeX lst
plain <- stringToLaTeX TextString $ concatMap stringify lst
- let noNote (Note _) = Str ""
- noNote x = x
- let lstNoNotes = walk noNote lst
+ let removeInvalidInline (Note _) = []
+ removeInvalidInline (Span (id', _, _) _) | not (null id') = []
+ removeInvalidInline (Image _ _ _) = []
+ removeInvalidInline x = [x]
+ let lstNoNotes = foldr (mappend . (\x -> walkM removeInvalidInline x)) mempty lst
txtNoNotes <- inlineListToLaTeX lstNoNotes
-- footnotes in sections don't work (except for starred variants)
-- unless you specify an optional argument:
-- \section[mysec]{mysec\footnote{blah}}
- optional <- if unnumbered || lstNoNotes == lst
+ optional <- if unnumbered || lstNoNotes == lst || lstNoNotes == []
then return empty
else do
return $ brackets txtNoNotes