mirror of
https://github.com/jgm/pandoc.git
synced 2026-09-26 17:35:49 +00:00
Implement table headings in dokuwiki writer (#386)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
Simple table with caption:
|
||||
|
||||
Demonstration of simple table syntax.
|
||||
| Right | Left | Center | Default |
|
||||
^ Right ^ Left ^ Center ^ Default ^
|
||||
| 12 | 12 | 12 | 12 |
|
||||
| 123 | 123 | 123 | 123 |
|
||||
| 1 | 1 | 1 | 1 |
|
||||
|
||||
Simple table without caption:
|
||||
|
||||
| Right | Left | Center | Default |
|
||||
^ Right ^ Left ^ Center ^ Default ^
|
||||
| 12 | 12 | 12 | 12 |
|
||||
| 123 | 123 | 123 | 123 |
|
||||
| 1 | 1 | 1 | 1 |
|
||||
@@ -16,7 +16,7 @@ Simple table without caption:
|
||||
Simple table indented two spaces:
|
||||
|
||||
Demonstration of simple table syntax.
|
||||
| Right | Left | Center | Default |
|
||||
^ Right ^ Left ^ Center ^ Default ^
|
||||
| 12 | 12 | 12 | 12 |
|
||||
| 123 | 123 | 123 | 123 |
|
||||
| 1 | 1 | 1 | 1 |
|
||||
@@ -24,13 +24,13 @@ Demonstration of simple table syntax.
|
||||
Multiline table with caption:
|
||||
|
||||
Here's the caption. It may span multiple lines.
|
||||
| Centered Header | Left Aligned | Right Aligned | Default aligned |
|
||||
^ Centered Header ^ Left Aligned ^ Right Aligned ^ Default aligned ^
|
||||
| First | row | 12.0 | Example of a row that spans multiple lines. |
|
||||
| Second | row | 5.0 | Here's another one. Note the blank line between rows. |
|
||||
|
||||
Multiline table without caption:
|
||||
|
||||
| Centered Header | Left Aligned | Right Aligned | Default aligned |
|
||||
^ Centered Header ^ Left Aligned ^ Right Aligned ^ Default aligned ^
|
||||
| First | row | 12.0 | Example of a row that spans multiple lines. |
|
||||
| Second | row | 5.0 | Here's another one. Note the blank line between rows. |
|
||||
|
||||
|
||||
Reference in New Issue
Block a user