diff options
author | John MacFarlane <jgm@berkeley.edu> | 2016-05-23 10:39:08 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2016-05-23 10:39:08 -0700 |
commit | 654bdf72bfe608cea1b606028a4bf9570bb63b8f (patch) | |
tree | d5c54ecb01c1d743673544d05d87ef4cedafaaca /src/Text/Pandoc/Writers/Org.hs | |
parent | e3ca9793aa1d495ad6070ba63cb91311ec69132e (diff) | |
parent | 5667e0959a09035e155beaa1432c48828c4e9396 (diff) | |
download | pandoc-654bdf72bfe608cea1b606028a4bf9570bb63b8f.tar.gz |
Merge pull request #2941 from tarleb/org-drawer-improvements
Org drawer improvements
Diffstat (limited to 'src/Text/Pandoc/Writers/Org.hs')
-rw-r--r-- | src/Text/Pandoc/Writers/Org.hs | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/Org.hs b/src/Text/Pandoc/Writers/Org.hs index bc400c998..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 @@ -239,8 +250,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 |