diff options
author | John MacFarlane <fiddlosopher@gmail.com> | 2012-02-04 12:27:24 -0800 |
---|---|---|
committer | John MacFarlane <fiddlosopher@gmail.com> | 2012-02-04 12:27:24 -0800 |
commit | 47eb69a7e171ea20968a77749f59462fce571e83 (patch) | |
tree | 6a8e373f8b117ab35972e7b5f95ca8e77ab045fc /src/Text/Pandoc | |
parent | ade08f63301a32ca1eee16b2870661341119138d (diff) | |
download | pandoc-47eb69a7e171ea20968a77749f59462fce571e83.tar.gz |
LaTeX reader: Factored out rawEnv
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/LaTeX.hs | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs index 5cd13fa1d..6b537550f 100644 --- a/src/Text/Pandoc/Readers/LaTeX.hs +++ b/src/Text/Pandoc/Readers/LaTeX.hs @@ -514,14 +514,18 @@ environment :: LP Blocks environment = do controlSeq "begin" name <- braced - parseRaw <- stateParseRaw `fmap` getState - let addBegin x = "\\begin{" ++ name ++ "}" ++ x case M.lookup name environments of - Just p -> p - Nothing -> if parseRaw - then (rawBlock "latex" . addBegin) <$> - (withRaw (env name blocks) >>= applyMacros' . snd) - else env name blocks + Just p -> p <|> rawEnv name + Nothing -> rawEnv name + +rawEnv :: String -> LP Blocks +rawEnv name = do + let addBegin x = "\\begin{" ++ name ++ "}" ++ x + parseRaw <- stateParseRaw `fmap` getState + if parseRaw + then (rawBlock "latex" . addBegin) <$> + (withRaw (env name blocks) >>= applyMacros' . snd) + else env name blocks -- | Replace "include" commands with file contents. handleIncludes :: String -> IO String |