diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-05 22:43:27 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-03-05 22:43:27 -0800 |
commit | 8b3a81e4dd8bf46a822980781e28d9777a076c6a (patch) | |
tree | 27a6756e51a356a92f16c1fd4c53ffe2501f816e | |
parent | 3b63cb0903baf4bc551d2b63d884c0fa556f11a0 (diff) | |
download | pandoc-8b3a81e4dd8bf46a822980781e28d9777a076c6a.tar.gz |
LaTeX reader: Handle language attribute for lstlistings.
Convert it to a highlighting-kate language name.
-rw-r--r-- | src/Text/Pandoc/Highlighting.hs | 3 | ||||
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 7 |
2 files changed, 7 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Highlighting.hs b/src/Text/Pandoc/Highlighting.hs index be600fbcd..11d608db6 100644 --- a/src/Text/Pandoc/Highlighting.hs +++ b/src/Text/Pandoc/Highlighting.hs @@ -87,7 +87,8 @@ langToListingsMap :: M.Map String String langToListingsMap = M.fromList langsList listingsToLangMap :: M.Map String String -listingsToLangMap = M.fromList $ reverse langsList +listingsToLangMap = M.fromList $ map switch langsList + where switch (a,b) = (b,a) langsList :: [(String, String)] langsList = [("ada","Ada") diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 887b17068..005120623 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -52,6 +52,7 @@ import Data.List (intercalate) import qualified Data.Map as M import qualified Control.Exception as E import System.FilePath (takeExtension, addExtension) +import Text.Pandoc.Highlighting (fromListingsLanguage) -- | Parse LaTeX from string and return 'Pandoc' document. readLaTeX :: ReaderOptions -- ^ Reader options @@ -819,11 +820,13 @@ environments = M.fromList , ("verbatim", codeBlock <$> (verbEnv "verbatim")) , ("Verbatim", codeBlock <$> (verbEnv "Verbatim")) , ("lstlisting", do options <- option [] keyvals - let classes = [ "numberLines" | - lookup "numbers" options == Just "left" ] let kvs = [ (if k == "firstnumber" then "startFrom" else k, v) | (k,v) <- options ] + let classes = [ "numberLines" | + lookup "numbers" options == Just "left" ] + ++ maybe [] (:[]) (lookup "language" options + >>= fromListingsLanguage) let attr = ("",classes,kvs) codeBlockWith attr <$> (verbEnv "lstlisting")) , ("minted", liftA2 (\l c -> codeBlockWith ("",[l],[]) c) |