gmccreight-WikiCreole 0.1.4

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