git.iko.soy/typeable/pandoc
on master help sign in
Initial work to create dokuwiki writer (#386)

In this first version, all dokuwiki files are straight copies of the media wiki counterparts.

commit7eded47bcdd10d1e32125121c7b84f952b1a326e authorClare Macrae <clare.macrae@googlemail.com> dateSun 14 Jul 2013, 13:40 (13 years ago) parentbd1079e
8 files changed+1280−3
data/templates+1−1 pandoc.cabal+2−1 pandoc.hs+1 src/Text/Pandoc.hs+3 src/Text/Pandoc/Writers/DokuWiki.hs+407 tests/Tests/Old.hs+1−1 tests/tables.dokuwiki+212 tests/writer.dokuwiki+653
data/templates+1−1

Submodule changed.

pandoc.cabal+2−1
@@ -19,7 +19,7 @@ Description: Pandoc is a Haskell library for converting from one markup
1919 reStructuredText, LaTeX, DocBook, MediaWiki markup, Haddock
2020 markup, OPML, and Textile, and it can write markdown,
2121 reStructuredText, HTML, LaTeX, ConTeXt, Docbook, OPML,
22− OpenDocument, ODT, Word docx, RTF, MediaWiki, Textile,
22+ OpenDocument, ODT, Word docx, RTF, MediaWiki, DokuWiki, Textile,
2323 groff man pages, plain text, Emacs Org-Mode, AsciiDoc,
2424 EPUB (v2 and v3), FictionBook2, and several kinds of
2525 HTML/javascript slide shows (S5, Slidy, Slideous, DZSlides,
@@ -324,6 +324,7 @@ Library
324324 Text.Pandoc.Writers.Custom,
325325 Text.Pandoc.Writers.Textile,
326326 Text.Pandoc.Writers.MediaWiki,
327+ Text.Pandoc.Writers.DokuWiki,
327328 Text.Pandoc.Writers.RTF,
328329 Text.Pandoc.Writers.ODT,
329330 Text.Pandoc.Writers.Docx,
pandoc.hs+1
@@ -769,6 +769,7 @@ defaultReaderName fallback (x:xs) =
769769 ".db" -> "docbook"
770770 ".opml" -> "opml"
771771 ".wiki" -> "mediawiki"
772+ ".dokuwiki" -> "dokuwiki"
772773 ".textile" -> "textile"
773774 ".native" -> "native"
774775 ".json" -> "json"
src/Text/Pandoc.hs+3
@@ -88,6 +88,7 @@ module Text.Pandoc
8888 , writeOpenDocument
8989 , writeMan
9090 , writeMediaWiki
91+ , writeDokuWiki
9192 , writeTextile
9293 , writeRTF
9394 , writeODT
@@ -137,6 +138,7 @@ import Text.Pandoc.Writers.OpenDocument
137138import Text.Pandoc.Writers.Man
138139import Text.Pandoc.Writers.RTF
139140import Text.Pandoc.Writers.MediaWiki
141+import Text.Pandoc.Writers.DokuWiki
140142import Text.Pandoc.Writers.Textile
141143import Text.Pandoc.Writers.Org
142144import Text.Pandoc.Writers.AsciiDoc
@@ -257,6 +259,7 @@ writers = [
257259 ,("plain" , PureStringWriter writePlain)
258260 ,("rst" , PureStringWriter writeRST)
259261 ,("mediawiki" , PureStringWriter writeMediaWiki)
262+ ,("dokuwiki" , PureStringWriter writeDokuWiki)
260263 ,("textile" , PureStringWriter writeTextile)
261264 ,("rtf" , IOStringWriter writeRTFWithEmbeddedImages)
262265 ,("org" , PureStringWriter writeOrg)
src/Text/Pandoc/Writers/DokuWiki.hsnew file+407
@@ -0,0 +1,407 @@
1+{-
2+Copyright (C) 2008-2010 John MacFarlane <jgm@berkeley.edu>
3+
4+This program is free software; you can redistribute it and/or modify
5+it under the terms of the GNU General Public License as published by
6+the Free Software Foundation; either version 2 of the License, or
7+(at your option) any later version.
8+
9+This program is distributed in the hope that it will be useful,
10+but WITHOUT ANY WARRANTY; without even the implied warranty of
11+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+GNU General Public License for more details.
13+
14+You should have received a copy of the GNU General Public License
15+along with this program; if not, write to the Free Software
16+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17+-}
18+
19+{- |
20+ Module : Text.Pandoc.Writers.DokuWiki
21+ Copyright : Copyright (C) 2008-2010 John MacFarlane
22+ License : GNU GPL, version 2 or above
23+
24+ Maintainer : John MacFarlane <jgm@berkeley.edu>
25+ Stability : alpha
26+ Portability : portable
27+
28+Conversion of 'Pandoc' documents to DokuWiki markup.
29+
30+DokuWiki: <https://www.dokuwiki.org/dokuwiki>
31+-}
32+module Text.Pandoc.Writers.DokuWiki ( writeDokuWiki ) where
33+import Text.Pandoc.Definition
34+import Text.Pandoc.Options
35+import Text.Pandoc.Shared
36+import Text.Pandoc.Writers.Shared
37+import Text.Pandoc.Templates (renderTemplate')
38+import Text.Pandoc.XML ( escapeStringForXML )
39+import Data.List ( intersect, intercalate )
40+import Network.URI ( isURI )
41+import Control.Monad.State
42+
43+data WriterState = WriterState {
44+ stNotes :: Bool -- True if there are notes
45+ , stListLevel :: [Char] -- String at beginning of list items, e.g. "**"
46+ , stUseTags :: Bool -- True if we should use HTML tags because we're in a complex list
47+ }
48+
49+-- | Convert Pandoc to DokuWiki.
50+writeDokuWiki :: WriterOptions -> Pandoc -> String
51+writeDokuWiki opts document =
52+ evalState (pandocToDokuWiki opts document)
53+ (WriterState { stNotes = False, stListLevel = [], stUseTags = False })
54+
55+-- | Return DokuWiki representation of document.
56+pandocToDokuWiki :: WriterOptions -> Pandoc -> State WriterState String
57+pandocToDokuWiki opts (Pandoc meta blocks) = do
58+ metadata <- metaToJSON opts
59+ (fmap trimr . blockListToDokuWiki opts)
60+ (inlineListToDokuWiki opts)
61+ meta
62+ body <- blockListToDokuWiki opts blocks
63+ notesExist <- get >>= return . stNotes
64+ let notes = if notesExist
65+ then "\n<references />"
66+ else ""
67+ let main = body ++ notes
68+ let context = defField "body" main
69+ $ defField "toc" (writerTableOfContents opts)
70+ $ metadata
71+ if writerStandalone opts
72+ then return $ renderTemplate' (writerTemplate opts) context
73+ else return main
74+
75+-- | Escape special characters for DokuWiki.
76+escapeString :: String -> String
77+escapeString = escapeStringForXML
78+
79+-- | Convert Pandoc block element to DokuWiki.
80+blockToDokuWiki :: WriterOptions -- ^ Options
81+ -> Block -- ^ Block element
82+ -> State WriterState String
83+
84+blockToDokuWiki _ Null = return ""
85+
86+blockToDokuWiki opts (Plain inlines) =
87+ inlineListToDokuWiki opts inlines
88+
89+-- title beginning with fig: indicates that the image is a figure
90+blockToDokuWiki opts (Para [Image txt (src,'f':'i':'g':':':tit)]) = do
91+ capt <- if null txt
92+ then return ""
93+ else ("|caption " ++) `fmap` inlineListToDokuWiki opts txt
94+ let opt = if null txt
95+ then ""
96+ else "|alt=" ++ if null tit then capt else tit ++ capt
97+ return $ "[[Image:" ++ src ++ "|frame|none" ++ opt ++ "]]\n"
98+
99+blockToDokuWiki opts (Para inlines) = do
100+ useTags <- get >>= return . stUseTags
101+ listLevel <- get >>= return . stListLevel
102+ contents <- inlineListToDokuWiki opts inlines
103+ return $ if useTags
104+ then "<p>" ++ contents ++ "</p>"
105+ else contents ++ if null listLevel then "\n" else ""
106+
107+blockToDokuWiki _ (RawBlock "mediawiki" str) = return str
108+blockToDokuWiki _ (RawBlock "html" str) = return str
109+blockToDokuWiki _ (RawBlock _ _) = return ""
110+
111+blockToDokuWiki _ HorizontalRule = return "\n-----\n"
112+
113+blockToDokuWiki opts (Header level _ inlines) = do
114+ contents <- inlineListToDokuWiki opts inlines
115+ let eqs = replicate level '='
116+ return $ eqs ++ " " ++ contents ++ " " ++ eqs ++ "\n"
117+
118+blockToDokuWiki _ (CodeBlock (_,classes,_) str) = do
119+ let at = classes `intersect` ["actionscript", "ada", "apache", "applescript", "asm", "asp",
120+ "autoit", "bash", "blitzbasic", "bnf", "c", "c_mac", "caddcl", "cadlisp", "cfdg", "cfm",
121+ "cpp", "cpp-qt", "csharp", "css", "d", "delphi", "diff", "div", "dos", "eiffel", "fortran",
122+ "freebasic", "gml", "groovy", "html4strict", "idl", "ini", "inno", "io", "java", "java5",
123+ "javascript", "latex", "lisp", "lua", "matlab", "mirc", "mpasm", "mysql", "nsis", "objc",
124+ "ocaml", "ocaml-brief", "oobas", "oracle8", "pascal", "perl", "php", "php-brief", "plsql",
125+ "python", "qbasic", "rails", "reg", "robots", "ruby", "sas", "scheme", "sdlbasic",
126+ "smalltalk", "smarty", "sql", "tcl", "", "thinbasic", "tsql", "vb", "vbnet", "vhdl",
127+ "visualfoxpro", "winbatch", "xml", "xpp", "z80"]
128+ let (beg, end) = if null at
129+ then ("<pre" ++ if null classes then ">" else " class=\"" ++ unwords classes ++ "\">", "</pre>")
130+ else ("<source lang=\"" ++ head at ++ "\">", "</source>")
131+ return $ beg ++ escapeString str ++ end
132+
133+blockToDokuWiki opts (BlockQuote blocks) = do
134+ contents <- blockListToDokuWiki opts blocks
135+ return $ "<blockquote>" ++ contents ++ "</blockquote>"
136+
137+blockToDokuWiki opts (Table capt aligns widths headers rows') = do
138+ let alignStrings = map alignmentToString aligns
139+ captionDoc <- if null capt
140+ then return ""
141+ else do
142+ c <- inlineListToDokuWiki opts capt
143+ return $ "<caption>" ++ c ++ "</caption>\n"
144+ let percent w = show (truncate (100*w) :: Integer) ++ "%"
145+ let coltags = if all (== 0.0) widths
146+ then ""
147+ else unlines $ map
148+ (\w -> "<col width=\"" ++ percent w ++ "\" />") widths
149+ head' <- if all null headers
150+ then return ""
151+ else do
152+ hs <- tableRowToDokuWiki opts alignStrings 0 headers
153+ return $ "<thead>\n" ++ hs ++ "\n</thead>\n"
154+ body' <- zipWithM (tableRowToDokuWiki opts alignStrings) [1..] rows'
155+ return $ "<table>\n" ++ captionDoc ++ coltags ++ head' ++
156+ "<tbody>\n" ++ unlines body' ++ "</tbody>\n</table>\n"
157+
158+blockToDokuWiki opts x@(BulletList items) = do
159+ oldUseTags <- get >>= return . stUseTags
160+ listLevel <- get >>= return . stListLevel
161+ let useTags = oldUseTags || not (isSimpleList x)
162+ if useTags
163+ then do
164+ modify $ \s -> s { stUseTags = True }
165+ contents <- mapM (listItemToDokuWiki opts) items
166+ modify $ \s -> s { stUseTags = oldUseTags }
167+ return $ "<ul>\n" ++ vcat contents ++ "</ul>\n"
168+ else do
169+ modify $ \s -> s { stListLevel = stListLevel s ++ "*" }
170+ contents <- mapM (listItemToDokuWiki opts) items
171+ modify $ \s -> s { stListLevel = init (stListLevel s) }
172+ return $ vcat contents ++ if null listLevel then "\n" else ""
173+
174+blockToDokuWiki opts x@(OrderedList attribs items) = do
175+ oldUseTags <- get >>= return . stUseTags
176+ listLevel <- get >>= return . stListLevel
177+ let useTags = oldUseTags || not (isSimpleList x)
178+ if useTags
179+ then do
180+ modify $ \s -> s { stUseTags = True }
181+ contents <- mapM (listItemToDokuWiki opts) items
182+ modify $ \s -> s { stUseTags = oldUseTags }
183+ return $ "<ol" ++ listAttribsToString attribs ++ ">\n" ++ vcat contents ++ "</ol>\n"
184+ else do
185+ modify $ \s -> s { stListLevel = stListLevel s ++ "#" }
186+ contents <- mapM (listItemToDokuWiki opts) items
187+ modify $ \s -> s { stListLevel = init (stListLevel s) }
188+ return $ vcat contents ++ if null listLevel then "\n" else ""
189+
190+blockToDokuWiki opts x@(DefinitionList items) = do
191+ oldUseTags <- get >>= return . stUseTags
192+ listLevel <- get >>= return . stListLevel
193+ let useTags = oldUseTags || not (isSimpleList x)
194+ if useTags
195+ then do
196+ modify $ \s -> s { stUseTags = True }
197+ contents <- mapM (definitionListItemToDokuWiki opts) items
198+ modify $ \s -> s { stUseTags = oldUseTags }
199+ return $ "<dl>\n" ++ vcat contents ++ "</dl>\n"
200+ else do
201+ modify $ \s -> s { stListLevel = stListLevel s ++ ";" }
202+ contents <- mapM (definitionListItemToDokuWiki opts) items
203+ modify $ \s -> s { stListLevel = init (stListLevel s) }
204+ return $ vcat contents ++ if null listLevel then "\n" else ""
205+
206+-- Auxiliary functions for lists:
207+
208+-- | Convert ordered list attributes to HTML attribute string
209+listAttribsToString :: ListAttributes -> String
210+listAttribsToString (startnum, numstyle, _) =
211+ let numstyle' = camelCaseToHyphenated $ show numstyle
212+ in (if startnum /= 1
213+ then " start=\"" ++ show startnum ++ "\""
214+ else "") ++
215+ (if numstyle /= DefaultStyle
216+ then " style=\"list-style-type: " ++ numstyle' ++ ";\""
217+ else "")
218+
219+-- | Convert bullet or ordered list item (list of blocks) to DokuWiki.
220+listItemToDokuWiki :: WriterOptions -> [Block] -> State WriterState String
221+listItemToDokuWiki opts items = do
222+ contents <- blockListToDokuWiki opts items
223+ useTags <- get >>= return . stUseTags
224+ if useTags
225+ then return $ "<li>" ++ contents ++ "</li>"
226+ else do
227+ marker <- get >>= return . stListLevel
228+ return $ marker ++ " " ++ contents
229+
230+-- | Convert definition list item (label, list of blocks) to DokuWiki.
231+definitionListItemToDokuWiki :: WriterOptions
232+ -> ([Inline],[[Block]])
233+ -> State WriterState String
234+definitionListItemToDokuWiki opts (label, items) = do
235+ labelText <- inlineListToDokuWiki opts label
236+ contents <- mapM (blockListToDokuWiki opts) items
237+ useTags <- get >>= return . stUseTags
238+ if useTags
239+ then return $ "<dt>" ++ labelText ++ "</dt>\n" ++
240+ (intercalate "\n" $ map (\d -> "<dd>" ++ d ++ "</dd>") contents)
241+ else do
242+ marker <- get >>= return . stListLevel
243+ return $ marker ++ " " ++ labelText ++ "\n" ++
244+ (intercalate "\n" $ map (\d -> init marker ++ ": " ++ d) contents)
245+
246+-- | True if the list can be handled by simple wiki markup, False if HTML tags will be needed.
247+isSimpleList :: Block -> Bool
248+isSimpleList x =
249+ case x of
250+ BulletList items -> all isSimpleListItem items
251+ OrderedList (num, sty, _) items -> all isSimpleListItem items &&
252+ num == 1 && sty `elem` [DefaultStyle, Decimal]
253+ DefinitionList items -> all isSimpleListItem $ concatMap snd items
254+ _ -> False
255+
256+-- | True if list item can be handled with the simple wiki syntax. False if
257+-- HTML tags will be needed.
258+isSimpleListItem :: [Block] -> Bool
259+isSimpleListItem [] = True
260+isSimpleListItem [x] =
261+ case x of
262+ Plain _ -> True
263+ Para _ -> True
264+ BulletList _ -> isSimpleList x
265+ OrderedList _ _ -> isSimpleList x
266+ DefinitionList _ -> isSimpleList x
267+ _ -> False
268+isSimpleListItem [x, y] | isPlainOrPara x =
269+ case y of
270+ BulletList _ -> isSimpleList y
271+ OrderedList _ _ -> isSimpleList y
272+ DefinitionList _ -> isSimpleList y
273+ _ -> False
274+isSimpleListItem _ = False
275+
276+isPlainOrPara :: Block -> Bool
277+isPlainOrPara (Plain _) = True
278+isPlainOrPara (Para _) = True
279+isPlainOrPara _ = False
280+
281+-- | Concatenates strings with line breaks between them.
282+vcat :: [String] -> String
283+vcat = intercalate "\n"
284+
285+-- Auxiliary functions for tables:
286+
287+tableRowToDokuWiki :: WriterOptions
288+ -> [String]
289+ -> Int
290+ -> [[Block]]
291+ -> State WriterState String
292+tableRowToDokuWiki opts alignStrings rownum cols' = do
293+ let celltype = if rownum == 0 then "th" else "td"
294+ let rowclass = case rownum of
295+ 0 -> "header"
296+ x | x `rem` 2 == 1 -> "odd"
297+ _ -> "even"
298+ cols'' <- sequence $ zipWith
299+ (\alignment item -> tableItemToDokuWiki opts celltype alignment item)
300+ alignStrings cols'
301+ return $ "<tr class=\"" ++ rowclass ++ "\">\n" ++ unlines cols'' ++ "</tr>"
302+
303+alignmentToString :: Alignment -> [Char]
304+alignmentToString alignment = case alignment of
305+ AlignLeft -> "left"
306+ AlignRight -> "right"
307+ AlignCenter -> "center"
308+ AlignDefault -> "left"
309+
310+tableItemToDokuWiki :: WriterOptions
311+ -> String
312+ -> String
313+ -> [Block]
314+ -> State WriterState String
315+tableItemToDokuWiki opts celltype align' item = do
316+ let mkcell x = "<" ++ celltype ++ " align=\"" ++ align' ++ "\">" ++
317+ x ++ "</" ++ celltype ++ ">"
318+ contents <- blockListToDokuWiki opts item
319+ return $ mkcell contents
320+
321+-- | Convert list of Pandoc block elements to DokuWiki.
322+blockListToDokuWiki :: WriterOptions -- ^ Options
323+ -> [Block] -- ^ List of block elements
324+ -> State WriterState String
325+blockListToDokuWiki opts blocks =
326+ mapM (blockToDokuWiki opts) blocks >>= return . vcat
327+
328+-- | Convert list of Pandoc inline elements to DokuWiki.
329+inlineListToDokuWiki :: WriterOptions -> [Inline] -> State WriterState String
330+inlineListToDokuWiki opts lst =
331+ mapM (inlineToDokuWiki opts) lst >>= return . concat
332+
333+-- | Convert Pandoc inline element to DokuWiki.
334+inlineToDokuWiki :: WriterOptions -> Inline -> State WriterState String
335+
336+inlineToDokuWiki opts (Emph lst) = do
337+ contents <- inlineListToDokuWiki opts lst
338+ return $ "''" ++ contents ++ "''"
339+
340+inlineToDokuWiki opts (Strong lst) = do
341+ contents <- inlineListToDokuWiki opts lst
342+ return $ "'''" ++ contents ++ "'''"
343+
344+inlineToDokuWiki opts (Strikeout lst) = do
345+ contents <- inlineListToDokuWiki opts lst
346+ return $ "<s>" ++ contents ++ "</s>"
347+
348+inlineToDokuWiki opts (Superscript lst) = do
349+ contents <- inlineListToDokuWiki opts lst
350+ return $ "<sup>" ++ contents ++ "</sup>"
351+
352+inlineToDokuWiki opts (Subscript lst) = do
353+ contents <- inlineListToDokuWiki opts lst
354+ return $ "<sub>" ++ contents ++ "</sub>"
355+
356+inlineToDokuWiki opts (SmallCaps lst) = inlineListToDokuWiki opts lst
357+
358+inlineToDokuWiki opts (Quoted SingleQuote lst) = do
359+ contents <- inlineListToDokuWiki opts lst
360+ return $ "\8216" ++ contents ++ "\8217"
361+
362+inlineToDokuWiki opts (Quoted DoubleQuote lst) = do
363+ contents <- inlineListToDokuWiki opts lst
364+ return $ "\8220" ++ contents ++ "\8221"
365+
366+inlineToDokuWiki opts (Cite _ lst) = inlineListToDokuWiki opts lst
367+
368+inlineToDokuWiki _ (Code _ str) =
369+ return $ "<code>" ++ (escapeString str) ++ "</code>"
370+
371+inlineToDokuWiki _ (Str str) = return $ escapeString str
372+
373+inlineToDokuWiki _ (Math _ str) = return $ "<math>" ++ str ++ "</math>"
374+ -- note: str should NOT be escaped
375+
376+inlineToDokuWiki _ (RawInline "mediawiki" str) = return str
377+inlineToDokuWiki _ (RawInline "html" str) = return str
378+inlineToDokuWiki _ (RawInline _ _) = return ""
379+
380+inlineToDokuWiki _ (LineBreak) = return "<br />"
381+
382+inlineToDokuWiki _ Space = return " "
383+
384+inlineToDokuWiki opts (Link txt (src, _)) = do
385+ label <- inlineListToDokuWiki opts txt
386+ case txt of
387+ [Str s] | escapeURI s == src -> return src
388+ _ -> if isURI src
389+ then return $ "[" ++ src ++ " " ++ label ++ "]"
390+ else return $ "[[" ++ src' ++ "|" ++ label ++ "]]"
391+ where src' = case src of
392+ '/':xs -> xs -- with leading / it's a
393+ _ -> src -- link to a help page
394+inlineToDokuWiki opts (Image alt (source, tit)) = do
395+ alt' <- inlineListToDokuWiki opts alt
396+ let txt = if (null tit)
397+ then if null alt
398+ then ""
399+ else "|" ++ alt'
400+ else "|" ++ tit
401+ return $ "[[Image:" ++ source ++ txt ++ "]]"
402+
403+inlineToDokuWiki opts (Note contents) = do
404+ contents' <- blockListToDokuWiki opts contents
405+ modify (\s -> s { stNotes = True })
406+ return $ "<ref>" ++ contents' ++ "</ref>"
407+ -- note - may not work for notes with multiple blocks
tests/Tests/Old.hs+1−1
@@ -136,7 +136,7 @@ tests = [ testGroup "markdown"
136136 ]
137137 , testGroup "other writers" $ map (\f -> testGroup f $ writerTests f)
138138 [ "opendocument" , "context" , "texinfo"
139− , "man" , "plain" , "rtf", "org", "asciidoc"
139+ , "man" , "plain" , "rtf", "org", "asciidoc", "dokuwiki"
140140 ]
141141 ]
142142
tests/tables.dokuwikinew file+212
@@ -0,0 +1,212 @@
1+Simple table with caption:
2+
3+<table>
4+<caption>Demonstration of simple table syntax.</caption>
5+<thead>
6+<tr class="header">
7+<th align="right">Right</th>
8+<th align="left">Left</th>
9+<th align="center">Center</th>
10+<th align="left">Default</th>
11+</tr>
12+</thead>
13+<tbody>
14+<tr class="odd">
15+<td align="right">12</td>
16+<td align="left">12</td>
17+<td align="center">12</td>
18+<td align="left">12</td>
19+</tr>
20+<tr class="even">
21+<td align="right">123</td>
22+<td align="left">123</td>
23+<td align="center">123</td>
24+<td align="left">123</td>
25+</tr>
26+<tr class="odd">
27+<td align="right">1</td>
28+<td align="left">1</td>
29+<td align="center">1</td>
30+<td align="left">1</td>
31+</tr>
32+</tbody>
33+</table>
34+
35+Simple table without caption:
36+
37+<table>
38+<thead>
39+<tr class="header">
40+<th align="right">Right</th>
41+<th align="left">Left</th>
42+<th align="center">Center</th>
43+<th align="left">Default</th>
44+</tr>
45+</thead>
46+<tbody>
47+<tr class="odd">
48+<td align="right">12</td>
49+<td align="left">12</td>
50+<td align="center">12</td>
51+<td align="left">12</td>
52+</tr>
53+<tr class="even">
54+<td align="right">123</td>
55+<td align="left">123</td>
56+<td align="center">123</td>
57+<td align="left">123</td>
58+</tr>
59+<tr class="odd">
60+<td align="right">1</td>
61+<td align="left">1</td>
62+<td align="center">1</td>
63+<td align="left">1</td>
64+</tr>
65+</tbody>
66+</table>
67+
68+Simple table indented two spaces:
69+
70+<table>
71+<caption>Demonstration of simple table syntax.</caption>
72+<thead>
73+<tr class="header">
74+<th align="right">Right</th>
75+<th align="left">Left</th>
76+<th align="center">Center</th>
77+<th align="left">Default</th>
78+</tr>
79+</thead>
80+<tbody>
81+<tr class="odd">
82+<td align="right">12</td>
83+<td align="left">12</td>
84+<td align="center">12</td>
85+<td align="left">12</td>
86+</tr>
87+<tr class="even">
88+<td align="right">123</td>
89+<td align="left">123</td>
90+<td align="center">123</td>
91+<td align="left">123</td>
92+</tr>
93+<tr class="odd">
94+<td align="right">1</td>
95+<td align="left">1</td>
96+<td align="center">1</td>
97+<td align="left">1</td>
98+</tr>
99+</tbody>
100+</table>
101+
102+Multiline table with caption:
103+
104+<table>
105+<caption>Here's the caption. It may span multiple lines.</caption>
106+<col width="15%" />
107+<col width="13%" />
108+<col width="16%" />
109+<col width="33%" />
110+<thead>
111+<tr class="header">
112+<th align="center">Centered Header</th>
113+<th align="left">Left Aligned</th>
114+<th align="right">Right Aligned</th>
115+<th align="left">Default aligned</th>
116+</tr>
117+</thead>
118+<tbody>
119+<tr class="odd">
120+<td align="center">First</td>
121+<td align="left">row</td>
122+<td align="right">12.0</td>
123+<td align="left">Example of a row that spans multiple lines.</td>
124+</tr>
125+<tr class="even">
126+<td align="center">Second</td>
127+<td align="left">row</td>
128+<td align="right">5.0</td>
129+<td align="left">Here's another one. Note the blank line between rows.</td>
130+</tr>
131+</tbody>
132+</table>
133+
134+Multiline table without caption:
135+
136+<table>
137+<col width="15%" />
138+<col width="13%" />
139+<col width="16%" />
140+<col width="33%" />
141+<thead>
142+<tr class="header">
143+<th align="center">Centered Header</th>
144+<th align="left">Left Aligned</th>
145+<th align="right">Right Aligned</th>
146+<th align="left">Default aligned</th>
147+</tr>
148+</thead>
149+<tbody>
150+<tr class="odd">
151+<td align="center">First</td>
152+<td align="left">row</td>
153+<td align="right">12.0</td>
154+<td align="left">Example of a row that spans multiple lines.</td>
155+</tr>
156+<tr class="even">
157+<td align="center">Second</td>
158+<td align="left">row</td>
159+<td align="right">5.0</td>
160+<td align="left">Here's another one. Note the blank line between rows.</td>
161+</tr>
162+</tbody>
163+</table>
164+
165+Table without column headers:
166+
167+<table>
168+<tbody>
169+<tr class="odd">
170+<td align="right">12</td>
171+<td align="left">12</td>
172+<td align="center">12</td>
173+<td align="right">12</td>
174+</tr>
175+<tr class="even">
176+<td align="right">123</td>
177+<td align="left">123</td>
178+<td align="center">123</td>
179+<td align="right">123</td>
180+</tr>
181+<tr class="odd">
182+<td align="right">1</td>
183+<td align="left">1</td>
184+<td align="center">1</td>
185+<td align="right">1</td>
186+</tr>
187+</tbody>
188+</table>
189+
190+Multiline table without column headers:
191+
192+<table>
193+<col width="15%" />
194+<col width="13%" />
195+<col width="16%" />
196+<col width="33%" />
197+<tbody>
198+<tr class="odd">
199+<td align="center">First</td>
200+<td align="left">row</td>
201+<td align="right">12.0</td>
202+<td align="left">Example of a row that spans multiple lines.</td>
203+</tr>
204+<tr class="even">
205+<td align="center">Second</td>
206+<td align="left">row</td>
207+<td align="right">5.0</td>
208+<td align="left">Here's another one. Note the blank line between rows.</td>
209+</tr>
210+</tbody>
211+</table>
212+
tests/writer.dokuwikinew file+653
@@ -0,0 +1,653 @@
1+This is a set of tests for pandoc. Most of them are adapted from John Gruber’s markdown test suite.
2+
3+
4+-----
5+
6+= Headers =
7+
8+== Level 2 with an [[url|embedded link]] ==
9+
10+=== Level 3 with ''emphasis'' ===
11+
12+==== Level 4 ====
13+
14+===== Level 5 =====
15+
16+= Level 1 =
17+
18+== Level 2 with ''emphasis'' ==
19+
20+=== Level 3 ===
21+
22+with no blank line
23+
24+== Level 2 ==
25+
26+with no blank line
27+
28+
29+-----
30+
31+= Paragraphs =
32+
33+Here’s a regular paragraph.
34+
35+In Markdown 1.0.0 and earlier. Version 8. This line turns into a list item. Because a hard-wrapped line in the middle of a paragraph looked like a list item.
36+
37+Here’s one with a bullet. * criminey.
38+
39+There should be a hard line break<br />here.
40+
41+
42+-----
43+
44+= Block Quotes =
45+
46+E-mail style:
47+
48+<blockquote>This is a block quote. It is pretty short.
49+</blockquote>
50+<blockquote>Code in a block quote:
51+
52+<pre>sub status {
53+ print &quot;working&quot;;
54+}</pre>
55+A list:
56+
57+# item one
58+# item two
59+
60+Nested block quotes:
61+
62+<blockquote>nested
63+</blockquote>
64+<blockquote>nested
65+</blockquote></blockquote>
66+This should not be a block quote: 2 &gt; 1.
67+
68+And a following paragraph.
69+
70+
71+-----
72+
73+= Code Blocks =
74+
75+Code:
76+
77+<pre>---- (should be four hyphens)
78+
79+sub status {
80+ print &quot;working&quot;;
81+}
82+
83+this code block is indented by one tab</pre>
84+And:
85+
86+<pre> this code block is indented by two tabs
87+
88+These should not be escaped: \$ \\ \&gt; \[ \{</pre>
89+
90+-----
91+
92+= Lists =
93+
94+== Unordered ==
95+
96+Asterisks tight:
97+
98+* asterisk 1
99+* asterisk 2
100+* asterisk 3
101+
102+Asterisks loose:
103+
104+* asterisk 1
105+* asterisk 2
106+* asterisk 3
107+
108+Pluses tight:
109+
110+* Plus 1
111+* Plus 2
112+* Plus 3
113+
114+Pluses loose:
115+
116+* Plus 1
117+* Plus 2
118+* Plus 3
119+
120+Minuses tight:
121+
122+* Minus 1
123+* Minus 2
124+* Minus 3
125+
126+Minuses loose:
127+
128+* Minus 1
129+* Minus 2
130+* Minus 3
131+
132+== Ordered ==
133+
134+Tight:
135+
136+# First
137+# Second
138+# Third
139+
140+and:
141+
142+# One
143+# Two
144+# Three
145+
146+Loose using tabs:
147+
148+# First
149+# Second
150+# Third
151+
152+and using spaces:
153+
154+# One
155+# Two
156+# Three
157+
158+Multiple paragraphs:
159+
160+<ol style="list-style-type: decimal;">
161+<li><p>Item 1, graf one.</p>
162+<p>Item 1. graf two. The quick brown fox jumped over the lazy dog’s back.</p></li>
163+<li><p>Item 2.</p></li>
164+<li><p>Item 3.</p></li></ol>
165+
166+== Nested ==
167+
168+* Tab
169+** Tab
170+*** Tab
171+
172+Here’s another:
173+
174+# First
175+# Second:
176+#* Fee
177+#* Fie
178+#* Foe
179+# Third
180+
181+Same thing but with paragraphs:
182+
183+# First
184+# Second:
185+#* Fee
186+#* Fie
187+#* Foe
188+# Third
189+
190+== Tabs and spaces ==
191+
192+* this is a list item indented with tabs
193+* this is a list item indented with spaces
194+** this is an example list item indented with tabs
195+** this is an example list item indented with spaces
196+
197+== Fancy list markers ==
198+
199+<ol start="2" style="list-style-type: decimal;">
200+<li>begins with 2</li>
201+<li><p>and now 3</p>
202+<p>with a continuation</p>
203+<ol start="4" style="list-style-type: lower-roman;">
204+<li>sublist with roman numerals, starting with 4</li>
205+<li>more items
206+<ol style="list-style-type: upper-alpha;">
207+<li>a subsublist</li>
208+<li>a subsublist</li></ol>
209+</li></ol>
210+</li></ol>
211+
212+Nesting:
213+
214+<ol style="list-style-type: upper-alpha;">
215+<li>Upper Alpha
216+<ol style="list-style-type: upper-roman;">
217+<li>Upper Roman.
218+<ol start="6" style="list-style-type: decimal;">
219+<li>Decimal start with 6
220+<ol start="3" style="list-style-type: lower-alpha;">
221+<li>Lower alpha with paren</li></ol>
222+</li></ol>
223+</li></ol>
224+</li></ol>
225+
226+Autonumbering:
227+
228+# Autonumber.
229+# More.
230+## Nested.
231+
232+Should not be a list item:
233+
234+M.A. 2007
235+
236+B. Williams
237+
238+
239+-----
240+
241+= Definition Lists =
242+
243+Tight using spaces:
244+
245+; apple
246+: red fruit
247+; orange
248+: orange fruit
249+; banana
250+: yellow fruit
251+
252+Tight using tabs:
253+
254+; apple
255+: red fruit
256+; orange
257+: orange fruit
258+; banana
259+: yellow fruit
260+
261+Loose:
262+
263+; apple
264+: red fruit
265+; orange
266+: orange fruit
267+; banana
268+: yellow fruit
269+
270+Multiple blocks with italics:
271+
272+<dl>
273+<dt>''apple''</dt>
274+<dd><p>red fruit</p>
275+<p>contains seeds, crisp, pleasant to taste</p></dd>
276+<dt>''orange''</dt>
277+<dd><p>orange fruit</p>
278+<pre>{ orange code block }</pre>
279+<blockquote><p>orange block quote</p></blockquote></dd></dl>
280+
281+Multiple definitions, tight:
282+
283+; apple
284+: red fruit
285+: computer
286+; orange
287+: orange fruit
288+: bank
289+
290+Multiple definitions, loose:
291+
292+; apple
293+: red fruit
294+: computer
295+; orange
296+: orange fruit
297+: bank
298+
299+Blank line after term, indented marker, alternate markers:
300+
301+; apple
302+: red fruit
303+: computer
304+; orange
305+: orange fruit
306+;# sublist
307+;# sublist
308+
309+= HTML Blocks =
310+
311+Simple block on one line:
312+
313+<div>
314+foo
315+</div>
316+
317+And nested without indentation:
318+
319+<div>
320+<div>
321+<div>
322+foo
323+</div>
324+</div>
325+<div>
326+bar
327+</div>
328+</div>
329+
330+Interpreted markdown in a table:
331+
332+<table>
333+<tr>
334+<td>
335+This is ''emphasized''
336+</td>
337+<td>
338+And this is '''strong'''
339+</td>
340+</tr>
341+</table>
342+
343+<script type="text/javascript">document.write('This *should not* be interpreted as markdown');</script>
344+
345+Here’s a simple block:
346+
347+<div>
348+
349+foo
350+</div>
351+
352+This should be a code block, though:
353+
354+<pre>&lt;div&gt;
355+ foo
356+&lt;/div&gt;</pre>
357+As should this:
358+
359+<pre>&lt;div&gt;foo&lt;/div&gt;</pre>
360+Now, nested:
361+
362+<div>
363+ <div>
364+ <div>
365+
366+foo
367+</div>
368+ </div>
369+</div>
370+
371+This should just be an HTML comment:
372+
373+<!-- Comment -->
374+
375+Multiline:
376+
377+<!--
378+Blah
379+Blah
380+-->
381+
382+<!--
383+ This is another comment.
384+-->
385+
386+Code block:
387+
388+<pre>&lt;!-- Comment --&gt;</pre>
389+Just plain comment, with trailing spaces on the line:
390+
391+<!-- foo -->
392+
393+Code:
394+
395+<pre>&lt;hr /&gt;</pre>
396+Hr’s:
397+
398+<hr>
399+
400+<hr />
401+
402+<hr />
403+
404+<hr>
405+
406+<hr />
407+
408+<hr />
409+
410+<hr class="foo" id="bar" />
411+
412+<hr class="foo" id="bar" />
413+
414+<hr class="foo" id="bar">
415+
416+
417+-----
418+
419+= Inline Markup =
420+
421+This is ''emphasized'', and so ''is this''.
422+
423+This is '''strong''', and so '''is this'''.
424+
425+An ''[[url|emphasized link]]''.
426+
427+'''''This is strong and em.'''''
428+
429+So is '''''this''''' word.
430+
431+'''''This is strong and em.'''''
432+
433+So is '''''this''''' word.
434+
435+This is code: <code>&gt;</code>, <code>$</code>, <code>\</code>, <code>\$</code>, <code>&lt;html&gt;</code>.
436+
437+<s>This is ''strikeout''.</s>
438+
439+Superscripts: a<sup>bc</sup>d a<sup>''hello''</sup> a<sup>hello there</sup>.
440+
441+Subscripts: H<sub>2</sub>O, H<sub>23</sub>O, H<sub>many of them</sub>O.
442+
443+These should not be superscripts or subscripts, because of the unescaped spaces: a^b c^d, a~b c~d.
444+
445+
446+-----
447+
448+= Smart quotes, ellipses, dashes =
449+
450+“Hello,” said the spider. “‘Shelob’ is my name.”
451+
452+‘A’, ‘B’, and ‘C’ are letters.
453+
454+‘Oak,’ ‘elm,’ and ‘beech’ are names of trees. So is ‘pine.’
455+
456+‘He said, “I want to go.”’ Were you alive in the 70’s?
457+
458+Here is some quoted ‘<code>code</code>’ and a “[http://example.com/?foo=1&bar=2 quoted link]”.
459+
460+Some dashes: one—two — three—four — five.
461+
462+Dashes between numbers: 5–7, 255–66, 1987–1999.
463+
464+Ellipses…and…and….
465+
466+
467+-----
468+
469+= LaTeX =
470+
471+*
472+* <math>2+2=4</math>
473+* <math>x \in y</math>
474+* <math>\alpha \wedge \omega</math>
475+* <math>223</math>
476+* <math>p</math>-Tree
477+* Here’s some display math: <math>\frac{d}{dx}f(x)=\lim_{h\to 0}\frac{f(x+h)-f(x)}{h}</math>
478+* Here’s one that has a line break in it: <math>\alpha + \omega \times x^2</math>.
479+
480+These shouldn’t be math:
481+
482+* To get the famous equation, write <code>$e = mc^2$</code>.
483+* $22,000 is a ''lot'' of money. So is $34,000. (It worked if “lot” is emphasized.)
484+* Shoes ($20) and socks ($5).
485+* Escaped <code>$</code>: $73 ''this should be emphasized'' 23$.
486+
487+Here’s a LaTeX table:
488+
489+
490+
491+-----
492+
493+= Special Characters =
494+
495+Here is some unicode:
496+
497+* I hat: Î
498+* o umlaut: ö
499+* section: §
500+* set membership: ∈
501+* copyright: ©
502+
503+AT&amp;T has an ampersand in their name.
504+
505+AT&amp;T is another way to write it.
506+
507+This &amp; that.
508+
509+4 &lt; 5.
510+
511+6 &gt; 5.
512+
513+Backslash: \
514+
515+Backtick: `
516+
517+Asterisk: *
518+
519+Underscore: _
520+
521+Left brace: {
522+
523+Right brace: }
524+
525+Left bracket: [
526+
527+Right bracket: ]
528+
529+Left paren: (
530+
531+Right paren: )
532+
533+Greater-than: &gt;
534+
535+Hash: #
536+
537+Period: .
538+
539+Bang: !
540+
541+Plus: +
542+
543+Minus: -
544+
545+
546+-----
547+
548+= Links =
549+
550+== Explicit ==
551+
552+Just a [[url/|URL]].
553+
554+[[url/|URL and title]].
555+
556+[[url/|URL and title]].
557+
558+[[url/|URL and title]].
559+
560+[[url/|URL and title]]
561+
562+[[url/|URL and title]]
563+
564+[[url/with_underscore|with_underscore]]
565+
566+[mailto:nobody@nowhere.net Email link]
567+
568+[[|Empty]].
569+
570+== Reference ==
571+
572+Foo [[url/|bar]].
573+
574+Foo [[url/|bar]].
575+
576+Foo [[url/|bar]].
577+
578+With [[url/|embedded [brackets]]].
579+
580+[[url/|b]] by itself should be a link.
581+
582+Indented [[url|once]].
583+
584+Indented [[url|twice]].
585+
586+Indented [[url|thrice]].
587+
588+This should [not][] be a link.
589+
590+<pre>[not]: /url</pre>
591+Foo [[url/|bar]].
592+
593+Foo [[url/|biz]].
594+
595+== With ampersands ==
596+
597+Here’s a [http://example.com/?foo=1&bar=2 link with an ampersand in the URL].
598+
599+Here’s a link with an amersand in the link text: [http://att.com/ AT&amp;T].
600+
601+Here’s an [[script?foo=1&bar=2|inline link]].
602+
603+Here’s an [[script?foo=1&bar=2|inline link in pointy braces]].
604+
605+== Autolinks ==
606+
607+With an ampersand: http://example.com/?foo=1&bar=2
608+
609+* In a list?
610+* http://example.com/
611+* It should.
612+
613+An e-mail address: [mailto:nobody@nowhere.net nobody@nowhere.net]
614+
615+<blockquote>Blockquoted: http://example.com/
616+</blockquote>
617+Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code>
618+
619+<pre>or here: &lt;http://example.com/&gt;</pre>
620+
621+-----
622+
623+= Images =
624+
625+From “Voyage dans la Lune” by Georges Melies (1902):
626+
627+[[Image:lalune.jpg|frame|none|alt=Voyage dans la Lune|caption lalune]]
628+
629+Here is a movie [[Image:movie.jpg|movie]] icon.
630+
631+
632+-----
633+
634+= Footnotes =
635+
636+Here is a footnote reference,<ref>Here is the footnote. It can go anywhere after the footnote reference. It need not be placed at the end of the document.
637+</ref> and another.<ref>Here’s the long note. This one contains multiple blocks.
638+
639+Subsequent blocks are indented to show that they belong to the footnote (as with list items).
640+
641+<pre> { &lt;code&gt; }</pre>
642+If you want, you can indent every line, but you can also be lazy and just indent the first line of each block.
643+</ref> This should ''not'' be a footnote reference, because it contains a space.[^my note] Here is an inline note.<ref>This is ''easier'' to type. Inline notes may contain [http://google.com links] and <code>]</code> verbatim characters, as well as [bracketed text].
644+</ref>
645+
646+<blockquote>Notes can go in quotes.<ref>In quote.
647+</ref>
648+</blockquote>
649+# And in list items.<ref>In list.</ref>
650+
651+This paragraph should not be part of the note, as it is not indented.
652+
653+<references />