diff options
author | Albert Krewinkel <tarleb@moltkeplatz.de> | 2014-04-25 16:14:52 +0200 |
---|---|---|
committer | Albert Krewinkel <tarleb@moltkeplatz.de> | 2014-04-25 16:17:24 +0200 |
commit | b09412d852880a0c8e18e1cab9b0ce33f0e0e8a2 (patch) | |
tree | db39f82aafb4a8f0b77dcc717f2f9ffefa4ff296 /src/Text/Pandoc/Writers | |
parent | 2eec20d92fd0f498da5b66ac03cf6f8159392323 (diff) | |
download | pandoc-b09412d852880a0c8e18e1cab9b0ce33f0e0e8a2.tar.gz |
LaTeX writer: Mark span contents with label if span has an ID
Prepend `\label{span-id}` to span contents iff `span-id` is defined.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r-- | src/Text/Pandoc/Writers/LaTeX.hs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs index e12c9078f..e52220f01 100644 --- a/src/Text/Pandoc/Writers/LaTeX.hs +++ b/src/Text/Pandoc/Writers/LaTeX.hs @@ -655,16 +655,20 @@ isQuoted _ = False -- | Convert inline element to LaTeX inlineToLaTeX :: Inline -- ^ Inline to convert -> State WriterState Doc -inlineToLaTeX (Span (_,classes,_) ils) = do +inlineToLaTeX (Span (id',classes,_) ils) = do let noEmph = "csl-no-emph" `elem` classes let noStrong = "csl-no-strong" `elem` classes let noSmallCaps = "csl-no-smallcaps" `elem` classes - ((if noEmph then inCmd "textup" else id) . - (if noStrong then inCmd "textnormal" else id) . - (if noSmallCaps then inCmd "textnormal" else id) . - (if not (noEmph || noStrong || noSmallCaps) - then braces - else id)) `fmap` inlineListToLaTeX ils + let label' = if (null id') + then empty + else text "\\label" <> braces (text $ toLabel id') + fmap (label' <>) + ((if noEmph then inCmd "textup" else id) . + (if noStrong then inCmd "textnormal" else id) . + (if noSmallCaps then inCmd "textnormal" else id) . + (if not (noEmph || noStrong || noSmallCaps) + then braces + else id)) `fmap` inlineListToLaTeX ils inlineToLaTeX (Emph lst) = inlineListToLaTeX lst >>= return . inCmd "emph" inlineToLaTeX (Strong lst) = |