aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2013-08-25 20:48:38 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2013-08-25 20:48:38 -0700
commite7a4bcc6fed37afbba423e4c41df6043d7158b3f (patch)
tree8c6e59c1dcb6749262e87ba701b1dce736ab1123 /src/Text
parenta68805bebd172b107e75fe330698cbc7eee7f75a (diff)
parent5f09cf7ff033ae11c5094fe39f8cd2ac11657229 (diff)
downloadpandoc-e7a4bcc6fed37afbba423e4c41df6043d7158b3f.tar.gz
Merge pull request #961 from nougad/add_latex_listings_label
Write id for code block to label attr in latex when listing is used
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs3
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs8
2 files changed, 8 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index e558ed1b9..9dbcd3644 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -46,6 +46,7 @@ import Text.Pandoc.Builder
import Data.Char (isLetter)
import Control.Applicative
import Data.Monoid
+import Data.Maybe (fromMaybe)
import System.Environment (getEnv)
import System.FilePath (replaceExtension, (</>))
import Data.List (intercalate, intersperse)
@@ -898,7 +899,7 @@ environments = M.fromList
lookup "numbers" options == Just "left" ]
++ maybe [] (:[]) (lookup "language" options
>>= fromListingsLanguage)
- let attr = ("",classes,kvs)
+ let attr = (fromMaybe "" (lookup "label" options),classes,kvs)
codeBlockWith attr <$> (verbEnv "lstlisting"))
, ("minted", do options <- option [] keyvals
lang <- grouped (many1 $ satisfy (/='}'))
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index 6a781ddec..37ca60ce3 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -309,7 +309,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 &&
@@ -340,7 +340,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