aboutsummaryrefslogtreecommitdiff
path: root/src/Text/Pandoc/Writers
diff options
context:
space:
mode:
authorclaremacrae <github@cfmacrae.fastmail.co.uk>2013-08-17 08:48:29 +0100
committerclaremacrae <github@cfmacrae.fastmail.co.uk>2013-08-17 08:48:29 +0100
commiteb4fe5e82c65b5dc2f5689e4b1bceff0179397b5 (patch)
tree540a9e9dbdc385b812f2d07dba515b6fd1fa8c6b /src/Text/Pandoc/Writers
parent48645a47555dd5c243f5d28f9c8274b368917856 (diff)
downloadpandoc-eb4fe5e82c65b5dc2f5689e4b1bceff0179397b5.tar.gz
Implement table headings in dokuwiki writer (#386)
Diffstat (limited to 'src/Text/Pandoc/Writers')
-rw-r--r--src/Text/Pandoc/Writers/DokuWiki.hs21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/Text/Pandoc/Writers/DokuWiki.hs b/src/Text/Pandoc/Writers/DokuWiki.hs
index 87145d723..76fe2fa36 100644
--- a/src/Text/Pandoc/Writers/DokuWiki.hs
+++ b/src/Text/Pandoc/Writers/DokuWiki.hs
@@ -36,7 +36,7 @@ DokuWiki: <https://www.dokuwiki.org/dokuwiki>
[ ] Implement definition lists
[ ] Don't generate lists using <ol> and <ul>
[ ] Don't generate <div>
- [ ] Implement conversion of tables
+ [ ] Implement alignment of text in tables
[ ] Implement comments
[ ] Work through the Dokuwiki spec, and check I've not missed anything out
[ ] Test the output in Dokuwiki - and compare against the display of another format, e.g. HTML
@@ -160,7 +160,7 @@ blockToDokuWiki opts (Table capt aligns _ headers rows') = do
head' <- if all null headers
then return ""
else do
- hs <- tableRowToDokuWiki opts alignStrings 0 headers
+ hs <- tableHeaderToDokuWiki opts alignStrings 0 headers
return $ hs ++ "\n"
body' <- zipWithM (tableRowToDokuWiki opts alignStrings) [1..] rows'
return $ captionDoc ++ head' ++
@@ -314,6 +314,19 @@ vcat = intercalate "\n"
-- Auxiliary functions for tables:
+-- TODO Eliminate copy-and-pasted code in tableHeaderToDokuWiki and tableRowToDokuWiki
+tableHeaderToDokuWiki :: WriterOptions
+ -> [String]
+ -> Int
+ -> [[Block]]
+ -> State WriterState String
+tableHeaderToDokuWiki opts alignStrings rownum cols' = do
+ let celltype = if rownum == 0 then "" else ""
+ cols'' <- sequence $ zipWith
+ (\alignment item -> tableItemToDokuWiki opts celltype alignment item)
+ alignStrings cols'
+ return $ "^ " ++ "" ++ joinHeaders cols'' ++ " ^"
+
tableRowToDokuWiki :: WriterOptions
-> [String]
-> Int
@@ -348,6 +361,10 @@ tableItemToDokuWiki opts celltype align' item = do
joinColumns :: [String] -> String
joinColumns = intercalate " | "
+-- | Concatenates headers together.
+joinHeaders :: [String] -> String
+joinHeaders = intercalate " ^ "
+
-- | Convert list of Pandoc block elements to DokuWiki.
blockListToDokuWiki :: WriterOptions -- ^ Options
-> [Block] -- ^ List of block elements