From f3d27e4c80a8b33493cfdef9fda8247aaa14c801 Mon Sep 17 00:00:00 2001 From: Albert Krewinkel Date: Sat, 21 May 2016 15:40:05 +0200 Subject: Org reader/writer: use CUSTOM_ID in properties The `ID` property is reserved for internal use by Org-mode and should not be used. The `CUSTOM_ID` property is to be used instead, it is converted to the `ID` property for certain export format. The reader and writer erroneously used `ID`. This is corrected by using `CUSTOM_ID` where appropriate. --- src/Text/Pandoc/Writers/Org.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/Text/Pandoc/Writers/Org.hs') diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index bc400c998..e2196dcc7 100644 --- a/src/Text/Pandoc/Writers/Org.hs +++ b/src/Text/Pandoc/Writers/Org.hs @@ -239,8 +239,8 @@ propertiesDrawer (ident, classes, kv) = let drawerStart = text ":PROPERTIES:" drawerEnd = text ":END:" - kv' = if (classes == mempty) then kv else ("class", unwords classes):kv - kv'' = if (ident == mempty) then kv' else ("id", ident):kv' + kv' = if (classes == mempty) then kv else ("CLASS", unwords classes):kv + kv'' = if (ident == mempty) then kv' else ("CUSTOM_ID", ident):kv' properties = vcat $ map kvToOrgProperty kv'' in drawerStart <> cr <> properties <> cr <> drawerEnd -- cgit v1.2.3 From 5667e0959a09035e155beaa1432c48828c4e9396 Mon Sep 17 00:00:00 2001 From: Carlos Sosa Date: Sun, 1 Mar 2015 23:23:21 -0800 Subject: 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 --- src/Text/Pandoc/Writers/Org.hs | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/Text/Pandoc/Writers/Org.hs') 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 -- cgit v1.2.3