git.iko.soy/typeable/pandoc
on master help sign in
RST writer: use `.. container` for generic Divs, instead of raw HTML.
commitc3f17cb0d7d590c828214deda1d58e65da1b3812 authorJohn MacFarlane <jgm@berkeley.edu> dateMon 13 Aug 2018, 11:00 (8 years ago) parent91cc249
2 files changed+24−72
src/Text/Pandoc/Writers/RST.hs+10−4 test/writer.rst+14−68
src/Text/Pandoc/Writers/RST.hs+10−4
@@ -211,11 +211,17 @@ blockToRST :: PandocMonad m
211211 => Block -- ^ Block element
212212 -> RST m Doc
213213blockToRST Null = return empty
214−blockToRST (Div attr bs) = do
214+blockToRST (Div (ident,classes,_kvs) bs) = do
215215 contents <- blockListToRST bs
216− let startTag = ".. raw:: html" $+$ nest 3 (tagWithAttrs "div" attr)
217− let endTag = ".. raw:: html" $+$ nest 3 "</div>"
218− return $ blankline <> startTag $+$ contents $+$ endTag $$ blankline
216+ let classes' = filter (/= "container") classes
217+ return $ blankline $$
218+ (".. container::" <> space <>
219+ text (unwords classes')) $$
220+ (if null ident
221+ then blankline
222+ else " :name: " <> text ident $$ blankline) $$
223+ nest 3 contents $$
224+ blankline
219225blockToRST (Plain inlines) = inlineListToRST inlines
220226-- title beginning with fig: indicates that the image is a figure
221227blockToRST (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
test/writer.rst+14−68
@@ -385,53 +385,23 @@ HTML Blocks
385385
386386Simple block on one line:
387387
388−.. raw:: html
389−
390− <div>
391−
392−foo
388+.. container::
393389
394−.. raw:: html
395−
396− </div>
390+ foo
397391
398392And nested without indentation:
399393
400−.. raw:: html
401−
402− <div>
403−
404−.. raw:: html
405−
406− <div>
407−
408−.. raw:: html
409−
410− <div>
411−
412−foo
413−
414−.. raw:: html
415−
416− </div>
417−
418−.. raw:: html
419−
420− </div>
394+.. container::
421395
422−.. raw:: html
396+ .. container::
423397
424− <div>
398+ .. container::
425399
426−bar
400+ foo
427401
428−.. raw:: html
402+ .. container::
429403
430− </div>
431−
432−.. raw:: html
433−
434− </div>
404+ bar
435405
436406Interpreted markdown in a table:
437407
@@ -477,15 +447,9 @@ And this is **strong**
477447
478448Here’s a simple block:
479449
480−.. raw:: html
481−
482− <div>
483−
484−foo
485−
486−.. raw:: html
450+.. container::
487451
488− </div>
452+ foo
489453
490454This should be a code block, though:
491455
@@ -503,31 +467,13 @@ As should this:
503467
504468Now, nested:
505469
506−.. raw:: html
507−
508− <div>
470+.. container::
509471
510−.. raw:: html
472+ .. container::
511473
512− <div>
474+ .. container::
513475
514−.. raw:: html
515−
516− <div>
517−
518−foo
519−
520−.. raw:: html
521−
522− </div>
523−
524−.. raw:: html
525−
526− </div>
527−
528−.. raw:: html
529−
530− </div>
476+ foo
531477
532478This should just be an HTML comment:
533479