git.iko.soy/typeable/pandoc
on master help sign in
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>

commit5667e0959a09035e155beaa1432c48828c4e9396 authorCarlos Sosa <gnusosa@gnusosa.net> dateSun 1 Mar 2015, 23:23 (12 years ago) parenta4717c2
1 file changed+11
src/Text/Pandoc/Writers/Org.hs+11
src/Text/Pandoc/Writers/Org.hs+11
@@ -110,6 +110,17 @@ isRawFormat f =
110110blockToOrg :: Block -- ^ Block element
111111 -> State WriterState Doc
112112blockToOrg Null = return empty
113+blockToOrg (Div (_,classes@(cls:_),kvs) bs) | "drawer" `elem` classes = do
114+ contents <- blockListToOrg bs
115+ let drawerNameTag = ":" <> text cls <> ":"
116+ let keys = vcat $ map (\(k,v) ->
117+ ":" <> text k <> ":"
118+ <> space <> text v) kvs
119+ let drawerEndTag = text ":END:"
120+ return $ drawerNameTag $$ cr $$ keys $$
121+ blankline $$ contents $$
122+ blankline $$ drawerEndTag $$
123+ blankline
113124blockToOrg (Div attrs bs) = do
114125 contents <- blockListToOrg bs
115126 let startTag = tagWithAttrs "div" attrs