root/trunk/vendor/bluecloth/tests/05_Markdown.tests.rb

Revision 420, 30.1 kB (checked in by tobi, 3 years ago)

redcloth, bluecloth and rubypants are now bundeled with typo

Line 
1 #!/usr/bin/ruby
2 #
3 # Test case for BlueCloth Markdown transforms.
4 # $Id: TEMPLATE.rb.tpl,v 1.2 2003/09/11 04:59:51 deveiant Exp $
5 #
6 # Copyright (c) 2004 The FaerieMUD Consortium.
7 #
8
9 if !defined?( BlueCloth ) || !defined?( BlueCloth::TestCase )
10         basedir = File::dirname( __FILE__ )
11         require File::join( basedir, 'bctestcase' )
12 end
13
14
15 ### This test case tests ...
16 class SubfunctionsTestCase < BlueCloth::TestCase
17
18         ### Test email address output
19         Emails = %w[
20                 address@example.com
21                 foo-list-admin@bar.com
22                 fu@bar.COM
23                 baz@ruby-lang.org
24                 foo-tim-bazzle@bar-hop.co.uk
25                 littlestar@twinkle.twinkle.band.CO.ZA
26                 ll@lll.lllll.ll
27                 Ull@Ulll.Ulllll.ll
28                 UUUU1@UU1.UU1UUU.UU
29                 l@ll.ll
30                 Ull.Ullll@llll.ll
31                 Ulll-Ull.Ulllll@ll.ll
32                 1@111.ll
33         ]
34         # I can't see a way to handle IDNs clearly yet, so these will have to wait.
35         #       info@öko.de
36         #       jemand@büro.de
37         #       irgendwo-interreßant@dÅgta.se
38         #]
39
40         def test_10_email_address
41                 printTestHeader "BlueCloth: Inline email address"
42                 rval = match = nil
43
44                 Emails.each {|addr|
45                         assert_nothing_raised {
46                                 rval = BlueCloth::new( "<#{addr}>" ).to_html
47                         }
48
49                         match = %r{<p><a href="([^\"]+)">[^<]+</a></p>}.match( rval )
50                         assert_not_nil match, "Match against output #{rval}"
51                         assert_equal "mailto:#{addr}", decode( match[1] )
52                 }
53         end
54
55
56         def decode( str )
57                 str.gsub( /&#(x[a-f0-9]+|\d{3});/i ) {|match|
58                         code = $1
59                         debugMsg "Decoding %p" % code
60
61                         case code
62                         when /^x([a-f0-9]+)/i
63                                 debugMsg "  (hex) = %p" % $1.to_i(16).chr
64                                 $1.to_i(16).chr
65                         when /\d{3}/
66                                 debugMsg "  (oct) = %p" % code.to_i.chr
67                                 code.to_i.chr
68                         else
69                                 raise "Hmmm... malformed entity %p" % code
70                         end
71                 }
72         end
73
74
75
76         #################################################################
77         ###     A U T O - G E N E R A T E D   T E S T S
78         #################################################################
79
80         # Parse the data section into a hash of test specifications
81         TestSets = {}
82         begin
83                 seenEnd = false
84                 inMetaSection = true
85                 inInputSection = true
86                 section, description, input, output = '', '', '', ''
87                 linenum = 0
88
89                 # Read this file, skipping lines until the __END__ token. Then start
90                 # reading the tests.
91                 File::foreach( __FILE__ ) {|line|
92                         linenum += 1
93                         if /^__END__/ =~ line then seenEnd = true; next end
94                         debugMsg "#{linenum}: #{line.chomp}"
95                         next unless seenEnd
96
97                         # Start off in the meta section, which has sections and
98                         # descriptions.
99                         if inMetaSection
100                                
101                                 case line
102
103                                 # Left angles switch into data section for the current section
104                                 # and description.
105                                 when /^<<</
106                                         inMetaSection = false
107                                         next
108
109                                 # Section headings look like:
110                                 # ### [Code blocks]
111                                 when /^### \[([^\]]+)\]/
112                                         section = $1.chomp
113                                         TestSets[ section ] ||= {}
114
115                                 # Descriptions look like:
116                                 # # Para plus code block
117                                 when /^# (.*)/
118                                         description = $1.chomp
119                                         TestSets[ section ][ description ] ||= {
120                                                 :line => linenum,
121                                                 :sets => [],
122                                         }
123
124                                 end
125
126                         # Data section has input and expected output parts
127                         else
128
129                                 case line
130
131                                 # Right angles terminate a data section, at which point we
132                                 # should have enough data to add a test.
133                                 when /^>>>/
134                                         TestSets[ section ][ description ][:sets] << [ input.chomp, output.chomp ]
135
136                                         inMetaSection = true
137                                         inInputSection = true
138                                         input = ''; output = ''
139
140                                 # 3-Dashed divider with text divides input from output
141                                 when /^--- (.+)/
142                                         inInputSection = false
143
144                                 # Anything else adds to either input or output
145                                 else
146                                         if inInputSection
147                                                 input += line
148                                         else
149                                                 output += line
150                                         end
151                                 end
152                         end
153                 }                       
154         end
155
156         debugMsg "Test sets: %p" % TestSets
157
158         # Auto-generate tests out of the test specifications
159         TestSets.each {|sname, section|
160
161                 # Generate a test method for each section
162                 section.each do |desc, test|
163                         methname = "test_%03d_%s" %
164                                 [ test[:line], desc.gsub(/\W+/, '_').downcase ]
165
166                         # Header
167                         code = %{
168                                 def #{methname}
169                                         printTestHeader "BlueCloth: #{desc}"
170                                         rval = nil
171                         }
172
173                         # An assertion for each input/output pair
174                         test[:sets].each {|input, output|
175                                 code << %{
176                                         assert_nothing_raised {
177                                                 obj = BlueCloth::new(%p)
178                                                 rval = obj.to_html
179                                         }
180                                         assert_equal %p, rval
181
182                                 } % [ input, output ]
183                         }
184
185                         code << %{
186                                 end
187                         }
188
189
190                         debugMsg "--- %s [%s]:\n%s\n---\n" % [sname, desc, code]
191                         eval code
192                 end
193
194         }
195
196 end
197
198
199 __END__
200
201 ### [Paragraphs and Line Breaks]
202
203 # Paragraphs
204 <<<
205 This is some stuff that should all be
206 put in one paragraph
207 even though
208 it occurs over several lines.
209
210 And this is a another
211 one.
212 --- Should become:
213 <p>This is some stuff that should all be
214 put in one paragraph
215 even though
216 it occurs over several lines.</p>
217
218 <p>And this is a another
219 one.</p>
220 >>>
221
222 # Line breaks
223 <<<
224 Mostly the same kind of thing 
225 with two spaces at the end 
226 of each line 
227 should result in 
228 line breaks, though.
229
230 And this is a another 
231 one.
232 --- Should become:
233 <p>Mostly the same kind of thing<br/>
234 with two spaces at the end<br/>
235 of each line<br/>
236 should result in<br/>
237 line breaks, though.</p>
238
239 <p>And this is a another<br/>
240 one.</p>
241 >>>
242
243 # Escaping special characters
244 <<<
245 The left shift operator, which is written as <<, is often used & greatly admired.
246 --- Should become:
247 <p>The left shift operator, which is written as &lt;&lt;, is often used &amp; greatly admired.</p>
248 >>>
249
250 # Preservation of named entities
251 <<<
252 The left shift operator, which is written as &lt;&lt;, is often used &amp; greatly admired.
253 --- Should become:
254 <p>The left shift operator, which is written as &lt;&lt;, is often used &amp; greatly admired.</p>
255 >>>
256
257 # Preservation of decimal-encoded entities
258 <<<
259 The left shift operator, which is written as &#060;&#060;, is often used &#038; greatly admired.
260 --- Should become:
261 <p>The left shift operator, which is written as &#060;&#060;, is often used &#038; greatly admired.</p>
262 >>>
263
264 # Preservation of hex-encoded entities
265 <<<
266 The left shift operator, which is written as &#x3c;&#x3c;, is often used &#x26; greatly admired.
267 --- Should become:
268 <p>The left shift operator, which is written as &#x3c;&#x3c;, is often used &#x26; greatly admired.</p>
269 >>>
270
271 # Inline HTML - table tags
272 <<<
273 This is a regular paragraph.
274
275 <table>
276     <tr>
277         <td>Foo</td>
278     </tr>
279 </table>
280
281 This is another regular paragraph.
282 --- Should become:
283 <p>This is a regular paragraph.</p>
284
285 <table>
286     <tr>
287         <td>Foo</td>
288     </tr>
289 </table>
290
291 <p>This is another regular paragraph.</p>
292 >>>
293
294 # Inline HTML - div tags
295 <<<
296 This is a regular paragraph.
297
298 <div>
299    Something
300 </div>
301 Something else.
302 --- Should become:
303 <p>This is a regular paragraph.</p>
304
305 <div>
306    Something
307 </div>
308
309 <p>Something else.</p>
310 >>>
311
312
313 # Inline HTML - Plain HR
314 <<<
315 This is a regular paragraph.
316
317 <hr />
318
319 Something else.
320 --- Should become:
321 <p>This is a regular paragraph.</p>
322
323 <hr />
324
325 <p>Something else.</p>
326 >>>
327
328
329 # Inline HTML - Fancy HR
330 <<<
331 This is a regular paragraph.
332
333 <hr class="publishers-mark" id="first-hrule" />
334
335 Something else.
336 --- Should become:
337 <p>This is a regular paragraph.</p>
338
339 <hr class="publishers-mark" id="first-hrule" />
340
341 <p>Something else.</p>
342 >>>
343
344
345 # Inline HTML - Iframe
346 <<<
347 This is a regular paragraph.
348
349 <iframe src="foo.html" id="foo-frame"></iframe>
350
351 Something else.
352 --- Should become:
353 <p>This is a regular paragraph.</p>
354
355 <iframe src="foo.html" id="foo-frame"></iframe>
356
357 <p>Something else.</p>
358 >>>
359
360
361 # Inline HTML - mathml
362 <<<
363 Examples
364 --------
365
366 Now that we have met some of the key players, it is time to see what we can
367 do. Here are some examples and comments which illustrate the use of the basic
368 layout and token elements. Consider the expression x2 + 4x + 4 = 0. A basic
369 MathML presentation encoding for this would be:
370
371 <math>
372   <mrow>
373         <msup>
374           <mi>x</mi>
375           <mn>2</mn>
376         </msup>
377         <mo>+</mo>
378         <mn>4</mn>
379         <mi>x</mi>
380         <mo>+</mo>
381         <mn>4</mn>
382         <mo>=</mo>
383         <mn>0</mn>
384   </mrow>
385 </math>
386
387 This encoding will display as you would expect. However, if we were interested
388 in reusing this expression in unknown situations, we would likely want to spend
389 a little more effort analyzing and encoding the logical expression structure.
390
391 --- Should become:
392 <h2>Examples</h2>
393
394 <p>Now that we have met some of the key players, it is time to see what we can
395 do. Here are some examples and comments which illustrate the use of the basic
396 layout and token elements. Consider the expression x2 + 4x + 4 = 0. A basic
397 MathML presentation encoding for this would be:</p>
398
399 <math>
400   <mrow>
401     <msup>
402       <mi>x</mi>
403       <mn>2</mn>
404     </msup>
405     <mo>+</mo>
406     <mn>4</mn>
407     <mi>x</mi>
408     <mo>+</mo>
409     <mn>4</mn>
410     <mo>=</mo>
411     <mn>0</mn>
412   </mrow>
413 </math>
414
415 <p>This encoding will display as you would expect. However, if we were interested
416 in reusing this expression in unknown situations, we would likely want to spend
417 a little more effort analyzing and encoding the logical expression structure.</p>
418 >>>
419
420
421 # Span-level HTML
422 <<<
423 This is some stuff with a <span class="foo">spanned bit of text</span> in
424 it. And <del>this *should* be a bit of deleted text</del> which should be
425 preserved, and part of it emphasized.
426 --- Should become:
427 <p>This is some stuff with a <span class="foo">spanned bit of text</span> in
428 it. And <del>this <em>should</em> be a bit of deleted text</del> which should be
429 preserved, and part of it emphasized.</p>
430 >>>
431
432 # Inline HTML (Case-sensitivity)
433 <<<
434 This is a regular paragraph.
435
436 <TABLE>
437     <TR>
438         <TD>Foo</TD>
439     </TR>
440 </TABLE>
441
442 This is another regular paragraph.
443 --- Should become:
444 <p>This is a regular paragraph.</p>
445
446 <TABLE>
447     <TR>
448         <TD>Foo</TD>
449     </TR>
450 </TABLE>
451
452 <p>This is another regular paragraph.</p>
453 >>>
454
455 # Span-level HTML (Case-sensitivity)
456 <<<
457 This is some stuff with a <SPAN CLASS="foo">spanned bit of text</SPAN> in
458 it. And <DEL>this *should* be a bit of deleted text</DEL> which should be
459 preserved, and part of it emphasized.
460 --- Should become:
461 <p>This is some stuff with a <SPAN CLASS="foo">spanned bit of text</SPAN> in
462 it. And <DEL>this <em>should</em> be a bit of deleted text</DEL> which should be
463 preserved, and part of it emphasized.</p>
464 >>>
465
466
467
468 ### [Code spans]
469
470 # Single backtick
471 <<<
472 Making `code` work for you
473 --- Should become:
474 <p>Making <code>code</code> work for you</p>
475 >>>
476
477 # Literal backtick with doubling
478 <<<
479 Making `` `code` `` work for you
480 --- Should become:
481 <p>Making <code>`code`</code> work for you</p>
482 >>>
483
484 # Many repetitions
485 <<<
486 Making `````code````` work for you
487 --- Should become:
488 <p>Making <code>code</code> work for you</p>
489 >>>
490
491 # Two in a row
492 <<<
493 This `thing` should be `two` spans.
494 --- Should become:
495 <p>This <code>thing</code> should be <code>two</code> spans.</p>
496 >>>
497
498 # At the beginning of a newline
499 <<<
500 I should think that the
501 `tar` command would be universal.
502 --- Should become:
503 <p>I should think that the
504 <code>tar</code> command would be universal.</p>
505 >>>
506
507 # Entity escaping
508 <<<
509 The left angle-bracket (`&lt;`) can also be written as a decimal-encoded
510 (`&#060;`) or hex-encoded (`&#x3c;`) entity.
511 --- Should become:
512 <p>The left angle-bracket (<code>&amp;lt;</code>) can also be written as a decimal-encoded
513 (<code>&amp;#060;</code>) or hex-encoded (<code>&amp;#x3c;</code>) entity.</p>
514 >>>
515
516 # At the beginning of a document (Bug #525)
517 <<<
518 `world` views
519 --- Should become:
520 <p><code>world</code> views</p>
521 >>>
522
523
524
525
526 ### [Code blocks]
527
528 # Para plus code block (literal tab)
529 <<<
530 This is a chunk of code:
531
532         some.code > some.other_code
533
534 Some stuff.
535 --- Should become:
536 <p>This is a chunk of code:</p>
537
538 <pre><code>some.code &gt; some.other_code
539 </code></pre>
540
541 <p>Some stuff.</p>
542 >>>
543
544 # Para plus code block (literal tab, no colon)
545 <<<
546 This is a chunk of code
547
548         some.code > some.other_code
549
550 Some stuff.
551 --- Should become:
552 <p>This is a chunk of code</p>
553
554 <pre><code>some.code &gt; some.other_code
555 </code></pre>
556
557 <p>Some stuff.</p>
558 >>>
559
560 # Para plus code block (tab-width spaces)
561 <<<
562 This is a chunk of code:
563
564     some.code > some.other_code
565
566 Some stuff.
567 --- Should become:
568 <p>This is a chunk of code:</p>
569
570 <pre><code>some.code &gt; some.other_code
571 </code></pre>
572
573 <p>Some stuff.</p>
574 >>>
575
576 # Para plus code block (tab-width spaces, no colon)
577 <<<
578 This is a chunk of code
579
580     some.code > some.other_code
581
582 Some stuff.
583 --- Should become:
584 <p>This is a chunk of code</p>
585
586 <pre><code>some.code &gt; some.other_code
587 </code></pre>
588
589 <p>Some stuff.</p>
590 >>>
591
592 # Colon with preceeding space
593 <<<
594 A regular paragraph, without a colon. :
595
596     This is a code block.
597
598 Some stuff.
599 --- Should become:
600 <p>A regular paragraph, without a colon. :</p>
601
602 <pre><code>This is a code block.
603 </code></pre>
604
605 <p>Some stuff.</p>
606 >>>
607
608 # Single colon
609 <<<
610 :
611        
612         some.code > some.other_code
613
614 Some stuff.
615 --- Should become:
616 <p>:</p>
617
618 <pre><code>some.code &gt; some.other_code
619 </code></pre>
620
621 <p>Some stuff.</p>
622 >>>
623
624 # Preserve leading whitespace (Bug #541)
625 <<<
626 Examples:
627
628           # (Waste character because first line is flush left !!!)
629           # Example script1
630           x = 1
631           x += 1
632           puts x
633
634 Some stuff.
635 --- Should become:
636 <p>Examples:</p>
637
638 <pre><code>      # (Waste character because first line is flush left !!!)
639       # Example script1
640       x = 1
641       x += 1
642       puts x
643 </code></pre>
644
645 <p>Some stuff.</p>
646 >>>
647
648
649 ### [Horizontal Rules]
650
651 # Hrule 1
652 <<<
653 * * *
654 --- Should become:
655 <hr/>
656 >>>
657
658 # Hrule 2
659 <<<
660 ***
661 --- Should become:
662 <hr/>
663 >>>
664
665 # Hrule 3
666 <<<
667 *****
668 --- Should become:
669 <hr/>
670 >>>
671
672 # Hrule 4
673 <<<
674 - - -
675 --- Should become:
676 <hr/>
677 >>>
678
679 # Hrule 5
680 <<<
681 ---------------------------------------
682 --- Should become:
683 <hr/>
684 >>>
685
686
687 ### [Titles]
688
689 # setext-style h1
690 <<<
691 Title Text
692 =
693 --- Should become:
694 <h1>Title Text</h1>
695 >>>
696
697 <<<
698 Title Text
699 ===
700 --- Should become:
701 <h1>Title Text</h1>
702 >>>
703
704 <<<
705 Title Text
706 ==========
707 --- Should become:
708 <h1>Title Text</h1>
709 >>>
710
711 # setext-style h2
712 <<<
713 Title Text
714 -
715 --- Should become:
716 <h2>Title Text</h2>
717 >>>
718
719 <<<
720 Title Text
721 ---
722 --- Should become:
723 <h2>Title Text</h2>
724 >>>
725
726 <<<
727 Title Text
728 ----------
729 --- Should become:
730 <h2>Title Text</h2>
731 >>>
732
733 # ATX-style h1
734 <<<
735 # Title Text
736 --- Should become:
737 <h1>Title Text</h1>
738 >>>
739
740 <<<
741 # Title Text #
742 --- Should become:
743 <h1>Title Text</h1>
744 >>>
745
746 <<<
747 # Title Text ###
748 --- Should become:
749 <h1>Title Text</h1>
750 >>>
751
752 <<<
753 # Title Text #####
754 --- Should become:
755 <h1>Title Text</h1>
756 >>>
757
758 # ATX-style h2
759 <<<
760 ## Title Text
761 --- Should become:
762 <h2>Title Text</h2>
763 >>>
764
765 <<<
766 ## Title Text #
767 --- Should become:
768 <h2>Title Text</h2>
769 >>>
770
771 <<<
772 ## Title Text ###
773 --- Should become:
774 <h2>Title Text</h2>
775 >>>
776
777 <<<
778 ## Title Text #####
779 --- Should become:
780 <h2>Title Text</h2>
781 >>>
782
783 # ATX-style h3
784 <<<
785 ### Title Text
786 --- Should become:
787 <h3>Title Text</h3>
788 >>>
789
790 <<<
791 ### Title Text #
792 --- Should become:
793 <h3>Title Text</h3>
794 >>>
795
796 <<<
797 ### Title Text ###
798 --- Should become:
799 <h3>Title Text</h3>
800 >>>
801
802 <<<
803 ### Title Text #####
804 --- Should become:
805 <h3>Title Text</h3>
806 >>>
807
808 # ATX-style h4
809 <<<
810 #### Title Text
811 --- Should become:
812 <h4>Title Text</h4>
813 >>>
814
815 <<<
816 #### Title Text #
817 --- Should become:
818 <h4>Title Text</h4>
819 >>>
820
821 <<<
822 #### Title Text ###
823 --- Should become:
824 <h4>Title Text</h4>
825 >>>
826
827 <<<
828 #### Title Text #####
829 --- Should become:
830 <h4>Title Text</h4>
831 >>>
832
833 # ATX-style h5
834 <<<
835 ##### Title Text
836 --- Should become:
837 <h5>Title Text</h5>
838 >>>
839
840 <<<
841 ##### Title Text #
842 --- Should become:
843 <h5>Title Text</h5>
844 >>>
845
846 <<<
847 ##### Title Text ###
848 --- Should become:
849 <h5>Title Text</h5>
850 >>>
851
852 <<<
853 ##### Title Text #####
854 --- Should become:
855 <h5>Title Text</h5>
856 >>>
857
858 # ATX-style h6
859 <<<
860 ###### Title Text
861 --- Should become:
862 <h6>Title Text</h6>
863 >>>
864
865 <<<
866 ###### Title Text #
867 --- Should become:
868 <h6>Title Text</h6>
869 >>>
870
871 <<<
872 ###### Title Text ###
873 --- Should become:
874 <h6>Title Text</h6>
875 >>>
876
877 <<<
878 ###### Title Text #####
879 --- Should become:
880 <h6>Title Text</h6>
881 >>>
882
883
884 ### [Blockquotes]
885
886 # Regular 1-level blockquotes
887 <<<
888 > Email-style angle brackets
889 > are used for blockquotes.
890 --- Should become:
891 <blockquote>
892     <p>Email-style angle brackets
893     are used for blockquotes.</p>
894 </blockquote>
895 >>>
896
897 # Doubled blockquotes
898 <<<
899 > > And, they can be nested.
900 --- Should become:
901 <blockquote>
902     <blockquote>
903         <p>And, they can be nested.</p>
904     </blockquote>
905 </blockquote>
906 >>>
907
908 # Nested blockquotes
909 <<<
910 > Email-style angle brackets
911 > are used for blockquotes.
912
913 > > And, they can be nested.
914 --- Should become:
915 <blockquote>
916     <p>Email-style angle brackets
917     are used for blockquotes.</p>
918    
919     <blockquote>
920         <p>And, they can be nested.</p>
921     </blockquote>
922 </blockquote>
923 >>>
924
925 # Lazy blockquotes
926 <<<
927 > This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
928 consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
929 Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
930
931 > Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
932 id sem consectetuer libero luctus adipiscing.
933 --- Should become:
934 <blockquote>
935     <p>This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
936     consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
937     Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.</p>
938    
939     <p>Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
940     id sem consectetuer libero luctus adipiscing.</p>
941 </blockquote>
942 >>>
943
944
945 # Blockquotes containing other markdown elements
946 <<<
947 > ## This is a header.
948 >
949 > 1.   This is the first list item.
950 > 2.   This is the second list item.
951 >
952 > Here's some example code:
953 >
954 >     return shell_exec("echo $input | $markdown_script");
955 --- Should become:
956 <blockquote>
957     <h2>This is a header.</h2>
958    
959     <ol>
960     <li>This is the first list item.</li>
961     <li>This is the second list item.</li>
962     </ol>
963    
964     <p>Here's some example code:</p>
965
966 <pre><code>return shell_exec("echo $input | $markdown_script");
967 </code></pre>
968 </blockquote>
969 >>>
970
971 # Blockquotes with a <pre> section
972 <<<
973 > The best approximation of the problem is the following code:
974 >
975 > <pre>
976 > foo + bar; foo.factorize; foo.display
977 > </pre>
978 >
979 > This should result in an error on any little-endian platform.
980 --- Should become:
981 <blockquote>
982     <p>The best approximation of the problem is the following code:</p>
983
984 <pre>
985 foo + bar; foo.factorize; foo.display
986 </pre>
987    
988     <p>This should result in an error on any little-endian platform.</p>
989 </blockquote>
990 >>>
991
992
993
994 ### [Images]
995
996 # Inline image with title
997 <<<
998 ![alt text](/path/img.jpg "Title")
999 --- Should become:
1000 <p><img src="/path/img.jpg" alt="alt text" title="Title"/></p>
1001 >>>
1002
1003 # Inline image with title (single-quotes)
1004 <<<
1005 ![alt text](/path/img.jpg 'Title')
1006 --- Should become:
1007 <p><img src="/path/img.jpg" alt="alt text" title="Title"/></p>
1008 >>>
1009
1010 # Inline image with title (with embedded quotes)
1011 <<<
1012 ![alt text](/path/img.jpg 'The "Title" Image')
1013 --- Should become:
1014 <p><img src="/path/img.jpg" alt="alt text" title="The &quot;Title&quot; Image"/></p>
1015 >>>
1016
1017 # Inline image without title
1018 <<<
1019 ![alt text](/path/img.jpg)
1020 --- Should become:
1021 <p><img src="/path/img.jpg" alt="alt text"/></p>
1022 >>>
1023
1024 # Inline image with quoted alt text
1025 <<<
1026 ![the "alt text"](/path/img.jpg)
1027 --- Should become:
1028 <p><img src="/path/img.jpg" alt="the &quot;alt text&quot;"/></p>
1029 >>>
1030
1031
1032 # Reference image
1033 <<<
1034 ![alt text][id]
1035
1036 [id]: /url/to/img.jpg "Title"
1037 --- Should become:
1038 <p><img src="/url/to/img.jpg" alt="alt text" title="Title"/></p>
1039 >>>
1040
1041
1042
1043 ### [Emphasis]
1044
1045 # Emphasis (<em>) with asterisks
1046 <<<
1047 Use *single splats* for emphasis.
1048 --- Should become:
1049 <p>Use <em>single splats</em> for emphasis.</p>
1050 >>>
1051
1052 # Emphasis (<em>) with underscores
1053 <<<
1054 Use *underscores* for emphasis.
1055 --- Should become:
1056 <p>Use <em>underscores</em> for emphasis.</p>
1057 >>>
1058
1059 # Strong emphasis (<strong>) with asterisks
1060 <<<
1061 Use **double splats** for more emphasis.
1062 --- Should become:
1063 <p>Use <strong>double splats</strong> for more emphasis.</p>
1064 >>>
1065
1066 # Strong emphasis (<strong>) with underscores
1067 <<<
1068 Use __doubled underscores__ for more emphasis.
1069 --- Should become:
1070 <p>Use <strong>doubled underscores</strong> for more emphasis.</p>
1071 >>>
1072
1073 # Combined emphasis types 1
1074 <<<
1075 Use *single splats* or _single unders_ for normal emphasis.
1076 --- Should become:
1077 <p>Use <em>single splats</em> or <em>single unders</em> for normal emphasis.</p>
1078 >>>
1079
1080 # Combined emphasis types 2
1081 <<<
1082 Use _single unders_ for normal emphasis
1083 or __double them__ for strong emphasis.
1084 --- Should become:
1085 <p>Use <em>single unders</em> for normal emphasis
1086 or <strong>double them</strong> for strong emphasis.</p>
1087 >>>
1088
1089 # Emphasis containing escaped metachars
1090 <<<
1091 You can include literal *\*splats\** by escaping them.
1092 --- Should become:
1093 <p>You can include literal <em>*splats*</em> by escaping them.</p>
1094 >>>
1095
1096 # Two instances of asterisked emphasis on one line
1097 <<<
1098 If there's *two* splatted parts on a *single line* it should still work.
1099 --- Should become:
1100 <p>If there's <em>two</em> splatted parts on a <em>single line</em> it should still work.</p>
1101 >>>
1102
1103 # Two instances of double asterisked emphasis on one line
1104 <<<
1105 This **doubled** one should **work too**.
1106 --- Should become:
1107 <p>This <strong>doubled</strong> one should <strong>work too</strong>.</p>
1108 >>>
1109
1110 # Two instances of underscore emphasis on one line
1111 <<<
1112 If there's _two_ underbarred parts on a _single line_ it should still work.
1113 --- Should become:
1114 <p>If there's <em>two</em> underbarred parts on a <em>single line</em> it should still work.</p>
1115 >>>
1116
1117 # Two instances of doubled underscore emphasis on one line
1118 <<<
1119 This __doubled__ one should __work too__.
1120 --- Should become:
1121 <p>This <strong>doubled</strong> one should <strong>work too</strong>.</p>
1122 >>>
1123
1124 # Initial emphasis (asterisk)
1125 <<<
1126 *Something* like this should be bold.
1127 --- Should become:
1128 <p><em>Something</em> like this should be bold.</p>
1129 >>>
1130
1131 # Initial emphasis (underscore)
1132 <<<
1133 _Something_ like this should be bold.
1134 --- Should become:
1135 <p><em>Something</em> like this should be bold.</p>
1136 >>>
1137
1138 # Initial strong emphasis (asterisk)
1139 <<<
1140 **Something** like this should be bold.
1141 --- Should become:
1142 <p><strong>Something</strong> like this should be bold.</p>
1143 >>>
1144
1145 # Initial strong emphasis (underscore)
1146 <<<
1147 __Something__ like this should be bold.
1148 --- Should become:
1149 <p><strong>Something</strong> like this should be bold.</p>
1150 >>>
1151
1152 # Partial-word emphasis (Bug #568)
1153 <<<
1154 **E**xtended **TURN**
1155 --- Should become:
1156 <p><strong>E</strong>xtended <strong>TURN</strong></p>
1157 >>>
1158
1159
1160
1161 ### [Links]
1162
1163 # Inline link, no title
1164 <<<
1165 An [example](http://url.com/).
1166 --- Should become:
1167 <p>An <a href="http://url.com/">example</a>.</p>
1168 >>>
1169
1170 # Inline link with title
1171 <<<
1172 An [example](http://url.com/ "Check out url.com!").
1173 --- Should become:
1174 <p>An <a href="http://url.com/" title="Check out url.com!">example</a>.</p>
1175 >>>
1176
1177 # Reference-style link, no title
1178 <<<
1179 An [example][ex] reference-style link.
1180
1181 [ex]: http://www.bluefi.com/
1182 --- Should become:
1183 <p>An <a href="http://www.bluefi.com/">example</a> reference-style link.</p>
1184 >>>
1185
1186 # Reference-style link with quoted title
1187 <<<
1188 An [example][ex] reference-style link.
1189
1190 [ex]: http://www.bluefi.com/ "Check out our air."
1191 --- Should become:
1192 <p>An <a href="http://www.bluefi.com/" title="Check out our air.">example</a> reference-style link.</p>
1193 >>>
1194
1195 # Reference-style link with paren title
1196 <<<
1197 An [example][ex] reference-style link.
1198
1199 [ex]: http://www.bluefi.com/ (Check out our air.)
1200 --- Should become:
1201 <p>An <a href="http://www.bluefi.com/" title="Check out our air.">example</a> reference-style link.</p>
1202 >>>
1203
1204 # Reference-style link with one of each (hehe)
1205 <<<
1206 An [example][ex] reference-style link.
1207
1208 [ex]: http://www.bluefi.com/ "Check out our air.)
1209 --- Should become:
1210 <p>An <a href="http://www.bluefi.com/" title="Check out our air.">example</a> reference-style link.</p>
1211 >>>
1212
1213 " <- For syntax highlighting
1214
1215 # Reference-style link with intervening space
1216 <<<
1217 You can split the [linked part] [ex] from
1218 the reference part with a single space.
1219
1220 [ex]: http://www.treefrog.com/ "for some reason"
1221 --- Should become:
1222 <p>You can split the <a href="http://www.treefrog.com/" title="for some reason">linked part</a> from
1223 the reference part with a single space.</p>
1224 >>>
1225
1226 # Reference-style link with intervening space
1227 <<<
1228 You can split the [linked part]
1229  [ex] from the reference part
1230 with a newline in case your editor wraps it there, I guess.
1231
1232 [ex]: http://www.treefrog.com/
1233 --- Should become:
1234 <p>You can split the <a href="http://www.treefrog.com/">linked part</a> from the reference part
1235 with a newline in case your editor wraps it there, I guess.</p>
1236 >>>
1237
1238 # Reference-style anchors
1239 <<<
1240 I get 10 times more traffic from [Google] [1] than from
1241 [Yahoo] [2] or [MSN] [3].
1242
1243   [1]: http://google.com/        "Google"
1244   [2]: http://search.yahoo.com/  "Yahoo Search"
1245   [3]: http://search.msn.com/    "MSN Search"
1246 --- Should become:
1247 <p>I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from
1248 <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
1249 >>>
1250
1251 # Implicit name-link shortcut anchors
1252 <<<
1253 I get 10 times more traffic from [Google][] than from
1254 [Yahoo][] or [MSN][].
1255
1256   [google]: http://google.com/        "Google"
1257   [yahoo]:  http://search.yahoo.com/  "Yahoo Search"
1258   [msn]:    http://search.msn.com/    "MSN Search"
1259 --- Should become:
1260 <p>I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a> than from
1261 <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
1262 >>>
1263
1264 # Inline anchors
1265 <<<
1266 I get 10 times more traffic from [Google](http://google.com/ "Google")
1267 than from [Yahoo](http://search.yahoo.com/ "Yahoo Search") or
1268 [MSN](http://search.msn.com/ "MSN Search").
1269 --- Should become:
1270 <p>I get 10 times more traffic from <a href="http://google.com/" title="Google">Google</a>
1271 than from <a href="http://search.yahoo.com/" title="Yahoo Search">Yahoo</a> or
1272 <a href="http://search.msn.com/" title="MSN Search">MSN</a>.</p>
1273 >>>
1274
1275 # Graceful fail for unclosed brackets (and bug #524)
1276 <<<
1277 This is just a [bracket opener; it should fail gracefully.
1278 --- Should become:
1279 <p>This is just a [bracket opener; it should fail gracefully.</p>
1280 >>>
1281
1282 # Unresolved reference-style links (Bug #620)
1283 <<<
1284 This is an unresolved [url][1].
1285 --- Should become:
1286 <p>This is an unresolved [url][1].</p>
1287 >>>
1288
1289
1290 ### [Auto-links]
1291
1292 # Plain HTTP link
1293 <<<
1294 This is a reference to <http://www.FaerieMUD.org/>. You should follow it.
1295 --- Should become:
1296 <p>This is a reference to <a href="http://www.FaerieMUD.org/">http://www.FaerieMUD.org/</a>. You should follow it.</p>
1297 >>>
1298
1299 # FTP link
1300 <<<
1301 Why not download your very own chandelier from <ftp://ftp.usuc.edu/pub/foof/mir/>?
1302 --- Should become:
1303 <p>Why not download your very own chandelier from <a href="ftp://ftp.usuc.edu/pub/foof/mir/">ftp://ftp.usuc.edu/pub/foof/mir/</a>?</p>
1304 >>>
1305
1306
1307 ### [Lists]
1308
1309