aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/RST.hs15
-rw-r--r--test/command/4833.md20
2 files changed, 32 insertions, 3 deletions
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index 7a299e4e9..005db5e77 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -211,12 +211,21 @@ blockToRST :: PandocMonad m
=> Block -- ^ Block element
-> RST m Doc
blockToRST Null = return empty
+blockToRST (Div ("",["admonition-title"],[]) _) = return empty
+ -- this is generated by the rst reader and can safely be
+ -- omitted when we're generating rst
blockToRST (Div (ident,classes,_kvs) bs) = do
contents <- blockListToRST bs
- let classes' = filter (/= "container") classes
+ let admonitions = ["attention","caution","danger","error","hint",
+ "important","note","tip","warning","admonition"]
+ let admonition = case classes of
+ (cl:_)
+ | cl `elem` admonitions
+ -> ".. " <> text cl <> "::"
+ cls -> ".. container::" <> space <>
+ text (unwords (filter (/= "container") cls))
return $ blankline $$
- (".. container::" <> space <>
- text (unwords classes')) $$
+ admonition $$
(if null ident
then blankline
else " :name: " <> text ident $$ blankline) $$
diff --git a/test/command/4833.md b/test/command/4833.md
new file mode 100644
index 000000000..ed6de606b
--- /dev/null
+++ b/test/command/4833.md
@@ -0,0 +1,20 @@
+```
+pandoc -f native -t rst
+[Div ("",["warning"],[])
+ [Div ("",["admonition-title"],[])
+ [Para [Str "Warning"]]
+ ,Para [Str "Hi"]]]
+^D
+.. warning::
+
+ Hi
+```
+```
+pandoc -f native -t rst
+[Div ("",["unknown"],[])
+ [Para [Str "Hi"]]]
+^D
+.. container:: unknown
+
+ Hi
+```