diff options
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 1efaa9231..5f7d7bcb6 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -507,6 +507,7 @@ directive' = do let body' = body ++ "\n\n" case label of "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body) + "role" -> return mempty "container" -> parseFromString parseBlocks body' "replace" -> B.para <$> -- consumed by substKey parseFromString (trimInlines . mconcat <$> many inline) @@ -856,6 +857,7 @@ inline = choice [ whitespace , superscript , subscript , math + , interpretedRole , note , smart , hyphens @@ -921,9 +923,16 @@ interpreted role = try $ do -- Note, this doesn't precisely implement the complex rule in -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules -- but it should be good enough for most purposes - unmarkedInterpretedText = do - result <- enclosed (atStart $ char '`') (char '`') anyChar - return result + +unmarkedInterpretedText :: RSTParser [Char] +unmarkedInterpretedText = enclosed (atStart $ char '`') (char '`') anyChar + +-- For unknown interpreted roles, we just ignore the role. +interpretedRole :: RSTParser Inlines +interpretedRole = try $ B.str <$> + ( (roleMarker *> unmarkedInterpretedText) + <|> (unmarkedInterpretedText <* roleMarker) ) + where roleMarker = char ':' *> many1Till (letter <|> char '-') (char ':') superscript :: RSTParser Inlines superscript = B.superscript . B.str <$> interpreted "sup" |