aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2012-05-29 16:59:56 -0700
committerJohn MacFarlane <jgm@berkeley.edu>2012-05-29 16:59:56 -0700
commit9a47237412035833ea5c6b7900b11fbd0da29b69 (patch)
tree7dffae855296e64027eb2602a7f3446be58d7400
parent91e9d904b5fa1f8e354a0ae06fc1b3ba76f41ec5 (diff)
downloadpandoc-9a47237412035833ea5c6b7900b11fbd0da29b69.tar.gz
RST reader: handle figures.
Closes #522.
-rw-r--r--src/Text/Pandoc/Readers/RST.hs15
1 files changed, 15 insertions, 0 deletions
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