aboutsummaryrefslogtreecommitdiff
path: root/src/Text
diff options
context:
space:
mode:
authorCarlos Sosa <gnusosa@gnusosa.net>2015-03-01 23:23:21 -0800
committerAlbert Krewinkel <albert@zeitkraut.de>2016-05-23 10:00:14 +0200
commit5667e0959a09035e155beaa1432c48828c4e9396 (patch)
tree3c10852dc866b863ea17ee9ff467c7f82546b737 /src/Text
parenta4717c2fc5d82bc4740b21927ca7db3115a8b1af (diff)
downloadpandoc-5667e0959a09035e155beaa1432c48828c4e9396.tar.gz
Org writer: add drawer capability
For the implementation of the Drawer element in the Org Writer, we make use of a generic Block container with attributes. The presence of a `drawer` class defines that the `Div` constructor is a drawer. The first class defines the drawer name to use. The key-value list in the attributes defines the keys to add inside the Drawer. Lastly, the list of Block elements contains miscellaneous blocks elements to add inside of the Drawer. Signed-off-by: Albert Krewinkel <albert@zeitkraut.de>
Diffstat (limited to 'src/Text')
-rw-r--r--src/Text/Pandoc/Writers/Org.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs
index e2196dcc7..f87aeca81 100644
--- a/src/Text/Pandoc/Writers/Org.hs
+++ b/src/Text/Pandoc/Writers/Org.hs
@@ -110,6 +110,17 @@ isRawFormat f =
blockToOrg :: Block -- ^ Block element
-> State WriterState Doc
blockToOrg Null = return empty
+blockToOrg (Div (_,classes@(cls:_),kvs) bs) | "drawer" `elem` classes = do
+ contents <- blockListToOrg bs
+ let drawerNameTag = ":" <> text cls <> ":"
+ let keys = vcat $ map (\(k,v) ->
+ ":" <> text k <> ":"
+ <> space <> text v) kvs
+ let drawerEndTag = text ":END:"
+ return $ drawerNameTag $$ cr $$ keys $$
+ blankline $$ contents $$
+ blankline $$ drawerEndTag $$
+ blankline
blockToOrg (Div attrs bs) = do
contents <- blockListToOrg bs
let startTag = tagWithAttrs "div" attrs