aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Text/Pandoc/Writers/RST.hs14
-rw-r--r--test/writer.rst82
2 files changed, 24 insertions, 72 deletions
diff --git a/src/Text/Pandoc/Writers/RST.hs b/src/Text/Pandoc/Writers/RST.hs
index 566bcbeef..7a299e4e9 100644
--- a/src/Text/Pandoc/Writers/RST.hs
+++ b/src/Text/Pandoc/Writers/RST.hs
@@ -211,11 +211,17 @@ blockToRST :: PandocMonad m
=> Block -- ^ Block element
-> RST m Doc
blockToRST Null = return empty
-blockToRST (Div attr bs) = do
+blockToRST (Div (ident,classes,_kvs) bs) = do
contents <- blockListToRST bs
- let startTag = ".. raw:: html" $+$ nest 3 (tagWithAttrs "div" attr)
- let endTag = ".. raw:: html" $+$ nest 3 "</div>"
- return $ blankline <> startTag $+$ contents $+$ endTag $$ blankline
+ let classes' = filter (/= "container") classes
+ return $ blankline $$
+ (".. container::" <> space <>
+ text (unwords classes')) $$
+ (if null ident
+ then blankline
+ else " :name: " <> text ident $$ blankline) $$
+ nest 3 contents $$
+ blankline
blockToRST (Plain inlines) = inlineListToRST inlines
-- title beginning with fig: indicates that the image is a figure
blockToRST (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
diff --git a/test/writer.rst b/test/writer.rst
index 0c986b887..b47490de2 100644
--- a/test/writer.rst
+++ b/test/writer.rst
@@ -385,53 +385,23 @@ HTML Blocks
Simple block on one line:
-.. raw:: html
-
- <div>
-
-foo
+.. container::
-.. raw:: html
-
- </div>
+ foo
And nested without indentation:
-.. raw:: html
-
- <div>
-
-.. raw:: html
-
- <div>
-
-.. raw:: html
-
- <div>
-
-foo
-
-.. raw:: html
-
- </div>
-
-.. raw:: html
-
- </div>
+.. container::
-.. raw:: html
+ .. container::
- <div>
+ .. container::
-bar
+ foo
-.. raw:: html
+ .. container::
- </div>
-
-.. raw:: html
-
- </div>
+ bar
Interpreted markdown in a table:
@@ -477,15 +447,9 @@ And this is **strong**
Here’s a simple block:
-.. raw:: html
-
- <div>
-
-foo
-
-.. raw:: html
+.. container::
- </div>
+ foo
This should be a code block, though:
@@ -503,31 +467,13 @@ As should this:
Now, nested:
-.. raw:: html
-
- <div>
+.. container::
-.. raw:: html
+ .. container::
- <div>
+ .. container::
-.. raw:: html
-
- <div>
-
-foo
-
-.. raw:: html
-
- </div>
-
-.. raw:: html
-
- </div>
-
-.. raw:: html
-
- </div>
+ foo
This should just be an HTML comment: