aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-02-04 12:27:24 -0800
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-02-04 12:27:24 -0800
commit47eb69a7e171ea20968a77749f59462fce571e83 (patch)
tree6a8e373f8b117ab35972e7b5f95ca8e77ab045fc /src/Text/Pandoc/Readers
parentade08f63301a32ca1eee16b2870661341119138d (diff)
downloadpandoc-47eb69a7e171ea20968a77749f59462fce571e83.tar.gz
LaTeX reader: Factored out rawEnv
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs18
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