diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2013-06-27 18:54:31 -0700 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2013-06-27 18:54:31 -0700 |
commit | 82e46bf3852b776defab85f3347115260d332250 (patch) | |
tree | ab11f775bb50e1b4356a8c302df492e87c3344c9 /src/Text | |
parent | 79a4ea03e2d0a252fd24af3444cf5b64ee724100 (diff) | |
download | pandoc-82e46bf3852b776defab85f3347115260d332250.tar.gz |
LaTeX reader: Support alltt environment.
Closes #892.
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 0d4afb2a7..1a22f2ad2 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -35,6 +35,7 @@ module Text.Pandoc.Readers.LaTeX ( readLaTeX, ) where import Text.Pandoc.Definition +import Text.Pandoc.Generic import Text.Pandoc.Shared import Text.Pandoc.Options import Text.Pandoc.Biblio (processBiblio) @@ -48,7 +49,7 @@ import Control.Applicative import Data.Monoid import System.Environment (getEnv) import System.FilePath (replaceExtension, (</>)) -import Data.List (intercalate) +import Data.List (intercalate, intersperse) import qualified Data.Map as M import qualified Control.Exception as E import System.FilePath (takeExtension, addExtension) @@ -776,13 +777,21 @@ keyval = try $ do keyvals :: LP [(String, String)] keyvals = try $ char '[' *> manyTill keyval (char ']') +alltt :: String -> LP Blocks +alltt t = bottomUp strToCode <$> parseFromString blocks + (substitute " " "\\ " $ substitute "%" "\\%" $ + concat $ intersperse "\\\\\n" $ lines t) + where strToCode (Str s) = Code nullAttr s + strToCode x = x + verbatimEnv :: LP (String, String) verbatimEnv = do (_,r) <- withRaw $ do controlSeq "begin" name <- braced guard $ name == "verbatim" || name == "Verbatim" || - name == "lstlisting" || name == "minted" + name == "lstlisting" || name == "minted" || + name == "alltt" verbEnv name rest <- getInput return (r,rest) @@ -808,6 +817,7 @@ environments = M.fromList , ("itemize", bulletList <$> listenv "itemize" (many item)) , ("description", definitionList <$> listenv "description" (many descItem)) , ("enumerate", ordered_list) + , ("alltt", alltt =<< verbEnv "alltt") , ("code", guardEnabled Ext_literate_haskell *> (codeBlockWith ("",["sourceCode","literate","haskell"],[]) <$> verbEnv "code")) |