diff options
-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) |