2 # -*- coding: utf-8 -*-
5 # Author: David Goodger <goodger@python.org>
6 # Copyright: This module has been placed in the public domain.
9 Tests for inline markup in docutils/parsers/rst/states.py.
10 Interpreted text tests are in a separate module, test_interpreted.py.
13 from __init__
import DocutilsTestSupport
16 s
= DocutilsTestSupport
.ParserTestSuite()
17 s
.generateTests(totest
)
22 totest
['emphasis'] = [
27 <document source="test data">
33 l'*emphasis* with the *emphasis*' apostrophe.
34 l\u2019*emphasis* with the *emphasis*\u2019 apostrophe.
37 <document source="test data">
59 <document source="test data">
66 *emphasis without closing asterisk
69 <document source="test data">
71 <problematic ids="id2" refid="id1">
73 emphasis without closing asterisk
74 <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
76 Inline emphasis start-string without end-string.
78 [r
"""some punctuation is allowed around inline markup, e.g.
79 /*emphasis*/, -*emphasis*-, and :*emphasis*: (delimiters),
80 (*emphasis*), [*emphasis*], <*emphasis*>, {*emphasis*} (open/close pairs)
81 *emphasis*., *emphasis*,, *emphasis*!, and *emphasis*\ (closing delimiters),
84 )*emphasis*(, ]*emphasis*[, >*emphasis*>, }*emphasis*{ (close/open pairs),
85 (*), [*], '*' or '"*"' ("quoted" start-string),
86 x*2* or 2*x* (alphanumeric char before),
87 \*args or * (escaped, whitespace behind start-string),
88 or *the\* *stars\* *inside* (escaped, whitespace before end-string).
90 However, '*args' will trigger a warning and may be problematic.
95 <document source="test data">
97 some punctuation is allowed around inline markup, e.g.
132 (closing delimiters),
135 )*emphasis*(, ]*emphasis*[, >*emphasis*>, }*emphasis*{ (close/open pairs),
136 (*), [*], '*' or '"*"' ("quoted" start-string),
137 x*2* or 2*x* (alphanumeric char before),
138 *args or * (escaped, whitespace behind start-string),
142 (escaped, whitespace before end-string).
145 <problematic ids="id2" refid="id1">
147 args' will trigger a warning and may be problematic.
148 <system_message backrefs="id2" ids="id1" level="2" line="13" source="test data" type="WARNING">
150 Inline emphasis start-string without end-string.
158 Quotes around inline markup:
160 '*emphasis*' "*emphasis*" Straight,
161 ‘*emphasis*’ “*emphasis*” English, ...,
162 « *emphasis* » ‹ *emphasis* › « *emphasis* » ‹ *emphasis* ›
163 « *emphasis* » ‹ *emphasis* › French,
164 „*emphasis*“ ‚*emphasis*‘ »*emphasis*« ›*emphasis*‹ German, Czech, ...,
165 „*emphasis*” «*emphasis*» Romanian,
166 “*emphasis*„ ‘*emphasis*‚ Greek,
167 「*emphasis*」 『*emphasis*』traditional Chinese,
168 ”*emphasis*” ’*emphasis*’ »*emphasis*» ›*emphasis*› Swedish, Finnish,
169 „*emphasis*” ‚*emphasis*’ Polish,
170 „*emphasis*” »*emphasis*« ’*emphasis*’ Hungarian,
173 <document source="test data">
175 Quotes around inline markup:
194 \u202f\xbb \u2039\u202f
197 \u202f\u203a \xab\xa0
207 \u2005\xbb \u2039\u2005
223 \u2039 German, Czech, ...,
244 \u300ftraditional Chinese,
257 \u203a Swedish, Finnish,
277 Emphasized asterisk: *\**
279 Emphasized double asterisk: *\***
282 <document source="test data">
284 Emphasized asterisk: \n\
288 Emphasized double asterisk: \n\
299 <document source="test data">
305 l'**strong** and l\u2019**strong** with apostrophe
308 <document source="test data">
319 quoted '**strong**', quoted "**strong**",
320 quoted \u2018**strong**\u2019, quoted \u201c**strong**\u201d,
321 quoted \xab**strong**\xbb
324 <document source="test data">
336 \u2019, quoted \u201c
346 (**strong**) but not (**) or '(** ' or x**2 or \**kwargs or **
348 (however, '**kwargs' will trigger a warning and may be problematic)
351 <document source="test data">
356 ) but not (**) or '(** ' or x**2 or **kwargs or **
359 <problematic ids="id2" refid="id1">
361 kwargs' will trigger a warning and may be problematic)
362 <system_message backrefs="id2" ids="id1" level="2" line="4" source="test data" type="WARNING">
364 Inline strong start-string without end-string.
367 Strong asterisk: *****
369 Strong double asterisk: ******
372 <document source="test data">
378 Strong double asterisk: \n\
383 **strong without closing asterisks
386 <document source="test data">
388 <problematic ids="id2" refid="id1">
390 strong without closing asterisks
391 <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
393 Inline strong start-string without end-string.
397 totest
['literal'] = [
402 <document source="test data">
411 <document source="test data">
420 <document source="test data">
429 <document source="test data">
435 l'``literal`` and l\u2019``literal`` with apostrophe
438 <document source="test data">
449 quoted '``literal``', quoted "``literal``",
450 quoted \u2018``literal``\u2019, quoted \u201c``literal``\u201d,
451 quoted \xab``literal``\xbb
454 <document source="test data">
466 \u2019, quoted \u201c
476 ``'literal'`` with quotes, ``"literal"`` with quotes,
477 ``\u2018literal\u2019`` with quotes, ``\u201cliteral\u201d`` with quotes,
478 ``\xabliteral\xbb`` with quotes
481 <document source="test data">
500 ``literal ``TeX quotes'' & \backslash`` but not "``" or ``
502 (however, ``standalone TeX quotes'' will trigger a warning
503 and may be problematic)
506 <document source="test data">
509 literal ``TeX quotes'' & \\backslash
513 <problematic ids="id2" refid="id1">
515 standalone TeX quotes'' will trigger a warning
516 and may be problematic)
517 <system_message backrefs="id2" ids="id1" level="2" line="4" source="test data" type="WARNING">
519 Inline literal start-string without end-string.
522 Find the ```interpreted text``` in this paragraph!
525 <document source="test data">
533 ``literal without closing backquotes
536 <document source="test data">
538 <problematic ids="id2" refid="id1">
540 literal without closing backquotes
541 <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
543 Inline literal start-string without end-string.
546 Python ``list``\s use square bracket syntax.
549 <document source="test data">
554 s use square bracket syntax.
558 totest
['references'] = [
563 <document source="test data">
565 <reference name="ref" refname="ref">
569 l'ref_ and l\u2019ref_ with apostrophe
572 <document source="test data">
575 <reference name="ref" refname="ref">
578 <reference name="ref" refname="ref">
583 quoted 'ref_', quoted "ref_",
584 quoted \u2018ref_\u2019, quoted \u201cref_\u201d,
586 but not 'ref ref'_, "ref ref"_, \u2018ref ref\u2019_,
587 \u201cref ref\u201d_, or \xabref ref\xbb_
590 <document source="test data">
593 <reference name="ref" refname="ref">
596 <reference name="ref" refname="ref">
600 <reference name="ref" refname="ref">
602 \u2019, quoted \u201c
603 <reference name="ref" refname="ref">
607 <reference name="ref" refname="ref">
610 but not 'ref ref'_, "ref ref"_, \u2018ref ref\u2019_,
611 \u201cref ref\u201d_, or \xabref ref\xbb_
617 <document source="test data">
619 <reference anonymous="1" name="ref">
623 l'ref__ and l\u2019ref__ with apostrophe
626 <document source="test data">
629 <reference anonymous="1" name="ref">
632 <reference anonymous="1" name="ref">
637 quoted 'ref__', quoted "ref__",
638 quoted \u2018ref__\u2019, quoted \u201cref__\u201d,
639 quoted \xabref__\xbb,
640 but not 'ref ref'__, "ref ref"__, \u2018ref ref\u2019__,
641 \u201cref ref\u201d__, or \xabref ref\xbb__
644 <document source="test data">
647 <reference anonymous="1" name="ref">
650 <reference anonymous="1" name="ref">
654 <reference anonymous="1" name="ref">
656 \u2019, quoted \u201c
657 <reference anonymous="1" name="ref">
661 <reference anonymous="1" name="ref">
664 but not 'ref ref'__, "ref ref"__, \u2018ref ref\u2019__,
665 \u201cref ref\u201d__, or \xabref ref\xbb__
668 ref_, r_, r_e-f_, -ref_, and anonymousref__,
669 but not _ref_ or __attr__ or object.__attr__
672 <document source="test data">
674 <reference name="ref" refname="ref">
677 <reference name="r" refname="r">
680 <reference name="r_e-f" refname="r_e-f">
683 <reference name="ref" refname="ref">
686 <reference anonymous="1" name="anonymousref">
689 but not _ref_ or __attr__ or object.__attr__
693 totest
['phrase_references'] = [
698 <document source="test data">
700 <reference name="phrase reference" refname="phrase reference">
704 l'`phrase reference`_ and l\u2019`phrase reference`_ with apostrophe
707 <document source="test data">
710 <reference name="phrase reference" refname="phrase reference">
713 <reference name="phrase reference" refname="phrase reference">
718 quoted '`phrase reference`_', quoted "`phrase reference`_",
719 quoted \u2018`phrase reference`_\u2019,
720 quoted \u201c`phrase reference`_\u201d,
721 quoted \xab`phrase reference`_\xbb
724 <document source="test data">
727 <reference name="phrase reference" refname="phrase reference">
730 <reference name="phrase reference" refname="phrase reference">
734 <reference name="phrase reference" refname="phrase reference">
738 <reference name="phrase reference" refname="phrase reference">
742 <reference name="phrase reference" refname="phrase reference">
747 `'phrase reference'`_ with quotes, `"phrase reference"`_ with quotes,
748 `\u2018phrase reference\u2019`_ with quotes,
749 `\u201cphrase reference\u201d`_ with quotes,
750 `\xabphrase reference\xbb`_ with quotes
753 <document source="test data">
755 <reference name="'phrase reference'" refname="'phrase reference'">
758 <reference name=""phrase reference"" refname=""phrase reference"">
761 <reference name="\u2018phrase reference\u2019" refname="\u2018phrase reference\u2019">
762 \u2018phrase reference\u2019
764 <reference name="\u201cphrase reference\u201d" refname="\u201cphrase reference\u201d">
765 \u201cphrase reference\u201d
767 <reference name="\xabphrase reference\xbb" refname="\xabphrase reference\xbb">
768 \xabphrase reference\xbb
772 `anonymous reference`__
775 <document source="test data">
777 <reference anonymous="1" name="anonymous reference">
781 l'`anonymous reference`__ and l\u2019`anonymous reference`__ with apostrophe
784 <document source="test data">
787 <reference anonymous="1" name="anonymous reference">
790 <reference anonymous="1" name="anonymous reference">
795 quoted '`anonymous reference`__', quoted "`anonymous reference`__",
796 quoted \u2018`anonymous reference`__\u2019,
797 quoted \u201c`anonymous reference`__\u201d,
798 quoted \xab`anonymous reference`__\xbb
801 <document source="test data">
804 <reference anonymous="1" name="anonymous reference">
807 <reference anonymous="1" name="anonymous reference">
811 <reference anonymous="1" name="anonymous reference">
815 <reference anonymous="1" name="anonymous reference">
819 <reference anonymous="1" name="anonymous reference">
824 `'anonymous reference'`__ with quotes, `"anonymous reference"`__ with quotes,
825 `\u2018anonymous reference\u2019`__ with quotes,
826 `\u201canonymous reference\u201d`__ with quotes,
827 `\xabanonymous reference\xbb`__ with quotes
830 <document source="test data">
832 <reference anonymous="1" name="'anonymous reference'">
833 'anonymous reference'
835 <reference anonymous="1" name=""anonymous reference"">
836 "anonymous reference"
838 <reference anonymous="1" name="\u2018anonymous reference\u2019">
839 \u2018anonymous reference\u2019
841 <reference anonymous="1" name="\u201canonymous reference\u201d">
842 \u201canonymous reference\u201d
844 <reference anonymous="1" name="\xabanonymous reference\xbb">
845 \xabanonymous reference\xbb
853 <document source="test data">
855 <reference name="phrase reference across lines" refname="phrase reference across lines">
860 `phrase\`_ reference`_
863 <document source="test data">
865 <reference name="phrase`_ reference" refname="phrase`_ reference">
869 Invalid phrase reference:
871 :role:`phrase reference`_
874 <document source="test data">
876 Invalid phrase reference:
878 <problematic ids="id2" refid="id1">
879 :role:`phrase reference`_
880 <system_message backrefs="id2" ids="id1" level="2" line="3" source="test data" type="WARNING">
882 Mismatch: both interpreted text role prefix and reference suffix.
885 Invalid phrase reference:
887 `phrase reference`:role:_
890 <document source="test data">
892 Invalid phrase reference:
894 <problematic ids="id2" refid="id1">
895 `phrase reference`:role:_
896 <system_message backrefs="id2" ids="id1" level="2" line="3" source="test data" type="WARNING">
898 Mismatch: both interpreted text role suffix and reference suffix.
901 `phrase reference_ without closing backquote
904 <document source="test data">
906 <problematic ids="id2" refid="id1">
909 <reference name="reference" refname="reference">
911 without closing backquote
912 <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
914 Inline interpreted text or phrase reference start-string without end-string.
917 `anonymous phrase reference__ without closing backquote
920 <document source="test data">
922 <problematic ids="id2" refid="id1">
925 <reference anonymous="1" name="reference">
927 without closing backquote
928 <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
930 Inline interpreted text or phrase reference start-string without end-string.
934 totest
['embedded_URIs'] = [
936 `phrase reference <http://example.com>`_
939 <document source="test data">
941 <reference name="phrase reference" refuri="http://example.com">
943 <target ids="phrase-reference" names="phrase\ reference" refuri="http://example.com">
946 `anonymous reference <http://example.com>`__
949 <document source="test data">
951 <reference name="anonymous reference" refuri="http://example.com">
955 `embedded URI on next line
956 <http://example.com>`__
959 <document source="test data">
961 <reference name="embedded URI on next line" refuri="http://example.com">
962 embedded URI on next line
965 `embedded URI across lines <http://example.com/
969 <document source="test data">
971 <reference name="embedded URI across lines" refuri="http://example.com/long/path">
972 embedded URI across lines
975 `embedded URI with whitespace <http://example.com/
976 long/path /and /whitespace>`__
979 <document source="test data">
981 <reference name="embedded URI with whitespace" refuri="http://example.com/long/path/and/whitespace">
982 embedded URI with whitespace
985 `embedded URI with escaped whitespace <http://example.com/a\
986 long/path\ and/some\ escaped\ whitespace>`__
988 `<omitted\ reference\ text\ with\ escaped\ whitespace>`__
991 <document source="test data">
993 <reference name="embedded URI with escaped whitespace" refuri="http://example.com/a long/path and/some escaped whitespace">
994 embedded URI with escaped whitespace
996 <reference name="omitted reference text with escaped whitespace" refuri="omitted reference text with escaped whitespace">
997 omitted reference text with escaped whitespace
1000 `embedded email address <jdoe@example.com>`__
1002 `embedded email address broken across lines <jdoe
1006 <document source="test data">
1008 <reference name="embedded email address" refuri="mailto:jdoe@example.com">
1009 embedded email address
1011 <reference name="embedded email address broken across lines" refuri="mailto:jdoe@example.com">
1012 embedded email address broken across lines
1015 `embedded URI with too much whitespace < http://example.com/
1016 long/path /and /whitespace >`__
1018 `embedded URI with too much whitespace at end <http://example.com/
1019 long/path /and /whitespace >`__
1021 `embedded URI with no preceding whitespace<http://example.com>`__
1023 `escaped URI \<http://example.com>`__
1025 See `HTML Anchors: \<a>`_.
1028 <document source="test data">
1030 <reference anonymous="1" name="embedded URI with too much whitespace < http://example.com/ long/path /and /whitespace >">
1031 embedded URI with too much whitespace < http://example.com/
1032 long/path /and /whitespace >
1034 <reference anonymous="1" name="embedded URI with too much whitespace at end <http://example.com/ long/path /and /whitespace >">
1035 embedded URI with too much whitespace at end <http://example.com/
1036 long/path /and /whitespace >
1038 <reference anonymous="1" name="embedded URI with no preceding whitespace<http://example.com>">
1039 embedded URI with no preceding whitespace<http://example.com>
1041 <reference anonymous="1" name="escaped URI <http://example.com>">
1042 escaped URI <http://example.com>
1045 <reference name="HTML Anchors: <a>" refname="html anchors: <a>">
1050 Relative URIs' reference text can be omitted:
1057 <document source="test data">
1059 Relative URIs' reference text can be omitted:
1061 <reference name="reference" refuri="reference">
1063 <target ids="reference" names="reference" refuri="reference">
1065 <reference name="anonymous" refuri="anonymous">
1069 Escape trailing low-line char in URIs:
1076 <document source="test data">
1078 Escape trailing low-line char in URIs:
1080 <reference name="reference_" refuri="reference_">
1082 <target ids="reference" names="reference_" refuri="reference_">
1084 <reference name="anonymous_" refuri="anonymous_">
1088 Escape other char in URIs:
1092 `<anonymous\\call>`__
1095 <document source="test data">
1097 Escape other char in URIs:
1099 <reference name="reference:1" refuri="reference:1">
1101 <target ids="reference-1" names="reference:1" refuri="reference:1">
1103 <reference name="anonymouscall" refuri="anonymouscall">
1108 totest
['embedded_aliases'] = [
1110 `phrase reference <alias_>`_
1113 <document source="test data">
1115 <reference name="phrase reference" refname="alias">
1117 <target names="phrase\ reference" refname="alias">
1120 `anonymous reference <alias_>`__
1123 <document source="test data">
1125 <reference name="anonymous reference" refname="alias">
1129 `embedded alias on next line
1133 <document source="test data">
1135 <reference name="embedded alias on next line" refname="alias">
1136 embedded alias on next line
1139 `embedded alias across lines <alias
1143 <document source="test data">
1145 <reference name="embedded alias across lines" refname="alias phrase">
1146 embedded alias across lines
1149 `embedded alias with whitespace <alias
1153 <document source="test data">
1155 <reference name="embedded alias with whitespace" refname="alias long phrase">
1156 embedded alias with whitespace
1159 `<embedded alias with whitespace_>`__
1162 <document source="test data">
1164 <reference name="embedded alias with whitespace" refname="embedded alias with whitespace">
1165 embedded alias with whitespace
1168 `no embedded alias (whitespace inside bracket) < alias_ >`__
1170 `no embedded alias (no preceding whitespace)<alias_>`__
1173 <document source="test data">
1175 <reference anonymous="1" name="no embedded alias (whitespace inside bracket) < alias_ >">
1176 no embedded alias (whitespace inside bracket) < alias_ >
1178 <reference anonymous="1" name="no embedded alias (no preceding whitespace)<alias_>">
1179 no embedded alias (no preceding whitespace)<alias_>
1182 `anonymous reference <alias\ with\\ escaped \:characters_>`__
1185 <document source="test data">
1187 <reference name="anonymous reference" refname="aliaswith\ escaped :characters">
1191 `anonymous reference <alias\ with\\ escaped \:characters_>`__
1194 <document source="test data">
1196 <reference name="anonymous reference" refname="aliaswith\ escaped :characters">
1201 totest
['inline_targets'] = [
1205 Here is _`another target` in some text. And _`yet
1206 another target`, spanning lines.
1208 _`Here is a TaRgeT` with case and spacial difficulties.
1211 <document source="test data">
1213 <target ids="target" names="target">
1217 <target ids="another-target" names="another\ target">
1219 in some text. And \n\
1220 <target ids="yet-another-target" names="yet\ another\ target">
1225 <target ids="here-is-a-target" names="here\ is\ a\ target">
1227 with case and spacial difficulties.
1230 l'_`target1` and l\u2019_`target2` with apostrophe
1233 <document source="test data">
1236 <target ids="target1" names="target1">
1239 <target ids="target2" names="target2">
1244 quoted '_`target1`', quoted "_`target2`",
1245 quoted \u2018_`target3`\u2019, quoted \u201c_`target4`\u201d,
1246 quoted \xab_`target5`\xbb
1249 <document source="test data">
1252 <target ids="target1" names="target1">
1255 <target ids="target2" names="target2">
1259 <target ids="target3" names="target3">
1261 \u2019, quoted \u201c
1262 <target ids="target4" names="target4">
1266 <target ids="target5" names="target5">
1271 _`'target1'` with quotes, _`"target2"` with quotes,
1272 _`\u2018target3\u2019` with quotes, _`\u201ctarget4\u201d` with quotes,
1273 _`\xabtarget5\xbb` with quotes
1276 <document source="test data">
1278 <target ids="target1" names="'target1'">
1281 <target ids="target2" names=""target2"">
1284 <target ids="target3" names="\u2018target3\u2019">
1287 <target ids="target4" names="\u201ctarget4\u201d">
1290 <target ids="target5" names="\xabtarget5\xbb">
1295 But this isn't a _target; targets require backquotes.
1297 And _`this`_ is just plain confusing.
1300 <document source="test data">
1302 But this isn't a _target; targets require backquotes.
1305 <problematic ids="id2" refid="id1">
1307 this`_ is just plain confusing.
1308 <system_message backrefs="id2" ids="id1" level="2" line="3" source="test data" type="WARNING">
1310 Inline target start-string without end-string.
1313 _`inline target without closing backquote
1316 <document source="test data">
1318 <problematic ids="id2" refid="id1">
1320 inline target without closing backquote
1321 <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
1323 Inline target start-string without end-string.
1327 totest
['footnote_reference'] = [
1332 <document source="test data">
1334 <footnote_reference ids="id1" refname="1">
1341 <document source="test data">
1343 <footnote_reference auto="1" ids="id1">
1349 <document source="test data">
1351 <footnote_reference auto="1" ids="id1" refname="label">
1357 <document source="test data">
1359 <footnote_reference auto="*" ids="id1">
1362 Adjacent footnote refs are not possible: [*]_[#label]_ [#]_[2]_ [1]_[*]_
1365 <document source="test data">
1367 Adjacent footnote refs are not possible: [*]_[#label]_ [#]_[2]_ [1]_[*]_
1371 totest
['citation_reference'] = [
1376 <document source="test data">
1378 <citation_reference ids="id1" refname="citation">
1382 [citation]_ and [cit-ation]_ and [cit.ation]_ and [CIT1]_ but not [CIT 1]_
1385 <document source="test data">
1387 <citation_reference ids="id1" refname="citation">
1390 <citation_reference ids="id2" refname="cit-ation">
1393 <citation_reference ids="id3" refname="cit.ation">
1396 <citation_reference ids="id4" refname="cit1">
1401 Adjacent citation refs are not possible: [citation]_[CIT1]_
1404 <document source="test data">
1406 Adjacent citation refs are not possible: [citation]_[CIT1]_
1410 totest
['substitution_references'] = [
1415 <document source="test data">
1417 <substitution_reference refname="subref">
1421 |subref|_ and |subref|__
1424 <document source="test data">
1426 <reference refname="subref">
1427 <substitution_reference refname="subref">
1430 <reference anonymous="1">
1431 <substitution_reference refname="subref">
1435 |substitution reference|
1438 <document source="test data">
1440 <substitution_reference refname="substitution reference">
1441 substitution reference
1448 <document source="test data">
1450 <substitution_reference refname="substitution reference">
1455 |substitution reference without closing verbar
1458 <document source="test data">
1460 <problematic ids="id2" refid="id1">
1462 substitution reference without closing verbar
1463 <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
1465 Inline substitution_reference start-string without end-string.
1468 first | then || and finally |||
1471 <document source="test data">
1473 first | then || and finally |||
1477 totest
['standalone_hyperlink'] = [
1479 http://www.standalone.hyperlink.com
1481 http:/one-slash-only.absolute.path
1483 [http://example.com]
1485 (http://example.com)
1487 <http://example.com>
1489 http://[1080:0:0:0:8:800:200C:417A]/IPv6address.html
1491 http://[3ffe:2a00:100:7031::1] (the final "]" is ambiguous in text)
1493 http://[3ffe:2a00:100:7031::1]/
1495 mailto:someone@somewhere.com
1497 news:comp.lang.python
1499 An email address in a sentence: someone@somewhere.com.
1501 ftp://ends.with.a.period.
1503 (a.question.mark@end?)
1506 <document source="test data">
1508 <reference refuri="http://www.standalone.hyperlink.com">
1509 http://www.standalone.hyperlink.com
1511 <reference refuri="http:/one-slash-only.absolute.path">
1512 http:/one-slash-only.absolute.path
1515 <reference refuri="http://example.com">
1520 <reference refuri="http://example.com">
1525 <reference refuri="http://example.com">
1529 <reference refuri="http://[1080:0:0:0:8:800:200C:417A]/IPv6address.html">
1530 http://[1080:0:0:0:8:800:200C:417A]/IPv6address.html
1532 <reference refuri="http://[3ffe:2a00:100:7031::1">
1533 http://[3ffe:2a00:100:7031::1
1534 ] (the final "]" is ambiguous in text)
1536 <reference refuri="http://[3ffe:2a00:100:7031::1]/">
1537 http://[3ffe:2a00:100:7031::1]/
1539 <reference refuri="mailto:someone@somewhere.com">
1540 mailto:someone@somewhere.com
1542 <reference refuri="news:comp.lang.python">
1543 news:comp.lang.python
1545 An email address in a sentence: \n\
1546 <reference refuri="mailto:someone@somewhere.com">
1547 someone@somewhere.com
1550 <reference refuri="ftp://ends.with.a.period">
1551 ftp://ends.with.a.period
1555 <reference refuri="mailto:a.question.mark@end">
1560 Valid URLs with escaped markup characters:
1562 http://example.com/\*content\*/whatever
1564 http://example.com/\*content*/whatever
1567 <document source="test data">
1569 Valid URLs with escaped markup characters:
1571 <reference refuri="http://example.com/*content*/whatever">
1572 http://example.com/*content*/whatever
1574 <reference refuri="http://example.com/*content*/whatever">
1575 http://example.com/*content*/whatever
1578 Valid URLs may end with punctuation inside "<>":
1580 <http://example.org/ends-with-dot.>
1583 <document source="test data">
1585 Valid URLs may end with punctuation inside "<>":
1588 <reference refuri="http://example.org/ends-with-dot.">
1589 http://example.org/ends-with-dot.
1593 Valid URLs with interesting endings:
1595 http://example.org/ends-with-pluses++
1598 <document source="test data">
1600 Valid URLs with interesting endings:
1602 <reference refuri="http://example.org/ends-with-pluses++">
1603 http://example.org/ends-with-pluses++
1606 None of these are standalone hyperlinks (their "schemes"
1607 are not recognized): signal:noise, a:b.
1610 <document source="test data">
1612 None of these are standalone hyperlinks (their "schemes"
1613 are not recognized): signal:noise, a:b.
1616 Escaped email addresses are not recognized: test\@example.org
1619 <document source="test data">
1621 Escaped email addresses are not recognized: test@example.org
1625 totest
['markup recognition rules'] = [
1627 __This__ should be left alone.
1630 <document source="test data">
1632 __This__ should be left alone.
1635 Character-level m\ *a*\ **r**\ ``k``\ `u`:title:\p
1636 with backslash-escaped whitespace, including new\
1640 <document source="test data">
1652 with backslash-escaped whitespace, including newlines.
1655 text-*separated*\u2010*by*\u2011*various*\u2012*dashes*\u2013*and*\u2014*hyphens*.
1656 \u00bf*punctuation*? \u00a1*examples*!\u00a0*\u00a0no-break-space\u00a0*.
1659 <document source="test data">
1688 \u00a0no-break-space\u00a0
1691 # Whitespace characters:
1692 # \u180e*MONGOLIAN VOWEL SEPARATOR*\u180e, fails in Python 2.4
1696 or *space* or one of
1697 \xa0*NO-BREAK SPACE*\xa0,
1698 \u1680*OGHAM SPACE MARK*\u1680,
1699 \u2000*EN QUAD*\u2000,
1700 \u2001*EM QUAD*\u2001,
1701 \u2002*EN SPACE*\u2002,
1702 \u2003*EM SPACE*\u2003,
1703 \u2004*THREE-PER-EM SPACE*\u2004,
1704 \u2005*FOUR-PER-EM SPACE*\u2005,
1705 \u2006*SIX-PER-EM SPACE*\u2006,
1706 \u2007*FIGURE SPACE*\u2007,
1707 \u2008*PUNCTUATION SPACE*\u2008,
1708 \u2009*THIN SPACE*\u2009,
1709 \u200a*HAIR SPACE*\u200a,
1710 \u202f*NARROW NO-BREAK SPACE*\u202f,
1711 \u205f*MEDIUM MATHEMATICAL SPACE*\u205f,
1712 \u3000*IDEOGRAPHIC SPACE*\u3000,
1713 \u2028*LINE SEPARATOR*\u2028
1716 <document source="test data">
1780 NARROW NO-BREAK SPACE
1784 MEDIUM MATHEMATICAL SPACE
1795 inline markup separated by non-ASCII whitespace
1796 \xa0**NO-BREAK SPACE**\xa0, \xa0``NO-BREAK SPACE``\xa0, \xa0`NO-BREAK SPACE`\xa0,
1797 \u2000**EN QUAD**\u2000, \u2000``EN QUAD``\u2000, \u2000`EN QUAD`\u2000,
1798 \u202f**NARROW NBSP**\u202f, \u202f``NARROW NBSP``\u202f, \u202f`NARROW NBSP`\u202f,
1801 <document source="test data">
1803 inline markup separated by non-ASCII whitespace
1835 # « * » ‹ * › « * » ‹ * › « * » ‹ * › French,
1837 "Quoted" markup start-string (matched openers & closers) -> no markup:
1839 '*' "*" (*) <*> [*] {*}
1842 Some international quoting styles:
1843 ‘*’ “*” English, ...,
1844 „*“ ‚*‘ »*« ›*‹ German, Czech, ...,
1847 「*」 『*』traditional Chinese,
1848 ”*” ’*’ »*» ›*› Swedish, Finnish,
1850 „*” »*« ’*’ Hungarian,
1852 But this is „*’ emphasized »*‹.
1855 <document source="test data">
1857 "Quoted" markup start-string (matched openers & closers) -> no markup:
1859 '*' "*" (*) <*> [*] {*}
1862 Some international quoting styles:
1863 ‘*’ “*” English, ...,
1864 „*“ ‚*‘ »*« ›*‹ German, Czech, ...,
1867 「*」 『*』traditional Chinese,
1868 ”*” ’*’ »*» ›*› Swedish, Finnish,
1870 „*” »*« ’*’ Hungarian,
1880 if __name__
== '__main__':
1882 unittest
.main(defaultTest
='suite')