Website: add template and basic stylesheet with menu. Update buildhtml.py (and theref...
[docutils.git] / sandbox / gitpull / web_stylesheet_and_menu / test / test_transforms / test_hyperlinks.py
blob2245e724562664455ece2177a002bf5f1d59a70d
1 #! /usr/bin/env python
3 # $Id$
4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
7 """
8 Tests for docutils.transforms.references.Hyperlinks.
9 """
11 from __init__ import DocutilsTestSupport
12 from docutils.transforms.references import PropagateTargets, \
13 AnonymousHyperlinks, IndirectHyperlinks, ExternalTargets, \
14 InternalTargets, DanglingReferences
16 from docutils.parsers.rst import Parser
19 def suite():
20 parser = Parser()
21 s = DocutilsTestSupport.TransformTestSuite(parser)
22 s.generateTests(totest)
23 return s
25 totest = {}
27 # Exhaustive listing of hyperlink variations: every combination of
28 # target/reference, direct/indirect, internal/external, and named/anonymous,
29 # plus embedded URIs.
30 totest['exhaustive_hyperlinks'] = ((PropagateTargets, AnonymousHyperlinks,
31 IndirectHyperlinks,
32 ExternalTargets, InternalTargets,
33 DanglingReferences), [
34 ["""\
35 direct_ external
37 .. _direct: http://direct
38 """,
39 """\
40 <document source="test data">
41 <paragraph>
42 <reference name="direct" refuri="http://direct">
43 direct
44 external
45 <target ids="direct" names="direct" refuri="http://direct">
46 """],
47 ["""\
48 indirect_ external
50 .. _indirect: xtarget_
51 .. _xtarget: http://indirect
52 """,
53 """\
54 <document source="test data">
55 <paragraph>
56 <reference name="indirect" refuri="http://indirect">
57 indirect
58 external
59 <target ids="indirect" names="indirect" refuri="http://indirect">
60 <target ids="xtarget" names="xtarget" refuri="http://indirect">
61 """],
62 ["""\
63 .. _direct:
65 direct_ internal
66 """,
67 """\
68 <document source="test data">
69 <target refid="direct">
70 <paragraph ids="direct" names="direct">
71 <reference name="direct" refid="direct">
72 direct
73 internal
74 """],
75 ["""\
76 .. _ztarget:
78 indirect_ internal
80 .. _indirect2: ztarget_
81 .. _indirect: indirect2_
82 """,
83 """\
84 <document source="test data">
85 <target refid="ztarget">
86 <paragraph ids="ztarget" names="ztarget">
87 <reference name="indirect" refid="ztarget">
88 indirect
89 internal
90 <target ids="indirect2" names="indirect2" refid="ztarget">
91 <target ids="indirect" names="indirect" refid="ztarget">
92 """],
93 ["""\
94 Implicit
95 --------
97 indirect_ internal
99 .. _indirect: implicit_
100 """,
101 """\
102 <document source="test data">
103 <section ids="implicit" names="implicit">
104 <title>
105 Implicit
106 <paragraph>
107 <reference name="indirect" refid="implicit">
108 indirect
109 internal
110 <target ids="indirect" names="indirect" refid="implicit">
111 """],
112 ["""\
113 Implicit
114 --------
116 `multiply-indirect`_ internal
118 .. _multiply-indirect: indirect_
119 .. _indirect: implicit_
120 """,
121 """\
122 <document source="test data">
123 <section ids="implicit" names="implicit">
124 <title>
125 Implicit
126 <paragraph>
127 <reference name="multiply-indirect" refid="implicit">
128 multiply-indirect
129 internal
130 <target ids="multiply-indirect" names="multiply-indirect" refid="implicit">
131 <target ids="indirect" names="indirect" refid="implicit">
132 """],
133 ["""\
134 circular_ indirect reference
136 .. _circular: indirect_
137 .. _indirect: circular_
138 """,
139 """\
140 <document source="test data">
141 <paragraph>
142 <problematic ids="id2" refid="id1">
143 circular_
144 indirect reference
145 <target ids="circular" names="circular" refid="circular">
146 <problematic ids="id3 indirect" names="indirect" refid="id1">
147 .. _indirect: circular_
148 <system_message backrefs="id2 id3" ids="id1" level="3" line="3" source="test data" type="ERROR">
149 <paragraph>
150 Indirect hyperlink target "circular" (id="circular") refers to target "indirect", forming a circular reference.
151 """],
152 ["""\
153 Implicit
154 --------
156 Duplicate implicit targets.
158 Implicit
159 --------
161 indirect_ internal
163 .. _indirect: implicit_
165 Direct internal reference: Implicit_
166 """,
167 """\
168 <document source="test data">
169 <section dupnames="implicit" ids="implicit">
170 <title>
171 Implicit
172 <paragraph>
173 Duplicate implicit targets.
174 <section dupnames="implicit" ids="id1">
175 <title>
176 Implicit
177 <system_message backrefs="id1" level="1" line="7" source="test data" type="INFO">
178 <paragraph>
179 Duplicate implicit target name: "implicit".
180 <paragraph>
181 <problematic ids="id3" refid="id2">
182 indirect_
183 internal
184 <target ids="indirect" names="indirect" refname="implicit">
185 <paragraph>
186 Direct internal reference:
187 <problematic ids="id5" refid="id4">
188 Implicit_
189 <system_message backrefs="id3" ids="id2" level="3" line="11" source="test data" type="ERROR">
190 <paragraph>
191 Indirect hyperlink target "indirect" (id="indirect") refers to target "implicit", which is a duplicate, and cannot be used as a unique reference.
192 <system_message backrefs="id5" ids="id4" level="3" line="13" source="test data" type="ERROR">
193 <paragraph>
194 Duplicate target name, cannot be used as a unique reference: "implicit".
195 """],
196 ["""\
197 `direct external`__
199 __ http://direct
200 """,
201 """\
202 <document source="test data">
203 <paragraph>
204 <reference anonymous="1" name="direct external" refuri="http://direct">
205 direct external
206 <target anonymous="1" ids="id1" refuri="http://direct">
207 """],
208 ["""\
209 `indirect external`__
211 __ xtarget_
212 .. _xtarget: http://indirect
213 """,
214 """\
215 <document source="test data">
216 <paragraph>
217 <reference anonymous="1" name="indirect external" refuri="http://indirect">
218 indirect external
219 <target anonymous="1" ids="id1" refuri="http://indirect">
220 <target ids="xtarget" names="xtarget" refuri="http://indirect">
221 """],
222 ["""\
225 `direct internal`__
226 """,
227 """\
228 <document source="test data">
229 <target anonymous="1" refid="id1">
230 <paragraph ids="id1">
231 <reference anonymous="1" name="direct internal" refid="id1">
232 direct internal
233 """],
234 ["""\
235 .. _ztarget:
237 `indirect internal`__
239 __ ztarget_
240 """,
241 """\
242 <document source="test data">
243 <target refid="ztarget">
244 <paragraph ids="ztarget" names="ztarget">
245 <reference anonymous="1" name="indirect internal" refid="ztarget">
246 indirect internal
247 <target anonymous="1" ids="id1" refid="ztarget">
248 """],
249 ["""\
250 .. _ztarget:
252 First
254 .. _ztarget:
256 Second
258 `indirect internal`__
260 __ ztarget_
261 """,
262 """\
263 <document source="test data">
264 <target dupnames="ztarget" refid="ztarget">
265 <paragraph ids="ztarget">
266 First
267 <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING">
268 <paragraph>
269 Duplicate explicit target name: "ztarget".
270 <target dupnames="ztarget" refid="id1">
271 <paragraph ids="id1">
272 Second
273 <paragraph>
274 <problematic ids="id4" refid="id3">
275 `indirect internal`__
276 <target anonymous="1" ids="id2" refname="ztarget">
277 <system_message backrefs="id4" ids="id3" level="3" line="11" source="test data" type="ERROR">
278 <paragraph>
279 Indirect hyperlink target (id="id2") refers to target "ztarget", which is a duplicate, and cannot be used as a unique reference.
280 """],
281 ["""\
282 The next anonymous hyperlink reference is parsed (and discarded) at
283 some point, but nonetheless anonymous hyperlink references and targets
284 match in this snippet.
286 .. |invalid| replace:: anonymous__
288 hyperlink__
290 __ URL
291 """,
292 """\
293 <document source="test data">
294 <paragraph>
295 The next anonymous hyperlink reference is parsed (and discarded) at
296 some point, but nonetheless anonymous hyperlink references and targets
297 match in this snippet.
298 <system_message level="3" line="5" source="test data" type="ERROR">
299 <paragraph>
300 Substitution definition contains illegal element:
301 <literal_block xml:space="preserve">
302 <reference anonymous="1" name="anonymous">
303 anonymous
304 <literal_block xml:space="preserve">
305 .. |invalid| replace:: anonymous__
306 <paragraph>
307 <reference anonymous="1" name="hyperlink" refuri="URL">
308 hyperlink
309 <target anonymous="1" ids="id1" refuri="URL">
310 """],
311 ["""\
312 An `embedded uri <http://direct>`_.
314 Another reference to the same `embedded URI`_.
315 """,
316 """\
317 <document source="test data">
318 <paragraph>
319 An \n\
320 <reference name="embedded uri" refuri="http://direct">
321 embedded uri
322 <target ids="embedded-uri" names="embedded\ uri" refuri="http://direct">
324 <paragraph>
325 Another reference to the same \n\
326 <reference name="embedded URI" refuri="http://direct">
327 embedded URI
329 """],
330 ["""\
331 An `anonymous embedded uri <http://direct>`__.
332 """,
333 """\
334 <document source="test data">
335 <paragraph>
336 An \n\
337 <reference name="anonymous embedded uri" refuri="http://direct">
338 anonymous embedded uri
340 """],
341 ["""\
342 An `embedded alias <alias_>`_.
344 Another reference to the same `embedded alias`_.
346 .. _alias: ham.py
347 """,
348 """\
349 <document source="test data">
350 <paragraph>
351 An \n\
352 <reference name="embedded alias" refuri="ham.py">
353 embedded alias
354 <target names="embedded\ alias" refuri="ham.py">
356 <paragraph>
357 Another reference to the same \n\
358 <reference name="embedded alias" refuri="ham.py">
359 embedded alias
361 <target ids="alias" names="alias" refuri="ham.py">
362 """],
363 ["""\
364 An `anonymous embedded alias <redirect_>`__.
366 .. _redirect: spam.py
367 """,
368 """\
369 <document source="test data">
370 <paragraph>
371 An \n\
372 <reference name="anonymous embedded alias" refuri="spam.py">
373 anonymous embedded alias
375 <target ids="redirect" names="redirect" refuri="spam.py">
376 """],
377 ["""\
378 An `embedded alias <alias_>`_ with unknown reference.
379 """,
380 """\
381 <document source="test data">
382 <paragraph>
383 An \n\
384 <problematic ids="id3" refid="id2">
385 `embedded alias <alias_>`_
386 <target names="embedded\ alias" refname="alias">
387 with unknown reference.
388 <system_message ids="id1" level="3" line="1" source="test data" type="ERROR">
389 <paragraph>
390 Indirect hyperlink target "embedded alias" refers to target "alias", which does not exist.
391 <system_message backrefs="id3" ids="id2" level="3" line="1" source="test data" type="ERROR">
392 <paragraph>
393 Unknown target name: "alias".
394 <system_message level="1" line="1" source="test data" type="INFO">
395 <paragraph>
396 Hyperlink target "embedded alias" is not referenced.\
397 """],
398 ["""\
399 An embedded URI with trailing underline:
400 `__init__ <http:example.py.html#__init__>`__.
401 """,
402 """\
403 <document source="test data">
404 <paragraph>
405 An embedded URI with trailing underline:
406 <reference name="__init__" refuri="http:example.py.html#__init__">
407 __init__
409 """],
410 ["""\
411 Hyperlinks with angle-bracketed text need escaping.
413 See `Element \<a>`_, `Element <b\>`_, and `Element <c>\ `_.
415 .. _`Element <a>`:
416 .. _`Element <b>`:
417 .. _`Element <c>`: elements.txt
418 """,
419 """\
420 <document source="test data">
421 <paragraph>
422 Hyperlinks with angle-bracketed text need escaping.
423 <paragraph>
424 See \n\
425 <reference name="Element <a>" refuri="elements.txt">
426 Element <a>
427 , \n\
428 <reference name="Element <b>" refuri="elements.txt">
429 Element <b>
430 , and \n\
431 <reference name="Element <c>" refuri="elements.txt">
432 Element <c>
434 <target refid="element-a">
435 <target refid="element-b">
436 <target ids="element-c element-b element-a" names="element\ <c> element\ <b> element\ <a>" refuri="elements.txt">
437 """],
438 ["""\
439 .. _target:
441 .. [1] Footnote; target_
442 """,
443 """\
444 <document source="test data">
445 <target ids="target" names="target">
446 <footnote ids="id1" names="1">
447 <label>
449 <paragraph>
450 Footnote; \n\
451 <reference name="target" refid="target">
452 target
453 """],
454 ["""\
455 .. _target:
457 .. [cit] Citation; target_
458 """,
459 """\
460 <document source="test data">
461 <target ids="target" names="target">
462 <citation ids="cit" names="cit">
463 <label>
465 <paragraph>
466 Citation; \n\
467 <reference name="target" refid="target">
468 target
469 """],
472 totest['hyperlinks'] = ((PropagateTargets, AnonymousHyperlinks,
473 IndirectHyperlinks, ExternalTargets,
474 InternalTargets, DanglingReferences), [
475 ["""\
476 .. _internal hyperlink:
478 This paragraph referenced.
480 By this `internal hyperlink`_ reference.
481 """,
482 """\
483 <document source="test data">
484 <target refid="internal-hyperlink">
485 <paragraph ids="internal-hyperlink" names="internal\ hyperlink">
486 This paragraph referenced.
487 <paragraph>
488 By this \n\
489 <reference name="internal hyperlink" refid="internal-hyperlink">
490 internal hyperlink
491 reference.
492 """],
493 ["""\
494 .. _chained:
495 .. _internal hyperlink:
497 This paragraph referenced.
499 By this `internal hyperlink`_ reference
500 as well as by this chained_ reference.
502 The results of the transform are not visible at the XML level.
503 """,
504 """\
505 <document source="test data">
506 <target refid="chained">
507 <target refid="internal-hyperlink">
508 <paragraph ids="internal-hyperlink chained" names="internal\ hyperlink chained">
509 This paragraph referenced.
510 <paragraph>
511 By this \n\
512 <reference name="internal hyperlink" refid="internal-hyperlink">
513 internal hyperlink
514 reference
515 as well as by this \n\
516 <reference name="chained" refid="chained">
517 chained
518 reference.
519 <paragraph>
520 The results of the transform are not visible at the XML level.
521 """],
522 ["""\
523 .. _chained:
524 __ http://anonymous
526 Anonymous__ and chained_ both refer to the same URI.
527 """,
528 """\
529 <document source="test data">
530 <target refid="chained">
531 <target anonymous="1" ids="id1 chained" names="chained" refuri="http://anonymous">
532 <paragraph>
533 <reference anonymous="1" name="Anonymous" refuri="http://anonymous">
534 Anonymous
535 and \n\
536 <reference name="chained" refuri="http://anonymous">
537 chained
538 both refer to the same URI.
539 """],
540 ["""\
541 .. _a:
542 .. _b:
545 """,
546 """\
547 <document source="test data">
548 <target refid="a">
549 <target refid="b">
550 <paragraph ids="b a" names="b a">
552 <system_message level="1" line="1" source="test data" type="INFO">
553 <paragraph>
554 Hyperlink target "a" is not referenced.
555 <system_message level="1" line="2" source="test data" type="INFO">
556 <paragraph>
557 Hyperlink target "b" is not referenced.
558 """],
559 ["""\
560 .. _a:
561 .. _b:
564 """,
565 """\
566 <document source="test data">
567 <target refid="a">
568 <target refid="b">
569 <paragraph ids="b a" names="b a">
570 <reference name="a" refid="a">
572 <system_message level="1" line="2" source="test data" type="INFO">
573 <paragraph>
574 Hyperlink target "b" is not referenced.
575 """],
576 ["""\
577 .. _a:
578 .. _b:
581 """,
582 """\
583 <document source="test data">
584 <target refid="a">
585 <target refid="b">
586 <paragraph ids="b a" names="b a">
587 <reference name="b" refid="b">
589 <system_message level="1" line="1" source="test data" type="INFO">
590 <paragraph>
591 Hyperlink target "a" is not referenced.
592 """],
593 ["""\
594 .. _a:
595 .. _b:
597 a_\ b_
598 """,
599 """\
600 <document source="test data">
601 <target refid="a">
602 <target refid="b">
603 <paragraph ids="b a" names="b a">
604 <reference name="a" refid="a">
606 <reference name="b" refid="b">
608 """],
609 ["""\
610 .. _external hyperlink: http://uri
612 `External hyperlink`_ reference.
613 """,
614 """\
615 <document source="test data">
616 <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
617 <paragraph>
618 <reference name="External hyperlink" refuri="http://uri">
619 External hyperlink
620 reference.
621 """],
622 ["""\
623 .. _external hyperlink: http://uri
624 .. _indirect target: `external hyperlink`_
625 """,
626 """\
627 <document source="test data">
628 <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
629 <target ids="indirect-target" names="indirect\ target" refuri="http://uri">
630 <system_message level="1" line="2" source="test data" type="INFO">
631 <paragraph>
632 Hyperlink target "indirect target" is not referenced.
633 """],
634 ["""\
635 .. _chained:
636 .. _external hyperlink: http://uri
638 `External hyperlink`_ reference
639 and a chained_ reference too.
640 """,
641 """\
642 <document source="test data">
643 <target refid="chained">
644 <target ids="external-hyperlink chained" names="external\ hyperlink chained" refuri="http://uri">
645 <paragraph>
646 <reference name="External hyperlink" refuri="http://uri">
647 External hyperlink
648 reference
649 and a \n\
650 <reference name="chained" refuri="http://uri">
651 chained
652 reference too.
653 """],
654 ["""\
655 .. _external hyperlink: http://uri
656 .. _indirect hyperlink: `external hyperlink`_
658 `Indirect hyperlink`_ reference.
659 """,
660 """\
661 <document source="test data">
662 <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
663 <target ids="indirect-hyperlink" names="indirect\ hyperlink" refuri="http://uri">
664 <paragraph>
665 <reference name="Indirect hyperlink" refuri="http://uri">
666 Indirect hyperlink
667 reference.
668 """],
669 ["""\
670 .. _external hyperlink: http://uri
671 .. _chained:
672 .. _indirect hyperlink: `external hyperlink`_
674 Chained_ `indirect hyperlink`_ reference.
675 """,
676 """\
677 <document source="test data">
678 <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
679 <target refuri="http://uri">
680 <target ids="indirect-hyperlink chained" names="indirect\ hyperlink chained" refuri="http://uri">
681 <paragraph>
682 <reference name="Chained" refuri="http://uri">
683 Chained
685 <reference name="indirect hyperlink" refuri="http://uri">
686 indirect hyperlink
687 reference.
688 """],
689 ["""\
690 .. __: http://full
692 __ http://simplified
693 .. _external: http://indirect.external
694 __ external_
697 `Full syntax anonymous external hyperlink reference`__,
698 `chained anonymous external reference`__,
699 `simplified syntax anonymous external hyperlink reference`__,
700 `indirect anonymous hyperlink reference`__,
701 `internal anonymous hyperlink reference`__.
702 """,
703 """\
704 <document source="test data">
705 <target anonymous="1" ids="id1" refuri="http://full">
706 <target anonymous="1" refid="id2">
707 <target anonymous="1" ids="id3 id2" refuri="http://simplified">
708 <target ids="external" names="external" refuri="http://indirect.external">
709 <target anonymous="1" ids="id4" refuri="http://indirect.external">
710 <target anonymous="1" refid="id5">
711 <paragraph ids="id5">
712 <reference anonymous="1" name="Full syntax anonymous external hyperlink reference" refuri="http://full">
713 Full syntax anonymous external hyperlink reference
715 <reference anonymous="1" name="chained anonymous external reference" refuri="http://simplified">
716 chained anonymous external reference
718 <reference anonymous="1" name="simplified syntax anonymous external hyperlink reference" refuri="http://simplified">
719 simplified syntax anonymous external hyperlink reference
721 <reference anonymous="1" name="indirect anonymous hyperlink reference" refuri="http://indirect.external">
722 indirect anonymous hyperlink reference
724 <reference anonymous="1" name="internal anonymous hyperlink reference" refid="id5">
725 internal anonymous hyperlink reference
727 """],
728 ["""\
729 Duplicate external target_'s (different URIs):
731 .. _target: first
733 .. _target: second
734 """,
735 """\
736 <document source="test data">
737 <paragraph>
738 Duplicate external \n\
739 <problematic ids="id3" refid="id2">
740 target_
741 's (different URIs):
742 <target dupnames="target" ids="target" refuri="first">
743 <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING">
744 <paragraph>
745 Duplicate explicit target name: "target".
746 <target dupnames="target" ids="id1" refuri="second">
747 <system_message backrefs="id3" ids="id2" level="3" line="1" source="test data" type="ERROR">
748 <paragraph>
749 Duplicate target name, cannot be used as a unique reference: "target".
750 """],
751 ["""\
752 Duplicate external targets (different URIs) without reference:
754 .. _target: first
756 .. _target: second
757 """,
758 """\
759 <document source="test data">
760 <paragraph>
761 Duplicate external targets (different URIs) without reference:
762 <target dupnames="target" ids="target" refuri="first">
763 <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING">
764 <paragraph>
765 Duplicate explicit target name: "target".
766 <target dupnames="target" ids="id1" refuri="second">
767 """],
768 ["""\
769 Several__ anonymous__ hyperlinks__, but not enough targets.
771 __ http://example.org
772 """,
773 """\
774 <document source="test data">
775 <paragraph>
776 <problematic ids="id3" refid="id2">
777 Several__
779 <problematic ids="id4" refid="id2">
780 anonymous__
782 <problematic ids="id5" refid="id2">
783 hyperlinks__
784 , but not enough targets.
785 <target anonymous="1" ids="id1" refuri="http://example.org">
786 <system_message backrefs="id3 id4 id5" ids="id2" level="3" source="test data" type="ERROR">
787 <paragraph>
788 Anonymous hyperlink mismatch: 3 references but 1 targets.
789 See "backrefs" attribute for IDs.
790 """],
791 ["""\
792 .. _external: http://uri
793 .. _indirect: external_
794 .. _internal:
796 .. image:: picture.png
797 :target: external_
799 .. image:: picture.png
800 :target: indirect_
802 .. image:: picture.png
803 :target: internal_
804 """,
805 """\
806 <document source="test data">
807 <target ids="external" names="external" refuri="http://uri">
808 <target ids="indirect" names="indirect" refuri="http://uri">
809 <target refid="internal">
810 <reference ids="internal" name="external" names="internal" refuri="http://uri">
811 <image uri="picture.png">
812 <reference name="indirect" refuri="http://uri">
813 <image uri="picture.png">
814 <reference name="internal" refid="internal">
815 <image uri="picture.png">
816 """],
817 ["""\
818 .. contents:: Table of Contents
819 .. _indirect reference to the table of contents: `table of contents`_
821 Section
822 =======
824 Testing an `indirect reference to the table of contents`_.
825 """,
826 """\
827 <document source="test data">
828 <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
829 <title>
830 Table of Contents
831 <bullet_list>
832 <list_item>
833 <paragraph>
834 <reference ids="id1" refid="section">
835 Section
836 <target ids="indirect-reference-to-the-table-of-contents" names="indirect\ reference\ to\ the\ table\ of\ contents" refid="table-of-contents">
837 <section ids="section" names="section">
838 <title refid="id1">
839 Section
840 <paragraph>
841 Testing an
842 <reference name="indirect reference to the table of contents" refid="table-of-contents">
843 indirect reference to the table of contents
845 """],
846 ["""\
847 .. _explicit target:
849 Title
850 -----
852 Let's reference it (`explicit target`_) to avoid an irrelevant error.
853 """,
854 """\
855 <document source="test data">
856 <target refid="explicit-target">
857 <section ids="title explicit-target" names="title explicit\ target">
858 <title>
859 Title
860 <paragraph>
861 Let's reference it (
862 <reference name="explicit target" refid="explicit-target">
863 explicit target
864 ) to avoid an irrelevant error.
865 """],
866 ["""\
867 target1_ should refer to target2_, not the Title.
869 .. _target1:
870 .. _target2: URI
872 Title
873 =====
874 """,
875 """\
876 <document source="test data">
877 <paragraph>
878 <reference name="target1" refuri="URI">
879 target1
880 should refer to \n\
881 <reference name="target2" refuri="URI">
882 target2
883 , not the Title.
884 <target refid="target1">
885 <target ids="target2 target1" names="target2 target1" refuri="URI">
886 <section ids="title" names="title">
887 <title>
888 Title
889 """],
890 ["""\
891 Unknown reference_.
892 """,
893 """\
894 <document source="test data">
895 <paragraph>
896 Unknown \n\
897 <problematic ids="id2" refid="id1">
898 reference_
900 <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
901 <paragraph>
902 Unknown target name: "reference".
903 """],
904 ["""\
905 Duplicate manual footnote labels, with reference ([1]_):
907 .. [1] Footnote.
909 .. [1] Footnote.
910 """,
911 """\
912 <document source="test data">
913 <paragraph>
914 Duplicate manual footnote labels, with reference (
915 <problematic ids="id5 id1" refid="id4">
916 [1]_
918 <footnote dupnames="1" ids="id2">
919 <label>
921 <paragraph>
922 Footnote.
923 <footnote dupnames="1" ids="id3">
924 <label>
926 <system_message backrefs="id3" level="2" line="5" source="test data" type="WARNING">
927 <paragraph>
928 Duplicate explicit target name: "1".
929 <paragraph>
930 Footnote.
931 <system_message backrefs="id5" ids="id4" level="3" line="1" source="test data" type="ERROR">
932 <paragraph>
933 Duplicate target name, cannot be used as a unique reference: "1".
934 """],
938 if __name__ == '__main__':
939 import unittest
940 unittest.main(defaultTest='suite')