diff options
-rw-r--r-- | src/Text/Pandoc/Readers/RST.hs | 6 | ||||
-rw-r--r-- | src/Text/Pandoc/Writers/RST.hs | 7 | ||||
-rw-r--r-- | test/Tests/Readers/RST.hs | 3 | ||||
-rw-r--r-- | test/command/3407.md | 13 |
4 files changed, 23 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Readers/RST.hs b/src/Text/Pandoc/Readers/RST.hs index 0f594fe1b..190b065fb 100644 --- a/src/Text/Pandoc/Readers/RST.hs +++ b/src/Text/Pandoc/Readers/RST.hs @@ -1399,10 +1399,8 @@ renderRole contents fmt role attr = case role of case M.lookup custom customRoles of Just (newRole, newFmt, newAttr) -> renderRole contents newFmt newRole newAttr - Nothing -> do - pos <- getPosition - logMessage $ SkippedContent (":" ++ custom ++ ":") pos - return $ B.str contents -- Undefined role + Nothing -> -- undefined role + return $ B.spanWith ("",[],[("role",role)]) (B.str contents) where titleRef ref = return $ B.str ref -- FIXME: Not a sensible behaviour rfcLink rfcNo = B.link rfcUrl ("RFC " ++ rfcNo) $ B.str ("RFC " ++ rfcNo) diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs index 17f5b3f91..8c941f568 100644 --- a/src/Text/Pandoc/Writers/RST.hs +++ b/src/Text/Pandoc/Writers/RST.hs @@ -439,7 +439,12 @@ inlineListToRST lst = -- | Convert Pandoc inline element to RST. inlineToRST :: PandocMonad m => Inline -> RST m Doc -inlineToRST (Span _ ils) = inlineListToRST ils +inlineToRST (Span (_,_,kvs) ils) = do + contents <- inlineListToRST ils + return $ + case lookup "role" kvs of + Just role -> ":" <> text role <> ":`" <> contents <> "`" + Nothing -> contents inlineToRST (Emph lst) = do contents <- inlineListToRST lst return $ "*" <> contents <> "*" diff --git a/test/Tests/Readers/RST.hs b/test/Tests/Readers/RST.hs index cbca1564f..61a2673f5 100644 --- a/test/Tests/Readers/RST.hs +++ b/test/Tests/Readers/RST.hs @@ -162,7 +162,8 @@ tests = [ "line block with blank line" =: , "role with recursive inheritance" =: ".. role:: haskell(code)\n.. role:: lhs(haskell)\n\n:lhs:`text`" =?> para (codeWith ("", ["lhs", "haskell", "sourceCode"], []) "text") - , "unknown role" =: ":unknown:`text`" =?> para (str "text") + , "unknown role" =: ":unknown:`text`" =?> + para (spanWith ("",[],[("role","unknown")]) (str "text")) ] , testGroup "footnotes" [ "remove space before note" =: T.unlines diff --git a/test/command/3407.md b/test/command/3407.md new file mode 100644 index 000000000..3160d1263 --- /dev/null +++ b/test/command/3407.md @@ -0,0 +1,13 @@ +``` +% pandoc -f native -t rst +[Para [Span ("",[],[("role","foo")]) [Str "text"]]] +^D +:foo:`text` +``` + +``` +% pandoc -f rst -t native +:foo:`text` +^D +[Para [Span ("",[],[("role","foo")]) [Str "text"]]] +``` |