@@ -36,7 +36,7 @@ DokuWiki: <https://www.dokuwiki.org/dokuwiki>
3636 [ ] Implement definition lists
3737 [ ] Don't generate lists using <ol> and <ul>
3838 [ ] Don't generate <div>
39− [ ] Implement conversion of tables
39+ [ ] Implement alignment of text in tables
4040 [ ] Implement comments
4141 [ ] Work through the Dokuwiki spec, and check I've not missed anything out
4242 [ ] 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
160160 head' <- if all null headers
161161 then return ""
162162 else do
163− hs <- tableRowToDokuWiki opts alignStrings 0 headers
163+ hs <- tableHeaderToDokuWiki opts alignStrings 0 headers
164164 return $ hs ++ "\n"
165165 body' <- zipWithM (tableRowToDokuWiki opts alignStrings) [1..] rows'
166166 return $ captionDoc ++ head' ++
@@ -314,6 +314,19 @@ vcat = intercalate "\n"
314314
315315-- Auxiliary functions for tables:
316316
317+-- TODO Eliminate copy-and-pasted code in tableHeaderToDokuWiki and tableRowToDokuWiki
318+tableHeaderToDokuWiki :: WriterOptions
319+ -> [String]
320+ -> Int
321+ -> [[Block]]
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)
327+ alignStrings cols'
328+ return $ "^ " ++ "" ++ joinHeaders cols'' ++ " ^"
329+
317330tableRowToDokuWiki :: WriterOptions
318331 -> [String]
319332 -> Int
@@ -348,6 +361,10 @@ tableItemToDokuWiki opts celltype align' item = do
348361joinColumns :: [String] -> String
349362joinColumns = intercalate " | "
350363
364+-- | Concatenates headers together.
365+joinHeaders :: [String] -> String
366+joinHeaders = intercalate " ^ "
367+
351368-- | Convert list of Pandoc block elements to DokuWiki.
352369blockListToDokuWiki :: WriterOptions -- ^ Options
353370 -> [Block] -- ^ List of block elements