WikiCreole 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/test/test_all.rb ADDED
@@ -0,0 +1,895 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'test/unit'
4
+ require 'wiki_creole'
5
+
6
+ class TC_WikiCreole < Test::Unit::TestCase
7
+
8
+ $strict = false
9
+
10
+ #-----------------------------------------------------------------------------
11
+ # This first section is the low level method sanity tests.
12
+
13
+ def test_strip_leading_and_trailing_eq_and_whitespace
14
+ assert_equal "head", WikiCreole.strip_leading_and_trailing_eq_and_whitespace("==head")
15
+ assert_equal "head", WikiCreole.strip_leading_and_trailing_eq_and_whitespace(" == head")
16
+ assert_equal "head", WikiCreole.strip_leading_and_trailing_eq_and_whitespace("head ==")
17
+ assert_equal "head", WikiCreole.strip_leading_and_trailing_eq_and_whitespace("head == ")
18
+ assert_equal "head", WikiCreole.strip_leading_and_trailing_eq_and_whitespace("head ")
19
+ assert_equal "head", WikiCreole.strip_leading_and_trailing_eq_and_whitespace(" head")
20
+ assert_equal "head", WikiCreole.strip_leading_and_trailing_eq_and_whitespace(" head ")
21
+ end
22
+
23
+ def test_strip_list
24
+ assert_equal "`head", WikiCreole.strip_list(" *head")
25
+ assert_equal "\n`head", WikiCreole.strip_list("\n *head")
26
+ assert_equal "`**head", WikiCreole.strip_list("***head")
27
+ end
28
+
29
+ def test_chunk_filter_lambdas
30
+ assert_equal "a string with a in it", WikiCreole.filter_string_x_with_chunk_filter_y("a string with a : in it", :ip)
31
+ assert_equal "a string with a newline", WikiCreole.filter_string_x_with_chunk_filter_y("a string with a newline\n", :p)
32
+ assert_equal "a string with a newline", WikiCreole.filter_string_x_with_chunk_filter_y("a string with a newline\n", :dd)
33
+ assert_equal "", WikiCreole.filter_string_x_with_chunk_filter_y("a non-blank string", :blank)
34
+
35
+ #special... uses strip_list function inside the lamda function
36
+ assert_equal "`head", WikiCreole.filter_string_x_with_chunk_filter_y(" *head", :ul)
37
+ assert_equal "head", WikiCreole.filter_string_x_with_chunk_filter_y("head == ", :h5)
38
+ end
39
+
40
+ def test_init
41
+ WikiCreole.init
42
+ assert_equal 1, 1
43
+ end
44
+
45
+ def test_sub_chunk_for
46
+ WikiCreole.init
47
+ str = "//Hello// **Hello**"
48
+ assert_equal :p, WikiCreole.get_sub_chunk_for(str, :top, 0)
49
+ assert_equal :em, WikiCreole.get_sub_chunk_for(str, :p, 0)
50
+ assert_equal :plain, WikiCreole.get_sub_chunk_for(str, :p, 9)
51
+ assert_equal :strong, WikiCreole.get_sub_chunk_for(str, :p, 10)
52
+ end
53
+
54
+ def test_strong
55
+ s = WikiCreole.creole_parse("**Hello**")
56
+ assert_equal "<p><strong>Hello</strong></p>\n\n", s
57
+ end
58
+
59
+ def test_italic
60
+ s = WikiCreole.creole_parse("//Hello//")
61
+ assert_equal "<p><em>Hello</em></p>\n\n", s
62
+ end
63
+
64
+ def test_italic_bold_with_no_spaces
65
+ s = WikiCreole.creole_parse("//Hello//**Hello**")
66
+ assert_equal "<p><em>Hello</em><strong>Hello</strong></p>\n\n", s
67
+ end
68
+
69
+ def test_italic_bold_with_a_space_in_the_middle
70
+ s = WikiCreole.creole_parse("//Hello// **Hello**")
71
+ assert_equal "<p><em>Hello</em> <strong>Hello</strong></p>\n\n", s
72
+ end
73
+
74
+ def test_two_paragraph_italic_bold_with_a_space_in_the_middle
75
+ s = WikiCreole.creole_parse("//Hello// **Hello**\n\n//Hello// **Hello**")
76
+ assert_equal "<p><em>Hello</em> <strong>Hello</strong></p>\n\n<p>" +
77
+ "<em>Hello</em> <strong>Hello</strong></p>\n\n", s
78
+ end
79
+
80
+ def test_link_with_a_page_name
81
+ s = WikiCreole.creole_parse("the site http://www.yahoo.com/page.html is a site")
82
+ assert_equal %Q{<p>the site <a href="http://www.yahoo.com/page.html">http://www.yahoo.com/page.html</a> is a site</p>\n\n}, s
83
+ end
84
+
85
+ def test_link_with_a_trailing_slash
86
+ # This test caught a bug in the initial parser, so I changed the ilink
87
+ # :stops regex so it worked.
88
+ s = WikiCreole.creole_parse("the site http://www.yahoo.com/ is a site")
89
+ assert_equal %Q{<p>the site <a href="http://www.yahoo.com/">http://www.yahoo.com/</a> is a site</p>\n\n}, s
90
+ end
91
+
92
+ def test_escaped_url
93
+ # This behavior is wrong. If you move the tilda to the
94
+ # beginning of the http, where it makes more sense, it breaks. Without
95
+ # negative lookback assertions it may be the best we can do without
96
+ # significanly hampering performance.
97
+ s = WikiCreole.creole_parse("the site http:~//www.yahoo.com/ is a site")
98
+ assert_equal %Q{<p>the site http://www.yahoo.com/ is a site</p>\n\n}, s
99
+ end
100
+
101
+ #-----------------------------------------------------------------------------
102
+ # Test the links
103
+
104
+ def test_link_with_text
105
+ markup = "This is a paragraph with a [[ link | some link ]].\nCheck it out."
106
+ goodhtml = %Q{<p>This is a paragraph with a <a href="link">some link</a>.\nCheck it out.</p>\n\n}
107
+
108
+ assert_equal goodhtml, WikiCreole.creole_parse(markup)
109
+
110
+ end
111
+
112
+ def test_link_with_no_text
113
+ markup = "This is a paragraph with a [[ link ]].\nCheck it out."
114
+ goodhtml = %Q{<p>This is a paragraph with a <a href="link">link</a>.\nCheck it out.</p>\n\n}
115
+
116
+ assert_equal goodhtml, WikiCreole.creole_parse(markup)
117
+
118
+ end
119
+
120
+ def test_user_supplied_creole_link_function
121
+
122
+ uppercase = Proc.new {|s|
123
+ s.upcase!
124
+ s
125
+ }
126
+ WikiCreole.creole_link(uppercase)
127
+
128
+ markup = "This is a paragraph with an uppercased [[ link ]].\nCheck it out."
129
+ goodhtml = %Q{<p>This is a paragraph with an uppercased <a href="LINK">link</a>.\nCheck it out.</p>\n\n}
130
+
131
+ assert_equal goodhtml, WikiCreole.creole_parse(markup)
132
+
133
+ # set the link function back to being nil so that the rest of the tests
134
+ # are not affected by the custom link function
135
+ WikiCreole.creole_link(nil)
136
+
137
+ end
138
+
139
+ def test_puts_existing_creole_tags
140
+ tags = WikiCreole.creole_tag()
141
+ assert tags.index(/u: open\(<u>\) close\(<\/u>\)/)
142
+ end
143
+
144
+ def test_custom_creole_tag
145
+ WikiCreole.creole_tag(:p, :open, "<p class=special>")
146
+
147
+ markup = "This is a paragraph."
148
+ goodhtml = "<p class=special>This is a paragraph.</p>\n\n"
149
+
150
+ assert_equal goodhtml, WikiCreole.creole_parse(markup)
151
+ WikiCreole.creole_tag(:p, :open, "<p>")
152
+ end
153
+
154
+ def test_user_supplied_plugin_function
155
+ uppercase = Proc.new {|s|
156
+ s.upcase!
157
+ s
158
+ }
159
+ WikiCreole.creole_plugin(uppercase)
160
+
161
+ markup = "This is a paragraph with an uppercasing << plugin >>.\nCheck it out."
162
+ goodhtml = %Q{<p>This is a paragraph with an uppercasing PLUGIN .\nCheck it out.</p>\n\n}
163
+
164
+ assert_equal goodhtml, WikiCreole.creole_parse(markup)
165
+
166
+ # set the link function back to being nil so that the rest of the tests
167
+ # are not affected by the custom link function
168
+ WikiCreole.creole_plugin(nil)
169
+ end
170
+
171
+ #-----------------------------------------------------------------------------
172
+ # Below here are all the file based tests. They read the .markup file,
173
+ # parse it, then validate that it matches the pre-existing .html file.
174
+
175
+ def test_amp
176
+ run_testfile("amp")
177
+ end
178
+
179
+ def test_block
180
+ run_testfile("block")
181
+ end
182
+
183
+ def test_escape
184
+ run_testfile("escape")
185
+ end
186
+
187
+ def test_inline
188
+ run_testfile("inline")
189
+ end
190
+
191
+ def test_specialchars
192
+ run_testfile("specialchars")
193
+ end
194
+
195
+ def test_jsp_wiki
196
+ # This test was found on the Creole website. I had to hand-tweak it a bit
197
+ # for it to make sense for our paticular settings, however, the fundamentals
198
+ # are the same as they were in the original test.
199
+ run_testfile("jsp_wiki")
200
+ end
201
+
202
+ def run_testfile(name)
203
+ name = "test_" + name
204
+ markup = File.read("./test/#{name}.markup")
205
+ html = File.read("./test/#{name}.html")
206
+ parsed = WikiCreole.creole_parse(markup)
207
+ #write_file("./test/#{name}.processed", parsed) if name.index(/jsp/)
208
+ assert_equal html, parsed
209
+ end
210
+
211
+ def write_file(filename, data)
212
+ f = File.new(filename, "w")
213
+ f.write(data)
214
+ f.close
215
+ end
216
+
217
+ #---------------------------------------------------------------------
218
+ # The following tests are adapted from http://github.com/larsch/creole/tree/master and were written by Lars Christensen
219
+
220
+ def test_larsch_bold
221
+ # Creole1.0: Bold can be used inside paragraphs
222
+ tc "<p>This <strong>is</strong> bold</p>\n\n", "This **is** bold"
223
+ tc "<p>This <strong>is</strong> bold and <strong>bold</strong>ish</p>\n\n", "This **is** bold and **bold**ish"
224
+
225
+ # Creole1.0: Bold can be used inside list items
226
+ html = "
227
+ <ul>
228
+ <li>This is <strong>bold</strong></li>
229
+ </ul>
230
+ "
231
+ tc html, "* This is **bold**"
232
+
233
+ # Creole1.0: Bold can be used inside table cells
234
+ html = "
235
+ <table>
236
+ <tr>
237
+ <td>This is <strong>bold</strong></td>
238
+ </tr>
239
+ </table>
240
+
241
+ "
242
+ tc html, "|This is **bold**|"
243
+
244
+ # Creole1.0: Links can appear inside bold text:
245
+ tc("<p>A bold link: <strong><a href=\"http://wikicreole.org/\">http://wikicreole.org/</a> nice!</strong></p>\n\n",
246
+ "A bold link: **http://wikicreole.org/ nice!**")
247
+
248
+ # Creole1.0: Bold will end at the end of paragraph
249
+ tc "<p>This <strong>is bold</strong></p>\n\n", "This **is bold"
250
+
251
+ # Creole1.0: Bold will end at the end of list items
252
+ html = "
253
+ <ul>
254
+ <li>Item <strong>bold</strong></li>
255
+ <li>Item normal</li>
256
+ </ul>
257
+ "
258
+ tc html, "* Item **bold\n* Item normal"
259
+
260
+ # Creole1.0: Bold will end at the end of table cells
261
+ html = "
262
+ <table>
263
+ <tr>
264
+ <td>Item <strong>bold</strong></td>
265
+ <td>Another <strong>bold</strong></td>
266
+ </tr>
267
+ </table>
268
+
269
+ "
270
+ tc html, "|Item **bold|Another **bold"
271
+
272
+ # Creole1.0: Bold should not cross paragraphs
273
+ tc("<p>This <strong>is</strong></p>\n\n<p>bold<strong> maybe</strong></p>\n\n",
274
+ "This **is\n\nbold** maybe")
275
+
276
+ # Creole1.0-Implied: Bold should be able to cross a single line break
277
+ tc "<p>This <strong>is\nbold</strong></p>\n\n", "This **is\nbold**"
278
+ end
279
+
280
+ def test_larsch_italic
281
+ # Creole1.0: Italic can be used inside paragraphs
282
+ tc("<p>This <em>is</em> italic</p>\n\n",
283
+ "This //is// italic")
284
+ tc("<p>This <em>is</em> italic and <em>italic</em>ish</p>\n\n",
285
+ "This //is// italic and //italic//ish")
286
+
287
+ # Creole1.0: Italic can be used inside list items
288
+ html = "
289
+ <ul>
290
+ <li>This is <em>italic</em></li>
291
+ </ul>
292
+ "
293
+ tc html, "* This is //italic//"
294
+
295
+ # Creole1.0: Italic can be used inside table cells
296
+ html = "
297
+ <table>
298
+ <tr>
299
+ <td>This is <em>italic</em></td>
300
+ </tr>
301
+ </table>
302
+
303
+ "
304
+ tc html, "|This is //italic//|"
305
+
306
+ # Creole1.0: Links can appear inside italic text:
307
+ tc("<p>A italic link: <em><a href=\"http://wikicreole.org/\">http://wikicreole.org/</a> nice!</em></p>\n\n",
308
+ "A italic link: //http://wikicreole.org/ nice!//")
309
+
310
+ # Creole1.0: Italic will end at the end of paragraph
311
+ tc "<p>This <em>is italic</em></p>\n\n", "This //is italic"
312
+
313
+ # Creole1.0: Italic will end at the end of list items
314
+ html = "
315
+ <ul>
316
+ <li>Item <em>italic</em></li>
317
+ <li>Item normal</li>
318
+ </ul>
319
+ "
320
+ tc html, "* Item //italic\n* Item normal"
321
+
322
+ # Creole1.0: Italic will end at the end of table cells
323
+ html = "
324
+ <table>
325
+ <tr>
326
+ <td>Item <em>italic</em></td>
327
+ <td>Another <em>italic</em></td>
328
+ </tr>
329
+ </table>
330
+
331
+ "
332
+ tc html, "|Item //italic|Another //italic"
333
+
334
+ # Creole1.0: Italic should not cross paragraphs
335
+ tc("<p>This <em>is</em></p>\n\n<p>italic<em> maybe</em></p>\n\n",
336
+ "This //is\n\nitalic// maybe")
337
+
338
+ # Creole1.0-Implied: Italic should be able to cross lines
339
+ tc "<p>This <em>is\nitalic</em></p>\n\n", "This //is\nitalic//"
340
+ end
341
+
342
+ def test_larsch_bold_italics
343
+ # Creole1.0: By example
344
+ tc "<p><strong><em>bold italics</em></strong></p>\n\n", "**//bold italics//**"
345
+
346
+ # Creole1.0: By example
347
+ tc "<p><em><strong>bold italics</strong></em></p>\n\n", "//**bold italics**//"
348
+
349
+ # Creole1.0: By example
350
+ tc "<p><em>This is <strong>also</strong> good.</em></p>\n\n", "//This is **also** good.//"
351
+ end
352
+
353
+ def test_larsch_headings
354
+ # Creole1.0: Only three differed sized levels of heading are required.
355
+ tc "<h1>Heading 1</h1>\n\n", "= Heading 1 ="
356
+ tc "<h2>Heading 2</h2>\n\n", "== Heading 2 =="
357
+ tc "<h3>Heading 3</h3>\n\n", "=== Heading 3 ==="
358
+ unless $strict
359
+ tc "<h4>Heading 4</h4>\n\n", "==== Heading 4 ===="
360
+ tc "<h5>Heading 5</h5>\n\n", "===== Heading 5 ====="
361
+ tc "<h6>Heading 6</h6>\n\n", "====== Heading 6 ======"
362
+ end
363
+
364
+ # Creole1.0: Closing (right-side) equal signs are optional
365
+ tc "<h1>Heading 1</h1>\n\n", "=Heading 1"
366
+ tc "<h2>Heading 2</h2>\n\n", "== Heading 2"
367
+ tc "<h3>Heading 3</h3>\n\n", " === Heading 3"
368
+
369
+ # Creole1.0: Closing (right-side) equal signs don't need to be balanced and don't impact the kind of heading generated
370
+ tc "<h1>Heading 1</h1>\n\n", "=Heading 1 ==="
371
+ tc "<h2>Heading 2</h2>\n\n", "== Heading 2 ="
372
+ tc "<h3>Heading 3</h3>\n\n", " === Heading 3 ==========="
373
+
374
+ # Creole1.0: Whitespace is allowed before the left-side equal signs.
375
+ # TODO XXX: These don't work in this version of the parser
376
+ #tc "<h1>Heading 1</h1>\n\n", "\t= Heading 1 ="
377
+ #tc "<h2>Heading 2</h2>\n\n", " \t == Heading 2 =="
378
+
379
+ # Creole1.0: Only white-space characters are permitted after the closing equal signs.
380
+ tc "<h1>Heading 1</h1>\n\n", " = Heading 1 = "
381
+ tc "<h2>Heading 2</h2>\n\n", " == Heading 2 == \t "
382
+
383
+ # !!Creole1.0 doesn't specify if text after closing equal signs
384
+ # !!becomes part of the heading or invalidates the entire heading.
385
+ # tc "<p> == Heading 2 == foo</p>\n\n", " == Heading 2 == foo"
386
+ unless $strict
387
+ tc "<h2>Heading 2 == foo</h2>\n\n", " == Heading 2 == foo"
388
+ end
389
+
390
+ # Creole1.0-Implied: Line must start with equal sign
391
+ tc "<p>foo = Heading 1 =</p>\n\n", "foo = Heading 1 ="
392
+ end
393
+
394
+ # left off adding Lars' tests here... will do more as time allows.
395
+
396
+ # def test_larsch_links
397
+ # # Creole1.0: Links
398
+ # tc "<p><a href=\"link\">link</a></p>", "[[link]]"
399
+
400
+ # # Creole1.0: Links can appear in paragraphs (i.e. inline item)
401
+ # tc "<p>Hello, <a href=\"world\">world</a></p>", "Hello, [[world]]"
402
+
403
+ # # Creole1.0: Named links
404
+ # tc "<p><a href=\"MyBigPage\">Go to my page</a></p>", "[[MyBigPage|Go to my page]]"
405
+
406
+ # # Creole1.0: URLs
407
+ # tc "<p><a href=\"http://www.wikicreole.org/\">http://www.wikicreole.org/</a></p>", "[[http://www.wikicreole.org/]]"
408
+
409
+ # # Creole1.0: Free-standing URL's should be turned into links
410
+ # tc "<p><a href=\"http://www.wikicreole.org/\">http://www.wikicreole.org/</a></p>", "http://www.wikicreole.org/"
411
+
412
+ # # Creole1.0: Single punctuation characters at the end of URLs
413
+ # # should not be considered a part of the URL.
414
+ # [',','.','?','!',':',';','\'','"'].each { |punct|
415
+ # esc_punct = escape_html(punct)
416
+ # tc "<p><a href=\"http://www.wikicreole.org/\">http://www.wikicreole.org/</a>#{esc_punct}</p>", "http://www.wikicreole.org/#{punct}"
417
+ # }
418
+ # # Creole1.0: Nameds URLs (by example)
419
+ # tc("<p><a href=\"http://www.wikicreole.org/\">Visit the WikiCreole website</a></p>",
420
+ # "[[http://www.wikicreole.org/|Visit the WikiCreole website]]")
421
+
422
+ # unless $strict
423
+ # # Parsing markup within a link is optional
424
+ # tc "<p><a href=\"Weird+Stuff\">**Weird** //Stuff//</a></p>", "[[Weird Stuff|**Weird** //Stuff//]]"
425
+ # end
426
+
427
+ # # Inside bold
428
+ # tc "<p><strong><a href=\"link\">link</a></strong></p>", "**[[link]]**"
429
+
430
+ # # Whitespace inside [[ ]] should be ignored
431
+ # tc("<p><a href=\"link\">link</a></p>", "[[ link ]]")
432
+ # tc("<p><a href=\"link+me\">link me</a></p>", "[[ link me ]]")
433
+ # tc("<p><a href=\"http://dot.com/\">dot.com</a></p>", "[[ http://dot.com/ \t| \t dot.com ]]")
434
+ # tc("<p><a href=\"http://dot.com/\">dot.com</a></p>", "[[ http://dot.com/ | dot.com ]]")
435
+ # end
436
+
437
+ # def test_larsch_paragraph
438
+ # # Creole1.0: One or more blank lines end paragraphs.
439
+ # tc "<p>This is my text.</p><p>This is more text.</p>", "This is\nmy text.\n\nThis is\nmore text."
440
+ # tc "<p>This is my text.</p><p>This is more text.</p>", "This is\nmy text.\n\n\nThis is\nmore text."
441
+ # tc "<p>This is my text.</p><p>This is more text.</p>", "This is\nmy text.\n\n\n\nThis is\nmore text."
442
+
443
+ # # Creole1.0: A list end paragraphs too.
444
+ # tc "<p>Hello</p><ul><li>Item</li></ul>", "Hello\n* Item\n"
445
+
446
+ # # Creole1.0: A table end paragraphs too.
447
+ # tc "<p>Hello</p><table><tr><td>Cell</td></tr></table>", "Hello\n|Cell|"
448
+
449
+ # # Creole1.0: A nowiki end paragraphs too.
450
+ # tc "<p>Hello</p><pre>nowiki</pre>", "Hello\n{{{\nnowiki\n}}}\n"
451
+
452
+ # unless $strict
453
+ # # A heading ends a paragraph (not specced)
454
+ # tc "<p>Hello</p><h1>Heading</h1>", "Hello\n= Heading =\n"
455
+ # end
456
+ # end
457
+
458
+ # def test_larsch_linebreak
459
+ # # Creole1.0: \\ (wiki-style) for line breaks.
460
+ # tc "<p>This is the first line,<br/>and this is the second.</p>", "This is the first line,\\\\and this is the second."
461
+ # end
462
+
463
+ # def test_larsch_unordered_lists
464
+ # # Creole1.0: List items begin with a * at the beginning of a line.
465
+ # # Creole1.0: An item ends at the next *
466
+ # tc "<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>", "* Item 1\n *Item 2\n *\t\tItem 3\n"
467
+
468
+ # # Creole1.0: Whitespace is optional before and after the *.
469
+ # tc("<ul><li>Item 1</li><li>Item 2</li><li>Item 3</li></ul>",
470
+ # " * Item 1\n*Item 2\n \t*\t\tItem 3\n")
471
+
472
+ # # Creole1.0: A space is required if if the list element starts with bold text.
473
+ # tc("<ul><ul><ul><li>Item 1</li></ul></ul></ul>", "***Item 1")
474
+ # tc("<ul><li><strong>Item 1</strong></li></ul>", "* **Item 1")
475
+
476
+ # # Creole1.0: An item ends at blank line
477
+ # tc("<ul><li>Item</li></ul><p>Par</p>", "* Item\n\nPar\n")
478
+
479
+ # # Creole1.0: An item ends at a heading
480
+ # tc("<ul><li>Item</li></ul><h1>Heading</h1>", "* Item\n= Heading =\n")
481
+
482
+ # # Creole1.0: An item ends at a table
483
+ # tc("<ul><li>Item</li></ul><table><tr><td>Cell</td></tr></table>", "* Item\n|Cell|\n")
484
+
485
+ # # Creole1.0: An item ends at a nowiki block
486
+ # tc("<ul><li>Item</li></ul><pre>Code</pre>", "* Item\n{{{\nCode\n}}}\n")
487
+
488
+ # # Creole1.0: An item can span multiple lines
489
+ # tc("<ul><li>The quick brown fox jumps over lazy dog.</li><li>Humpty Dumpty sat on a wall.</li></ul>",
490
+ # "* The quick\nbrown fox\n\tjumps over\nlazy dog.\n*Humpty Dumpty\nsat\t\non a wall.")
491
+
492
+ # # Creole1.0: An item can contain line breaks
493
+ # tc("<ul><li>The quick brown<br/>fox jumps over lazy dog.</li></ul>",
494
+ # "* The quick brown\\\\fox jumps over lazy dog.")
495
+
496
+ # # Creole1.0: Nested
497
+ # tc "<ul><li>Item 1</li><ul><li>Item 2</li></ul><li>Item 3</li></ul>", "* Item 1\n **Item 2\n *\t\tItem 3\n"
498
+
499
+ # # Creole1.0: Nested up to 5 levels
500
+ # tc("<ul><li>Item 1</li><ul><li>Item 2</li><ul><li>Item 3</li><ul><li>Item 4</li><ul><li>Item 5</li></ul></ul></ul></ul></ul>",
501
+ # "*Item 1\n**Item 2\n***Item 3\n****Item 4\n*****Item 5\n")
502
+
503
+ # # Creole1.0: ** immediatly following a list element will be treated as a nested unordered element.
504
+ # tc("<ul><li>Hello, World!</li><ul><li>Not bold</li></ul></ul>",
505
+ # "*Hello,\nWorld!\n**Not bold\n")
506
+
507
+ # # Creole1.0: ** immediatly following a list element will be treated as a nested unordered element.
508
+ # tc("<ol><li>Hello, World!</li><ul><li>Not bold</li></ul></ol>",
509
+ # "#Hello,\nWorld!\n**Not bold\n")
510
+
511
+ # # Creole1.0: [...] otherwise it will be treated as the beginning of bold text.
512
+ # tc("<ul><li>Hello, World!</li></ul><p><strong>Not bold</strong></p>",
513
+ # "*Hello,\nWorld!\n\n**Not bold\n")
514
+ # end
515
+
516
+ # def test_larsch_ordered_lists
517
+ # # Creole1.0: List items begin with a * at the beginning of a line.
518
+ # # Creole1.0: An item ends at the next *
519
+ # tc "<ol><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>", "# Item 1\n #Item 2\n #\t\tItem 3\n"
520
+
521
+ # # Creole1.0: Whitespace is optional before and after the #.
522
+ # tc("<ol><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>",
523
+ # " # Item 1\n#Item 2\n \t#\t\tItem 3\n")
524
+
525
+ # # Creole1.0: A space is required if if the list element starts with bold text.
526
+ # tc("<ol><ol><ol><li>Item 1</li></ol></ol></ol>", "###Item 1")
527
+ # tc("<ol><li><strong>Item 1</strong></li></ol>", "# **Item 1")
528
+
529
+ # # Creole1.0: An item ends at blank line
530
+ # tc("<ol><li>Item</li></ol><p>Par</p>", "# Item\n\nPar\n")
531
+
532
+ # # Creole1.0: An item ends at a heading
533
+ # tc("<ol><li>Item</li></ol><h1>Heading</h1>", "# Item\n= Heading =\n")
534
+
535
+ # # Creole1.0: An item ends at a table
536
+ # tc("<ol><li>Item</li></ol><table><tr><td>Cell</td></tr></table>", "# Item\n|Cell|\n")
537
+
538
+ # # Creole1.0: An item ends at a nowiki block
539
+ # tc("<ol><li>Item</li></ol><pre>Code</pre>", "# Item\n{{{\nCode\n}}}\n")
540
+
541
+ # # Creole1.0: An item can span multiple lines
542
+ # tc("<ol><li>The quick brown fox jumps over lazy dog.</li><li>Humpty Dumpty sat on a wall.</li></ol>",
543
+ # "# The quick\nbrown fox\n\tjumps over\nlazy dog.\n#Humpty Dumpty\nsat\t\non a wall.")
544
+
545
+ # # Creole1.0: An item can contain line breaks
546
+ # tc("<ol><li>The quick brown<br/>fox jumps over lazy dog.</li></ol>",
547
+ # "# The quick brown\\\\fox jumps over lazy dog.")
548
+
549
+ # # Creole1.0: Nested
550
+ # tc "<ol><li>Item 1</li><ol><li>Item 2</li></ol><li>Item 3</li></ol>", "# Item 1\n ##Item 2\n #\t\tItem 3\n"
551
+
552
+ # # Creole1.0: Nested up to 5 levels
553
+ # tc("<ol><li>Item 1</li><ol><li>Item 2</li><ol><li>Item 3</li><ol><li>Item 4</li><ol><li>Item 5</li></ol></ol></ol></ol></ol>",
554
+ # "#Item 1\n##Item 2\n###Item 3\n####Item 4\n#####Item 5\n")
555
+
556
+ # # Creole1.0_Infered: The two-bullet rule only applies to **.
557
+ # tc("<ol><ol><li>Item</li></ol></ol>", "##Item")
558
+ # end
559
+
560
+ # def test_larsch_ordered_lists2
561
+ # tc "<ol><li>Item 1</li><li>Item 2</li><li>Item 3</li></ol>", "# Item 1\n #Item 2\n #\t\tItem 3\n"
562
+ # # Nested
563
+ # tc "<ol><li>Item 1</li><ol><li>Item 2</li></ol><li>Item 3</li></ol>", "# Item 1\n ##Item 2\n #\t\tItem 3\n"
564
+ # # Multiline
565
+ # tc "<ol><li>Item 1 on multiple lines</li></ol>", "# Item 1\non multiple lines"
566
+ # end
567
+
568
+ # def test_larsch_ambiguity_mixed_lists
569
+ # # ol following ul
570
+ # tc("<ul><li>uitem</li></ul><ol><li>oitem</li></ol>", "*uitem\n#oitem\n")
571
+
572
+ # # ul following ol
573
+ # tc("<ol><li>uitem</li></ol><ul><li>oitem</li></ul>", "#uitem\n*oitem\n")
574
+
575
+ # # 2ol following ul
576
+ # tc("<ul><li>uitem</li><ol><li>oitem</li></ol></ul>", "*uitem\n##oitem\n")
577
+
578
+ # # 2ul following ol
579
+ # tc("<ol><li>uitem</li><ul><li>oitem</li></ul></ol>", "#uitem\n**oitem\n")
580
+
581
+ # # 3ol following 3ul
582
+ # tc("<ul><ul><ul><li>uitem</li></ul><ol><li>oitem</li></ol></ul></ul>", "***uitem\n###oitem\n")
583
+
584
+ # # 2ul following 2ol
585
+ # tc("<ol><ol><li>uitem</li></ol><ul><li>oitem</li></ul></ol>", "##uitem\n**oitem\n")
586
+
587
+ # # ol following 2ol
588
+ # tc("<ol><ol><li>oitem1</li></ol><li>oitem2</li></ol>", "##oitem1\n#oitem2\n")
589
+ # # ul following 2ol
590
+ # tc("<ol><ol><li>oitem1</li></ol></ol><ul><li>oitem2</li></ul>", "##oitem1\n*oitem2\n")
591
+ # end
592
+
593
+ # def test_larsch_ambiguity_italics_and_url
594
+ # # Uncommon URL schemes should not be parsed as URLs
595
+ # tc("<p>This is what can go wrong:<em>this should be an italic text</em>.</p>",
596
+ # "This is what can go wrong://this should be an italic text//.")
597
+
598
+ # # A link inside italic text
599
+ # tc("<p>How about <em>a link, like <a href=\"http://example.org\">http://example.org</a>, in italic</em> text?</p>",
600
+ # "How about //a link, like http://example.org, in italic// text?")
601
+
602
+ # # Another test from Creole Wiki
603
+ # tc("<p>Formatted fruits, for example:<em>apples</em>, oranges, <strong>pears</strong> ...</p>",
604
+ # "Formatted fruits, for example://apples//, oranges, **pears** ...")
605
+ # end
606
+
607
+ # def test_ambiguity_bold_and_lists
608
+ # tc "<p><strong> bold text </strong></p>", "** bold text **"
609
+ # tc "<p> <strong> bold text </strong></p>", " ** bold text **"
610
+ # end
611
+
612
+ # def test_larsch_nowiki
613
+ # # ... works as block
614
+ # tc "<pre>Hello</pre>", "{{{\nHello\n}}}\n"
615
+
616
+ # # ... works inline
617
+ # tc "<p>Hello <tt>world</tt>.</p>", "Hello {{{world}}}."
618
+
619
+ # # Creole1.0: No wiki markup is interpreted inbetween
620
+ # tc "<pre>**Hello**</pre>", "{{{\n**Hello**\n}}}\n"
621
+
622
+ # # Creole1.0: Leading whitespaces are not permitted
623
+ # tc("<p> {{{ Hello }}}</p>", " {{{\nHello\n}}}")
624
+ # tc("<p>{{{ Hello }}}</p>", "{{{\nHello\n }}}")
625
+
626
+ # # Assumed: Should preserve whitespace
627
+ # tc("<pre> \t Hello, \t \n \t World \t </pre>",
628
+ # "{{{\n \t Hello, \t \n \t World \t \n}}}\n")
629
+
630
+ # # In preformatted blocks ... one leading space is removed
631
+ # tc("<pre>nowikiblock\n}}}</pre>", "{{{\nnowikiblock\n }}}\n}}}\n")
632
+
633
+ # # In inline nowiki, any trailing closing brace is included in the span
634
+ # tc("<p>this is <tt>nowiki}</tt></p>", "this is {{{nowiki}}}}")
635
+ # tc("<p>this is <tt>nowiki}}</tt></p>", "this is {{{nowiki}}}}}")
636
+ # tc("<p>this is <tt>nowiki}}}</tt></p>", "this is {{{nowiki}}}}}}")
637
+ # tc("<p>this is <tt>nowiki}}}}</tt></p>", "this is {{{nowiki}}}}}}}")
638
+ # end
639
+
640
+ # def test_larsch_html_escaping
641
+ # # Special HTML chars should be escaped
642
+ # tc("<p>&lt;b&gt;not bold&lt;/b&gt;</p>", "<b>not bold</b>")
643
+
644
+ # # Image tags should be escape
645
+ # tc("<p><img src=\"image.jpg\" alt=\"&quot;tag&quot;\"/></p>", "{{image.jpg|\"tag\"}}")
646
+
647
+ # # Malicious links should not be converted.
648
+ # tc("<p><a href=\"javascript%3Aalert%28%22Boo%21%22%29\">Click</a></p>", "[[javascript:alert(\"Boo!\")|Click]]")
649
+ # end
650
+
651
+ # def test_larschescape
652
+ # tc "<p>** Not Bold **</p>", "~** Not Bold ~**"
653
+ # tc "<p>// Not Italic //</p>", "~// Not Italic ~//"
654
+ # tc "<p>* Not Bullet</p>", "~* Not Bullet"
655
+ # # Following char is not a blank (space or line feed)
656
+ # tc "<p>Hello ~ world</p>", "Hello ~ world\n"
657
+ # tc "<p>Hello ~ world</p>", "Hello ~\nworld\n"
658
+ # # Not escaping inside URLs (Creole1.0 not clear on this)
659
+ # tc "<p><a href=\"http://example.org/~user/\">http://example.org/~user/</a></p>", "http://example.org/~user/"
660
+
661
+ # # Escaping links
662
+ # tc "<p>http://www.wikicreole.org/</p>", "~http://www.wikicreole.org/"
663
+ # end
664
+
665
+ # def test_larsch_horizontal_rule
666
+ # # Creole: Four hyphens make a horizontal rule
667
+ # tc "<hr/>", "----"
668
+
669
+ # # Creole1.0: Whitespace around them is allowed
670
+ # tc "<hr/>", " ----"
671
+ # tc "<hr/>", "---- "
672
+ # tc "<hr/>", " ---- "
673
+ # tc "<hr/>", " \t ---- \t "
674
+
675
+ # # Creole1.0: Nothing else than hyphens and whitespace is "allowed"
676
+ # tc "<p>foo ----</p>", "foo ----\n"
677
+ # tc "<p>---- foo</p>", "---- foo\n"
678
+
679
+ # # Creole1.0: [...] no whitespace is allowed between them
680
+ # tc "<p> -- -- </p>", " -- -- "
681
+ # tc "<p> -- -- </p>", " --\t-- "
682
+ # end
683
+
684
+ # def test_larsch_table
685
+ # tc "<table><tr><td>Hello, World!</td></tr></table>", "|Hello, World!|"
686
+ # # Multiple columns
687
+ # tc "<table><tr><td>c1</td><td>c2</td><td>c3</td></tr></table>", "|c1|c2|c3|"
688
+ # # Multiple rows
689
+ # tc "<table><tr><td>c11</td><td>c12</td></tr><tr><td>c21</td><td>c22</td></tr></table>", "|c11|c12|\n|c21|c22|\n"
690
+ # # End pipe is optional
691
+ # tc "<table><tr><td>c1</td><td>c2</td><td>c3</td></tr></table>", "|c1|c2|c3"
692
+ # # Empty cells
693
+ # tc "<table><tr><td>c1</td><td></td><td>c3</td></tr></table>", "|c1||c3"
694
+ # # Escaping cell separator
695
+ # tc "<table><tr><td>c1|c2</td><td>c3</td></tr></table>", "|c1~|c2|c3"
696
+ # # Escape in last cell + empty cell
697
+ # tc "<table><tr><td>c1</td><td>c2|</td></tr></table>", "|c1|c2~|"
698
+ # tc "<table><tr><td>c1</td><td>c2|</td></tr></table>", "|c1|c2~||"
699
+ # tc "<table><tr><td>c1</td><td>c2|</td><td></td></tr></table>", "|c1|c2~|||"
700
+ # # Equal sign after pipe make a header
701
+ # tc "<table><tr><th>Header</th></tr></table>", "|=Header|"
702
+ # end
703
+
704
+ # def test_larsch_following_table
705
+ # # table followed by heading
706
+ # tc("<table><tr><td>table</td></tr></table><h1>heading</h1>", "|table|\n=heading=\n")
707
+ # tc("<table><tr><td>table</td></tr></table><h1>heading</h1>", "|table|\n\n=heading=\n")
708
+ # # table followed by paragraph
709
+ # tc("<table><tr><td>table</td></tr></table><p>par</p>", "|table|\npar\n")
710
+ # tc("<table><tr><td>table</td></tr></table><p>par</p>", "|table|\n\npar\n")
711
+ # # table followed by unordered list
712
+ # tc("<table><tr><td>table</td></tr></table><ul><li>item</li></ul>", "|table|\n*item\n")
713
+ # tc("<table><tr><td>table</td></tr></table><ul><li>item</li></ul>", "|table|\n\n*item\n")
714
+ # # table followed by ordered list
715
+ # tc("<table><tr><td>table</td></tr></table><ol><li>item</li></ol>", "|table|\n#item\n")
716
+ # tc("<table><tr><td>table</td></tr></table><ol><li>item</li></ol>", "|table|\n\n#item\n")
717
+ # # table followed by horizontal rule
718
+ # tc("<table><tr><td>table</td></tr></table><hr/>", "|table|\n----\n")
719
+ # tc("<table><tr><td>table</td></tr></table><hr/>", "|table|\n\n----\n")
720
+ # # table followed by nowiki block
721
+ # tc("<table><tr><td>table</td></tr></table><pre>pre</pre>", "|table|\n{{{\npre\n}}}\n")
722
+ # tc("<table><tr><td>table</td></tr></table><pre>pre</pre>", "|table|\n\n{{{\npre\n}}}\n")
723
+ # # table followed by table
724
+ # tc("<table><tr><td>table</td></tr><tr><td>table</td></tr></table>", "|table|\n|table|\n")
725
+ # tc("<table><tr><td>table</td></tr></table><table><tr><td>table</td></tr></table>", "|table|\n\n|table|\n")
726
+ # end
727
+
728
+ # def test_larsch_following_heading
729
+ # # heading
730
+ # tc("<h1>heading1</h1><h1>heading2</h1>", "=heading1=\n=heading2\n")
731
+ # tc("<h1>heading1</h1><h1>heading2</h1>", "=heading1=\n\n=heading2\n")
732
+ # # paragraph
733
+ # tc("<h1>heading</h1><p>par</p>", "=heading=\npar\n")
734
+ # tc("<h1>heading</h1><p>par</p>", "=heading=\n\npar\n")
735
+ # # unordered list
736
+ # tc("<h1>heading</h1><ul><li>item</li></ul>", "=heading=\n*item\n")
737
+ # tc("<h1>heading</h1><ul><li>item</li></ul>", "=heading=\n\n*item\n")
738
+ # # ordered list
739
+ # tc("<h1>heading</h1><ol><li>item</li></ol>", "=heading=\n#item\n")
740
+ # tc("<h1>heading</h1><ol><li>item</li></ol>", "=heading=\n\n#item\n")
741
+ # # horizontal rule
742
+ # tc("<h1>heading</h1><hr/>", "=heading=\n----\n")
743
+ # tc("<h1>heading</h1><hr/>", "=heading=\n\n----\n")
744
+ # # nowiki block
745
+ # tc("<h1>heading</h1><pre>nowiki</pre>", "=heading=\n{{{\nnowiki\n}}}\n")
746
+ # tc("<h1>heading</h1><pre>nowiki</pre>", "=heading=\n\n{{{\nnowiki\n}}}\n")
747
+ # # table
748
+ # tc("<h1>heading</h1><table><tr><td>table</td></tr></table>", "=heading=\n|table|\n")
749
+ # tc("<h1>heading</h1><table><tr><td>table</td></tr></table>", "=heading=\n\n|table|\n")
750
+ # end
751
+
752
+ # def test_larsch_following_paragraph
753
+ # # heading
754
+ # tc("<p>par</p><h1>heading</h1>", "par\n=heading=")
755
+ # tc("<p>par</p><h1>heading</h1>", "par\n\n=heading=")
756
+ # # paragraph
757
+ # tc("<p>par par</p>", "par\npar\n")
758
+ # tc("<p>par</p><p>par</p>", "par\n\npar\n")
759
+ # # unordered
760
+ # tc("<p>par</p><ul><li>item</li></ul>", "par\n*item")
761
+ # tc("<p>par</p><ul><li>item</li></ul>", "par\n\n*item")
762
+ # # ordered
763
+ # tc("<p>par</p><ol><li>item</li></ol>", "par\n#item\n")
764
+ # tc("<p>par</p><ol><li>item</li></ol>", "par\n\n#item\n")
765
+ # # horizontal
766
+ # tc("<p>par</p><hr/>", "par\n----\n")
767
+ # tc("<p>par</p><hr/>", "par\n\n----\n")
768
+ # # nowiki
769
+ # tc("<p>par</p><pre>nowiki</pre>", "par\n{{{\nnowiki\n}}}\n")
770
+ # tc("<p>par</p><pre>nowiki</pre>", "par\n\n{{{\nnowiki\n}}}\n")
771
+ # # table
772
+ # tc("<p>par</p><table><tr><td>table</td></tr></table>", "par\n|table|\n")
773
+ # tc("<p>par</p><table><tr><td>table</td></tr></table>", "par\n\n|table|\n")
774
+ # end
775
+
776
+ # def test_larsch_following_unordered_list
777
+ # # heading
778
+ # tc("<ul><li>item</li></ul><h1>heading</h1>", "*item\n=heading=")
779
+ # tc("<ul><li>item</li></ul><h1>heading</h1>", "*item\n\n=heading=")
780
+ # # paragraph
781
+ # tc("<ul><li>item par</li></ul>", "*item\npar\n") # items may span multiple lines
782
+ # tc("<ul><li>item</li></ul><p>par</p>", "*item\n\npar\n")
783
+ # # unordered
784
+ # tc("<ul><li>item</li><li>item</li></ul>", "*item\n*item\n")
785
+ # tc("<ul><li>item</li></ul><ul><li>item</li></ul>", "*item\n\n*item\n")
786
+ # # ordered
787
+ # tc("<ul><li>item</li></ul><ol><li>item</li></ol>", "*item\n#item\n")
788
+ # tc("<ul><li>item</li></ul><ol><li>item</li></ol>", "*item\n\n#item\n")
789
+ # # horizontal rule
790
+ # tc("<ul><li>item</li></ul><hr/>", "*item\n----\n")
791
+ # tc("<ul><li>item</li></ul><hr/>", "*item\n\n----\n")
792
+ # # nowiki
793
+ # tc("<ul><li>item</li></ul><pre>nowiki</pre>", "*item\n{{{\nnowiki\n}}}\n")
794
+ # tc("<ul><li>item</li></ul><pre>nowiki</pre>", "*item\n\n{{{\nnowiki\n}}}\n")
795
+ # # table
796
+ # tc("<ul><li>item</li></ul><table><tr><td>table</td></tr></table>", "*item\n|table|\n")
797
+ # tc("<ul><li>item</li></ul><table><tr><td>table</td></tr></table>", "*item\n\n|table|\n")
798
+ # end
799
+
800
+ # def test_larsch_following_ordered_list
801
+ # # heading
802
+ # tc("<ol><li>item</li></ol><h1>heading</h1>", "#item\n=heading=")
803
+ # tc("<ol><li>item</li></ol><h1>heading</h1>", "#item\n\n=heading=")
804
+ # # paragraph
805
+ # tc("<ol><li>item par</li></ol>", "#item\npar\n") # items may span multiple lines
806
+ # tc("<ol><li>item</li></ol><p>par</p>", "#item\n\npar\n")
807
+ # # unordered
808
+ # tc("<ol><li>item</li></ol><ul><li>item</li></ul>", "#item\n*item\n")
809
+ # tc("<ol><li>item</li></ol><ul><li>item</li></ul>", "#item\n\n*item\n")
810
+ # # ordered
811
+ # tc("<ol><li>item</li><li>item</li></ol>", "#item\n#item\n")
812
+ # tc("<ol><li>item</li></ol><ol><li>item</li></ol>", "#item\n\n#item\n")
813
+ # # horizontal role
814
+ # tc("<ol><li>item</li></ol><hr/>", "#item\n----\n")
815
+ # tc("<ol><li>item</li></ol><hr/>", "#item\n\n----\n")
816
+ # # nowiki
817
+ # tc("<ol><li>item</li></ol><pre>nowiki</pre>", "#item\n{{{\nnowiki\n}}}\n")
818
+ # tc("<ol><li>item</li></ol><pre>nowiki</pre>", "#item\n\n{{{\nnowiki\n}}}\n")
819
+ # # table
820
+ # tc("<ol><li>item</li></ol><table><tr><td>table</td></tr></table>", "#item\n|table|\n")
821
+ # tc("<ol><li>item</li></ol><table><tr><td>table</td></tr></table>", "#item\n\n|table|\n")
822
+ # end
823
+
824
+ # def test_larsch_following_horizontal_rule
825
+ # # heading
826
+ # tc("<hr/><h1>heading</h1>", "----\n=heading=")
827
+ # tc("<hr/><h1>heading</h1>", "----\n\n=heading=")
828
+ # # paragraph
829
+ # tc("<hr/><p>par</p>", "----\npar\n")
830
+ # tc("<hr/><p>par</p>", "----\n\npar\n")
831
+ # # unordered
832
+ # tc("<hr/><ul><li>item</li></ul>", "----\n*item")
833
+ # tc("<hr/><ul><li>item</li></ul>", "----\n*item")
834
+ # # ordered
835
+ # tc("<hr/><ol><li>item</li></ol>", "----\n#item")
836
+ # tc("<hr/><ol><li>item</li></ol>", "----\n#item")
837
+ # # horizontal
838
+ # tc("<hr/><hr/>", "----\n----\n")
839
+ # tc("<hr/><hr/>", "----\n\n----\n")
840
+ # # nowiki
841
+ # tc("<hr/><pre>nowiki</pre>", "----\n{{{\nnowiki\n}}}\n")
842
+ # tc("<hr/><pre>nowiki</pre>", "----\n\n{{{\nnowiki\n}}}\n")
843
+ # # table
844
+ # tc("<hr/><table><tr><td>table</td></tr></table>", "----\n|table|\n")
845
+ # tc("<hr/><table><tr><td>table</td></tr></table>", "----\n\n|table|\n")
846
+ # end
847
+
848
+ # def test_larsch_following_nowiki_block
849
+ # # heading
850
+ # tc("<pre>nowiki</pre><h1>heading</h1>", "{{{\nnowiki\n}}}\n=heading=")
851
+ # tc("<pre>nowiki</pre><h1>heading</h1>", "{{{\nnowiki\n}}}\n\n=heading=")
852
+ # # paragraph
853
+ # tc("<pre>nowiki</pre><p>par</p>", "{{{\nnowiki\n}}}\npar")
854
+ # tc("<pre>nowiki</pre><p>par</p>", "{{{\nnowiki\n}}}\n\npar")
855
+ # # unordered
856
+ # tc("<pre>nowiki</pre><ul><li>item</li></ul>", "{{{\nnowiki\n}}}\n*item\n")
857
+ # tc("<pre>nowiki</pre><ul><li>item</li></ul>", "{{{\nnowiki\n}}}\n\n*item\n")
858
+ # # ordered
859
+ # tc("<pre>nowiki</pre><ol><li>item</li></ol>", "{{{\nnowiki\n}}}\n#item\n")
860
+ # tc("<pre>nowiki</pre><ol><li>item</li></ol>", "{{{\nnowiki\n}}}\n\n#item\n")
861
+ # # horizontal
862
+ # tc("<pre>nowiki</pre><hr/>", "{{{\nnowiki\n}}}\n----\n")
863
+ # tc("<pre>nowiki</pre><hr/>", "{{{\nnowiki\n}}}\n\n----\n")
864
+ # # nowiki
865
+ # tc("<pre>nowiki</pre><pre>nowiki</pre>", "{{{\nnowiki\n}}}\n{{{\nnowiki\n}}}\n")
866
+ # tc("<pre>nowiki</pre><pre>nowiki</pre>", "{{{\nnowiki\n}}}\n\n{{{\nnowiki\n}}}\n")
867
+ # # table
868
+ # tc("<pre>nowiki</pre><table><tr><td>table</td></tr></table>", "{{{\nnowiki\n}}}\n|table|\n")
869
+ # tc("<pre>nowiki</pre><table><tr><td>table</td></tr></table>", "{{{\nnowiki\n}}}\n\n|table|\n")
870
+ # end
871
+
872
+ # def test_larsch_image
873
+ # tc("<p><img src=\"image.jpg\"/></p>", "{{image.jpg}}")
874
+ # tc("<p><img src=\"image.jpg\" alt=\"tag\"/></p>", "{{image.jpg|tag}}")
875
+ # tc("<p><img src=\"http://example.org/image.jpg\"/></p>", "{{http://example.org/image.jpg}}")
876
+ # end
877
+
878
+ # def test_larsch_bold_combo
879
+ # tc("<p><strong>bold and</strong></p><table><tr><td>table</td></tr></table><p>end<strong></strong></p>",
880
+ # "**bold and\n|table|\nend**")
881
+ # end
882
+
883
+ def tc(html, creole)
884
+ output = WikiCreole.creole_parse(creole)
885
+
886
+ #if it's one of the specially formatted blocks of html, then strip it
887
+ if html.index(/\n {4}$/m)
888
+ html.sub!(/^\n/, "")
889
+ html.gsub!(/^ {4}/, "")
890
+ end
891
+
892
+ assert_equal html, output
893
+ end
894
+
895
+ end