aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorFlorian Eitel <florian.eitel@wooga.net>2013-08-22 20:15:36 +0200
committerFlorian Eitel <florian.eitel@wooga.net>2013-08-22 20:15:36 +0200
commit5f09cf7ff033ae11c5094fe39f8cd2ac11657229 (patch)
tree13030bd56e334ad092201ad91fd39b01d70c4b18 /src/Text/Pandoc/Writers
parentf7c14eddd81dfb89111b482cf49289d9d0135cc2 (diff)
downloadpandoc-5f09cf7ff033ae11c5094fe39f8cd2ac11657229.tar.gz
Write id for code block to label attr in latex when listing is used
The code: ~~~{#test} asdf ~~~ gets compiled to html: <pre id="test"> asdf </pre> So it is possible to link to the identifier `test` But this doesn't happen on latex When using the listings package (`--listings`) it is possible to set the identifier using the `label=test` property: \begin{lstlisting}[label=id] hi \end{lstlisting} And this is exactly what this patch is doing. Modified LaTeX Reader/Writer and added tests for this.
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index ab579a326..bf056001f 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -313,7 +313,7 @@ blockToLaTeX (BlockQuote lst) = do
_ -> do
contents <- blockListToLaTeX lst
return $ "\\begin{quote}" $$ contents $$ "\\end{quote}"
-blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do
+blockToLaTeX (CodeBlock (identifier,classes,keyvalAttr) str) = do
opts <- gets stOptions
case () of
_ | isEnabled Ext_literate_haskell opts && "haskell" `elem` classes &&
@@ -344,7 +344,11 @@ blockToLaTeX (CodeBlock (_,classes,keyvalAttr) str) = do
[ (if key == "startFrom"
then "firstnumber"
else key) ++ "=" ++ attr |
- (key,attr) <- keyvalAttr ]
+ (key,attr) <- keyvalAttr ] ++
+ (if identifier == ""
+ then []
+ else [ "label=" ++ identifier ])
+
else []
printParams
| null params = empty