git.iko.soy/typeable/pandoc
on master help sign in
LaTeX reader: more robust parsing of unknown environments.
1b6c973John MacFarlane
src/Text/Pandoc/Readers/LaTeX.hs+9−2
@@ -859,8 +859,14 @@ tok = try $ grouped inline <|> inlineCommand <|> str <$> count 1 inlineChar
859opt :: LP Inlines
859opt :: LP Inlines
860opt = bracketed inline
860opt = bracketed inline
861
861
862+rawopt :: LP String
863+rawopt = do
864+ contents <- bracketed (many1 (noneOf "]") <|> try (string "\\]"))
865+ optional sp
866+ return $ "[" ++ contents ++ "]"
867+
862skipopts :: LP ()
868skipopts :: LP ()
863−skipopts = skipMany (opt *> optional sp)
869+skipopts = skipMany rawopt
864
870
865inlineText :: LP Inlines
871inlineText :: LP Inlines
866inlineText = str <$> many1 inlineChar
872inlineText = str <$> many1 inlineChar
@@ -883,8 +889,9 @@ inlineEnvironment = try $ do
883
889
884rawEnv :: String -> LP Blocks
890rawEnv :: String -> LP Blocks
885rawEnv name = do
891rawEnv name = do
886− let addBegin x = "\\begin{" ++ name ++ "}" ++ x
887 parseRaw <- getOption readerParseRaw
892 parseRaw <- getOption readerParseRaw
893+ rawOptions <- mconcat <$> many rawopt
894+ let addBegin x = "\\begin{" ++ name ++ "}" ++ rawOptions ++ x
888 if parseRaw
895 if parseRaw
889 then (rawBlock "latex" . addBegin) <$>
896 then (rawBlock "latex" . addBegin) <$>
890 (withRaw (env name blocks) >>= applyMacros' . snd)
897 (withRaw (env name blocks) >>= applyMacros' . snd)