From 9a47237412035833ea5c6b7900b11fbd0da29b69 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Tue, 29 May 2012 16:59:56 -0700 Subject: RST reader: handle figures. Closes #522. --- src/Text/Pandoc/Readers/RST.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/Text/Pandoc') diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 35fe5d768..d1010a736 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -127,6 +127,7 @@ block = choice [ codeBlock , blockQuote , fieldList , imageBlock + , figureBlock , customCodeBlock , mathBlock , defaultRoleBlock @@ -362,6 +363,20 @@ customCodeBlock = try $ do result <- indentedBlock return $ CodeBlock ("", ["sourceCode", language], []) $ stripTrailingNewlines result + +figureBlock :: GenParser Char ParserState Block +figureBlock = try $ do + string ".. figure::" + src <- removeLeadingTrailingSpace `fmap` manyTill anyChar newline + body <- indentedBlock + caption <- parseFromString extractCaption body + return $ Para [Image caption (src,"")] + +extractCaption :: GenParser Char ParserState [Inline] +extractCaption = try $ do + manyTill anyLine blanklines + many inline + -- | The 'math' directive (from Sphinx) for display math. mathBlock :: GenParser Char st Block mathBlock = try $ do -- cgit v1.2.3