all repos — grayfriday @ e10ba88263489d0358d7bc5fd6f5e153c603a2a3

blackfriday fork with a few changes

inline_test.go (view raw)

  1//
  2// Blackfriday Markdown Processor
  3// Available at http://github.com/russross/blackfriday
  4//
  5// Copyright © 2011 Russ Ross <russ@russross.com>.
  6// Distributed under the Simplified BSD License.
  7// See README.md for details.
  8//
  9
 10//
 11// Unit tests for inline parsing
 12//
 13
 14package blackfriday
 15
 16import (
 17	"testing"
 18)
 19
 20func runMarkdownInline(input string, extensions, htmlFlags int) string {
 21	extensions |= EXTENSION_AUTOLINK
 22	extensions |= EXTENSION_STRIKETHROUGH
 23
 24	htmlFlags |= HTML_USE_XHTML
 25
 26	renderer := HtmlRenderer(htmlFlags, "", "")
 27
 28	return string(Markdown([]byte(input), renderer, extensions))
 29}
 30
 31func doTestsInline(t *testing.T, tests []string) {
 32	doTestsInlineParam(t, tests, 0, 0)
 33}
 34
 35func doSafeTestsInline(t *testing.T, tests []string) {
 36	doTestsInlineParam(t, tests, 0, HTML_SAFELINK)
 37}
 38
 39func doTestsInlineParam(t *testing.T, tests []string, extensions, htmlFlags int) {
 40	// catch and report panics
 41	var candidate string
 42	/*
 43		defer func() {
 44			if err := recover(); err != nil {
 45				t.Errorf("\npanic while processing [%#v] (%v)\n", candidate, err)
 46			}
 47		}()
 48	*/
 49
 50	for i := 0; i+1 < len(tests); i += 2 {
 51		input := tests[i]
 52		candidate = input
 53		expected := tests[i+1]
 54		actual := runMarkdownInline(candidate, extensions, htmlFlags)
 55		if actual != expected {
 56			t.Errorf("\nInput   [%#v]\nExpected[%#v]\nActual  [%#v]",
 57				candidate, expected, actual)
 58		}
 59
 60		// now test every substring to stress test bounds checking
 61		if !testing.Short() {
 62			for start := 0; start < len(input); start++ {
 63				for end := start + 1; end <= len(input); end++ {
 64					candidate = input[start:end]
 65					_ = runMarkdownInline(candidate, extensions, htmlFlags)
 66				}
 67			}
 68		}
 69	}
 70}
 71
 72func TestEmphasis(t *testing.T) {
 73	var tests = []string{
 74		"nothing inline\n",
 75		"<p>nothing inline</p>\n",
 76
 77		"simple *inline* test\n",
 78		"<p>simple <em>inline</em> test</p>\n",
 79
 80		"*at the* beginning\n",
 81		"<p><em>at the</em> beginning</p>\n",
 82
 83		"at the *end*\n",
 84		"<p>at the <em>end</em></p>\n",
 85
 86		"*try two* in *one line*\n",
 87		"<p><em>try two</em> in <em>one line</em></p>\n",
 88
 89		"over *two\nlines* test\n",
 90		"<p>over <em>two\nlines</em> test</p>\n",
 91
 92		"odd *number of* markers* here\n",
 93		"<p>odd <em>number of</em> markers* here</p>\n",
 94
 95		"odd *number\nof* markers* here\n",
 96		"<p>odd <em>number\nof</em> markers* here</p>\n",
 97
 98		"simple _inline_ test\n",
 99		"<p>simple <em>inline</em> test</p>\n",
100
101		"_at the_ beginning\n",
102		"<p><em>at the</em> beginning</p>\n",
103
104		"at the _end_\n",
105		"<p>at the <em>end</em></p>\n",
106
107		"_try two_ in _one line_\n",
108		"<p><em>try two</em> in <em>one line</em></p>\n",
109
110		"over _two\nlines_ test\n",
111		"<p>over <em>two\nlines</em> test</p>\n",
112
113		"odd _number of_ markers_ here\n",
114		"<p>odd <em>number of</em> markers_ here</p>\n",
115
116		"odd _number\nof_ markers_ here\n",
117		"<p>odd <em>number\nof</em> markers_ here</p>\n",
118
119		"mix of *markers_\n",
120		"<p>mix of *markers_</p>\n",
121	}
122	doTestsInline(t, tests)
123}
124
125func TestStrong(t *testing.T) {
126	var tests = []string{
127		"nothing inline\n",
128		"<p>nothing inline</p>\n",
129
130		"simple **inline** test\n",
131		"<p>simple <strong>inline</strong> test</p>\n",
132
133		"**at the** beginning\n",
134		"<p><strong>at the</strong> beginning</p>\n",
135
136		"at the **end**\n",
137		"<p>at the <strong>end</strong></p>\n",
138
139		"**try two** in **one line**\n",
140		"<p><strong>try two</strong> in <strong>one line</strong></p>\n",
141
142		"over **two\nlines** test\n",
143		"<p>over <strong>two\nlines</strong> test</p>\n",
144
145		"odd **number of** markers** here\n",
146		"<p>odd <strong>number of</strong> markers** here</p>\n",
147
148		"odd **number\nof** markers** here\n",
149		"<p>odd <strong>number\nof</strong> markers** here</p>\n",
150
151		"simple __inline__ test\n",
152		"<p>simple <strong>inline</strong> test</p>\n",
153
154		"__at the__ beginning\n",
155		"<p><strong>at the</strong> beginning</p>\n",
156
157		"at the __end__\n",
158		"<p>at the <strong>end</strong></p>\n",
159
160		"__try two__ in __one line__\n",
161		"<p><strong>try two</strong> in <strong>one line</strong></p>\n",
162
163		"over __two\nlines__ test\n",
164		"<p>over <strong>two\nlines</strong> test</p>\n",
165
166		"odd __number of__ markers__ here\n",
167		"<p>odd <strong>number of</strong> markers__ here</p>\n",
168
169		"odd __number\nof__ markers__ here\n",
170		"<p>odd <strong>number\nof</strong> markers__ here</p>\n",
171
172		"mix of **markers__\n",
173		"<p>mix of **markers__</p>\n",
174	}
175	doTestsInline(t, tests)
176}
177
178func TestEmphasisMix(t *testing.T) {
179	var tests = []string{
180		"***triple emphasis***\n",
181		"<p><strong><em>triple emphasis</em></strong></p>\n",
182
183		"***triple\nemphasis***\n",
184		"<p><strong><em>triple\nemphasis</em></strong></p>\n",
185
186		"___triple emphasis___\n",
187		"<p><strong><em>triple emphasis</em></strong></p>\n",
188
189		"***triple emphasis___\n",
190		"<p>***triple emphasis___</p>\n",
191
192		"*__triple emphasis__*\n",
193		"<p><em><strong>triple emphasis</strong></em></p>\n",
194
195		"__*triple emphasis*__\n",
196		"<p><strong><em>triple emphasis</em></strong></p>\n",
197
198		"**improper *nesting** is* bad\n",
199		"<p><strong>improper *nesting</strong> is* bad</p>\n",
200
201		"*improper **nesting* is** bad\n",
202		"<p><em>improper **nesting</em> is** bad</p>\n",
203	}
204	doTestsInline(t, tests)
205}
206
207func TestStrikeThrough(t *testing.T) {
208	var tests = []string{
209		"nothing inline\n",
210		"<p>nothing inline</p>\n",
211
212		"simple ~~inline~~ test\n",
213		"<p>simple <del>inline</del> test</p>\n",
214
215		"~~at the~~ beginning\n",
216		"<p><del>at the</del> beginning</p>\n",
217
218		"at the ~~end~~\n",
219		"<p>at the <del>end</del></p>\n",
220
221		"~~try two~~ in ~~one line~~\n",
222		"<p><del>try two</del> in <del>one line</del></p>\n",
223
224		"over ~~two\nlines~~ test\n",
225		"<p>over <del>two\nlines</del> test</p>\n",
226
227		"odd ~~number of~~ markers~~ here\n",
228		"<p>odd <del>number of</del> markers~~ here</p>\n",
229
230		"odd ~~number\nof~~ markers~~ here\n",
231		"<p>odd <del>number\nof</del> markers~~ here</p>\n",
232	}
233	doTestsInline(t, tests)
234}
235
236func TestCodeSpan(t *testing.T) {
237	var tests = []string{
238		"`source code`\n",
239		"<p><code>source code</code></p>\n",
240
241		"` source code with spaces `\n",
242		"<p><code>source code with spaces</code></p>\n",
243
244		"` source code with spaces `not here\n",
245		"<p><code>source code with spaces</code>not here</p>\n",
246
247		"a `single marker\n",
248		"<p>a `single marker</p>\n",
249
250		"a single multi-tick marker with ``` no text\n",
251		"<p>a single multi-tick marker with ``` no text</p>\n",
252
253		"markers with ` ` a space\n",
254		"<p>markers with  a space</p>\n",
255
256		"`source code` and a `stray\n",
257		"<p><code>source code</code> and a `stray</p>\n",
258
259		"`source *with* _awkward characters_ in it`\n",
260		"<p><code>source *with* _awkward characters_ in it</code></p>\n",
261
262		"`split over\ntwo lines`\n",
263		"<p><code>split over\ntwo lines</code></p>\n",
264
265		"```multiple ticks``` for the marker\n",
266		"<p><code>multiple ticks</code> for the marker</p>\n",
267
268		"```multiple ticks `with` ticks inside```\n",
269		"<p><code>multiple ticks `with` ticks inside</code></p>\n",
270	}
271	doTestsInline(t, tests)
272}
273
274func TestLineBreak(t *testing.T) {
275	var tests = []string{
276		"this line  \nhas a break\n",
277		"<p>this line<br />\nhas a break</p>\n",
278
279		"this line \ndoes not\n",
280		"<p>this line\ndoes not</p>\n",
281
282		"this has an   \nextra space\n",
283		"<p>this has an<br />\nextra space</p>\n",
284	}
285	doTestsInline(t, tests)
286}
287
288func TestInlineLink(t *testing.T) {
289	var tests = []string{
290		"[foo](/bar/)\n",
291		"<p><a href=\"/bar/\">foo</a></p>\n",
292
293		"[foo with a title](/bar/ \"title\")\n",
294		"<p><a href=\"/bar/\" title=\"title\">foo with a title</a></p>\n",
295
296		"[foo with a title](/bar/\t\"title\")\n",
297		"<p><a href=\"/bar/\" title=\"title\">foo with a title</a></p>\n",
298
299		"[foo with a title](/bar/ \"title\"  )\n",
300		"<p><a href=\"/bar/\" title=\"title\">foo with a title</a></p>\n",
301
302		"[foo with a title](/bar/ title with no quotes)\n",
303		"<p><a href=\"/bar/ title with no quotes\">foo with a title</a></p>\n",
304
305		"[foo]()\n",
306		"<p>[foo]()</p>\n",
307
308		"![foo](/bar/)\n",
309		"<p><img src=\"/bar/\" alt=\"foo\" />\n</p>\n",
310
311		"![foo with a title](/bar/ \"title\")\n",
312		"<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title\" />\n</p>\n",
313
314		"![foo with a title](/bar/\t\"title\")\n",
315		"<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title\" />\n</p>\n",
316
317		"![foo with a title](/bar/ \"title\"  )\n",
318		"<p><img src=\"/bar/\" alt=\"foo with a title\" title=\"title\" />\n</p>\n",
319
320		"![foo with a title](/bar/ title with no quotes)\n",
321		"<p><img src=\"/bar/ title with no quotes\" alt=\"foo with a title\" />\n</p>\n",
322
323		"![foo]()\n",
324		"<p>![foo]()</p>\n",
325
326		"[a link]\t(/with_a_tab/)\n",
327		"<p><a href=\"/with_a_tab/\">a link</a></p>\n",
328
329		"[a link]  (/with_spaces/)\n",
330		"<p><a href=\"/with_spaces/\">a link</a></p>\n",
331
332		"[text (with) [[nested] (brackets)]](/url/)\n",
333		"<p><a href=\"/url/\">text (with) [[nested] (brackets)]</a></p>\n",
334
335		"[text (with) [broken nested] (brackets)]](/url/)\n",
336		"<p>[text (with) <a href=\"brackets\">broken nested</a>]](/url/)</p>\n",
337
338		"[text\nwith a newline](/link/)\n",
339		"<p><a href=\"/link/\">text\nwith a newline</a></p>\n",
340
341		"[text in brackets] [followed](/by a link/)\n",
342		"<p>[text in brackets] <a href=\"/by a link/\">followed</a></p>\n",
343
344		"[link with\\] a closing bracket](/url/)\n",
345		"<p><a href=\"/url/\">link with] a closing bracket</a></p>\n",
346
347		"[link with\\[ an opening bracket](/url/)\n",
348		"<p><a href=\"/url/\">link with[ an opening bracket</a></p>\n",
349
350		"[link with\\) a closing paren](/url/)\n",
351		"<p><a href=\"/url/\">link with) a closing paren</a></p>\n",
352
353		"[link with\\( an opening paren](/url/)\n",
354		"<p><a href=\"/url/\">link with( an opening paren</a></p>\n",
355
356		"[link](  with whitespace)\n",
357		"<p><a href=\"with whitespace\">link</a></p>\n",
358
359		"[link](  with whitespace   )\n",
360		"<p><a href=\"with whitespace\">link</a></p>\n",
361
362		"[![image](someimage)](with image)\n",
363		"<p><a href=\"with image\"><img src=\"someimage\" alt=\"image\" />\n</a></p>\n",
364
365		"[link](url \"one quote)\n",
366		"<p><a href=\"url &quot;one quote\">link</a></p>\n",
367
368		"[link](url 'one quote)\n",
369		"<p><a href=\"url 'one quote\">link</a></p>\n",
370
371		"[link](<url>)\n",
372		"<p><a href=\"url\">link</a></p>\n",
373
374		"[link & ampersand](/url/)\n",
375		"<p><a href=\"/url/\">link &amp; ampersand</a></p>\n",
376
377		"[link &amp; ampersand](/url/)\n",
378		"<p><a href=\"/url/\">link &amp; ampersand</a></p>\n",
379
380		"[link](/url/&query)\n",
381		"<p><a href=\"/url/&amp;query\">link</a></p>\n",
382
383		"[[t]](/t)\n",
384		"<p><a href=\"/t\">[t]</a></p>\n",
385	}
386	doTestsInline(t, tests)
387}
388
389func TestNofollowLink(t *testing.T) {
390	var tests = []string{
391		"[foo](http://bar.com/foo/)\n",
392		"<p><a href=\"http://bar.com/foo/\" rel=\"nofollow\">foo</a></p>\n",
393	}
394	doTestsInlineParam(t, tests, 0, HTML_SAFELINK|HTML_NOFOLLOW_LINKS|HTML_SANITIZE_OUTPUT)
395	// HTML_SANITIZE_OUTPUT won't allow relative links, so test that separately:
396	tests = []string{
397		"[foo](/bar/)\n",
398		"<p><a href=\"/bar/\">foo</a></p>\n",
399	}
400	doTestsInlineParam(t, tests, 0, HTML_SAFELINK|HTML_NOFOLLOW_LINKS)
401}
402
403func TestHrefTargetBlank(t *testing.T) {
404	var tests = []string{
405		// internal link
406		"[foo](/bar/)\n",
407		"<p><a href=\"/bar/\">foo</a></p>\n",
408
409		"[foo](http://example.com)\n",
410		"<p><a href=\"http://example.com\" target=\"_blank\">foo</a></p>\n",
411	}
412	doTestsInlineParam(t, tests, 0, HTML_SAFELINK|HTML_HREF_TARGET_BLANK)
413}
414
415func TestSafeInlineLink(t *testing.T) {
416	var tests = []string{
417		"[foo](/bar/)\n",
418		"<p><a href=\"/bar/\">foo</a></p>\n",
419
420		"[foo](http://bar/)\n",
421		"<p><a href=\"http://bar/\">foo</a></p>\n",
422
423		"[foo](https://bar/)\n",
424		"<p><a href=\"https://bar/\">foo</a></p>\n",
425
426		"[foo](ftp://bar/)\n",
427		"<p><a href=\"ftp://bar/\">foo</a></p>\n",
428
429		"[foo](mailto://bar/)\n",
430		"<p><a href=\"mailto://bar/\">foo</a></p>\n",
431
432		// Not considered safe
433		"[foo](baz://bar/)\n",
434		"<p><tt>foo</tt></p>\n",
435	}
436	doSafeTestsInline(t, tests)
437}
438
439func TestReferenceLink(t *testing.T) {
440	var tests = []string{
441		"[link][ref]\n",
442		"<p>[link][ref]</p>\n",
443
444		"[link][ref]\n   [ref]: /url/ \"title\"\n",
445		"<p><a href=\"/url/\" title=\"title\">link</a></p>\n",
446
447		"[link][ref]\n   [ref]: /url/\n",
448		"<p><a href=\"/url/\">link</a></p>\n",
449
450		"   [ref]: /url/\n",
451		"",
452
453		"   [ref]: /url/\n[ref2]: /url/\n [ref3]: /url/\n",
454		"",
455
456		"   [ref]: /url/\n[ref2]: /url/\n [ref3]: /url/\n    [4spaces]: /url/\n",
457		"<pre><code>[4spaces]: /url/\n</code></pre>\n",
458
459		"[hmm](ref2)\n   [ref]: /url/\n[ref2]: /url/\n [ref3]: /url/\n",
460		"<p><a href=\"ref2\">hmm</a></p>\n",
461
462		"[ref]\n",
463		"<p>[ref]</p>\n",
464
465		"[ref]\n   [ref]: /url/ \"title\"\n",
466		"<p><a href=\"/url/\" title=\"title\">ref</a></p>\n",
467	}
468	doTestsInline(t, tests)
469}
470
471func TestTags(t *testing.T) {
472	var tests = []string{
473		"a <span>tag</span>\n",
474		"<p>a <span>tag</span></p>\n",
475
476		"<span>tag</span>\n",
477		"<p><span>tag</span></p>\n",
478
479		"<span>mismatch</spandex>\n",
480		"<p><span>mismatch</spandex></p>\n",
481
482		"a <singleton /> tag\n",
483		"<p>a <singleton /> tag</p>\n",
484	}
485	doTestsInline(t, tests)
486}
487
488func TestAutoLink(t *testing.T) {
489	var tests = []string{
490		"http://foo.com/\n",
491		"<p><a href=\"http://foo.com/\">http://foo.com/</a></p>\n",
492
493		"1 http://foo.com/\n",
494		"<p>1 <a href=\"http://foo.com/\">http://foo.com/</a></p>\n",
495
496		"1http://foo.com/\n",
497		"<p>1<a href=\"http://foo.com/\">http://foo.com/</a></p>\n",
498
499		"1.http://foo.com/\n",
500		"<p>1.<a href=\"http://foo.com/\">http://foo.com/</a></p>\n",
501
502		"1. http://foo.com/\n",
503		"<ol>\n<li><a href=\"http://foo.com/\">http://foo.com/</a></li>\n</ol>\n",
504
505		"-http://foo.com/\n",
506		"<p>-<a href=\"http://foo.com/\">http://foo.com/</a></p>\n",
507
508		"- http://foo.com/\n",
509		"<ul>\n<li><a href=\"http://foo.com/\">http://foo.com/</a></li>\n</ul>\n",
510
511		"_http://foo.com/\n",
512		"<p>_<a href=\"http://foo.com/\">http://foo.com/</a></p>\n",
513
514		"令狐http://foo.com/\n",
515		"<p>令狐<a href=\"http://foo.com/\">http://foo.com/</a></p>\n",
516
517		"令狐 http://foo.com/\n",
518		"<p>令狐 <a href=\"http://foo.com/\">http://foo.com/</a></p>\n",
519
520		"ahttp://foo.com/\n",
521		"<p>ahttp://foo.com/</p>\n",
522
523		">http://foo.com/\n",
524		"<blockquote>\n<p><a href=\"http://foo.com/\">http://foo.com/</a></p>\n</blockquote>\n",
525
526		"> http://foo.com/\n",
527		"<blockquote>\n<p><a href=\"http://foo.com/\">http://foo.com/</a></p>\n</blockquote>\n",
528
529		"go to <http://foo.com/>\n",
530		"<p>go to <a href=\"http://foo.com/\">http://foo.com/</a></p>\n",
531
532		"a secure <https://link.org>\n",
533		"<p>a secure <a href=\"https://link.org\">https://link.org</a></p>\n",
534
535		"an email <mailto:some@one.com>\n",
536		"<p>an email <a href=\"mailto:some@one.com\">some@one.com</a></p>\n",
537
538		"an email <mailto://some@one.com>\n",
539		"<p>an email <a href=\"mailto://some@one.com\">some@one.com</a></p>\n",
540
541		"an email <some@one.com>\n",
542		"<p>an email <a href=\"mailto:some@one.com\">some@one.com</a></p>\n",
543
544		"an ftp <ftp://old.com>\n",
545		"<p>an ftp <a href=\"ftp://old.com\">ftp://old.com</a></p>\n",
546
547		"an ftp <ftp:old.com>\n",
548		"<p>an ftp <a href=\"ftp:old.com\">ftp:old.com</a></p>\n",
549
550		"a link with <http://new.com?query=foo&bar>\n",
551		"<p>a link with <a href=\"http://new.com?query=foo&amp;bar\">" +
552			"http://new.com?query=foo&amp;bar</a></p>\n",
553
554		"quotes mean a tag <http://new.com?query=\"foo\"&bar>\n",
555		"<p>quotes mean a tag <http://new.com?query=\"foo\"&bar></p>\n",
556
557		"quotes mean a tag <http://new.com?query='foo'&bar>\n",
558		"<p>quotes mean a tag <http://new.com?query='foo'&bar></p>\n",
559
560		"unless escaped <http://new.com?query=\\\"foo\\\"&bar>\n",
561		"<p>unless escaped <a href=\"http://new.com?query=&quot;foo&quot;&amp;bar\">" +
562			"http://new.com?query=&quot;foo&quot;&amp;bar</a></p>\n",
563
564		"even a > can be escaped <http://new.com?q=\\>&etc>\n",
565		"<p>even a &gt; can be escaped <a href=\"http://new.com?q=&gt;&amp;etc\">" +
566			"http://new.com?q=&gt;&amp;etc</a></p>\n",
567
568		"<a href=\"http://fancy.com\">http://fancy.com</a>\n",
569		"<p><a href=\"http://fancy.com\">http://fancy.com</a></p>\n",
570
571		"<a href=\"http://fancy.com\">This is a link</a>\n",
572		"<p><a href=\"http://fancy.com\">This is a link</a></p>\n",
573
574		"<a href=\"http://www.fancy.com/A_B.pdf\">http://www.fancy.com/A_B.pdf</a>\n",
575		"<p><a href=\"http://www.fancy.com/A_B.pdf\">http://www.fancy.com/A_B.pdf</a></p>\n",
576
577		"(<a href=\"http://www.fancy.com/A_B\">http://www.fancy.com/A_B</a> (\n",
578		"<p>(<a href=\"http://www.fancy.com/A_B\">http://www.fancy.com/A_B</a> (</p>\n",
579
580		"(<a href=\"http://www.fancy.com/A_B\">http://www.fancy.com/A_B</a> (part two: <a href=\"http://www.fancy.com/A_B\">http://www.fancy.com/A_B</a>)).\n",
581		"<p>(<a href=\"http://www.fancy.com/A_B\">http://www.fancy.com/A_B</a> (part two: <a href=\"http://www.fancy.com/A_B\">http://www.fancy.com/A_B</a>)).</p>\n",
582
583		"http://www.foo.com<br />\n",
584		"<p><a href=\"http://www.foo.com\">http://www.foo.com</a><br /></p>\n",
585
586		"http://foo.com/viewtopic.php?f=18&amp;t=297",
587		"<p><a href=\"http://foo.com/viewtopic.php?f=18&amp;t=297\">http://foo.com/viewtopic.php?f=18&amp;t=297</a></p>\n",
588
589		"http://foo.com/viewtopic.php?param=&quot;18&quot;zz",
590		"<p><a href=\"http://foo.com/viewtopic.php?param=&quot;18&quot;zz\">http://foo.com/viewtopic.php?param=&quot;18&quot;zz</a></p>\n",
591
592		"http://foo.com/viewtopic.php?param=&quot;18&quot;",
593		"<p><a href=\"http://foo.com/viewtopic.php?param=&quot;18&quot;\">http://foo.com/viewtopic.php?param=&quot;18&quot;</a></p>\n",
594	}
595	doTestsInline(t, tests)
596}
597
598func TestFootnotes(t *testing.T) {
599	tests := []string{
600		"testing footnotes.[^a]\n\n[^a]: This is the note\n",
601		`<p>testing footnotes.<sup class="footnote-ref" id="fnref:a"><a rel="footnote" href="#fn:a">1</a></sup></p>
602<div class="footnotes">
603
604<hr />
605
606<ol>
607<li id="fn:a">This is the note
608</li>
609</ol>
610</div>
611`,
612
613		`testing long[^b] notes.
614
615[^b]: Paragraph 1
616
617	Paragraph 2
618
619	` + "```\n\tsome code\n\t```" + `
620
621	Paragraph 3
622
623No longer in the footnote
624`,
625		`<p>testing long<sup class="footnote-ref" id="fnref:b"><a rel="footnote" href="#fn:b">1</a></sup> notes.</p>
626
627<p>No longer in the footnote</p>
628<div class="footnotes">
629
630<hr />
631
632<ol>
633<li id="fn:b"><p>Paragraph 1</p>
634
635<p>Paragraph 2</p>
636
637<p><code>
638some code
639</code></p>
640
641<p>Paragraph 3</p>
642</li>
643</ol>
644</div>
645`,
646
647		`testing[^c] multiple[^d] notes.
648
649[^c]: this is [note] c
650
651
652omg
653
654[^d]: this is note d
655
656what happens here
657
658[note]: /link/c
659
660`,
661		`<p>testing<sup class="footnote-ref" id="fnref:c"><a rel="footnote" href="#fn:c">1</a></sup> multiple<sup class="footnote-ref" id="fnref:d"><a rel="footnote" href="#fn:d">2</a></sup> notes.</p>
662
663<p>omg</p>
664
665<p>what happens here</p>
666<div class="footnotes">
667
668<hr />
669
670<ol>
671<li id="fn:c">this is <a href="/link/c">note</a> c
672</li>
673<li id="fn:d">this is note d
674</li>
675</ol>
676</div>
677`,
678
679		"testing inline^[this is the note] notes.\n",
680		`<p>testing inline<sup class="footnote-ref" id="fnref:this-is-the-note"><a rel="footnote" href="#fn:this-is-the-note">1</a></sup> notes.</p>
681<div class="footnotes">
682
683<hr />
684
685<ol>
686<li id="fn:this-is-the-note">this is the note</li>
687</ol>
688</div>
689`,
690
691		"testing multiple[^1] types^[inline note] of notes[^2]\n\n[^2]: the second deferred note\n[^1]: the first deferred note\n\n\twhich happens to be a block\n",
692		`<p>testing multiple<sup class="footnote-ref" id="fnref:1"><a rel="footnote" href="#fn:1">1</a></sup> types<sup class="footnote-ref" id="fnref:inline-note"><a rel="footnote" href="#fn:inline-note">2</a></sup> of notes<sup class="footnote-ref" id="fnref:2"><a rel="footnote" href="#fn:2">3</a></sup></p>
693<div class="footnotes">
694
695<hr />
696
697<ol>
698<li id="fn:1"><p>the first deferred note</p>
699
700<p>which happens to be a block</p>
701</li>
702<li id="fn:inline-note">inline note</li>
703<li id="fn:2">the second deferred note
704</li>
705</ol>
706</div>
707`,
708
709		`This is a footnote[^1]^[and this is an inline footnote]
710
711[^1]: the footnote text.
712
713    may be multiple paragraphs.
714`,
715		`<p>This is a footnote<sup class="footnote-ref" id="fnref:1"><a rel="footnote" href="#fn:1">1</a></sup><sup class="footnote-ref" id="fnref:and-this-is-an-i"><a rel="footnote" href="#fn:and-this-is-an-i">2</a></sup></p>
716<div class="footnotes">
717
718<hr />
719
720<ol>
721<li id="fn:1"><p>the footnote text.</p>
722
723<p>may be multiple paragraphs.</p>
724</li>
725<li id="fn:and-this-is-an-i">and this is an inline footnote</li>
726</ol>
727</div>
728`,
729
730		"empty footnote[^]\n\n[^]: fn text",
731		"<p>empty footnote<sup class=\"footnote-ref\" id=\"fnref:\"><a rel=\"footnote\" href=\"#fn:\">1</a></sup></p>\n<div class=\"footnotes\">\n\n<hr />\n\n<ol>\n<li id=\"fn:\">fn text\n</li>\n</ol>\n</div>\n",
732	}
733
734	doTestsInlineParam(t, tests, EXTENSION_FOOTNOTES, 0)
735}