aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2019-06-07 10:03:10 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2019-06-07 10:03:10 -0700
commitd8b4e45be0b22aa5939add501339b64252d802ea (patch)
treedf33e3150601061a3e19d2ae02784a05678478fc
parent20503894f39a1426c8623f604b98e88e93a16235 (diff)
downloadpandoc-d8b4e45be0b22aa5939add501339b64252d802ea.tar.gz
LaTeX writer: Include inline code attributes with `--listings`.
Closes #5420.
-rw-r--r--src/Text/Pandoc/Writers/LaTeX.hs16
-rw-r--r--test/command/5420.md6
2 files changed, 18 insertions, 4 deletions
diff --git a/src/Text/Pandoc/Writers/LaTeX.hs b/src/Text/Pandoc/Writers/LaTeX.hs
index e0cdd2054..467ef304a 100644
--- a/src/Text/Pandoc/Writers/LaTeX.hs
+++ b/src/Text/Pandoc/Writers/LaTeX.hs
@@ -1148,14 +1148,22 @@ inlineToLaTeX (Cite cits lst) = do
Biblatex -> citationsToBiblatex cits
_ -> inlineListToLaTeX lst
-inlineToLaTeX (Code (_,classes,_) str) = do
+inlineToLaTeX (Code (_,classes,kvs) str) = do
opts <- gets stOptions
inHeading <- gets stInHeading
inItem <- gets stInItem
let listingsCode = do
- let listingsopt = case getListingsLanguage classes of
- Just l -> "[language=" ++ mbBraced l ++ "]"
- Nothing -> ""
+ let listingsopts = (case getListingsLanguage classes of
+ Just l -> (("language", mbBraced l):)
+ Nothing -> id) $
+ [(k,v) | (k,v) <- kvs
+ , k `notElem` ["exports","tangle","results"]]
+ let listingsopt = if null listingsopts
+ then ""
+ else "[" ++
+ intercalate ", "
+ (map (\(k,v) -> k ++ "=" ++ v)
+ listingsopts) ++ "]"
inNote <- gets stInNote
when inNote $ modify $ \s -> s{ stVerbInNote = True }
let chr = case "!\"'()*,-./:;?@" \\ str of
diff --git a/test/command/5420.md b/test/command/5420.md
new file mode 100644
index 000000000..b638fe5d2
--- /dev/null
+++ b/test/command/5420.md
@@ -0,0 +1,6 @@
+```
+% pandoc --listings -t latex
+`int a = 1;`{.cpp style=cpp}
+^D
+\passthrough{\lstinline[language={C++}, style=cpp]!int a = 1;!}
+```