git.iko.soy/typeable/pandoc
on master help sign in
RST writer: use `.. container` for generic Divs, instead of raw HTML.
c3f17cbJohn MacFarlane
src/Text/Pandoc/Writers/RST.hs+10−4
@@ -211,11 +211,17 @@ blockToRST :: PandocMonad m
211 => Block -- ^ Block element
211 => Block -- ^ Block element
212 -> RST m Doc
212 -> RST m Doc
213blockToRST Null = return empty
213blockToRST Null = return empty
214−blockToRST (Div attr bs) = do
214+blockToRST (Div (ident,classes,_kvs) bs) = do
215 contents <- blockListToRST bs
215 contents <- blockListToRST bs
216− let startTag = ".. raw:: html" $+$ nest 3 (tagWithAttrs "div" attr)
216+ let classes' = filter (/= "container") classes
217− let endTag = ".. raw:: html" $+$ nest 3 "</div>"
218− return $ blankline <> startTag $+$ contents $+$ endTag $$ blankline
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
219blockToRST (Plain inlines) = inlineListToRST inlines
225blockToRST (Plain inlines) = inlineListToRST inlines
220-- title beginning with fig: indicates that the image is a figure
226-- title beginning with fig: indicates that the image is a figure
221blockToRST (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
227blockToRST (Para [Image attr txt (src,'f':'i':'g':':':tit)]) = do
test/writer.rst+14−68
@@ -385,53 +385,23 @@ HTML Blocks
385
385
386Simple block on one line:
386Simple block on one line:
387
387
388−.. raw:: html
388+.. container::
389−
390− <div>
391−
392−foo
393
389
394−.. raw:: html
390+ foo
395−
396− </div>
397
391
398And nested without indentation:
392And nested without indentation:
399
393
400−.. raw:: html
394+.. container::
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>
421
395
422−.. raw:: html
396+ .. container::
423
397
424− <div>
398+ .. container::
425
399
426−bar
400+ foo
427
401
428−.. raw:: html
402+ .. container::
429
403
430− </div>
404+ bar
431−
432−.. raw:: html
433−
434− </div>
435
405
436Interpreted markdown in a table:
406Interpreted markdown in a table:
437
407
@@ -477,15 +447,9 @@ And this is **strong**
477
447
478Here’s a simple block:
448Here’s a simple block:
479
449
480−.. raw:: html
450+.. container::
481−
482− <div>
483−
484−foo
485−
486−.. raw:: html
487
451
488− </div>
452+ foo
489
453
490This should be a code block, though:
454This should be a code block, though:
491
455
@@ -503,31 +467,13 @@ As should this:
503
467
504Now, nested:
468Now, nested:
505
469
506−.. raw:: html
470+.. container::
507−
508− <div>
509
471
510−.. raw:: html
472+ .. container::
511
473
512− <div>
474+ .. container::
513
475
514−.. raw:: html
515−
516− <div>
517−
518−foo
476+ foo
519−
520−.. raw:: html
521−
522− </div>
523−
524−.. raw:: html
525−
526− </div>
527−
528−.. raw:: html
529−
530− </div>
531
477
532This should just be an HTML comment:
478This should just be an HTML comment:
533
479