satteri-pulldown-cmark 0.3.2

A fork of the pulldown-cmark crate with MDX extensions, used in the satteri project.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
// This file is auto-generated by the build script
// Please, do not modify it manually

use super::test_markdown_html;

#[test]
fn footnotes_test_1() {
    let original = r##"Lorem ipsum.[^a] [^missing]

[^a]: Cool.
"##;
    let expected = r##"<p>Lorem ipsum.<sup><a href="#user-content-fn-a" id="user-content-fnref-a" data-footnote-ref aria-describedby="footnote-label">1</a></sup> [^missing]</p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-a">
<p>Cool. <a href="#user-content-fnref-a" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_2() {
    let original = r##"> This is the song that never ends.\
> Yes it goes on and on my friends.[^lambchops]
>
> [^lambchops]: <https://www.youtube.com/watch?v=0U2zJOryHKQ>
"##;
    let expected = r##"<blockquote>
<p>This is the song that never ends.<br>
Yes it goes on and on my friends.<sup><a href="#user-content-fn-lambchops" id="user-content-fnref-lambchops" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
</blockquote>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-lambchops">
<p><a href="https://www.youtube.com/watch?v=0U2zJOryHKQ">https://www.youtube.com/watch?v=0U2zJOryHKQ</a> <a href="#user-content-fnref-lambchops" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_3() {
    let original = r##"Songs that simply loop are a popular way to annoy people. [^examples]

[^examples]:
 * [The song that never ends](https://www.youtube.com/watch?v=0U2zJOryHKQ)
 * [I know a song that gets on everybody's nerves](https://www.youtube.com/watch?v=TehWI09qxls)
 * [Ninety-nine bottles of beer on the wall](https://www.youtube.com/watch?v=qVjCag8XoHQ)
"##;
    let expected = r##"<p>Songs that simply loop are a popular way to annoy people. <sup><a href="#user-content-fn-examples" id="user-content-fnref-examples" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
<ul>
<li><a href="https://www.youtube.com/watch?v=0U2zJOryHKQ">The song that never ends</a></li>
<li><a href="https://www.youtube.com/watch?v=TehWI09qxls">I know a song that gets on everybody's nerves</a></li>
<li><a href="https://www.youtube.com/watch?v=qVjCag8XoHQ">Ninety-nine bottles of beer on the wall</a></li>
</ul>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-examples">
<a href="#user-content-fnref-examples" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_4() {
    let original = r##"Songs that simply loop are a popular way to annoy people. [^examples]

[^examples]:
    * [The song that never ends](https://www.youtube.com/watch?v=0U2zJOryHKQ)
    * [I know a song that gets on everybody's nerves](https://www.youtube.com/watch?v=TehWI09qxls)
    * [Ninety-nine bottles of beer on the wall](https://www.youtube.com/watch?v=qVjCag8XoHQ)
"##;
    let expected = r##"<p>Songs that simply loop are a popular way to annoy people. <sup><a href="#user-content-fn-examples" id="user-content-fnref-examples" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-examples">
<ul>
<li><a href="https://www.youtube.com/watch?v=0U2zJOryHKQ">The song that never ends</a></li>
<li><a href="https://www.youtube.com/watch?v=TehWI09qxls">I know a song that gets on everybody's nerves</a></li>
<li><a href="https://www.youtube.com/watch?v=qVjCag8XoHQ">Ninety-nine bottles of beer on the wall</a></li>
</ul>
<a href="#user-content-fnref-examples" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_5() {
    let original = r##"[^not-code] [^code] [^quote] [^not-quote] [^indented-quote]

[^not-code]:         not code

[^code]:
        code

[^quote]: > quote

[^not-quote]:
 > external quote

[^indented-quote]:
    > indented quote
"##;
    let expected = r##"<p><sup><a href="#user-content-fn-not-code" id="user-content-fnref-not-code" data-footnote-ref aria-describedby="footnote-label">1</a></sup> <sup><a href="#user-content-fn-code" id="user-content-fnref-code" data-footnote-ref aria-describedby="footnote-label">2</a></sup> <sup><a href="#user-content-fn-quote" id="user-content-fnref-quote" data-footnote-ref aria-describedby="footnote-label">3</a></sup> <sup><a href="#user-content-fn-not-quote" id="user-content-fnref-not-quote" data-footnote-ref aria-describedby="footnote-label">4</a></sup> <sup><a href="#user-content-fn-indented-quote" id="user-content-fnref-indented-quote" data-footnote-ref aria-describedby="footnote-label">5</a></sup></p>
<blockquote>
<p>external quote</p>
</blockquote>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-not-code">
<p>not code <a href="#user-content-fnref-not-code" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-fn-code">
<pre><code>code
</code></pre>
<a href="#user-content-fnref-code" data-footnote-backref="" aria-label="Back to reference 2" class="data-footnote-backref">↩</a>
</li>
<li id="user-content-fn-quote">
<blockquote>
<p>quote</p>
</blockquote>
<a href="#user-content-fnref-quote" data-footnote-backref="" aria-label="Back to reference 3" class="data-footnote-backref">↩</a>
</li>
<li id="user-content-fn-not-quote">
<a href="#user-content-fnref-not-quote" data-footnote-backref="" aria-label="Back to reference 4" class="data-footnote-backref">↩</a>
</li>
<li id="user-content-fn-indented-quote">
<blockquote>
<p>indented quote</p>
</blockquote>
<a href="#user-content-fnref-indented-quote" data-footnote-backref="" aria-label="Back to reference 5" class="data-footnote-backref">↩</a>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_6() {
    let original = r##"[^ab] [^cd]

[^ab]: a
b

[^cd]: c\
d
"##;
    let expected = r##"<p><sup><a href="#user-content-fn-ab" id="user-content-fnref-ab" data-footnote-ref aria-describedby="footnote-label">1</a></sup> <sup><a href="#user-content-fn-cd" id="user-content-fnref-cd" data-footnote-ref aria-describedby="footnote-label">2</a></sup></p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-ab">
<p>a
b <a href="#user-content-fnref-ab" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-fn-cd">
<p>c<br>
d <a href="#user-content-fnref-cd" data-footnote-backref="" aria-label="Back to reference 2" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_7() {
    let original = r##"[^lorem]: If heaven ever wishes to grant me a boon, it will be a total effacing of the results of a mere chance which fixed my eye on a certain stray piece of shelf-paper. It was nothing on which I would naturally have stumbled in the course of my daily round, for it was an old number of an Australian journal, the Sydney Bulletin for April 18, 1925. It had escaped even the cutting bureau which had at the time of its issuance been avidly collecting material for my uncle's research.

I had largely given over my inquiries into what Professor Angell called the "Cthulhu Cult", and was visiting a learned friend in Paterson, New Jersey; the curator of a local museum and a mineralogist of note. Examining one day the reserve specimens roughly set on the storage shelves in a rear room of the museum, my eye was caught by an odd picture in one of the old papers spread beneath the stones. It was the Sydney Bulletin I have mentioned, for my friend had wide affiliations in all conceivable foreign parts; and the picture was a half-tone cut of a hideous stone image almost identical with that which Legrasse had found in the swamp.

[^ipsum]: If heaven ever wishes to grant me a boon, it will be a total effacing of the results of a mere chance which fixed my eye on a certain stray piece of shelf-paper. It was nothing on which I would naturally have stumbled in the course of my daily round, for it was an old number of an Australian journal, the Sydney Bulletin for April 18, 1925. It had escaped even the cutting bureau which had at the time of its issuance been avidly collecting material for my uncle's research.

    I had largely given over my inquiries into what Professor Angell called the "Cthulhu Cult", and was visiting a learned friend in Paterson, New Jersey; the curator of a local museum and a mineralogist of note. Examining one day the reserve specimens roughly set on the storage shelves in a rear room of the museum, my eye was caught by an odd picture in one of the old papers spread beneath the stones. It was the Sydney Bulletin I have mentioned, for my friend had wide affiliations in all conceivable foreign parts; and the picture was a half-tone cut of a hideous stone image almost identical with that which Legrasse had found in the swamp.
"##;
    let expected = r##"<p>I had largely given over my inquiries into what Professor Angell called the "Cthulhu Cult", and was visiting a learned friend in Paterson, New Jersey; the curator of a local museum and a mineralogist of note. Examining one day the reserve specimens roughly set on the storage shelves in a rear room of the museum, my eye was caught by an odd picture in one of the old papers spread beneath the stones. It was the Sydney Bulletin I have mentioned, for my friend had wide affiliations in all conceivable foreign parts; and the picture was a half-tone cut of a hideous stone image almost identical with that which Legrasse had found in the swamp.</p>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_8() {
    let original = r##"[^ipsum]: How much wood would a woodchuck chuck.

If a woodchuck could chuck wood.


# Forms of entertainment that aren't childish
"##;
    let expected = r##"<p>If a woodchuck could chuck wood.</p>
<h1>Forms of entertainment that aren't childish</h1>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_9() {
    let original = r##"Footnotes [^one] [^many].

[^one]:





    first paragraph inside footnote

[^many]: first paragraph inside footnote





    second paragraph still inside footnote
"##;
    let expected = r##"<p>Footnotes <sup><a href="#user-content-fn-one" id="user-content-fnref-one" data-footnote-ref aria-describedby="footnote-label">1</a></sup> <sup><a href="#user-content-fn-many" id="user-content-fnref-many" data-footnote-ref aria-describedby="footnote-label">2</a></sup>.</p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-one">
<p>first paragraph inside footnote <a href="#user-content-fnref-one" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-fn-many">
<p>first paragraph inside footnote</p>
<p>second paragraph still inside footnote <a href="#user-content-fnref-many" data-footnote-backref="" aria-label="Back to reference 2" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_10() {
    let original = r##"> He's also really stupid. [^why]
>
> [^why]: Because your mamma!

As such, we can guarantee that the non-childish forms of entertainment are probably more entertaining to adults, since, having had a whole childhood doing the childish ones, the non-childish ones are merely the ones that haven't gotten boring yet.
"##;
    let expected = r##"<blockquote>
<p>He's also really stupid. <sup><a href="#user-content-fn-why" id="user-content-fnref-why" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
</blockquote>
<p>As such, we can guarantee that the non-childish forms of entertainment are probably more entertaining to adults, since, having had a whole childhood doing the childish ones, the non-childish ones are merely the ones that haven't gotten boring yet.</p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-why">
<p>Because your mamma! <a href="#user-content-fnref-why" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_11() {
    let original = r##"Nested footnotes are considered poor style. [^a] [^xkcd] [^indent1] [^indent2]

[^a]: This does not mean that footnotes cannot reference each other. [^b]

[^b]: This means that a footnote definition cannot be directly inside another footnote definition.
> This means that a footnote cannot be directly inside another footnote's body. [^e]
>
> [^e]: They can, however, be inside anything else.

[^xkcd]: [The other kind of nested footnote is, however, considered poor style.](https://xkcd.com/1208/)

[^indent1]: indent1

    [^indent2]: indent2
"##;
    let expected = r##"<p>Nested footnotes are considered poor style. <sup><a href="#user-content-fn-a" id="user-content-fnref-a" data-footnote-ref aria-describedby="footnote-label">1</a></sup> <sup><a href="#user-content-fn-xkcd" id="user-content-fnref-xkcd" data-footnote-ref aria-describedby="footnote-label">2</a></sup> <sup><a href="#user-content-fn-indent1" id="user-content-fnref-indent1" data-footnote-ref aria-describedby="footnote-label">3</a></sup> <sup><a href="#user-content-fn-indent2" id="user-content-fnref-indent2" data-footnote-ref aria-describedby="footnote-label">4</a></sup></p>
<blockquote>
<p>This means that a footnote cannot be directly inside another footnote's body. <sup><a href="#user-content-fn-e" id="user-content-fnref-e" data-footnote-ref aria-describedby="footnote-label">5</a></sup></p>
</blockquote>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-a">
<p>This does not mean that footnotes cannot reference each other. <sup><a href="#user-content-fn-b" id="user-content-fnref-b" data-footnote-ref aria-describedby="footnote-label">6</a></sup> <a href="#user-content-fnref-a" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-fn-xkcd">
<p><a href="https://xkcd.com/1208/">The other kind of nested footnote is, however, considered poor style.</a> <a href="#user-content-fnref-xkcd" data-footnote-backref="" aria-label="Back to reference 2" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-fn-indent1">
<p>indent1 <a href="#user-content-fnref-indent1" data-footnote-backref="" aria-label="Back to reference 3" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-fn-indent2">
<p>indent2 <a href="#user-content-fnref-indent2" data-footnote-backref="" aria-label="Back to reference 4" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-fn-e">
<p>They can, however, be inside anything else. <a href="#user-content-fnref-e" data-footnote-backref="" aria-label="Back to reference 5" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-fn-b">
<p>This means that a footnote definition cannot be directly inside another footnote definition. <a href="#user-content-fnref-b" data-footnote-backref="" aria-label="Back to reference 6" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_12() {
    let original = r##"[^foo] [^bar]

[^foo]: [^bar]: 1
"##;
    let expected = r##"<p><sup><a href="#user-content-fn-foo" id="user-content-fnref-foo" data-footnote-ref aria-describedby="footnote-label">1</a></sup> <sup><a href="#user-content-fn-bar" id="user-content-fnref-bar" data-footnote-ref aria-describedby="footnote-label">2</a></sup></p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-foo">
<a href="#user-content-fnref-foo" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a>
</li>
<li id="user-content-fn-bar">
<p>1 <a href="#user-content-fnref-bar" data-footnote-backref="" aria-label="Back to reference 2" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_13() {
    let original = r##"[^Doh] Ray Me Fa So La Te Do! [^1]

[^Doh]: I know. Wrong Doe. And it won't render right.
[^1]: Common for people practicing music.
"##;
    let expected = r##"<p><sup><a href="#user-content-fn-doh" id="user-content-fnref-doh" data-footnote-ref aria-describedby="footnote-label">1</a></sup> Ray Me Fa So La Te Do! <sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">2</a></sup></p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-doh">
<p>I know. Wrong Doe. And it won't render right. <a href="#user-content-fnref-doh" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-fn-1">
<p>Common for people practicing music. <a href="#user-content-fnref-1" data-footnote-backref="" aria-label="Back to reference 2" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_14() {
    let original = r##"Lorem ipsum.[^a]

An unordered list before the footnotes:
* Ipsum
* Lorem

[^a]: Cool.
"##;
    let expected = r##"<p>Lorem ipsum.<sup><a href="#user-content-fn-a" id="user-content-fnref-a" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
<p>An unordered list before the footnotes:</p>
<ul>
<li>Ipsum</li>
<li>Lorem</li>
</ul>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-a">
<p>Cool. <a href="#user-content-fnref-a" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_15() {
    let original = r##"Songs that simply loop are a popular way to annoy people. [^examples]

[^examples]: * [The song that never ends](https://www.youtube.com/watch?v=0U2zJOryHKQ)
* [I know a song that gets on everybody's nerves](https://www.youtube.com/watch?v=TehWI09qxls)
* [Ninety-nine bottles of beer on the wall](https://www.youtube.com/watch?v=qVjCag8XoHQ)


Songs that simply loop are a popular way to annoy people. [^examples2]

[^examples2]: * [The song that never ends](https://www.youtube.com/watch?v=0U2zJOryHKQ) 2
    * [I know a song that gets on everybody's nerves](https://www.youtube.com/watch?v=TehWI09qxls) 2
    - [Ninety-nine bottles of beer on the wall](https://www.youtube.com/watch?v=qVjCag8XoHQ) 2


Songs that simply loop are a popular way to annoy people. [^examples3]

[^examples3]: * [The song that never ends](https://www.youtube.com/watch?v=0U2zJOryHKQ) 3

    * [I know a song that gets on everybody's nerves](https://www.youtube.com/watch?v=TehWI09qxls) 3

    * [Ninety-nine bottles of beer on the wall](https://www.youtube.com/watch?v=qVjCag8XoHQ) 3
"##;
    let expected = r##"<p>Songs that simply loop are a popular way to annoy people. <sup><a href="#user-content-fn-examples" id="user-content-fnref-examples" data-footnote-ref aria-describedby="footnote-label">1</a></sup></p>
<ul>
<li><a href="https://www.youtube.com/watch?v=TehWI09qxls">I know a song that gets on everybody's nerves</a></li>
<li><a href="https://www.youtube.com/watch?v=qVjCag8XoHQ">Ninety-nine bottles of beer on the wall</a></li>
</ul>
<p>Songs that simply loop are a popular way to annoy people. <sup><a href="#user-content-fn-examples2" id="user-content-fnref-examples2" data-footnote-ref aria-describedby="footnote-label">2</a></sup></p>
<p>Songs that simply loop are a popular way to annoy people. <sup><a href="#user-content-fn-examples3" id="user-content-fnref-examples3" data-footnote-ref aria-describedby="footnote-label">3</a></sup></p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-examples">
<ul>
<li><a href="https://www.youtube.com/watch?v=0U2zJOryHKQ">The song that never ends</a></li>
</ul>
<a href="#user-content-fnref-examples" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a>
</li>
<li id="user-content-fn-examples2">
<ul>
<li><a href="https://www.youtube.com/watch?v=0U2zJOryHKQ">The song that never ends</a> 2</li>
<li><a href="https://www.youtube.com/watch?v=TehWI09qxls">I know a song that gets on everybody's nerves</a> 2</li>
</ul>
<ul>
<li><a href="https://www.youtube.com/watch?v=qVjCag8XoHQ">Ninety-nine bottles of beer on the wall</a> 2</li>
</ul>
<a href="#user-content-fnref-examples2" data-footnote-backref="" aria-label="Back to reference 2" class="data-footnote-backref">↩</a>
</li>
<li id="user-content-fn-examples3">
<ul>
<li>
<p><a href="https://www.youtube.com/watch?v=0U2zJOryHKQ">The song that never ends</a> 3</p>
</li>
<li>
<p><a href="https://www.youtube.com/watch?v=TehWI09qxls">I know a song that gets on everybody's nerves</a> 3</p>
</li>
<li>
<p><a href="https://www.youtube.com/watch?v=qVjCag8XoHQ">Ninety-nine bottles of beer on the wall</a> 3</p>
</li>
</ul>
<a href="#user-content-fnref-examples3" data-footnote-backref="" aria-label="Back to reference 3" class="data-footnote-backref">↩</a>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

// Bracket-resolution: cmark-gfm leaves the URL after `]:` as raw text
// when the line isn't a valid reference definition (label contains
// unescaped brackets). Both we and remark autolink the URL via the GFM
// extension, so the expected output is updated to match remark.
#[test]
fn footnotes_test_16() {
    let original = r##"My [cmark-gfm][^c].

My [cmark-gfm][cmark-gfm][^c].

My [cmark-gfm][][^c].

My [cmark-gfm] [^c].

My [cmark-gfm[^c]].

[cmark-gfm]: https://github.com/github/cmark-gfm/blob/1e230827a584ebc9938c3eadc5059c55ef3c9abf/test/extensions.txt#L702

[^c]: cmark-gfm is under the MIT license, so incorporating parts of its
    test suite into pulldown-cmark should be fine.


My [otherlink[^c]].

[otherlink[^c]]: https://github.com/github/cmark-gfm/blob/1e230827a584ebc9938c3eadc5059c55ef3c9abf/test/extensions.txt#L702
"##;
    let expected = r##"<p>My [cmark-gfm]<sup><a href="#user-content-fn-c" id="user-content-fnref-c" data-footnote-ref aria-describedby="footnote-label">1</a></sup>.</p>
<p>My <a href="https://github.com/github/cmark-gfm/blob/1e230827a584ebc9938c3eadc5059c55ef3c9abf/test/extensions.txt#L702">cmark-gfm</a><sup><a href="#user-content-fn-c" id="user-content-fnref-c-2" data-footnote-ref aria-describedby="footnote-label">1</a></sup>.</p>
<p>My <a href="https://github.com/github/cmark-gfm/blob/1e230827a584ebc9938c3eadc5059c55ef3c9abf/test/extensions.txt#L702">cmark-gfm</a><sup><a href="#user-content-fn-c" id="user-content-fnref-c-3" data-footnote-ref aria-describedby="footnote-label">1</a></sup>.</p>
<p>My <a href="https://github.com/github/cmark-gfm/blob/1e230827a584ebc9938c3eadc5059c55ef3c9abf/test/extensions.txt#L702">cmark-gfm</a> <sup><a href="#user-content-fn-c" id="user-content-fnref-c-4" data-footnote-ref aria-describedby="footnote-label">1</a></sup>.</p>
<p>My [cmark-gfm<sup><a href="#user-content-fn-c" id="user-content-fnref-c-5" data-footnote-ref aria-describedby="footnote-label">1</a></sup>].</p>
<p>My [otherlink<sup><a href="#user-content-fn-c" id="user-content-fnref-c-6" data-footnote-ref aria-describedby="footnote-label">1</a></sup>].</p>
<p>[otherlink<sup><a href="#user-content-fn-c" id="user-content-fnref-c-7" data-footnote-ref aria-describedby="footnote-label">1</a></sup>]: <a href="https://github.com/github/cmark-gfm/blob/1e230827a584ebc9938c3eadc5059c55ef3c9abf/test/extensions.txt#L702">https://github.com/github/cmark-gfm/blob/1e230827a584ebc9938c3eadc5059c55ef3c9abf/test/extensions.txt#L702</a></p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-c">
<p>cmark-gfm is under the MIT license, so incorporating parts of its
test suite into pulldown-cmark should be fine. <a href="#user-content-fnref-c" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a> <a href="#user-content-fnref-c-2" data-footnote-backref="" aria-label="Back to reference 1-2" class="data-footnote-backref">↩<sup>2</sup></a> <a href="#user-content-fnref-c-3" data-footnote-backref="" aria-label="Back to reference 1-3" class="data-footnote-backref">↩<sup>3</sup></a> <a href="#user-content-fnref-c-4" data-footnote-backref="" aria-label="Back to reference 1-4" class="data-footnote-backref">↩<sup>4</sup></a> <a href="#user-content-fnref-c-5" data-footnote-backref="" aria-label="Back to reference 1-5" class="data-footnote-backref">↩<sup>5</sup></a> <a href="#user-content-fnref-c-6" data-footnote-backref="" aria-label="Back to reference 1-6" class="data-footnote-backref">↩<sup>6</sup></a> <a href="#user-content-fnref-c-7" data-footnote-backref="" aria-label="Back to reference 1-7" class="data-footnote-backref">↩<sup>7</sup></a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_17() {
    let original = r##"[^1]: footnote definition text

<!-- -->

    // indented code block
    fn main() {
        println!("hello world!");
    }
"##;
    let expected = r##"<!-- -->
<pre><code>// indented code block
fn main() {
    println!("hello world!");
}
</code></pre>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_18() {
    let original = r##"[^1]: footnote definition text
[^1]\: this is a reference, rather than a definition
"##;
    let expected = r##""##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_19() {
    let original = r##"[^1]:

    | column1 | column2 |
    |---------|---------|
    | row1a   | row1b   |
    | row2a   | row2b   |
"##;
    let expected = r##""##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

// Indented GFM tables at the document root: the original cmark-gfm
// expected emitted these as paragraphs with literal pipes. We (and
// remark-gfm) now recognise both runs as proper tables, so the expected
// HTML is regenerated from current remark output.
#[test]
fn footnotes_test_20() {
    let original = r##"* First
  [^1]: test
* Second [^1] test


> first
> [^2]: test
> Second [^2] test


   First   | Second
-----------|----------
first      | second
[^3]: test | test [^3]


|    First   | Second    |
|------------|-----------|
| first      | second    |
| [^4]: test | test [^4] |

> [^5]: * test [^5]
"##;
    let expected = r##"<ul>
<li>First</li>
<li>Second <sup><a href="#user-content-fn-1" id="user-content-fnref-1" data-footnote-ref aria-describedby="footnote-label">1</a></sup> test</li>
</ul>
<blockquote>
<p>first</p>
</blockquote>
<table>
<thead>
<tr>
<th>First</th>
<th>Second</th>
</tr>
</thead>
<tbody>
<tr>
<td>first</td>
<td>second</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>First</th>
<th>Second</th>
</tr>
</thead>
<tbody>
<tr>
<td>first</td>
<td>second</td>
</tr>
<tr>
<td>[^4]: test</td>
<td>test [^4]</td>
</tr>
</tbody>
</table>
<blockquote>
</blockquote>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-1">
<p>test <a href="#user-content-fnref-1" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_21() {
    let original = r##"Test [^] link

[^]: https://rust-lang.org
"##;
    let expected = r##"<p>Test <a href="https://rust-lang.org">^</a> link</p>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_22() {
    let original = r##"[^foo\
bar]: not a footnote definition

[baz\
quux]: https://rust-lang.org

[first
second]: https://rust-lang.org

[^third
fourth]: not a footnote definition

[baz\
quux]
[^foo\
bar]
[first
second]
[^third
fourth]
"##;
    let expected = r##"<p>[^foo<br>
bar]: not a footnote definition</p>
<p>[^third
fourth]: not a footnote definition</p>
<p><a href="https://rust-lang.org">baz<br>
quux</a>
[^foo<br>
bar]
<a href="https://rust-lang.org">first
second</a>
[^third
fourth]</p>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_23() {
    let original = r##"[^foo
]: https://rust-lang.org

[^foo
]
"##;
    let expected = r##"<p><a href="https://rust-lang.org">^foo
</a></p>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_24() {
    let original = r##"footnote [^baz]
footnote [^quux]

    [^quux]: x

   [^baz]: x
"##;
    let expected = r##"<p>footnote <sup><a href="#user-content-fn-baz" id="user-content-fnref-baz" data-footnote-ref aria-describedby="footnote-label">1</a></sup>
footnote [^quux]</p>
<pre><code>[^quux]: x
</code></pre>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-baz">
<p>x <a href="#user-content-fnref-baz" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_25() {
    let original = r##"Lorem ipsum.[^a][^b]

[^a]: Foo
[^b]: Bar
"##;
    let expected = r##"<p>Lorem ipsum.<sup><a href="#user-content-fn-a" id="user-content-fnref-a" data-footnote-ref aria-describedby="footnote-label">1</a></sup><sup><a href="#user-content-fn-b" id="user-content-fnref-b" data-footnote-ref aria-describedby="footnote-label">2</a></sup></p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-a">
<p>Foo <a href="#user-content-fnref-a" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-fn-b">
<p>Bar <a href="#user-content-fnref-b" data-footnote-backref="" aria-label="Back to reference 2" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}

#[test]
fn footnotes_test_26() {
    let original = r##"Lorem ipsum.[^a] [^b]

[^a]: Foo
[^b]: Bar
"##;
    let expected = r##"<p>Lorem ipsum.<sup><a href="#user-content-fn-a" id="user-content-fnref-a" data-footnote-ref aria-describedby="footnote-label">1</a></sup> <sup><a href="#user-content-fn-b" id="user-content-fnref-b" data-footnote-ref aria-describedby="footnote-label">2</a></sup></p>
<section data-footnotes class="footnotes"><h2 class="sr-only" id="footnote-label">Footnotes</h2>
<ol>
<li id="user-content-fn-a">
<p>Foo <a href="#user-content-fnref-a" data-footnote-backref="" aria-label="Back to reference 1" class="data-footnote-backref">↩</a></p>
</li>
<li id="user-content-fn-b">
<p>Bar <a href="#user-content-fnref-b" data-footnote-backref="" aria-label="Back to reference 2" class="data-footnote-backref">↩</a></p>
</li>
</ol>
</section>
"##;

    test_markdown_html(original, expected, 2052, false, false, false, false, false, false);
}