RST writer: use .. container for generic Divs, instead of raw HTML.

This commit is contained in:
John MacFarlane 2018-08-13 11:00:28 -07:00
parent 91cc2492fa
commit c3f17cb0d7
2 changed files with 24 additions and 72 deletions

View file

@ -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

View file

@ -385,53 +385,23 @@ HTML Blocks
Simple block on one line:
.. raw:: html
.. container::
<div>
foo
.. raw:: html
</div>
foo
And nested without indentation:
.. raw:: html
.. container::
<div>
.. container::
.. raw:: html
.. container::
<div>
foo
.. raw:: html
.. container::
<div>
foo
.. raw:: html
</div>
.. raw:: html
</div>
.. raw:: html
<div>
bar
.. raw:: html
</div>
.. raw:: html
</div>
bar
Interpreted markdown in a table:
@ -477,15 +447,9 @@ And this is **strong**
Heres a simple block:
.. raw:: html
.. container::
<div>
foo
.. raw:: html
</div>
foo
This should be a code block, though:
@ -503,31 +467,13 @@ As should this:
Now, nested:
.. raw:: html
.. container::
<div>
.. container::
.. raw:: html
.. container::
<div>
.. raw:: html
<div>
foo
.. raw:: html
</div>
.. raw:: html
</div>
.. raw:: html
</div>
foo
This should just be an HTML comment: