aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2013-03-06 09:58:47 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2013-03-06 09:58:47 -0800
commitf7d37c97bbaf79109198a12e247bff68eb1f71b1 (patch)
treef5e352d599116432e1c38e0bbafdde6fe4a3b9f9 /src/Text/Pandoc/Readers
parent8b3a81e4dd8bf46a822980781e28d9777a076c6a (diff)
downloadpandoc-f7d37c97bbaf79109198a12e247bff68eb1f71b1.tar.gz
LaTeX reader: Better support for Verbatim and minted environments.
Closes #763.
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs21
1 files changed, 18 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index 005120623..b6f09bbb1 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -818,7 +818,14 @@ environments = M.fromList
(codeBlockWith ("",["sourceCode","literate","haskell"],[]) <$>
verbEnv "code"))
, ("verbatim", codeBlock <$> (verbEnv "verbatim"))
- , ("Verbatim", codeBlock <$> (verbEnv "Verbatim"))
+ , ("Verbatim", do options <- option [] keyvals
+ let kvs = [ (if k == "firstnumber"
+ then "startFrom"
+ else k, v) | (k,v) <- options ]
+ let classes = [ "numberLines" |
+ lookup "numbers" options == Just "left" ]
+ let attr = ("",classes,kvs)
+ codeBlockWith attr <$> (verbEnv "Verbatim"))
, ("lstlisting", do options <- option [] keyvals
let kvs = [ (if k == "firstnumber"
then "startFrom"
@@ -829,8 +836,16 @@ environments = M.fromList
>>= fromListingsLanguage)
let attr = ("",classes,kvs)
codeBlockWith attr <$> (verbEnv "lstlisting"))
- , ("minted", liftA2 (\l c -> codeBlockWith ("",[l],[]) c)
- (grouped (many1 $ satisfy (/= '}'))) (verbEnv "minted"))
+ , ("minted", do options <- option [] keyvals
+ lang <- grouped (many1 $ satisfy (/='}'))
+ let kvs = [ (if k == "firstnumber"
+ then "startFrom"
+ else k, v) | (k,v) <- options ]
+ let classes = [ lang | not (null lang) ] ++
+ [ "numberLines" |
+ lookup "linenos" options == Just "true" ]
+ let attr = ("",classes,kvs)
+ codeBlockWith attr <$> (verbEnv "minted"))
, ("obeylines", parseFromString
(para . trimInlines . mconcat <$> many inline) =<<
intercalate "\\\\\n" . lines <$> verbEnv "obeylines")