aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Readers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Text/Pandoc/Readers')
-rw-r--r--src/Text/Pandoc/Readers/RST.hs15
-rw-r--r--src/Text/Pandoc/Readers/Textile.hs15
2 files changed, 19 insertions, 11 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
diff --git a/src/Text/Pandoc/Readers/Textile.hs b/src/Text/Pandoc/Readers/Textile.hs
index abc686a84..348900d38 100644
--- a/src/Text/Pandoc/Readers/Textile.hs
+++ b/src/Text/Pandoc/Readers/Textile.hs
@@ -493,19 +493,12 @@ escapedInline :: GenParser Char ParserState Inline
escapedInline = escapedEqs <|> escapedTag
escapedEqs :: GenParser Char ParserState Inline
-escapedEqs = Str <$> (try $ surrounded (string "==") anyChar)
-
--- -- | literal text escaped between == ... ==
--- escapedEqs :: GenParser Char ParserState Inline
--- escapedEqs = try $ do
--- string "=="
--- contents <- manyTill anyChar (try $ string "==")
--- return $ Str contents
+escapedEqs = Str <$> (try $ string "==" *> manyTill anyChar (try $ string "=="))
-- | literal text escaped btw <notextile> tags
escapedTag :: GenParser Char ParserState Inline
-escapedTag = try $ Str <$>
- enclosed (string "<notextile>") (string "</notextile>") anyChar
+escapedTag = Str <$>
+ (try $ string "<notextile>" *> manyTill anyChar (try $ string "</notextile>"))
-- | Any special symbol defined in wordBoundaries
symbol :: GenParser Char ParserState Inline
@@ -533,7 +526,7 @@ attributes = choice [ enclosed (char '(') (char ')') anyChar,
surrounded :: GenParser Char st t -- ^ surrounding parser
-> GenParser Char st a -- ^ content parser (to be used repeatedly)
-> GenParser Char st [a]
-surrounded border = enclosed border border
+surrounded border = enclosed border (try border)
-- | Inlines are most of the time of the same form
simpleInline :: GenParser Char ParserState t -- ^ surrounding parser