Debian Codegraph @

tests/test_syntax/extensions/test_footnotes.py

raw
1 """
2 Python Markdown
3
4 A Python implementation of John Gruber's Markdown.
5
6 Documentation: https://python-markdown.github.io/
7 GitHub: https://github.com/Python-Markdown/markdown/
8 PyPI: https://pypi.org/project/Markdown/
9
10 Started by Manfred Stienstra (http://www.dwerg.net/).
11 Maintained for a few years by Yuri Takhteyev (http://www.freewisdom.org).
12 Currently maintained by Waylan Limberg (https://github.com/waylan),
13 Dmitry Shachnev (https://github.com/mitya57) and Isaac Muse (https://github.com/facelessuser).
14
15 Copyright 2007-2023 The Python Markdown Project (v. 1.7 and later)
16 Copyright 2004, 2005, 2006 Yuri Takhteyev (v. 0.2-1.6b)
17 Copyright 2004 Manfred Stienstra (the original version)
18
19 License: BSD (see LICENSE.md for details).
20 """
21
22 from markdown.test_tools import TestCase
23
24
25 class TestFootnotes(TestCase):
26
27 default_kwargs = {'extensions': ['footnotes']}
28 maxDiff = None
29
30 def test_basic_footnote(self):
31 self.assertMarkdownRenders(
32 self.dedent(
33 """
34 paragraph[^1]
35
36 [^1]: A Footnote
37 """
38 ),
39 '<p>paragraph<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></p>\n'
40 '<div class="footnote">\n'
41 '<hr />\n'
42 '<ol>\n'
43 '<li id="fn:1">\n'
44 '<p>A Footnote&#160;<a class="footnote-backref" href="#fnref:1"'
45 ' title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
46 '</li>\n'
47 '</ol>\n'
48 '</div>'
49 )
50
51 def test_multiple_footnotes(self):
52 self.assertMarkdownRenders(
53 self.dedent(
54 """
55 foo[^1]
56
57 bar[^2]
58
59 [^1]: Footnote 1
60 [^2]: Footnote 2
61 """
62 ),
63 '<p>foo<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></p>\n'
64 '<p>bar<sup id="fnref:2"><a class="footnote-ref" href="#fn:2">2</a></sup></p>\n'
65 '<div class="footnote">\n'
66 '<hr />\n'
67 '<ol>\n'
68 '<li id="fn:1">\n'
69 '<p>Footnote 1&#160;<a class="footnote-backref" href="#fnref:1"'
70 ' title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
71 '</li>\n'
72 '<li id="fn:2">\n'
73 '<p>Footnote 2&#160;<a class="footnote-backref" href="#fnref:2"'
74 ' title="Jump back to footnote 2 in the text">&#8617;</a></p>\n'
75 '</li>\n'
76 '</ol>\n'
77 '</div>'
78 )
79
80 def test_multiple_footnotes_multiline(self):
81 self.assertMarkdownRenders(
82 self.dedent(
83 """
84 foo[^1]
85
86 bar[^2]
87
88 [^1]: Footnote 1
89 line 2
90 [^2]: Footnote 2
91 """
92 ),
93 '<p>foo<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></p>\n'
94 '<p>bar<sup id="fnref:2"><a class="footnote-ref" href="#fn:2">2</a></sup></p>\n'
95 '<div class="footnote">\n'
96 '<hr />\n'
97 '<ol>\n'
98 '<li id="fn:1">\n'
99 '<p>Footnote 1\nline 2&#160;<a class="footnote-backref" href="#fnref:1"'
100 ' title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
101 '</li>\n'
102 '<li id="fn:2">\n'
103 '<p>Footnote 2&#160;<a class="footnote-backref" href="#fnref:2"'
104 ' title="Jump back to footnote 2 in the text">&#8617;</a></p>\n'
105 '</li>\n'
106 '</ol>\n'
107 '</div>'
108 )
109
110 def test_footnote_multi_line(self):
111 self.assertMarkdownRenders(
112 self.dedent(
113 """
114 paragraph[^1]
115 [^1]: A Footnote
116 line 2
117 """
118 ),
119 '<p>paragraph<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></p>\n'
120 '<div class="footnote">\n'
121 '<hr />\n'
122 '<ol>\n'
123 '<li id="fn:1">\n'
124 '<p>A Footnote\nline 2&#160;<a class="footnote-backref" href="#fnref:1"'
125 ' title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
126 '</li>\n'
127 '</ol>\n'
128 '</div>'
129 )
130
131 def test_footnote_multi_line_lazy_indent(self):
132 self.assertMarkdownRenders(
133 self.dedent(
134 """
135 paragraph[^1]
136 [^1]: A Footnote
137 line 2
138 """
139 ),
140 '<p>paragraph<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></p>\n'
141 '<div class="footnote">\n'
142 '<hr />\n'
143 '<ol>\n'
144 '<li id="fn:1">\n'
145 '<p>A Footnote\nline 2&#160;<a class="footnote-backref" href="#fnref:1"'
146 ' title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
147 '</li>\n'
148 '</ol>\n'
149 '</div>'
150 )
151
152 def test_footnote_multi_line_complex(self):
153 self.assertMarkdownRenders(
154 self.dedent(
155 """
156 paragraph[^1]
157
158 [^1]:
159
160 A Footnote
161 line 2
162
163 * list item
164
165 > blockquote
166 """
167 ),
168 '<p>paragraph<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></p>\n'
169 '<div class="footnote">\n'
170 '<hr />\n'
171 '<ol>\n'
172 '<li id="fn:1">\n'
173 '<p>A Footnote\nline 2</p>\n'
174 '<ul>\n<li>list item</li>\n</ul>\n'
175 '<blockquote>\n<p>blockquote</p>\n</blockquote>\n'
176 '<p><a class="footnote-backref" href="#fnref:1"'
177 ' title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
178 '</li>\n'
179 '</ol>\n'
180 '</div>'
181 )
182
183 def test_footnote_multple_complex(self):
184 self.assertMarkdownRenders(
185 self.dedent(
186 """
187 foo[^1]
188
189 bar[^2]
190
191 [^1]:
192
193 A Footnote
194 line 2
195
196 * list item
197
198 > blockquote
199
200 [^2]: Second footnote
201
202 paragraph 2
203 """
204 ),
205 '<p>foo<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></p>\n'
206 '<p>bar<sup id="fnref:2"><a class="footnote-ref" href="#fn:2">2</a></sup></p>\n'
207 '<div class="footnote">\n'
208 '<hr />\n'
209 '<ol>\n'
210 '<li id="fn:1">\n'
211 '<p>A Footnote\nline 2</p>\n'
212 '<ul>\n<li>list item</li>\n</ul>\n'
213 '<blockquote>\n<p>blockquote</p>\n</blockquote>\n'
214 '<p><a class="footnote-backref" href="#fnref:1"'
215 ' title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
216 '</li>\n'
217 '<li id="fn:2">\n'
218 '<p>Second footnote</p>\n'
219 '<p>paragraph 2&#160;<a class="footnote-backref" href="#fnref:2"'
220 ' title="Jump back to footnote 2 in the text">&#8617;</a></p>\n'
221 '</li>\n'
222 '</ol>\n'
223 '</div>'
224 )
225
226 def test_footnote_multple_complex_no_blank_line_between(self):
227 self.assertMarkdownRenders(
228 self.dedent(
229 """
230 foo[^1]
231
232 bar[^2]
233
234 [^1]:
235
236 A Footnote
237 line 2
238
239 * list item
240
241 > blockquote
242 [^2]: Second footnote
243
244 paragraph 2
245 """
246 ),
247 '<p>foo<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></p>\n'
248 '<p>bar<sup id="fnref:2"><a class="footnote-ref" href="#fn:2">2</a></sup></p>\n'
249 '<div class="footnote">\n'
250 '<hr />\n'
251 '<ol>\n'
252 '<li id="fn:1">\n'
253 '<p>A Footnote\nline 2</p>\n'
254 '<ul>\n<li>list item</li>\n</ul>\n'
255 '<blockquote>\n<p>blockquote</p>\n</blockquote>\n'
256 '<p><a class="footnote-backref" href="#fnref:1"'
257 ' title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
258 '</li>\n'
259 '<li id="fn:2">\n'
260 '<p>Second footnote</p>\n'
261 '<p>paragraph 2&#160;<a class="footnote-backref" href="#fnref:2"'
262 ' title="Jump back to footnote 2 in the text">&#8617;</a></p>\n'
263 '</li>\n'
264 '</ol>\n'
265 '</div>'
266 )
267
268 def test_backlink_text(self):
269 """Test back-link configuration."""
270
271 self.assertMarkdownRenders(
272 'paragraph[^1]\n\n[^1]: A Footnote',
273 '<p>paragraph<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></p>\n'
274 '<div class="footnote">\n'
275 '<hr />\n'
276 '<ol>\n'
277 '<li id="fn:1">\n'
278 '<p>A Footnote&#160;<a class="footnote-backref" href="#fnref:1"'
279 ' title="Jump back to footnote 1 in the text">back</a></p>\n'
280 '</li>\n'
281 '</ol>\n'
282 '</div>',
283 extension_configs={'footnotes': {'BACKLINK_TEXT': 'back'}}
284 )
285
286 def test_footnote_separator(self):
287 """Test separator configuration."""
288
289 self.assertMarkdownRenders(
290 'paragraph[^1]\n\n[^1]: A Footnote',
291 '<p>paragraph<sup id="fnref-1"><a class="footnote-ref" href="#fn-1">1</a></sup></p>\n'
292 '<div class="footnote">\n'
293 '<hr />\n'
294 '<ol>\n'
295 '<li id="fn-1">\n'
296 '<p>A Footnote&#160;<a class="footnote-backref" href="#fnref-1"'
297 ' title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
298 '</li>\n'
299 '</ol>\n'
300 '</div>',
301 extension_configs={'footnotes': {'SEPARATOR': '-'}}
302 )
303
304 def test_backlink_title(self):
305 """Test back-link title configuration without placeholder."""
306
307 self.assertMarkdownRenders(
308 'paragraph[^1]\n\n[^1]: A Footnote',
309 '<p>paragraph<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">1</a></sup></p>\n'
310 '<div class="footnote">\n'
311 '<hr />\n'
312 '<ol>\n'
313 '<li id="fn:1">\n'
314 '<p>A Footnote&#160;<a class="footnote-backref" href="#fnref:1"'
315 ' title="Jump back to footnote">&#8617;</a></p>\n'
316 '</li>\n'
317 '</ol>\n'
318 '</div>',
319 extension_configs={'footnotes': {'BACKLINK_TITLE': 'Jump back to footnote'}}
320 )
321
322 def test_superscript_text(self):
323 """Test superscript text configuration."""
324
325 self.assertMarkdownRenders(
326 'paragraph[^1]\n\n[^1]: A Footnote',
327 '<p>paragraph<sup id="fnref:1"><a class="footnote-ref" href="#fn:1">[1]</a></sup></p>\n'
328 '<div class="footnote">\n'
329 '<hr />\n'
330 '<ol>\n'
331 '<li id="fn:1">\n'
332 '<p>A Footnote&#160;<a class="footnote-backref" href="#fnref:1"'
333 ' title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
334 '</li>\n'
335 '</ol>\n'
336 '</div>',
337 extension_configs={'footnotes': {'SUPERSCRIPT_TEXT': '[{}]'}}
338 )
339
340 def test_footnote_order_by_doc_order(self):
341 """Test that footnotes occur in order of reference appearance when so configured."""
342
343 self.assertMarkdownRenders(
344 self.dedent(
345 """
346 First footnote reference[^first]. Second footnote reference[^last].
347
348 [^last]: Second footnote.
349 [^first]: First footnote.
350 """
351 ),
352 '<p>First footnote reference<sup id="fnref:first"><a class="footnote-ref" '
353 'href="#fn:first">1</a></sup>. Second footnote reference<sup id="fnref:last">'
354 '<a class="footnote-ref" href="#fn:last">2</a></sup>.</p>\n'
355 '<div class="footnote">\n'
356 '<hr />\n'
357 '<ol>\n'
358 '<li id="fn:first">\n'
359 '<p>First footnote.&#160;<a class="footnote-backref" href="#fnref:first" '
360 'title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
361 '</li>\n'
362 '<li id="fn:last">\n'
363 '<p>Second footnote.&#160;<a class="footnote-backref" href="#fnref:last" '
364 'title="Jump back to footnote 2 in the text">&#8617;</a></p>\n'
365 '</li>\n'
366 '</ol>\n'
367 '</div>',
368 extension_configs={'footnotes': {'USE_DEFINITION_ORDER': False}}
369 )
370
371 def test_footnote_order_tricky(self):
372 """Test a tricky sequence of footnote references."""
373
374 self.assertMarkdownRenders(
375 self.dedent(
376 """
377 `Footnote reference in code spans should be ignored[^tricky]`.
378 A footnote reference[^ordinary].
379 Another footnote reference[^tricky].
380
381 [^ordinary]: This should be the first footnote.
382 [^tricky]: This should be the second footnote.
383 """
384 ),
385 '<p><code>Footnote reference in code spans should be ignored[^tricky]</code>.\n'
386 'A footnote reference<sup id="fnref:ordinary">'
387 '<a class="footnote-ref" href="#fn:ordinary">1</a></sup>.\n'
388 'Another footnote reference<sup id="fnref:tricky">'
389 '<a class="footnote-ref" href="#fn:tricky">2</a></sup>.</p>\n'
390 '<div class="footnote">\n'
391 '<hr />\n'
392 '<ol>\n'
393 '<li id="fn:ordinary">\n'
394 '<p>This should be the first footnote.&#160;<a class="footnote-backref" '
395 'href="#fnref:ordinary" title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
396 '</li>\n'
397 '<li id="fn:tricky">\n'
398 '<p>This should be the second footnote.&#160;<a class="footnote-backref" '
399 'href="#fnref:tricky" title="Jump back to footnote 2 in the text">&#8617;</a></p>\n'
400 '</li>\n'
401 '</ol>\n'
402 '</div>'
403 )
404
405 def test_footnote_order_by_definition(self):
406 """Test that footnotes occur in order of definition occurrence when so configured."""
407
408 self.assertMarkdownRenders(
409 self.dedent(
410 """
411 First footnote reference[^last_def]. Second footnote reference[^first_def].
412
413 [^first_def]: First footnote.
414 [^last_def]: Second footnote.
415 """
416 ),
417 '<p>First footnote reference<sup id="fnref:last_def"><a class="footnote-ref" '
418 'href="#fn:last_def">2</a></sup>. Second footnote reference<sup id="fnref:first_def">'
419 '<a class="footnote-ref" href="#fn:first_def">1</a></sup>.</p>\n'
420 '<div class="footnote">\n'
421 '<hr />\n'
422 '<ol>\n'
423 '<li id="fn:first_def">\n'
424 '<p>First footnote.&#160;<a class="footnote-backref" href="#fnref:first_def" '
425 'title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
426 '</li>\n'
427 '<li id="fn:last_def">\n'
428 '<p>Second footnote.&#160;<a class="footnote-backref" href="#fnref:last_def" '
429 'title="Jump back to footnote 2 in the text">&#8617;</a></p>\n'
430 '</li>\n'
431 '</ol>\n'
432 '</div>',
433 extension_configs={'footnotes': {'USE_DEFINITION_ORDER': True}}
434 )
435
436 def test_footnote_reference_within_code_span(self):
437 """Test footnote reference within a code span."""
438
439 self.assertMarkdownRenders(
440 'A `code span with a footnote[^1] reference`.',
441 '<p>A <code>code span with a footnote[^1] reference</code>.</p>'
442 )
443
444 def test_footnote_reference_within_link(self):
445 """Test footnote reference within a link."""
446
447 self.assertMarkdownRenders(
448 'A [link with a footnote[^1] reference](http://example.com).',
449 '<p>A <a href="http://example.com">link with a footnote[^1] reference</a>.</p>'
450 )
451
452 def test_footnote_reference_within_footnote_definition(self):
453 """Test footnote definition containing another footnote reference."""
454
455 self.assertMarkdownRenders(
456 self.dedent(
457 """
458 Main footnote[^main].
459
460 [^main]: This footnote references another[^nested].
461 [^nested]: Nested footnote.
462 """
463 ),
464 '<p>Main footnote<sup id="fnref:main"><a class="footnote-ref" href="#fn:main">1</a></sup>.</p>\n'
465 '<div class="footnote">\n'
466 '<hr />\n'
467 '<ol>\n'
468 '<li id="fn:main">\n'
469 '<p>This footnote references another<sup id="fnref:nested"><a class="footnote-ref" '
470 'href="#fn:nested">2</a></sup>.&#160;<a class="footnote-backref" href="#fnref:main" '
471 'title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
472 '</li>\n'
473 '<li id="fn:nested">\n'
474 '<p>Nested footnote.&#160;<a class="footnote-backref" href="#fnref:nested" '
475 'title="Jump back to footnote 2 in the text">&#8617;</a></p>\n'
476 '</li>\n'
477 '</ol>\n'
478 '</div>'
479 )
480
481 def test_footnote_reference_within_blockquote(self):
482 """Test footnote reference within a blockquote."""
483
484 self.assertMarkdownRenders(
485 self.dedent(
486 """
487 > This is a quote with a footnote[^quote].
488
489 [^quote]: Quote footnote.
490 """
491 ),
492 '<blockquote>\n'
493 '<p>This is a quote with a footnote<sup id="fnref:quote">'
494 '<a class="footnote-ref" href="#fn:quote">1</a></sup>.</p>\n'
495 '</blockquote>\n'
496 '<div class="footnote">\n'
497 '<hr />\n'
498 '<ol>\n'
499 '<li id="fn:quote">\n'
500 '<p>Quote footnote.&#160;<a class="footnote-backref" href="#fnref:quote" '
501 'title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
502 '</li>\n'
503 '</ol>\n'
504 '</div>'
505 )
506
507 def test_footnote_reference_within_list(self):
508 """Test footnote reference within a list item."""
509
510 self.assertMarkdownRenders(
511 self.dedent(
512 """
513 1. First item with footnote[^note]
514 1. Second item
515
516 [^note]: List footnote.
517 """
518 ),
519 '<ol>\n'
520 '<li>First item with footnote<sup id="fnref:note">'
521 '<a class="footnote-ref" href="#fn:note">1</a></sup></li>\n'
522 '<li>Second item</li>\n'
523 '</ol>\n'
524 '<div class="footnote">\n'
525 '<hr />\n'
526 '<ol>\n'
527 '<li id="fn:note">\n'
528 '<p>List footnote.&#160;<a class="footnote-backref" href="#fnref:note" '
529 'title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
530 '</li>\n'
531 '</ol>\n'
532 '</div>'
533 )
534
535 def test_footnote_references_within_loose_list(self):
536 """Test footnote references within loose list items."""
537
538 self.assertMarkdownRenders(
539 self.dedent(
540 '''
541 * Reference to [^first]
542
543 * Reference to [^second]
544
545 [^first]: First footnote definition
546 [^second]: Second footnote definition
547 '''
548 ),
549 '<ul>\n'
550 '<li>\n'
551 '<p>Reference to <sup id="fnref:first"><a class="footnote-ref" href="#fn:first">1</a></sup></p>\n'
552 '</li>\n'
553 '<li>\n'
554 '<p>Reference to <sup id="fnref:second"><a class="footnote-ref" href="#fn:second">2</a></sup></p>\n'
555 '</li>\n'
556 '</ul>\n'
557 '<div class="footnote">\n'
558 '<hr />\n'
559 '<ol>\n'
560 '<li id="fn:first">\n'
561 '<p>First footnote definition&#160;<a class="footnote-backref" href="#fnref:first" '
562 'title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
563 '</li>\n'
564 '<li id="fn:second">\n'
565 '<p>Second footnote definition&#160;<a class="footnote-backref" href="#fnref:second" '
566 'title="Jump back to footnote 2 in the text">&#8617;</a></p>\n'
567 '</li>\n'
568 '</ol>\n'
569 '</div>'
570 )
571
572 def test_footnote_reference_within_html(self):
573 """Test footnote reference within HTML tags."""
574
575 self.assertMarkdownRenders(
576 self.dedent(
577 """
578 A <span>footnote reference[^1] within a span element</span>.
579
580 [^1]: The footnote.
581 """
582 ),
583 '<p>A <span>footnote reference<sup id="fnref:1">'
584 '<a class="footnote-ref" href="#fn:1">1</a>'
585 '</sup> within a span element</span>.</p>\n'
586 '<div class="footnote">\n'
587 '<hr />\n'
588 '<ol>\n'
589 '<li id="fn:1">\n'
590 '<p>The footnote.&#160;<a class="footnote-backref" href="#fnref:1" '
591 'title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
592 '</li>\n'
593 '</ol>\n'
594 '</div>'
595 )
596
597 def test_duplicate_footnote_references(self):
598 """Test multiple references to the same footnote."""
599
600 self.assertMarkdownRenders(
601 self.dedent(
602 """
603 First[^dup] and second[^dup] reference.
604
605 [^dup]: Duplicate footnote.
606 """
607 ),
608 '<p>First<sup id="fnref:dup">'
609 '<a class="footnote-ref" href="#fn:dup">1</a></sup> and second<sup id="fnref2:dup">'
610 '<a class="footnote-ref" href="#fn:dup">1</a></sup> reference.</p>\n'
611 '<div class="footnote">\n'
612 '<hr />\n'
613 '<ol>\n'
614 '<li id="fn:dup">\n'
615 '<p>Duplicate footnote.&#160;'
616 '<a class="footnote-backref" href="#fnref:dup" '
617 'title="Jump back to footnote 1 in the text">&#8617;</a>'
618 '<a class="footnote-backref" href="#fnref2:dup" '
619 'title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
620 '</li>\n'
621 '</ol>\n'
622 '</div>'
623 )
624
625 def test_footnote_reference_without_definition(self):
626 """Test footnote reference without corresponding definition."""
627
628 self.assertMarkdownRenders(
629 'This has a missing footnote[^missing].',
630 '<p>This has a missing footnote[^missing].</p>'
631 )
632
633 def test_footnote_definition_without_reference(self):
634 """Test footnote definition without corresponding reference."""
635
636 self.assertMarkdownRenders(
637 self.dedent(
638 """
639 No reference here.
640
641 [^orphan]: Orphaned footnote.
642 """
643 ),
644 '<p>No reference here.</p>\n'
645 '<div class="footnote">\n'
646 '<hr />\n'
647 '<ol>\n'
648 '<li id="fn:orphan">\n'
649 '<p>Orphaned footnote.&#160;<a class="footnote-backref" href="#fnref:orphan" '
650 'title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
651 '</li>\n'
652 '</ol>\n'
653 '</div>'
654 )
655
656 def test_footnote_id_with_special_chars(self):
657 """Test footnote id containing special and Unicode characters."""
658
659 self.assertMarkdownRenders(
660 self.dedent(
661 """
662 Special footnote id[^!#¤%/()=?+}{§øé].
663
664 [^!#¤%/()=?+}{§øé]: The footnote.
665 """
666 ),
667 '<p>Special footnote id<sup id="fnref:!#¤%/()=?+}{§øé">'
668 '<a class="footnote-ref" href="#fn:!#¤%/()=?+}{§øé">1</a></sup>.</p>\n'
669 '<div class="footnote">\n'
670 '<hr />\n'
671 '<ol>\n'
672 '<li id="fn:!#¤%/()=?+}{§øé">\n'
673 '<p>The footnote.&#160;<a class="footnote-backref" href="#fnref:!#¤%/()=?+}{§øé" '
674 'title="Jump back to footnote 1 in the text">&#8617;</a></p>\n'
675 '</li>\n'
676 '</ol>\n'
677 '</div>'
678 )