diff options
author | John MacFarlane <jgm@berkeley.edu> | 2018-08-13 11:12:16 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2018-08-13 11:17:26 -0700 |
commit | 919c50162ccc3d7a347a9427ca23887e54e8a333 (patch) | |
tree | 4071943f8bb4548af45072769fabfa1299d47892 /src/Text/Pandoc | |
parent | c3f17cb0d7d590c828214deda1d58e65da1b3812 (diff) | |
download | pandoc-919c50162ccc3d7a347a9427ca23887e54e8a333.tar.gz |
RST writer: render Divs with admonition classes as admonitions.
Also omit Div with class "admonition-title". These are generated
by the RST reader and should be omitted on round-trip.
Closes #4833.
Diffstat (limited to 'src/Text/Pandoc')
-rw-r--r-- | src/Text/Pandoc/Writers/RST.hs | 15 |
1 files changed, 12 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) $$ |