summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn MacFarlane <fiddlosopher@gmail.com>2012-09-30 14:59:13 -0700
committerJohn MacFarlane <fiddlosopher@gmail.com>2012-09-30 14:59:26 -0700
commit9294fc399c933405006fe51d89b92a3ae25e5824 (patch)
treeae8f7217ba9b5bb4b8832fd5a42719c6e984f8db
parent27bd6fb9773ea17359b9c4162a5b84a4ce0cb179 (diff)
Ignore unknown interpreted roles.
The contents are treated as rst, not literal, which will sometimes be wrong.
-rw-r--r--src/Text/Pandoc/Readers/RST.hs15
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"