From 47eb69a7e171ea20968a77749f59462fce571e83 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sat, 4 Feb 2012 12:27:24 -0800 Subject: LaTeX reader: Factored out rawEnv --- src/Text/Pandoc/Readers/LaTeX.hs | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/Text/Pandoc') 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 -- cgit v1.2.3