@@ -36,7 +36,7 @@ DokuWiki: <https://www.dokuwiki.org/dokuwiki>
36 [ ] Implement definition lists
36 [ ] Implement definition lists
37 [ ] Don't generate lists using <ol> and <ul>
37 [ ] Don't generate lists using <ol> and <ul>
38 [ ] Don't generate <div>
38 [ ] Don't generate <div>
39− [ ] Implement conversion of tables
39+ [ ] Implement alignment of text in tables
40 [ ] Implement comments
40 [ ] Implement comments
41 [ ] Work through the Dokuwiki spec, and check I've not missed anything out
41 [ ] Work through the Dokuwiki spec, and check I've not missed anything out
42 [ ] Test the output in Dokuwiki - and compare against the display of another format, e.g. HTML
42 [ ] 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
160 head' <- if all null headers
160 head' <- if all null headers
161 then return ""
161 then return ""
163− hs <- tableRowToDokuWiki opts alignStrings 0 headers
163+ hs <- tableHeaderToDokuWiki opts alignStrings 0 headers
164 return $ hs ++ "\n"
164 return $ hs ++ "\n"
165 body' <- zipWithM (tableRowToDokuWiki opts alignStrings) [1..] rows'
165 body' <- zipWithM (tableRowToDokuWiki opts alignStrings) [1..] rows'
166 return $ captionDoc ++ head' ++
166 return $ captionDoc ++ head' ++
@@ -314,6 +314,19 @@ vcat = intercalate "\n"
315-- Auxiliary functions for tables:
315-- Auxiliary functions for tables:
317+-- TODO Eliminate copy-and-pasted code in tableHeaderToDokuWiki and tableRowToDokuWiki
318+tableHeaderToDokuWiki :: WriterOptions
322+ -> State WriterState String
323+tableHeaderToDokuWiki opts alignStrings rownum cols' = do
324+ let celltype = if rownum == 0 then "" else ""
325+ cols'' <- sequence $ zipWith
326+ (\alignment item -> tableItemToDokuWiki opts celltype alignment item)
328+ return $ "^ " ++ "" ++ joinHeaders cols'' ++ " ^"
317tableRowToDokuWiki :: WriterOptions
330tableRowToDokuWiki :: WriterOptions
318 -> [String]
331 -> [String]
@@ -348,6 +361,10 @@ tableItemToDokuWiki opts celltype align' item = do
348joinColumns :: [String] -> String
361joinColumns :: [String] -> String
349joinColumns = intercalate " | "
362joinColumns = intercalate " | "
364+-- | Concatenates headers together.
365+joinHeaders :: [String] -> String
366+joinHeaders = intercalate " ^ "
351-- | Convert list of Pandoc block elements to DokuWiki.
368-- | Convert list of Pandoc block elements to DokuWiki.
352blockListToDokuWiki :: WriterOptions -- ^ Options
369blockListToDokuWiki :: WriterOptions -- ^ Options
353 -> [Block] -- ^ List of block elements
370 -> [Block] -- ^ List of block elements