[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.
This commit is contained in:
parent
015dead0bb
commit
5219599a77
1 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue