From 9294fc399c933405006fe51d89b92a3ae25e5824 Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 30 Sep 2012 14:59:13 -0700 Subject: Ignore unknown interpreted roles. The contents are treated as rst, not literal, which will sometimes be wrong. --- src/Text/Pandoc/Readers/RST.hs | 15 ++++++++++++--- 1 file 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" -- cgit v1.2.3