git.iko.soy/typeable/pandoc
on master help sign in
Fixed latex macro parsing.
8c55023John MacFarlane
src/Text/Pandoc/Parsing.hs+4−4
@@ -148,7 +148,7 @@ where
148
148
149import Text.Pandoc.Definition
149import Text.Pandoc.Definition
150import Text.Pandoc.Options
150import Text.Pandoc.Options
151−import Text.Pandoc.Builder (Blocks, Inlines)
151+import Text.Pandoc.Builder (Blocks, Inlines, rawBlock)
152import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
152import qualified Text.Pandoc.UTF8 as UTF8 (putStrLn)
153import Text.Parsec
153import Text.Parsec
154import Text.Parsec.Pos (newPos)
154import Text.Parsec.Pos (newPos)
@@ -1007,7 +1007,7 @@ nested p = do
1007--
1007--
1008
1008
1009-- | Parse a \newcommand or \renewcommand macro definition.
1009-- | Parse a \newcommand or \renewcommand macro definition.
1010−macro :: Parser [Char] ParserState Block
1010+macro :: Parser [Char] ParserState Blocks
1011macro = do
1011macro = do
1012 apply <- getOption readerApplyMacros
1012 apply <- getOption readerApplyMacros
1013 inp <- getInput
1013 inp <- getInput
@@ -1018,8 +1018,8 @@ macro = do
1018 then do
1018 then do
1019 updateState $ \st ->
1019 updateState $ \st ->
1020 st { stateMacros = ms ++ stateMacros st }
1020 st { stateMacros = ms ++ stateMacros st }
1021− return Null
1021+ return mempty
1022− else return $ RawBlock "latex" def'
1022+ else return $ rawBlock "latex" def'
1023
1023
1024-- | Apply current macros to string.
1024-- | Apply current macros to string.
1025applyMacros' :: String -> Parser [Char] ParserState String
1025applyMacros' :: String -> Parser [Char] ParserState String
src/Text/Pandoc/Readers/LaTeX.hs+1−1
@@ -204,7 +204,7 @@ block :: LP Blocks
204block = (mempty <$ comment)
204block = (mempty <$ comment)
205 <|> (mempty <$ ((spaceChar <|> newline) *> spaces))
205 <|> (mempty <$ ((spaceChar <|> newline) *> spaces))
206 <|> environment
206 <|> environment
207− <|> mempty <$ macro
207+ <|> macro
208 <|> blockCommand
208 <|> blockCommand
209 <|> paragraph
209 <|> paragraph
210 <|> grouped block
210 <|> grouped block
src/Text/Pandoc/Readers/Markdown.hs+1−1
@@ -355,7 +355,7 @@ parseBlocks = mconcat <$> manyTill block eof
355
355
356block :: MarkdownParser (F Blocks)
356block :: MarkdownParser (F Blocks)
357block = choice [ codeBlockFenced
357block = choice [ codeBlockFenced
358− , guardEnabled Ext_latex_macros *> (mempty <$ macro)
358+ , guardEnabled Ext_latex_macros *> (macro >>= return . return)
359 , header
359 , header
360 , lhsCodeBlock
360 , lhsCodeBlock
361 , rawTeXBlock
361 , rawTeXBlock