git.iko.soy/typeable/pandoc
on master help sign in
LaTeX writer: Mark span contents with label if span has an ID

Prepend `\label{span-id}` to span contents iff `span-id` is defined.

commitb09412d852880a0c8e18e1cab9b0ce33f0e0e8a2 authorAlbert Krewinkel <tarleb@moltkeplatz.de> dateFri 25 Apr 2014, 16:14 (13 years ago) parent2eec20d
1 file changed+11−7
src/Text/Pandoc/Writers/LaTeX.hs+11−7
src/Text/Pandoc/Writers/LaTeX.hs+11−7
@@ -655,16 +655,20 @@ isQuoted _ = False
655655-- | Convert inline element to LaTeX
656656inlineToLaTeX :: Inline -- ^ Inline to convert
657657 -> State WriterState Doc
658−inlineToLaTeX (Span (_,classes,_) ils) = do
658+inlineToLaTeX (Span (id',classes,_) ils) = do
659659 let noEmph = "csl-no-emph" `elem` classes
660660 let noStrong = "csl-no-strong" `elem` classes
661661 let noSmallCaps = "csl-no-smallcaps" `elem` classes
662− ((if noEmph then inCmd "textup" else id) .
663− (if noStrong then inCmd "textnormal" else id) .
664− (if noSmallCaps then inCmd "textnormal" else id) .
665− (if not (noEmph || noStrong || noSmallCaps)
666− then braces
667− else id)) `fmap` inlineListToLaTeX ils
662+ let label' = if (null id')
663+ then empty
664+ else text "\\label" <> braces (text $ toLabel id')
665+ fmap (label' <>)
666+ ((if noEmph then inCmd "textup" else id) .
667+ (if noStrong then inCmd "textnormal" else id) .
668+ (if noSmallCaps then inCmd "textnormal" else id) .
669+ (if not (noEmph || noStrong || noSmallCaps)
670+ then braces
671+ else id)) `fmap` inlineListToLaTeX ils
668672inlineToLaTeX (Emph lst) =
669673 inlineListToLaTeX lst >>= return . inCmd "emph"
670674inlineToLaTeX (Strong lst) =