git.iko.soy/typeable/pandoc
on master help sign in
More mediawiki reader tests.
a76c6dfJohn MacFarlane
src/Text/Pandoc/Readers/MediaWiki.hs+1−7
@@ -44,13 +44,7 @@ _ raw mediawiki:
44 _ templates or anything in {{}} (can be postprocessed)
44 _ templates or anything in {{}} (can be postprocessed)
45 _ category links
45 _ category links
46_ gallery tag?
46_ gallery tag?
47−_ tests for sup, sub, del
48−_ tests for pre, haskell, syntaxhighlight
49−_ tests for code, tt, hask
50−_ test for blockquote
51_ tests for native lists
47_ tests for native lists
52−_ tests for autolink urls
53−_ tests for external links
54-}
48-}
55module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where
49module Text.Pandoc.Readers.MediaWiki ( readMediaWiki ) where
56
50
@@ -175,7 +169,7 @@ syntaxhighlight = try $ do
175 let classes = maybe [] (:[]) mblang ++ maybe [] (const ["numberLines"]) mbline
169 let classes = maybe [] (:[]) mblang ++ maybe [] (const ["numberLines"]) mbline
176 let kvs = maybe [] (\x -> [("startFrom",x)]) mbstart
170 let kvs = maybe [] (\x -> [("startFrom",x)]) mbstart
177 contents <- charsInTags "syntaxhighlight"
171 contents <- charsInTags "syntaxhighlight"
178− return $ B.codeBlockWith ("",classes,kvs) contents
172+ return $ B.codeBlockWith ("",classes,kvs) $ trimCode contents
179
173
180haskell :: MWParser Blocks
174haskell :: MWParser Blocks
181haskell = B.codeBlockWith ("",["haskell"],[]) . trimCode <$>
175haskell = B.codeBlockWith ("",["haskell"],[]) . trimCode <$>
tests/mediawiki-reader.native+19−2
@@ -51,7 +51,24 @@ Pandoc (Meta {docTitle = [], docAuthors = [], docDate = []})
51,Para [Str "bud"]
51,Para [Str "bud"]
52,Para [Str "another"]
52,Para [Str "another"]
53,Header 2 [Str "raw",Space,Str "html"]
53,Header 2 [Str "raw",Space,Str "html"]
54−,Para [Str "hi",Space,RawInline "html" "<span style=\"color:red\">",Emph [Str "there"],RawInline "html" "</span>",Str "."]
54+,Para [Str "hi",Space,RawInline "html" "<span style=\"color:red\">",Emph [Str "there"],RawInline "html" "</span>",Str ".",Space,RawInline "html" "<ins>",Str "inserted",RawInline "html" "</ins>"]
55,RawBlock "html" "<div class=\"special\">"
55,RawBlock "html" "<div class=\"special\">"
56,Para [Str "hi",Space,Emph [Str "there"]]
56,Para [Str "hi",Space,Emph [Str "there"]]
57−,RawBlock "html" "</div>"]
57+,RawBlock "html" "</div>"
58+,Header 2 [Str "sup,",Space,Str "sub,",Space,Str "del"]
59+,Para [Str "H",Subscript [Str "2"],Str "O",Space,Str "base",Superscript [Emph [Str "exponent"]],Space,Strikeout [Str "hello"]]
60+,Header 2 [Str "inline",Space,Str "code"]
61+,Para [Code ("",[],[]) "*\8594*",Space,Code ("",[],[]) "typed",Space,Code ("",["haskell"],[]) ">>="]
62+,Header 2 [Str "code",Space,Str "blocks"]
63+,CodeBlock ("",[],[]) "case xs of\n (_:_) -> reverse xs\n [] -> ['*']"
64+,CodeBlock ("",["haskell"],[]) "case xs of\n (_:_) -> reverse xs\n [] -> ['*']"
65+,CodeBlock ("",["ruby","numberLines"],[("startFrom","100")]) "widgets.each do |w|\n print w.price\nend"
66+,Header 2 [Str "block",Space,Str "quotes"]
67+,Para [Str "Regular",Space,Str "paragraph"]
68+,BlockQuote
69+ [Para [Str "This",Space,Str "is",Space,Str "a",Space,Str "block",Space,Str "quote."]
70+ ,Para [Str "With",Space,Str "two",Space,Str "paragraphs."]]
71+,Para [Str "Nother",Space,Str "paragraph."]
72+,Header 2 [Str "external",Space,Str "links"]
73+,Para [Link [Emph [Str "Google"],Space,Str "search",Space,Str "engine"] ("http://google.com","")]
74+,Para [Link [Str "http://johnmacfarlane.net/pandoc/"] ("http://johnmacfarlane.net/pandoc/","")]]
tests/mediawiki-reader.wiki+47
@@ -91,9 +91,56 @@ another
91== raw html ==
91== raw html ==
92
92
93hi <span style="color:red">''there''</span>.
93hi <span style="color:red">''there''</span>.
94+<ins>inserted</ins>
94
95
95<div class="special">
96<div class="special">
96hi ''there''
97hi ''there''
97</div>
98</div>
98
99
100+== sup, sub, del ==
101+
102+H<sub>2</sub>O
103+base<sup>''exponent''</sup>
104+<del>hello</del>
105+
106+== inline code ==
107+
108+<code>*&rarr;*</code> <tt>typed</tt> <hask>&gt;&gt;=</hask>
109+
110+== code blocks ==
111+
112+<pre>
113+case xs of
114+ (_:_) -> reverse xs
115+ [] -> ['*']
116+</pre>
117+
118+<haskell>
119+case xs of
120+ (_:_) -> reverse xs
121+ [] -> ['*']
122+</haskell>
123+
124+<syntaxhighlight lang="ruby" line start=100>
125+widgets.each do |w|
126+ print w.price
127+end
128+</syntaxhighlight>
129+
130+== block quotes ==
131+
132+Regular paragraph
133+<blockquote>
134+This is a block quote.
135+
136+With two paragraphs.
137+</blockquote>
138+Nother paragraph.
139+
140+== external links ==
141+
142+[http://google.com ''Google'' search engine]
143+
144+http://johnmacfarlane.net/pandoc/
145+
99
146