Merge: src/model/model_index: model index uses BKTree
[nit.git] / lib / markdown2 / tests / test_markdown_daring.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either htmlress or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 # Markdown tests from DaringFireball
16 #
17 # See <https://daringfireball.net/projects/markdown/>.
18 module test_markdown_daring is test
19
20 import test_markdown
21
22 class TestMarkdownDaring
23 super TestMarkdownHtml
24 test
25
26 fun test_daring_encoding is test do
27 var md = """
28 AT&T has an ampersand in their name.
29
30 AT&amp;T is another way to write it.
31
32 This & that.
33
34 4 < 5.
35
36 6 > 5.
37
38 Here's a [link][1] with an ampersand in the URL.
39
40 Here's a link with an ampersand in the link text: [AT&T][2].
41
42 Here's an inline [link](/script?foo=1&bar=2).
43
44 Here's an inline [link](</script?foo=1&bar=2>).
45
46
47 [1]: http://example.com/?foo=1&bar=2
48 [2]: http://att.com/ "AT&T"
49 """
50
51 var html = """
52 <p>AT&amp;T has an ampersand in their name.</p>
53 <p>AT&amp;T is another way to write it.</p>
54 <p>This &amp; that.</p>
55 <p>4 &lt; 5.</p>
56 <p>6 &gt; 5.</p>
57 <p>Here's a <a href="http://example.com/?foo=1&amp;bar=2">link</a> with an ampersand in the URL.</p>
58 <p>Here's a link with an ampersand in the link text: <a href="http://att.com/" title="AT&amp;T">AT&amp;T</a>.</p>
59 <p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
60 <p>Here's an inline <a href="/script?foo=1&amp;bar=2">link</a>.</p>
61 """
62 assert md_to_html(md) == html
63 end
64
65 fun test_daring_autolinks is test do
66 var md = """
67 Link: <http://example.com/>.
68
69 With an ampersand: <http://example.com/?foo=1&bar=2>
70
71 * In a list?
72 * <http://example.com/>
73 * It should.
74
75 > Blockquoted: <http://example.com/>
76
77 Auto-links should not occur here: `<http://example.com/>`
78
79 or here: <http://example.com/>
80 """
81
82 var html = """
83 <p>Link: <a href="http://example.com/">http://example.com/</a>.</p>
84 <p>With an ampersand: <a href="http://example.com/?foo=1&amp;bar=2">http://example.com/?foo=1&amp;bar=2</a></p>
85 <ul>
86 <li>In a list?</li>
87 <li><a href="http://example.com/">http://example.com/</a></li>
88 <li>It should.</li>
89 </ul>
90 <blockquote>
91 <p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
92 </blockquote>
93 <p>Auto-links should not occur here: <code>&lt;http://example.com/&gt;</code></p>
94 <pre><code>or here: &lt;http://example.com/&gt;
95 </code></pre>
96 """
97 assert md_to_html(md) == html
98 end
99
100 fun test_daring_escape is test do
101 var md = """
102 These should all get escaped:
103
104 Backslash: \\
105
106 Backtick: \`
107
108 Asterisk: \*
109
110 Underscore: \_
111
112 Left brace: \{
113
114 Right brace: \}
115
116 Left bracket: \[
117
118 Right bracket: \]
119
120 Left paren: \(
121
122 Right paren: \)
123
124 Greater-than: \>
125
126 Hash: \#
127
128 Period: \.
129
130 Bang: \!
131
132 Plus: \+
133
134 Minus: \-
135
136
137 These should not, because they occur within a code block:
138
139 Backslash: \\
140
141 Backtick: \`
142
143 Asterisk: \*
144
145 Underscore: \_
146
147 Left brace: \{
148
149 Right brace: \}
150
151 Left bracket: \[
152
153 Right bracket: \]
154
155 Left paren: \(
156
157 Right paren: \)
158
159 Greater-than: \>
160
161 Hash: \#
162
163 Period: \.
164
165 Bang: \!
166
167 Plus: \+
168
169 Minus: \-
170
171 Nor should these, which occur in code spans:
172
173 Backslash: `\\`
174
175 Backtick: `` \` ``
176
177 Asterisk: `\*`
178
179 Underscore: `\_`
180
181 Left brace: `\{`
182
183 Right brace: `\}`
184
185 Left bracket: `\[`
186
187 Right bracket: `\]`
188
189 Left paren: `\(`
190
191 Right paren: `\)`
192
193 Greater-than: `\>`
194
195 Hash: `\#`
196
197 Period: `\.`
198
199 Bang: `\!`
200
201 Plus: `\+`
202
203 Minus: `\-`
204
205 These should get escaped, even though they're matching pairs for
206 other Markdown constructs:
207
208 \\\*asterisks\\\*
209
210 \\\_underscores\\\_
211
212 \\\`backticks\\\`
213
214 This is a code span with a literal backslash-backtick sequence: `` \` ``
215
216 This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.
217
218 This is a tag with backslashes <span attr='\\\\backslashes\\\\'>bar</span>.
219 """
220 var html = """
221 <p>These should all get escaped:</p>
222 <p>Backslash: \\</p>
223 <p>Backtick: \`</p>
224 <p>Asterisk: \*</p>
225 <p>Underscore: \_</p>
226 <p>Left brace: \{</p>
227 <p>Right brace: \}</p>
228 <p>Left bracket: \[</p>
229 <p>Right bracket: \]</p>
230 <p>Left paren: \(</p>
231 <p>Right paren: \)</p>
232 <p>Greater-than: &gt;</p>
233 <p>Hash: \#</p>
234 <p>Period: \.</p>
235 <p>Bang: \!</p>
236 <p>Plus: \+</p>
237 <p>Minus: \-</p>
238 <p>These should not, because they occur within a code block:</p>
239 <pre><code>Backslash: \\
240
241 Backtick: \`
242
243 Asterisk: \*
244
245 Underscore: \_
246
247 Left brace: \{
248
249 Right brace: \}
250
251 Left bracket: \[
252
253 Right bracket: \]
254
255 Left paren: \(
256
257 Right paren: \)
258
259 Greater-than: \&gt;
260
261 Hash: \#
262
263 Period: \.
264
265 Bang: \!
266
267 Plus: \+
268
269 Minus: \-
270 </code></pre>
271 <p>Nor should these, which occur in code spans:</p>
272 <p>Backslash: <code>\\</code></p>
273 <p>Backtick: <code>\`</code></p>
274 <p>Asterisk: <code>\*</code></p>
275 <p>Underscore: <code>\_</code></p>
276 <p>Left brace: <code>\{</code></p>
277 <p>Right brace: <code>\}</code></p>
278 <p>Left bracket: <code>\[</code></p>
279 <p>Right bracket: <code>\]</code></p>
280 <p>Left paren: <code>\(</code></p>
281 <p>Right paren: <code>\)</code></p>
282 <p>Greater-than: <code>\&gt;</code></p>
283 <p>Hash: <code>\#</code></p>
284 <p>Period: <code>\.</code></p>
285 <p>Bang: <code>\!</code></p>
286 <p>Plus: <code>\+</code></p>
287 <p>Minus: <code>\-</code></p>
288 <p>These should get escaped, even though they're matching pairs for
289 other Markdown constructs:</p>
290 <p>*asterisks*</p>
291 <p>_underscores_</p>
292 <p>`backticks`</p>
293 <p>This is a code span with a literal backslash-backtick sequence: <code>\`</code></p>
294 <p>This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.</p>
295 <p>This is a tag with backslashes <span attr='\\\\backslashes\\\\'>bar</span>.</p>
296 """
297
298 assert md_to_html(md) == html
299 end
300
301 fun test_daring_blockquotes is test do
302 var md = """
303 > Example:
304 >
305 > sub status {
306 > print "working";
307 > }
308 >
309 > Or:
310 >
311 > sub status {
312 > return "working";
313 > }
314 """
315
316 var html = """
317 <blockquote>
318 <p>Example:</p>
319 <pre><code>sub status {
320 print &quot;working&quot;;
321 }
322 </code></pre>
323 <p>Or:</p>
324 <pre><code>sub status {
325 return &quot;working&quot;;
326 }
327 </code></pre>
328 </blockquote>
329 """
330 assert md_to_html(md) == html
331 end
332
333 fun test_daring_code_blocks is test do
334 var md = """
335 code block on the first line
336
337 Regular text.
338
339 code block indented by spaces
340
341 Regular text.
342
343 the lines in this block
344 all contain trailing spaces
345
346 Regular Text.
347
348 code block on the last line
349 """
350
351 var html = """
352 <pre><code>code block on the first line
353 </code></pre>
354 <p>Regular text.</p>
355 <pre><code>code block indented by spaces
356 </code></pre>
357 <p>Regular text.</p>
358 <pre><code>the lines in this block
359 all contain trailing spaces
360 </code></pre>
361 <p>Regular Text.</p>
362 <pre><code>code block on the last line
363 </code></pre>
364 """
365 assert md_to_html(md) == html
366 end
367
368 fun test_daring_rules is test do
369 var md = """
370 Dashes:
371
372 ---
373
374 ---
375
376 ---
377
378 ---
379
380 ---
381
382 - - -
383
384 - - -
385
386 - - -
387
388 - - -
389
390 - - -
391
392
393 Asterisks:
394
395 ***
396
397 ***
398
399 ***
400
401 ***
402
403 ***
404
405 * * *
406
407 * * *
408
409 * * *
410
411 * * *
412
413 * * *
414
415
416 Underscores:
417
418 ___
419
420 ___
421
422 ___
423
424 ___
425
426 ___
427
428 _ _ _
429
430 _ _ _
431
432 _ _ _
433
434 _ _ _
435
436 _ _ _
437 """
438
439 var html = """
440 <p>Dashes:</p>
441 <hr />
442 <hr />
443 <hr />
444 <hr />
445 <pre><code>---
446 </code></pre>
447 <hr />
448 <hr />
449 <hr />
450 <hr />
451 <pre><code>- - -
452 </code></pre>
453 <p>Asterisks:</p>
454 <hr />
455 <hr />
456 <hr />
457 <hr />
458 <pre><code>***
459 </code></pre>
460 <hr />
461 <hr />
462 <hr />
463 <hr />
464 <pre><code>* * *
465 </code></pre>
466 <p>Underscores:</p>
467 <hr />
468 <hr />
469 <hr />
470 <hr />
471 <pre><code>___
472 </code></pre>
473 <hr />
474 <hr />
475 <hr />
476 <hr />
477 <pre><code>_ _ _
478 </code></pre>
479 """
480 assert md_to_html(md) == html
481 end
482
483 fun test_daring_code_spans is test do
484 var md = """
485 `<test a="` content of attribute `">`
486
487 Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span>
488
489 Here's how you put `` `backticks` `` in a code span.
490 """
491
492 var html = """
493 <p><code>&lt;test a=&quot;</code> content of attribute <code>&quot;&gt;</code></p>
494 <p>Fix for backticks within HTML tag: <span attr='`ticks`'>like this</span></p>
495 <p>Here's how you put <code>`backticks`</code> in a code span.</p>
496 """
497 assert md_to_html(md) == html
498 end
499
500 fun test_daring_images is test do
501 var md = """
502 ![Alt text](/path/to/img.jpg)
503
504 ![Alt text](/path/to/img.jpg "Optional title")
505
506 Inline within a paragraph: [alt text](/url/).
507
508 ![alt text](/url/ "title preceded by two spaces")
509
510 ![alt text](/url/ "title has spaces afterward" )
511
512 ![alt text](</url/>)
513
514 ![alt text](</url/> "with a title").
515
516 ![Empty]()
517
518 ![this is a stupid URL](http://example.com/(parens).jpg)
519
520
521 ![alt text][foo]
522
523 [foo]: /url/
524
525 ![alt text][bar]
526
527 [bar]: /url/ "Title here"
528 """
529
530 var html = """
531 <p><img src="/path/to/img.jpg" alt="Alt text" /></p>
532 <p><img src="/path/to/img.jpg" alt="Alt text" title="Optional title" /></p>
533 <p>Inline within a paragraph: <a href="/url/">alt text</a>.</p>
534 <p><img src="/url/" alt="alt text" title="title preceded by two spaces" /></p>
535 <p><img src="/url/" alt="alt text" title="title has spaces afterward" /></p>
536 <p><img src="/url/" alt="alt text" /></p>
537 <p><img src="/url/" alt="alt text" title="with a title" />.</p>
538 <p><img src="" alt="Empty" /></p>
539 <p><img src="http://example.com/(parens).jpg" alt="this is a stupid URL" /></p>
540 <p><img src="/url/" alt="alt text" /></p>
541 <p><img src="/url/" alt="alt text" title="Title here" /></p>
542 """
543 assert md_to_html(md) == html
544 end
545
546 fun test_daring_links1 is test do
547 var md = """
548 Just a [URL](/url/).
549
550 [URL and title](/url/ "title").
551
552 [URL and title](/url/ "title preceded by two spaces").
553
554 [URL and title](/url/ "title preceded by a tab").
555
556 [URL and title](/url/ "title has spaces afterward" ).
557
558 [URL wrapped in angle brackets](</url/>).
559
560 [URL w/ angle brackets + title](</url/> "Here's the title").
561
562 [Empty]().
563
564 [With parens in the URL](http://en.wikipedia.org/wiki/WIMP_(computing))
565
566 (With outer parens and [parens in url](/foo(bar)))
567
568
569 [With parens in the URL](/foo(bar) "and a title")
570
571 (With outer parens and [parens in url](/foo(bar) "and a title"))
572 """
573
574 var html = """
575 <p>Just a <a href="/url/">URL</a>.</p>
576 <p><a href="/url/" title="title">URL and title</a>.</p>
577 <p><a href="/url/" title="title preceded by two spaces">URL and title</a>.</p>
578 <p><a href="/url/" title="title preceded by a tab">URL and title</a>.</p>
579 <p><a href="/url/" title="title has spaces afterward">URL and title</a>.</p>
580 <p><a href="/url/">URL wrapped in angle brackets</a>.</p>
581 <p><a href="/url/" title="Here's the title">URL w/ angle brackets + title</a>.</p>
582 <p><a href="">Empty</a>.</p>
583 <p><a href="http://en.wikipedia.org/wiki/WIMP_(computing)">With parens in the URL</a></p>
584 <p>(With outer parens and <a href="/foo(bar)">parens in url</a>)</p>
585 <p><a href="/foo(bar)" title="and a title">With parens in the URL</a></p>
586 <p>(With outer parens and <a href="/foo(bar)" title="and a title">parens in url</a>)</p>
587 """
588 assert md_to_html(md) == html
589 end
590
591 fun test_daring_links2 is test do
592 var md = """
593 Foo [bar][1].
594
595 Foo [bar][1].
596
597 Foo [bar][1].
598
599 [1]: /url/ "Title"
600
601
602 With [embedded [brackets]][b].
603
604
605 Indented [once][].
606
607 Indented [twice][].
608
609 Indented [thrice][].
610
611 Indented [four][] times.
612
613 [once]: /url
614
615 [twice]: /url
616
617 [thrice]: /url
618
619 [four]: /url
620
621
622 [b]: /url/
623
624 * * *
625
626 [this][this] should work
627
628 So should [this][this].
629
630 And [this][].
631
632 And [this][].
633
634 And [this].
635
636 But not [that][].
637
638 Nor [that][].
639
640 Nor [that].
641
642 [Something in brackets like [this][] should work]
643
644 [Same with [this].]
645
646 In this case, [this](/somethingelse/) points to something else.
647
648 Backslashing should suppress \\\[this] and [this\\\].
649
650 [this]: foo
651
652
653 * * *
654
655 Here's one where the [link
656 breaks] across lines.
657
658 Here's another where the [link
659 breaks] across lines, but with a line-ending space.
660
661
662 [link breaks]: /url/
663 """
664
665 var html = """
666 <p>Foo <a href="/url/" title="Title">bar</a>.</p>
667 <p>Foo <a href="/url/" title="Title">bar</a>.</p>
668 <p>Foo <a href="/url/" title="Title">bar</a>.</p>
669 <p>With <a href="/url/">embedded [brackets]</a>.</p>
670 <p>Indented <a href="/url">once</a>.</p>
671 <p>Indented <a href="/url">twice</a>.</p>
672 <p>Indented <a href="/url">thrice</a>.</p>
673 <pre><code>Indented [four][] times.
674 </code></pre>
675 <pre><code>[four]: /url
676 </code></pre>
677 <hr />
678 <p><a href="foo">this</a> should work</p>
679 <p>So should <a href="foo">this</a>.</p>
680 <p>And <a href="foo">this</a>.</p>
681 <p>And <a href="foo">this</a>.</p>
682 <p>And <a href="foo">this</a>.</p>
683 <p>But not [that][].</p>
684 <p>Nor [that][].</p>
685 <p>Nor [that].</p>
686 <p>[Something in brackets like <a href="foo">this</a> should work]</p>
687 <p>[Same with <a href="foo">this</a>.]</p>
688 <p>In this case, <a href="/somethingelse/">this</a> points to something else.</p>
689 <p>Backslashing should suppress [this] and [this].</p>
690 <hr />
691 <p>Here's one where the <a href="/url/">link
692 breaks</a> across lines.</p>
693 <p>Here's another where the <a href="/url/">link
694 breaks</a> across lines, but with a line-ending space.</p>
695 """
696 assert md_to_html(md) == html
697 end
698
699 fun test_daring_links3 is test do
700 var md = """
701 This is the [simple case].
702
703 [simple case]: /simple
704
705
706
707 This one has a [line
708 break].
709
710 This one has a [line
711 break] with a line-ending space.
712
713 [line break]: /foo
714
715
716 [this][that] and the [other]
717
718 [this]: /this
719 [that]: /that
720 [other]: /other
721 """
722
723 var html = """
724 <p>This is the <a href="/simple">simple case</a>.</p>
725 <p>This one has a <a href="/foo">line
726 break</a>.</p>
727 <p>This one has a <a href="/foo">line
728 break</a> with a line-ending space.</p>
729 <p><a href="/that">this</a> and the <a href="/other">other</a></p>
730 """
731 assert md_to_html(md) == html
732 end
733
734 fun test_daring_nested is test do
735 var md = """
736 > foo
737 >
738 > > bar
739 >
740 > foo
741 """
742
743 var html = """
744 <blockquote>
745 <p>foo</p>
746 <blockquote>
747 <p>bar</p>
748 </blockquote>
749 <p>foo</p>
750 </blockquote>
751 """
752 assert md_to_html(md) == html
753 end
754
755 fun test_daring_tidyness is test do
756 var md = """
757 > A list within a blockquote:
758 >
759 > * asterisk 1
760 > * asterisk 2
761 > * asterisk 3
762 """
763
764 var html = """
765 <blockquote>
766 <p>A list within a blockquote:</p>
767 <ul>
768 <li>asterisk 1</li>
769 <li>asterisk 2</li>
770 <li>asterisk 3</li>
771 </ul>
772 </blockquote>
773 """
774 assert md_to_html(md) == html
775 end
776
777 fun test_daring_list is test do
778 var md = """
779 ## Unordered
780
781 Asterisks tight:
782
783 * asterisk 1
784 * asterisk 2
785 * asterisk 3
786
787
788 Asterisks loose:
789
790 * asterisk 1
791
792 * asterisk 2
793
794 * asterisk 3
795
796 * * *
797
798 Pluses tight:
799
800 + Plus 1
801 + Plus 2
802 + Plus 3
803
804
805 Pluses loose:
806
807 + Plus 1
808
809 + Plus 2
810
811 + Plus 3
812
813 * * *
814
815
816 Minuses tight:
817
818 - Minus 1
819 - Minus 2
820 - Minus 3
821
822
823 Minuses loose:
824
825 - Minus 1
826
827 - Minus 2
828
829 - Minus 3
830
831
832 ## Ordered
833
834 Tight:
835
836 1. First
837 2. Second
838 3. Third
839
840 and:
841
842 1. One
843 2. Two
844 3. Three
845
846
847 Loose using tabs:
848
849 1. First
850
851 2. Second
852
853 3. Third
854
855 and using spaces:
856
857 1. One
858
859 2. Two
860
861 3. Three
862
863 Multiple paragraphs:
864
865 1. Item 1, graf one.
866
867 Item 2. graf two. The quick brown fox jumped over the lazy dog's
868 back.
869
870 2. Item 2.
871
872 3. Item 3.
873
874
875
876 ## Nested
877
878 * Tab
879 * Tab
880 * Tab
881
882 Here's another:
883
884 1. First
885 2. Second:
886 * Fee
887 * Fie
888 * Foe
889 3. Third
890
891 Same thing but with paragraphs:
892
893 1. First
894
895 2. Second:
896 * Fee
897 * Fie
898 * Foe
899
900 3. Third
901 """
902
903 var html = """
904 <h2>Unordered</h2>
905 <p>Asterisks tight:</p>
906 <ul>
907 <li>asterisk 1</li>
908 <li>asterisk 2</li>
909 <li>asterisk 3</li>
910 </ul>
911 <p>Asterisks loose:</p>
912 <ul>
913 <li>
914 <p>asterisk 1</p>
915 </li>
916 <li>
917 <p>asterisk 2</p>
918 </li>
919 <li>
920 <p>asterisk 3</p>
921 </li>
922 </ul>
923 <hr />
924 <p>Pluses tight:</p>
925 <ul>
926 <li>Plus 1</li>
927 <li>Plus 2</li>
928 <li>Plus 3</li>
929 </ul>
930 <p>Pluses loose:</p>
931 <ul>
932 <li>
933 <p>Plus 1</p>
934 </li>
935 <li>
936 <p>Plus 2</p>
937 </li>
938 <li>
939 <p>Plus 3</p>
940 </li>
941 </ul>
942 <hr />
943 <p>Minuses tight:</p>
944 <ul>
945 <li>Minus 1</li>
946 <li>Minus 2</li>
947 <li>Minus 3</li>
948 </ul>
949 <p>Minuses loose:</p>
950 <ul>
951 <li>
952 <p>Minus 1</p>
953 </li>
954 <li>
955 <p>Minus 2</p>
956 </li>
957 <li>
958 <p>Minus 3</p>
959 </li>
960 </ul>
961 <h2>Ordered</h2>
962 <p>Tight:</p>
963 <ol>
964 <li>First</li>
965 <li>Second</li>
966 <li>Third</li>
967 </ol>
968 <p>and:</p>
969 <ol>
970 <li>One</li>
971 <li>Two</li>
972 <li>Three</li>
973 </ol>
974 <p>Loose using tabs:</p>
975 <ol>
976 <li>
977 <p>First</p>
978 </li>
979 <li>
980 <p>Second</p>
981 </li>
982 <li>
983 <p>Third</p>
984 </li>
985 </ol>
986 <p>and using spaces:</p>
987 <ol>
988 <li>
989 <p>One</p>
990 </li>
991 <li>
992 <p>Two</p>
993 </li>
994 <li>
995 <p>Three</p>
996 </li>
997 </ol>
998 <p>Multiple paragraphs:</p>
999 <ol>
1000 <li>
1001 <p>Item 1, graf one.</p>
1002 <p>Item 2. graf two. The quick brown fox jumped over the lazy dog's
1003 back.</p>
1004 </li>
1005 <li>
1006 <p>Item 2.</p>
1007 </li>
1008 <li>
1009 <p>Item 3.</p>
1010 </li>
1011 </ol>
1012 <h2>Nested</h2>
1013 <ul>
1014 <li>Tab
1015 <ul>
1016 <li>Tab
1017 <ul>
1018 <li>Tab</li>
1019 </ul>
1020 </li>
1021 </ul>
1022 </li>
1023 </ul>
1024 <p>Here's another:</p>
1025 <ol>
1026 <li>First</li>
1027 <li>Second:
1028 <ul>
1029 <li>Fee</li>
1030 <li>Fie</li>
1031 <li>Foe</li>
1032 </ul>
1033 </li>
1034 <li>Third</li>
1035 </ol>
1036 <p>Same thing but with paragraphs:</p>
1037 <ol>
1038 <li>
1039 <p>First</p>
1040 </li>
1041 <li>
1042 <p>Second:</p>
1043 <ul>
1044 <li>Fee</li>
1045 <li>Fie</li>
1046 <li>Foe</li>
1047 </ul>
1048 </li>
1049 <li>
1050 <p>Third</p>
1051 </li>
1052 </ol>
1053 """
1054 assert md_to_html(md) == html
1055 end
1056
1057 fun test_daring_strong_em is test do
1058 var md = """
1059 ***This is strong and em.***
1060
1061 So is ***this*** word.
1062
1063 ___This is strong and em.___
1064
1065 So is ___this___ word.
1066 """
1067
1068 var html = """
1069 <p><em><strong>This is strong and em.</strong></em></p>
1070 <p>So is <em><strong>this</strong></em> word.</p>
1071 <p><em><strong>This is strong and em.</strong></em></p>
1072 <p>So is <em><strong>this</strong></em> word.</p>
1073 """
1074 assert md_to_html(md) == html
1075 end
1076
1077 fun test_daring_tabs is test do
1078 var md = """
1079 + this is a list item
1080 indented with tabs
1081
1082 + this is a list item
1083 indented with spaces
1084
1085 Code:
1086
1087 this code block is indented by one tab
1088
1089 And:
1090
1091 this code block is indented by two tabs
1092
1093 And:
1094
1095 + this is an example list item
1096 indented with tabs
1097
1098 + this is an example list item
1099 indented with spaces
1100 """
1101
1102 var html = """
1103 <ul>
1104 <li>
1105 <p>this is a list item
1106 indented with tabs</p>
1107 </li>
1108 <li>
1109 <p>this is a list item
1110 indented with spaces</p>
1111 </li>
1112 </ul>
1113 <p>Code:</p>
1114 <pre><code>this code block is indented by one tab
1115 </code></pre>
1116 <p>And:</p>
1117 <pre><code> this code block is indented by two tabs
1118 </code></pre>
1119 <p>And:</p>
1120 <pre><code>+ this is an example list item
1121 indented with tabs
1122
1123 + this is an example list item
1124 indented with spaces
1125 </code></pre>
1126 """
1127 assert md_to_html(md) == html
1128 end
1129
1130 fun test_daring_inline_html1 is test do
1131 var md = """
1132 Here's a simple block:
1133
1134 <div>
1135 foo
1136 </div>
1137
1138 This should be a code block, though:
1139
1140 <div>
1141 foo
1142 </div>
1143
1144 As should this:
1145
1146 <div>foo</div>
1147
1148 Now, nested:
1149
1150 <div>
1151 <div>
1152 <div>
1153 foo
1154 </div>
1155 </div>
1156 </div>
1157
1158 This should just be an HTML comment:
1159
1160 <!-- Comment -->
1161
1162 Multiline:
1163
1164 <!--
1165 Blah
1166 Blah
1167 -->
1168
1169 Code block:
1170
1171 <!-- Comment -->
1172
1173 Just plain comment, with trailing spaces on the line:
1174
1175 <!-- foo -->
1176
1177 Code:
1178
1179 <hr />
1180
1181 Hr's:
1182
1183 <hr>
1184
1185 <hr />
1186
1187 <hr />
1188
1189 <hr>
1190
1191 <hr />
1192
1193 <hr />
1194
1195 <hr class="foo" />
1196
1197 <hr class="foo"/>
1198
1199 <hr class="foo" >
1200 """
1201
1202 var html = """
1203 <p>Here's a simple block:</p>
1204 <div>
1205 foo
1206 </div>
1207 <p>This should be a code block, though:</p>
1208 <pre><code>&lt;div&gt;
1209 foo
1210 &lt;/div&gt;
1211 </code></pre>
1212 <p>As should this:</p>
1213 <pre><code>&lt;div&gt;foo&lt;/div&gt;
1214 </code></pre>
1215 <p>Now, nested:</p>
1216 <div>
1217 <div>
1218 <div>
1219 foo
1220 </div>
1221 </div>
1222 </div>
1223 <p>This should just be an HTML comment:</p>
1224 <!-- Comment -->
1225 <p>Multiline:</p>
1226 <!--
1227 Blah
1228 Blah
1229 -->
1230 <p>Code block:</p>
1231 <pre><code>&lt;!-- Comment --&gt;
1232 </code></pre>
1233 <p>Just plain comment, with trailing spaces on the line:</p>
1234 <!-- foo -->
1235 <p>Code:</p>
1236 <pre><code>&lt;hr /&gt;
1237 </code></pre>
1238 <p>Hr's:</p>
1239 <hr>
1240 <hr />
1241 <hr />
1242 <hr>
1243 <hr />
1244 <hr />
1245 <hr class="foo" />
1246 <hr class="foo"/>
1247 <hr class="foo" >
1248 """
1249 assert md_to_html(md) == html
1250 end
1251
1252 fun test_daring_inline_html2 is test do
1253 var md = """
1254 Simple block on one line:
1255
1256 <div>foo</div>
1257
1258 And nested without indentation:
1259
1260 <div>
1261 <div>
1262 <div>
1263 foo
1264 </div>
1265 <div style=">"/>
1266 </div>
1267 <div>bar</div>
1268 </div>
1269
1270 And with attributes:
1271
1272 <div>
1273 <div>
1274 </div>
1275 </div>
1276
1277 This was broken in 1.0.2b7:
1278
1279 <div class="inlinepage">
1280 <div class="toggleableend">
1281 foo
1282 </div>
1283 </div>
1284 """
1285
1286 var html = """
1287 <p>Simple block on one line:</p>
1288 <div>foo</div>
1289 <p>And nested without indentation:</p>
1290 <div>
1291 <div>
1292 <div>
1293 foo
1294 </div>
1295 <div style=">"/>
1296 </div>
1297 <div>bar</div>
1298 </div>
1299 <p>And with attributes:</p>
1300 <div>
1301 <div>
1302 </div>
1303 </div>
1304 <p>This was broken in 1.0.2b7:</p>
1305 <div class="inlinepage">
1306 <div class="toggleableend">
1307 foo
1308 </div>
1309 </div>
1310 """
1311 assert md_to_html(md) == html
1312 end
1313
1314 fun test_daring_inline_html3 is test do
1315 var md = """
1316 Paragraph one.
1317
1318 <!-- This is a simple comment -->
1319
1320 <!--
1321 This is another comment.
1322 -->
1323
1324 Paragraph two.
1325
1326 <!-- one comment block -- -- with two comments -->
1327
1328 The end.
1329 """
1330
1331 var html = """
1332 <p>Paragraph one.</p>
1333 <!-- This is a simple comment -->
1334 <!--
1335 This is another comment.
1336 -->
1337 <p>Paragraph two.</p>
1338 <!-- one comment block -- -- with two comments -->
1339 <p>The end.</p>
1340 """
1341 assert md_to_html(md) == html
1342 end
1343 end