aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc
diff options
context:
space:
mode:
authorNikolay Yakimov <root@livid.pp.ru>2015-03-21 22:39:07 +0300
committerNikolay Yakimov <root@livid.pp.ru>2015-03-30 05:37:00 +0300
commitf3e8274d0425b3bf7a2459a2d88af585b491507f (patch)
tree91ec28f8ec2b3b63114ec2f442cc4fe04a45caf5 /src/Text/Pandoc
parent34c6ff1f602cefa6c68af096a69bd1483e613606 (diff)
downloadpandoc-f3e8274d0425b3bf7a2459a2d88af585b491507f.tar.gz
LaTeX Reader: check for block-level newcommand aliases in blockCommand
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r--src/Text/Pandoc/Readers/LaTeX.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/LaTeX.hs b/src/Text/Pandoc/Readers/LaTeX.hs
index a517f9566..4d50ec4ed 100644
--- a/src/Text/Pandoc/Readers/LaTeX.hs
+++ b/src/Text/Pandoc/Readers/LaTeX.hs
@@ -239,17 +239,28 @@ block = (mempty <$ comment)
blocks :: LP Blocks
blocks = mconcat <$> many block
+getRawCommand :: String -> LP String
+getRawCommand name' = do
+ rawargs <- withRaw (skipopts *> option "" dimenarg *> many braced)
+ return $ '\\' : name' ++ snd rawargs
+
blockCommand :: LP Blocks
blockCommand = try $ do
name <- anyControlSeq
guard $ name /= "begin" && name /= "end"
star <- option "" (string "*" <* optional sp)
let name' = name ++ star
+ let raw = do
+ rawcommand <- getRawCommand name'
+ transformed <- applyMacros' rawcommand
+ if transformed /= rawcommand
+ then parseFromString blocks transformed
+ else mzero
case M.lookup name' blockCommands of
Just p -> p
Nothing -> case M.lookup name blockCommands of
Just p -> p
- Nothing -> mzero
+ Nothing -> raw
inBrackets :: Inlines -> Inlines
inBrackets x = (str "[") <> x <> (str "]")
@@ -385,8 +396,7 @@ inlineCommand = try $ do
star <- option "" (string "*")
let name' = name ++ star
let raw = do
- rawargs <- withRaw (skipopts *> option "" dimenarg *> many braced)
- let rawcommand = '\\' : name ++ star ++ snd rawargs
+ rawcommand <- getRawCommand name'
transformed <- applyMacros' rawcommand
if transformed /= rawcommand
then parseFromString inlines transformed