git.iko.soy/typeable/pandoc
on master help sign in
Ignore unknown interpreted roles.
9294fc3John MacFarlane
src/Text/Pandoc/Readers/RST.hs+12−3
@@ -507,6 +507,7 @@ directive' = do
507 let body' = body ++ "\n\n"
507 let body' = body ++ "\n\n"
508 case label of
508 case label of
509 "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body)
509 "raw" -> return $ B.rawBlock (trim top) (stripTrailingNewlines body)
510+ "role" -> return mempty
510 "container" -> parseFromString parseBlocks body'
511 "container" -> parseFromString parseBlocks body'
511 "replace" -> B.para <$> -- consumed by substKey
512 "replace" -> B.para <$> -- consumed by substKey
512 parseFromString (trimInlines . mconcat <$> many inline)
513 parseFromString (trimInlines . mconcat <$> many inline)
@@ -856,6 +857,7 @@ inline = choice [ whitespace
856 , superscript
857 , superscript
857 , subscript
858 , subscript
858 , math
859 , math
860+ , interpretedRole
859 , note
861 , note
860 , smart
862 , smart
861 , hyphens
863 , hyphens
@@ -921,9 +923,16 @@ interpreted role = try $ do
921 -- Note, this doesn't precisely implement the complex rule in
923 -- Note, this doesn't precisely implement the complex rule in
922 -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules
924 -- http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules
923 -- but it should be good enough for most purposes
925 -- but it should be good enough for most purposes
926+
924− unmarkedInterpretedText = do
927+unmarkedInterpretedText :: RSTParser [Char]
925− result <- enclosed (atStart $ char '`') (char '`') anyChar
928+unmarkedInterpretedText = enclosed (atStart $ char '`') (char '`') anyChar
926− return result
929+
930+-- For unknown interpreted roles, we just ignore the role.
931+interpretedRole :: RSTParser Inlines
932+interpretedRole = try $ B.str <$>
933+ ( (roleMarker *> unmarkedInterpretedText)
934+ <|> (unmarkedInterpretedText <* roleMarker) )
935+ where roleMarker = char ':' *> many1Till (letter <|> char '-') (char ':')
927
936
928superscript :: RSTParser Inlines
937superscript :: RSTParser Inlines
929superscript = B.superscript . B.str <$> interpreted "sup"
938superscript = B.superscript . B.str <$> interpreted "sup"