summaryrefslogtreecommitdiff
path: root/test/test_transforms
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_transforms')
-rw-r--r--test/test_transforms/__init__.py14
-rwxr-xr-xtest/test_transforms/test___init__.py43
-rwxr-xr-xtest/test_transforms/test_class.py191
-rwxr-xr-xtest/test_transforms/test_contents.py434
-rwxr-xr-xtest/test_transforms/test_docinfo.py334
-rwxr-xr-xtest/test_transforms/test_doctitle.py231
-rwxr-xr-xtest/test_transforms/test_expose_internals.py42
-rwxr-xr-xtest/test_transforms/test_filter.py41
-rwxr-xr-xtest/test_transforms/test_footnotes.py545
-rwxr-xr-xtest/test_transforms/test_hyperlinks.py845
-rwxr-xr-xtest/test_transforms/test_messages.py66
-rwxr-xr-xtest/test_transforms/test_peps.py68
-rwxr-xr-xtest/test_transforms/test_sectnum.py381
-rwxr-xr-xtest/test_transforms/test_strip_comments.py49
-rwxr-xr-xtest/test_transforms/test_substitutions.py353
-rwxr-xr-xtest/test_transforms/test_target_notes.py84
-rwxr-xr-xtest/test_transforms/test_transitions.py308
-rwxr-xr-xtest/test_transforms/test_writer_aux.py57
18 files changed, 4086 insertions, 0 deletions
diff --git a/test/test_transforms/__init__.py b/test/test_transforms/__init__.py
new file mode 100644
index 000000000..46fc50e06
--- /dev/null
+++ b/test/test_transforms/__init__.py
@@ -0,0 +1,14 @@
+import os
+import os.path
+import sys
+
+sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)))
+prev = ''
+while sys.path[0] != prev:
+ try:
+ import DocutilsTestSupport
+ break
+ except ImportError:
+ prev = sys.path[0]
+ sys.path[0] = os.path.dirname(prev)
+sys.path.pop(0)
diff --git a/test/test_transforms/test___init__.py b/test/test_transforms/test___init__.py
new file mode 100755
index 000000000..30e60afd3
--- /dev/null
+++ b/test/test_transforms/test___init__.py
@@ -0,0 +1,43 @@
+#! /usr/bin/env python
+
+# Author: Felix Wiemann
+# Contact: Felix_Wiemann@ososo.de
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Test module for transforms/__init__.py.
+"""
+
+from __init__ import DocutilsTestSupport # must be imported before docutils
+from docutils import transforms, utils
+import unittest
+
+
+class TestTransform(transforms.Transform):
+
+ default_priority = 100
+
+ applied = 0
+
+ def apply(self, **kwargs):
+ self.applied += 1
+ assert kwargs == {'foo': 42}
+
+
+class KwargsTestCase(unittest.TestCase):
+
+ def test_kwargs(self):
+ transformer = transforms.Transformer(utils.new_document('test data'))
+ transformer.add_transform(TestTransform, foo=42)
+ transformer.apply_transforms()
+ self.assertEqual(len(transformer.applied), 1)
+ self.assertEqual(len(transformer.applied[0]), 4)
+ transform_record = transformer.applied[0]
+ self.assertEqual(transform_record[1], TestTransform)
+ self.assertEqual(transform_record[3], {'foo': 42})
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/test/test_transforms/test_class.py b/test/test_transforms/test_class.py
new file mode 100755
index 000000000..4cd874ea3
--- /dev/null
+++ b/test/test_transforms/test_class.py
@@ -0,0 +1,191 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for `docutils.transforms.misc.ClassAttribute`.
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['class'] = ((), [
+["""\
+.. class:: one
+
+paragraph
+""",
+"""\
+<document source="test data">
+ <paragraph classes="one">
+ paragraph
+"""],
+["""\
+.. class:: two
+..
+
+ Block quote
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ <block_quote classes="two">
+ <paragraph>
+ Block quote
+"""],
+["""\
+ Block quote
+
+ .. class:: three
+
+Paragraph
+""",
+"""\
+<document source="test data">
+ <block_quote>
+ <paragraph>
+ Block quote
+ <paragraph classes="three">
+ Paragraph
+"""],
+["""\
+.. class:: four
+
+Section Title
+=============
+
+Paragraph
+""",
+"""\
+<document source="test data">
+ <section classes="four" ids="section-title" names="section\ title">
+ <title>
+ Section Title
+ <paragraph>
+ Paragraph
+"""],
+["""\
+.. class:: multiple
+
+ paragraph 1
+
+ paragraph 2
+""",
+"""\
+<document source="test data">
+ <paragraph classes="multiple">
+ paragraph 1
+ <paragraph classes="multiple">
+ paragraph 2
+"""],
+["""\
+.. class:: multiple
+
+ .. Just a comment. It's silly, but possible
+""",
+"""\
+<document source="test data">
+ <comment classes="multiple" xml:space="preserve">
+ Just a comment. It's silly, but possible
+"""],
+["""\
+.. class::
+
+.. class:: 99
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "class" directive:
+ 1 argument(s) required, 0 supplied.
+ <literal_block xml:space="preserve">
+ .. class::
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ Invalid class attribute value for "class" directive: "99".
+ <literal_block xml:space="preserve">
+ .. class:: 99
+"""],
+["""\
+.. class:: one
+.. class:: two
+
+multiple class values may be assigned to one element
+""",
+"""\
+<document source="test data">
+ <paragraph classes="one two">
+ multiple class values may be assigned to one element
+"""],
+["""\
+.. class:: one two
+
+multiple class values may be assigned to one element
+""",
+"""\
+<document source="test data">
+ <paragraph classes="one two">
+ multiple class values may be assigned to one element
+"""],
+["""\
+.. class:: fancy
+
+2. List starts at 2.
+3. Class should apply to list, not to system message.
+""",
+"""\
+<document source="test data">
+ <enumerated_list classes="fancy" enumtype="arabic" prefix="" start="2" suffix=".">
+ <list_item>
+ <paragraph>
+ List starts at 2.
+ <list_item>
+ <paragraph>
+ Class should apply to list, not to system message.
+ <system_message level="1" line="3" source="test data" type="INFO">
+ <paragraph>
+ Enumerated list start value not ordinal-1: "2" (ordinal 2)
+"""],
+["""\
+2. List starts at 2.
+3. Class should apply to next paragraph, not to system message.
+
+ .. class:: fancy
+
+A paragraph.
+""",
+"""\
+<document source="test data">
+ <enumerated_list enumtype="arabic" prefix="" start="2" suffix=".">
+ <list_item>
+ <paragraph>
+ List starts at 2.
+ <list_item>
+ <paragraph>
+ Class should apply to next paragraph, not to system message.
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Enumerated list start value not ordinal-1: "2" (ordinal 2)
+ <paragraph classes="fancy">
+ A paragraph.
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_contents.py b/test/test_transforms/test_contents.py
new file mode 100755
index 000000000..19705b5ba
--- /dev/null
+++ b/test/test_transforms/test_contents.py
@@ -0,0 +1,434 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for `docutils.transforms.parts.Contents` (via
+`docutils.transforms.universal.LastReaderPending`).
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.transforms.references import Substitutions
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['tables_of_contents'] = ((Substitutions,), [
+["""\
+.. contents::
+
+Title 1
+=======
+Paragraph 1.
+
+Title_ 2
+--------
+Paragraph 2.
+
+_`Title` 3
+``````````
+Paragraph 3.
+
+Title 4
+-------
+Paragraph 4.
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="contents" names="contents">
+ <title>
+ Contents
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id1" refid="title-1">
+ Title 1
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id2" refid="title-2">
+ Title
+ 2
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id3" refid="title-3">
+ Title
+ 3
+ <list_item>
+ <paragraph>
+ <reference ids="id4" refid="title-4">
+ Title 4
+ <section ids="title-1" names="title\ 1">
+ <title refid="id1">
+ Title 1
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title>
+ <reference name="Title" refname="title">
+ Title
+ 2
+ <paragraph>
+ Paragraph 2.
+ <section ids="title-3" names="title\ 3">
+ <title refid="id3">
+ <target ids="title" names="title">
+ Title
+ 3
+ <paragraph>
+ Paragraph 3.
+ <section ids="title-4" names="title\ 4">
+ <title refid="id4">
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+.. contents:: Table of Contents
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
+ <title>
+ Table of Contents
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id1" refid="title-1">
+ Title 1
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id2" refid="title-2">
+ Title 2
+ <section ids="title-1" names="title\ 1">
+ <title refid="id1">
+ Title 1
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title refid="id2">
+ Title 2
+ <paragraph>
+ Paragraph 2.
+"""],
+["""\
+.. contents:: There's an image in Title 2
+
+Title 1
+=======
+Paragraph 1.
+
+|Title 2|
+=========
+Paragraph 2.
+
+.. |Title 2| image:: title2.png
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="there-s-an-image-in-title-2" names="there's\ an\ image\ in\ title\ 2">
+ <title>
+ There's an image in Title 2
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id1" refid="title-1">
+ Title 1
+ <list_item>
+ <paragraph>
+ <reference ids="id2" refid="title-2">
+ Title 2
+ <section ids="title-1" names="title\ 1">
+ <title refid="id1">
+ Title 1
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title refid="id2">
+ <image alt="Title 2" uri="title2.png">
+ <paragraph>
+ Paragraph 2.
+ <substitution_definition names="Title\ 2">
+ <image alt="Title 2" uri="title2.png">
+"""], # emacs cruft: "
+["""\
+.. contents::
+ :depth: 2
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+```````
+Paragraph 3.
+
+Title 4
+-------
+Paragraph 4.
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="contents" names="contents">
+ <title>
+ Contents
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id1" refid="title-1">
+ Title 1
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id2" refid="title-2">
+ Title 2
+ <list_item>
+ <paragraph>
+ <reference ids="id3" refid="title-4">
+ Title 4
+ <section ids="title-1" names="title\ 1">
+ <title refid="id1">
+ Title 1
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title refid="id2">
+ Title 2
+ <paragraph>
+ Paragraph 2.
+ <section ids="title-3" names="title\ 3">
+ <title>
+ Title 3
+ <paragraph>
+ Paragraph 3.
+ <section ids="title-4" names="title\ 4">
+ <title refid="id3">
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+Title 1
+=======
+
+.. contents::
+ :local:
+
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+```````
+Paragraph 3.
+
+Title 4
+-------
+Paragraph 4.
+""",
+"""\
+<document source="test data">
+ <section ids="title-1" names="title\ 1">
+ <title>
+ Title 1
+ <topic classes="contents local" ids="contents" names="contents">
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id1" refid="title-2">
+ Title 2
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id2" refid="title-3">
+ Title 3
+ <list_item>
+ <paragraph>
+ <reference ids="id3" refid="title-4">
+ Title 4
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title refid="id1">
+ Title 2
+ <paragraph>
+ Paragraph 2.
+ <section ids="title-3" names="title\ 3">
+ <title refid="id2">
+ Title 3
+ <paragraph>
+ Paragraph 3.
+ <section ids="title-4" names="title\ 4">
+ <title refid="id3">
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+.. contents::
+ :local:
+
+Test duplicate name "Contents".
+
+Section
+--------
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <topic classes="contents local" ids="contents" names="contents">
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id1" refid="section">
+ Section
+ <paragraph>
+ Test duplicate name "Contents".
+ <section ids="section" names="section">
+ <title refid="id1">
+ Section
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. contents::
+ :backlinks: top
+
+Section
+--------
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="contents" names="contents">
+ <title>
+ Contents
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id1" refid="section">
+ Section
+ <section ids="section" names="section">
+ <title refid="contents">
+ Section
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. contents::
+ :backlinks: none
+
+Section
+--------
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="contents" names="contents">
+ <title>
+ Contents
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id1" refid="section">
+ Section
+ <section ids="section" names="section">
+ <title>
+ Section
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. contents::
+
+Degenerate case, no table of contents generated.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Degenerate case, no table of contents generated.
+"""],
+["""\
+Title 1
+=======
+
+Paragraph 1.
+
+.. sidebar:: Contents
+
+ .. contents::
+ :local:
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+```````
+Paragraph 3.
+""",
+"""\
+<document source="test data">
+ <section ids="title-1" names="title\ 1">
+ <title>
+ Title 1
+ <paragraph>
+ Paragraph 1.
+ <sidebar>
+ <title>
+ Contents
+ <topic classes="contents local" ids="contents" names="contents">
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id1" refid="title-2">
+ Title 2
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id2" refid="title-3">
+ Title 3
+ <section ids="title-2" names="title\ 2">
+ <title refid="id1">
+ Title 2
+ <paragraph>
+ Paragraph 2.
+ <section ids="title-3" names="title\ 3">
+ <title refid="id2">
+ Title 3
+ <paragraph>
+ Paragraph 3.
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_docinfo.py b/test/test_transforms/test_docinfo.py
new file mode 100755
index 000000000..994d034ea
--- /dev/null
+++ b/test/test_transforms/test_docinfo.py
@@ -0,0 +1,334 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for docutils.transforms.frontmatter.DocInfo.
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.transforms.frontmatter import DocInfo
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['bibliographic_field_lists'] = ((DocInfo,), [
+["""\
+.. Bibliographic element extraction.
+
+:Abstract:
+ There can only be one abstract.
+
+ It is automatically moved to the end of the other bibliographic elements.
+
+:Author: Me
+:Version: 1
+:Date: 2001-08-11
+:Parameter i: integer
+""",
+"""\
+<document source="test data">
+ <docinfo>
+ <author>
+ Me
+ <version>
+ 1
+ <date>
+ 2001-08-11
+ <field>
+ <field_name>
+ Parameter i
+ <field_body>
+ <paragraph>
+ integer
+ <topic classes="abstract">
+ <title>
+ Abstract
+ <paragraph>
+ There can only be one abstract.
+ <paragraph>
+ It is automatically moved to the end of the other bibliographic elements.
+ <comment xml:space="preserve">
+ Bibliographic element extraction.
+"""],
+["""\
+.. Bibliographic element extraction.
+
+:Abstract: Abstract 1.
+:Author: Me
+:Address: 123 My Street
+ Example, EX
+:Contact: me@my.org
+:Version: 1
+:Abstract: Abstract 2 (should generate a warning).
+:Date: 2001-08-11
+:Parameter i: integer
+""",
+"""\
+<document source="test data">
+ <docinfo>
+ <author>
+ Me
+ <address xml:space="preserve">
+ 123 My Street
+ Example, EX
+ <contact>
+ <reference refuri="mailto:me@my.org">
+ me@my.org
+ <version>
+ 1
+ <field>
+ <field_name>
+ Abstract
+ <field_body>
+ <paragraph>
+ Abstract 2 (should generate a warning).
+ <system_message level="2" line="9" source="test data" type="WARNING">
+ <paragraph>
+ There can only be one "Abstract" field.
+ <date>
+ 2001-08-11
+ <field>
+ <field_name>
+ Parameter i
+ <field_body>
+ <paragraph>
+ integer
+ <topic classes="abstract">
+ <title>
+ Abstract
+ <paragraph>
+ Abstract 1.
+ <comment xml:space="preserve">
+ Bibliographic element extraction.
+"""],
+["""\
+:Author: - must be a paragraph
+:Status: a *simple* paragraph
+:Date: But only one
+
+ paragraph.
+:Version:
+
+.. and not empty either
+""",
+"""\
+<document source="test data">
+ <docinfo>
+ <field>
+ <field_name>
+ Author
+ <field_body>
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ must be a paragraph
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Cannot extract bibliographic field "Author" containing anything other than a single paragraph.
+ <status>
+ a \n\
+ <emphasis>
+ simple
+ paragraph
+ <field>
+ <field_name>
+ Date
+ <field_body>
+ <paragraph>
+ But only one
+ <paragraph>
+ paragraph.
+ <system_message level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Cannot extract compound bibliographic field "Date".
+ <field>
+ <field_name>
+ Version
+ <field_body>
+ <system_message level="2" line="6" source="test data" type="WARNING">
+ <paragraph>
+ Cannot extract empty bibliographic field "Version".
+ <comment xml:space="preserve">
+ and not empty either
+"""],
+["""\
+:Authors: Me, Myself, **I**
+:Authors: PacMan; Ms. PacMan; PacMan, Jr.
+:Authors:
+ Here
+
+ There
+
+ *Everywhere*
+:Authors: - First
+ - Second
+ - Third
+""",
+"""\
+<document source="test data">
+ <docinfo>
+ <authors>
+ <author>
+ Me
+ <author>
+ Myself
+ <author>
+ I
+ <authors>
+ <author>
+ PacMan
+ <author>
+ Ms. PacMan
+ <author>
+ PacMan, Jr.
+ <authors>
+ <author>
+ Here
+ <author>
+ There
+ <author>
+ <emphasis>
+ Everywhere
+ <authors>
+ <author>
+ First
+ <author>
+ Second
+ <author>
+ Third
+"""],
+["""\
+:Authors: Only One
+:Authors: One, Only;
+""",
+"""\
+<document source="test data">
+ <docinfo>
+ <authors>
+ <author>
+ Only One
+ <authors>
+ <author>
+ One, Only
+"""],
+["""\
+:Authors:
+
+:Authors: 1. One
+ 2. Two
+
+:Authors:
+ -
+ -
+
+:Authors:
+ - One
+
+ Two
+
+:Authors:
+ - One
+
+ Two
+""",
+"""\
+<document source="test data">
+ <docinfo>
+ <field>
+ <field_name>
+ Authors
+ <field_body>
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Cannot extract empty bibliographic field "Authors".
+ <field>
+ <field_name>
+ Authors
+ <field_body>
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ One
+ <list_item>
+ <paragraph>
+ Two
+ <system_message level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
+ <field>
+ <field_name>
+ Authors
+ <field_body>
+ <bullet_list bullet="-">
+ <list_item>
+ <list_item>
+ <system_message level="2" line="6" source="test data" type="WARNING">
+ <paragraph>
+ Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
+ <field>
+ <field_name>
+ Authors
+ <field_body>
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ One
+ <paragraph>
+ Two
+ <system_message level="2" line="10" source="test data" type="WARNING">
+ <paragraph>
+ Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
+ <field>
+ <field_name>
+ Authors
+ <field_body>
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ One
+ <paragraph>
+ Two
+ <system_message level="2" line="15" source="test data" type="WARNING">
+ <paragraph>
+ Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
+"""],
+["""\
+.. RCS keyword extraction.
+
+:Status: (some text) $""" + """RCSfile: test_docinfo.py,v $ (more text)
+:Date: (some text) $""" + """Date: 2002/10/08 01:34:23 $ (more text)
+:Date: (some text) $""" + """Date: 2005-03-26T16:21:28.693201Z $ (more text)
+:Version: (some text) $""" + """Revision: 1.1 $ (more text)
+""",
+"""\
+<document source="test data">
+ <docinfo>
+ <status>
+ (some text) test_docinfo.py (more text)
+ <date>
+ (some text) 2002-10-08 (more text)
+ <date>
+ (some text) 2005-03-26 (more text)
+ <version>
+ (some text) 1.1 (more text)
+ <comment xml:space="preserve">
+ RCS keyword extraction.
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_doctitle.py b/test/test_transforms/test_doctitle.py
new file mode 100755
index 000000000..3000f53a5
--- /dev/null
+++ b/test/test_transforms/test_doctitle.py
@@ -0,0 +1,231 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for docutils.transforms.frontmatter.DocTitle.
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.transforms.frontmatter import DocTitle, SectionSubTitle
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['section_headers'] = ((DocTitle, SectionSubTitle), [
+["""\
+.. test title promotion
+
+Title
+=====
+
+Paragraph.
+""",
+"""\
+<document ids="title" names="title" source="test data" title="Title">
+ <title>
+ Title
+ <comment xml:space="preserve">
+ test title promotion
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+Title
+=====
+Paragraph (no blank line).
+""",
+"""\
+<document ids="title" names="title" source="test data" title="Title">
+ <title>
+ Title
+ <paragraph>
+ Paragraph (no blank line).
+"""],
+["""\
+Paragraph.
+
+Title
+=====
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph.
+ <section ids="title" names="title">
+ <title>
+ Title
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+Title
+=====
+
+Subtitle
+--------
+
+.. title:: Another Title
+
+Test title, subtitle, and title metadata.
+""",
+"""\
+<document ids="title" names="title" source="test data" title="Another Title">
+ <title>
+ Title
+ <subtitle ids="subtitle" names="subtitle">
+ Subtitle
+ <paragraph>
+ Test title, subtitle, and title metadata.
+"""],
+["""\
+Title
+====
+
+Test short underline.
+""",
+"""\
+<document ids="title" names="title" source="test data" title="Title">
+ <title>
+ Title
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Title underline too short.
+ <literal_block xml:space="preserve">
+ Title
+ ====
+ <paragraph>
+ Test short underline.
+"""],
+["""\
+=======
+ Long Title
+=======
+
+Test long title and space normalization.
+The system_message should move after the document title
+(it was before the beginning of the section).
+""",
+"""\
+<document ids="long-title" names="long\ title" source="test data" title="Long Title">
+ <title>
+ Long Title
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Title overline too short.
+ <literal_block xml:space="preserve">
+ =======
+ Long Title
+ =======
+ <paragraph>
+ Test long title and space normalization.
+ The system_message should move after the document title
+ (it was before the beginning of the section).
+"""],
+["""\
+.. Test multiple second-level titles.
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+-------
+Paragraph 3.
+""",
+"""\
+<document ids="title-1" names="title\ 1" source="test data" title="Title 1">
+ <title>
+ Title 1
+ <comment xml:space="preserve">
+ Test multiple second-level titles.
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title>
+ Title 2
+ <paragraph>
+ Paragraph 2.
+ <section ids="title-3" names="title\ 3">
+ <title>
+ Title 3
+ <paragraph>
+ Paragraph 3.
+"""],
+["""\
+.. |foo| replace:: bar
+
+.. _invisible target:
+
+Title
+=====
+This title should be the document title despite the
+substitution_definition.
+""",
+"""\
+<document ids="title" names="title" source="test data" title="Title">
+ <title>
+ Title
+ <substitution_definition names="foo">
+ bar
+ <target ids="invisible-target" names="invisible\ target">
+ <paragraph>
+ This title should be the document title despite the
+ substitution_definition.
+"""],
+["""\
+(Because of this paragraph, the following is not a doc title.)
+
+===============
+ Section Title
+===============
+
+Subtitle
+========
+
+-----------------
+ Another Section
+-----------------
+
+Another Subtitle
+----------------
+
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ (Because of this paragraph, the following is not a doc title.)
+ <section ids="section-title" names="section\ title">
+ <title>
+ Section Title
+ <subtitle ids="subtitle" names="subtitle">
+ Subtitle
+ <section ids="another-section" names="another\ section">
+ <title>
+ Another Section
+ <subtitle ids="another-subtitle" names="another\ subtitle">
+ Another Subtitle
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_expose_internals.py b/test/test_transforms/test_expose_internals.py
new file mode 100755
index 000000000..69193246a
--- /dev/null
+++ b/test/test_transforms/test_expose_internals.py
@@ -0,0 +1,42 @@
+#! /usr/bin/env python
+
+# Author: Felix Wiemann
+# Contact: Felix_Wiemann@ososo.de
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Test module for universal.ExposeInternals transform.
+"""
+
+
+from __init__ import DocutilsTestSupport # must be imported before docutils
+from docutils.transforms.universal import ExposeInternals
+from docutils.parsers.rst import Parser
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(
+ parser, suite_settings={'expose_internals': ['rawsource', 'source']})
+ s.generateTests(totest)
+ return s
+
+
+totest = {}
+
+totest['transitions'] = ((ExposeInternals,), [
+["""\
+This is a test.
+""",
+"""\
+<document internal:rawsource="" source="test data">
+ <paragraph internal:rawsource="This is a test." internal:source="test data">
+ This is a test.
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_filter.py b/test/test_transforms/test_filter.py
new file mode 100755
index 000000000..009600d81
--- /dev/null
+++ b/test/test_transforms/test_filter.py
@@ -0,0 +1,41 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for docutils.transforms.components.Filter.
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['meta'] = ((), [
+["""\
+.. meta::
+ :description: The reStructuredText plaintext markup language
+ :keywords: plaintext,markup language
+""",
+"""\
+<document source="test data">
+ <meta content="The reStructuredText plaintext markup language" name="description">
+ <meta content="plaintext,markup language" name="keywords">
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_footnotes.py b/test/test_transforms/test_footnotes.py
new file mode 100755
index 000000000..86cbd2110
--- /dev/null
+++ b/test/test_transforms/test_footnotes.py
@@ -0,0 +1,545 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for docutils.transforms.references.Footnotes.
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.transforms.references import Footnotes
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['footnotes'] = ((Footnotes,), [
+["""\
+[#autolabel]_
+
+.. [#autolabel] text
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <footnote_reference auto="1" ids="id1" refid="autolabel">
+ 1
+ <footnote auto="1" backrefs="id1" ids="autolabel" names="autolabel">
+ <label>
+ 1
+ <paragraph>
+ text
+"""],
+["""\
+autonumber: [#]_
+
+.. [#] text
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ autonumber: \n\
+ <footnote_reference auto="1" ids="id1" refid="id2">
+ 1
+ <footnote auto="1" backrefs="id1" ids="id2" names="1">
+ <label>
+ 1
+ <paragraph>
+ text
+"""],
+["""\
+[#]_ is the first auto-numbered footnote reference.
+[#]_ is the second auto-numbered footnote reference.
+
+.. [#] Auto-numbered footnote 1.
+.. [#] Auto-numbered footnote 2.
+.. [#] Auto-numbered footnote 3.
+
+[#]_ is the third auto-numbered footnote reference.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <footnote_reference auto="1" ids="id1" refid="id3">
+ 1
+ is the first auto-numbered footnote reference.
+ <footnote_reference auto="1" ids="id2" refid="id4">
+ 2
+ is the second auto-numbered footnote reference.
+ <footnote auto="1" backrefs="id1" ids="id3" names="1">
+ <label>
+ 1
+ <paragraph>
+ Auto-numbered footnote 1.
+ <footnote auto="1" backrefs="id2" ids="id4" names="2">
+ <label>
+ 2
+ <paragraph>
+ Auto-numbered footnote 2.
+ <footnote auto="1" backrefs="id6" ids="id5" names="3">
+ <label>
+ 3
+ <paragraph>
+ Auto-numbered footnote 3.
+ <paragraph>
+ <footnote_reference auto="1" ids="id6" refid="id5">
+ 3
+ is the third auto-numbered footnote reference.
+"""],
+["""\
+[#third]_ is a reference to the third auto-numbered footnote.
+
+.. [#first] First auto-numbered footnote.
+.. [#second] Second auto-numbered footnote.
+.. [#third] Third auto-numbered footnote.
+
+[#second]_ is a reference to the second auto-numbered footnote.
+[#first]_ is a reference to the first auto-numbered footnote.
+[#third]_ is another reference to the third auto-numbered footnote.
+
+Here are some internal cross-references to the implicit targets
+generated by the footnotes: first_, second_, third_.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <footnote_reference auto="1" ids="id1" refid="third">
+ 3
+ is a reference to the third auto-numbered footnote.
+ <footnote auto="1" backrefs="id3" ids="first" names="first">
+ <label>
+ 1
+ <paragraph>
+ First auto-numbered footnote.
+ <footnote auto="1" backrefs="id2" ids="second" names="second">
+ <label>
+ 2
+ <paragraph>
+ Second auto-numbered footnote.
+ <footnote auto="1" backrefs="id1 id4" ids="third" names="third">
+ <label>
+ 3
+ <paragraph>
+ Third auto-numbered footnote.
+ <paragraph>
+ <footnote_reference auto="1" ids="id2" refid="second">
+ 2
+ is a reference to the second auto-numbered footnote.
+ <footnote_reference auto="1" ids="id3" refid="first">
+ 1
+ is a reference to the first auto-numbered footnote.
+ <footnote_reference auto="1" ids="id4" refid="third">
+ 3
+ is another reference to the third auto-numbered footnote.
+ <paragraph>
+ Here are some internal cross-references to the implicit targets
+ generated by the footnotes: \n\
+ <reference name="first" refname="first">
+ first
+ , \n\
+ <reference name="second" refname="second">
+ second
+ , \n\
+ <reference name="third" refname="third">
+ third
+ .
+"""],
+["""\
+Mixed anonymous and labelled auto-numbered footnotes:
+
+[#four]_ should be 4, [#]_ should be 1,
+[#]_ should be 3, [#]_ is one too many,
+[#two]_ should be 2, and [#six]_ doesn't exist.
+
+.. [#] Auto-numbered footnote 1.
+.. [#two] Auto-numbered footnote 2.
+.. [#] Auto-numbered footnote 3.
+.. [#four] Auto-numbered footnote 4.
+.. [#five] Auto-numbered footnote 5.
+.. [#five] Auto-numbered footnote 5 again (duplicate).
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Mixed anonymous and labelled auto-numbered footnotes:
+ <paragraph>
+ <footnote_reference auto="1" ids="id1" refid="four">
+ 4
+ should be 4, \n\
+ <footnote_reference auto="1" ids="id2" refid="id7">
+ 1
+ should be 1,
+ <footnote_reference auto="1" ids="id3" refid="id8">
+ 3
+ should be 3, \n\
+ <problematic ids="id11 id4" refid="id10">
+ [#]_
+ is one too many,
+ <footnote_reference auto="1" ids="id5" refid="two">
+ 2
+ should be 2, and \n\
+ <footnote_reference auto="1" ids="id6" refname="six">
+ doesn't exist.
+ <footnote auto="1" backrefs="id2" ids="id7" names="1">
+ <label>
+ 1
+ <paragraph>
+ Auto-numbered footnote 1.
+ <footnote auto="1" backrefs="id5" ids="two" names="two">
+ <label>
+ 2
+ <paragraph>
+ Auto-numbered footnote 2.
+ <footnote auto="1" backrefs="id3" ids="id8" names="3">
+ <label>
+ 3
+ <paragraph>
+ Auto-numbered footnote 3.
+ <footnote auto="1" backrefs="id1" ids="four" names="four">
+ <label>
+ 4
+ <paragraph>
+ Auto-numbered footnote 4.
+ <footnote auto="1" dupnames="five" ids="five">
+ <label>
+ 5
+ <paragraph>
+ Auto-numbered footnote 5.
+ <footnote auto="1" dupnames="five" ids="id9">
+ <label>
+ 6
+ <system_message backrefs="id9" level="2" line="12" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "five".
+ <paragraph>
+ Auto-numbered footnote 5 again (duplicate).
+ <system_message backrefs="id11" ids="id10" level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ Too many autonumbered footnote references: only 2 corresponding footnotes available.
+"""],
+["""\
+Mixed auto-numbered and manual footnotes:
+
+.. [1] manually numbered
+.. [#] auto-numbered
+.. [#label] autonumber-labeled
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Mixed auto-numbered and manual footnotes:
+ <footnote ids="id1" names="1">
+ <label>
+ 1
+ <paragraph>
+ manually numbered
+ <footnote auto="1" ids="id2" names="2">
+ <label>
+ 2
+ <paragraph>
+ auto-numbered
+ <footnote auto="1" ids="label" names="label">
+ <label>
+ 3
+ <paragraph>
+ autonumber-labeled
+"""],
+["""\
+A labeled autonumbered footnote referece: [#footnote]_.
+
+An unlabeled autonumbered footnote referece: [#]_.
+
+.. [#] Unlabeled autonumbered footnote.
+.. [#footnote] Labeled autonumbered footnote.
+ Note that the footnotes are not in the same
+ order as the references.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A labeled autonumbered footnote referece: \n\
+ <footnote_reference auto="1" ids="id1" refid="footnote">
+ 2
+ .
+ <paragraph>
+ An unlabeled autonumbered footnote referece: \n\
+ <footnote_reference auto="1" ids="id2" refid="id3">
+ 1
+ .
+ <footnote auto="1" backrefs="id2" ids="id3" names="1">
+ <label>
+ 1
+ <paragraph>
+ Unlabeled autonumbered footnote.
+ <footnote auto="1" backrefs="id1" ids="footnote" names="footnote">
+ <label>
+ 2
+ <paragraph>
+ Labeled autonumbered footnote.
+ Note that the footnotes are not in the same
+ order as the references.
+"""],
+["""\
+Mixed manually-numbered, anonymous auto-numbered,
+and labelled auto-numbered footnotes:
+
+[#four]_ should be 4, [#]_ should be 2,
+[1]_ is 1, [3]_ is 3,
+[#]_ should be 6, [#]_ is one too many,
+[#five]_ should be 5, and [#eight]_ doesn't exist.
+
+.. [1] Manually-numbered footnote 1.
+.. [#] Auto-numbered footnote 2.
+.. [#four] Auto-numbered footnote 4.
+.. [3] Manually-numbered footnote 3
+.. [#five] Auto-numbered footnote 5.
+.. [#] Auto-numbered footnote 6.
+.. [#five] Auto-numbered footnote 5 again (duplicate).
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Mixed manually-numbered, anonymous auto-numbered,
+ and labelled auto-numbered footnotes:
+ <paragraph>
+ <footnote_reference auto="1" ids="id1" refid="four">
+ 4
+ should be 4, \n\
+ <footnote_reference auto="1" ids="id2" refid="id10">
+ 2
+ should be 2,
+ <footnote_reference ids="id3" refid="id9">
+ 1
+ is 1, \n\
+ <footnote_reference ids="id4" refid="id11">
+ 3
+ is 3,
+ <footnote_reference auto="1" ids="id5" refid="id12">
+ 6
+ should be 6, \n\
+ <problematic ids="id15 id6" refid="id14">
+ [#]_
+ is one too many,
+ <footnote_reference auto="1" ids="id7" refname="five">
+ should be 5, and \n\
+ <footnote_reference auto="1" ids="id8" refname="eight">
+ doesn't exist.
+ <footnote backrefs="id3" ids="id9" names="1">
+ <label>
+ 1
+ <paragraph>
+ Manually-numbered footnote 1.
+ <footnote auto="1" backrefs="id2" ids="id10" names="2">
+ <label>
+ 2
+ <paragraph>
+ Auto-numbered footnote 2.
+ <footnote auto="1" backrefs="id1" ids="four" names="four">
+ <label>
+ 4
+ <paragraph>
+ Auto-numbered footnote 4.
+ <footnote backrefs="id4" ids="id11" names="3">
+ <label>
+ 3
+ <paragraph>
+ Manually-numbered footnote 3
+ <footnote auto="1" dupnames="five" ids="five">
+ <label>
+ 5
+ <paragraph>
+ Auto-numbered footnote 5.
+ <footnote auto="1" backrefs="id5" ids="id12" names="6">
+ <label>
+ 6
+ <paragraph>
+ Auto-numbered footnote 6.
+ <footnote auto="1" dupnames="five" ids="id13">
+ <label>
+ 7
+ <system_message backrefs="id13" level="2" line="15" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "five".
+ <paragraph>
+ Auto-numbered footnote 5 again (duplicate).
+ <system_message backrefs="id15" ids="id14" level="3" line="4" source="test data" type="ERROR">
+ <paragraph>
+ Too many autonumbered footnote references: only 2 corresponding footnotes available.
+"""],
+["""\
+Referencing a footnote by symbol [*]_.
+
+.. [*] This is an auto-symbol footnote.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Referencing a footnote by symbol \n\
+ <footnote_reference auto="*" ids="id1" refid="id2">
+ *
+ .
+ <footnote auto="*" backrefs="id1" ids="id2">
+ <label>
+ *
+ <paragraph>
+ This is an auto-symbol footnote.
+"""],
+["""\
+A sequence of symbol footnote references:
+[*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_ [*]_.
+
+.. [*] Auto-symbol footnote 1.
+.. [*] Auto-symbol footnote 2.
+.. [*] Auto-symbol footnote 3.
+.. [*] Auto-symbol footnote 4.
+.. [*] Auto-symbol footnote 5.
+.. [*] Auto-symbol footnote 6.
+.. [*] Auto-symbol footnote 7.
+.. [*] Auto-symbol footnote 8.
+.. [*] Auto-symbol footnote 9.
+.. [*] Auto-symbol footnote 10.
+.. [*] Auto-symbol footnote 11.
+.. [*] Auto-symbol footnote 12.
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ A sequence of symbol footnote references:
+ <footnote_reference auto="*" ids="id1" refid="id13">
+ *
+ \n\
+ <footnote_reference auto="*" ids="id2" refid="id14">
+ \u2020
+ \n\
+ <footnote_reference auto="*" ids="id3" refid="id15">
+ \u2021
+ \n\
+ <footnote_reference auto="*" ids="id4" refid="id16">
+ \u00A7
+ \n\
+ <footnote_reference auto="*" ids="id5" refid="id17">
+ \u00B6
+ \n\
+ <footnote_reference auto="*" ids="id6" refid="id18">
+ #
+ \n\
+ <footnote_reference auto="*" ids="id7" refid="id19">
+ \u2660
+ \n\
+ <footnote_reference auto="*" ids="id8" refid="id20">
+ \u2665
+ \n\
+ <footnote_reference auto="*" ids="id9" refid="id21">
+ \u2666
+ \n\
+ <footnote_reference auto="*" ids="id10" refid="id22">
+ \u2663
+ \n\
+ <footnote_reference auto="*" ids="id11" refid="id23">
+ **
+ \n\
+ <footnote_reference auto="*" ids="id12" refid="id24">
+ \u2020\u2020
+ .
+ <footnote auto="*" backrefs="id1" ids="id13">
+ <label>
+ *
+ <paragraph>
+ Auto-symbol footnote 1.
+ <footnote auto="*" backrefs="id2" ids="id14">
+ <label>
+ \u2020
+ <paragraph>
+ Auto-symbol footnote 2.
+ <footnote auto="*" backrefs="id3" ids="id15">
+ <label>
+ \u2021
+ <paragraph>
+ Auto-symbol footnote 3.
+ <footnote auto="*" backrefs="id4" ids="id16">
+ <label>
+ \u00A7
+ <paragraph>
+ Auto-symbol footnote 4.
+ <footnote auto="*" backrefs="id5" ids="id17">
+ <label>
+ \u00B6
+ <paragraph>
+ Auto-symbol footnote 5.
+ <footnote auto="*" backrefs="id6" ids="id18">
+ <label>
+ #
+ <paragraph>
+ Auto-symbol footnote 6.
+ <footnote auto="*" backrefs="id7" ids="id19">
+ <label>
+ \u2660
+ <paragraph>
+ Auto-symbol footnote 7.
+ <footnote auto="*" backrefs="id8" ids="id20">
+ <label>
+ \u2665
+ <paragraph>
+ Auto-symbol footnote 8.
+ <footnote auto="*" backrefs="id9" ids="id21">
+ <label>
+ \u2666
+ <paragraph>
+ Auto-symbol footnote 9.
+ <footnote auto="*" backrefs="id10" ids="id22">
+ <label>
+ \u2663
+ <paragraph>
+ Auto-symbol footnote 10.
+ <footnote auto="*" backrefs="id11" ids="id23">
+ <label>
+ **
+ <paragraph>
+ Auto-symbol footnote 11.
+ <footnote auto="*" backrefs="id12" ids="id24">
+ <label>
+ \u2020\u2020
+ <paragraph>
+ Auto-symbol footnote 12.
+"""],
+["""\
+Duplicate manual footnote labels:
+
+.. [1] Footnote.
+
+.. [1] Footnote.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Duplicate manual footnote labels:
+ <footnote dupnames="1" ids="id1">
+ <label>
+ 1
+ <paragraph>
+ Footnote.
+ <footnote dupnames="1" ids="id2">
+ <label>
+ 1
+ <system_message backrefs="id2" level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "1".
+ <paragraph>
+ Footnote.
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_hyperlinks.py b/test/test_transforms/test_hyperlinks.py
new file mode 100755
index 000000000..cef12a4f1
--- /dev/null
+++ b/test/test_transforms/test_hyperlinks.py
@@ -0,0 +1,845 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for docutils.transforms.references.Hyperlinks.
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.transforms.references import PropagateTargets, \
+ AnonymousHyperlinks, IndirectHyperlinks, ExternalTargets, \
+ InternalTargets, DanglingReferences
+
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+# Exhaustive listing of hyperlink variations: every combination of
+# target/reference, direct/indirect, internal/external, and named/anonymous,
+# plus embedded URIs.
+totest['exhaustive_hyperlinks'] = ((PropagateTargets, AnonymousHyperlinks,
+ IndirectHyperlinks,
+ ExternalTargets, InternalTargets,
+ DanglingReferences), [
+["""\
+direct_ external
+
+.. _direct: http://direct
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="direct" refuri="http://direct">
+ direct
+ external
+ <target ids="direct" names="direct" refuri="http://direct">
+"""],
+["""\
+indirect_ external
+
+.. _indirect: xtarget_
+.. _xtarget: http://indirect
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="indirect" refuri="http://indirect">
+ indirect
+ external
+ <target ids="indirect" names="indirect" refuri="http://indirect">
+ <target ids="xtarget" names="xtarget" refuri="http://indirect">
+"""],
+["""\
+.. _direct:
+
+direct_ internal
+""",
+"""\
+<document source="test data">
+ <target refid="direct">
+ <paragraph ids="direct" names="direct">
+ <reference name="direct" refid="direct">
+ direct
+ internal
+"""],
+["""\
+.. _ztarget:
+
+indirect_ internal
+
+.. _indirect2: ztarget_
+.. _indirect: indirect2_
+""",
+"""\
+<document source="test data">
+ <target refid="ztarget">
+ <paragraph ids="ztarget" names="ztarget">
+ <reference name="indirect" refid="ztarget">
+ indirect
+ internal
+ <target ids="indirect2" names="indirect2" refid="ztarget">
+ <target ids="indirect" names="indirect" refid="ztarget">
+"""],
+["""\
+Implicit
+--------
+
+indirect_ internal
+
+.. _indirect: implicit_
+""",
+"""\
+<document source="test data">
+ <section ids="implicit" names="implicit">
+ <title>
+ Implicit
+ <paragraph>
+ <reference name="indirect" refid="implicit">
+ indirect
+ internal
+ <target ids="indirect" names="indirect" refid="implicit">
+"""],
+["""\
+Implicit
+--------
+
+`multiply-indirect`_ internal
+
+.. _multiply-indirect: indirect_
+.. _indirect: implicit_
+""",
+"""\
+<document source="test data">
+ <section ids="implicit" names="implicit">
+ <title>
+ Implicit
+ <paragraph>
+ <reference name="multiply-indirect" refid="implicit">
+ multiply-indirect
+ internal
+ <target ids="multiply-indirect" names="multiply-indirect" refid="implicit">
+ <target ids="indirect" names="indirect" refid="implicit">
+"""],
+["""\
+circular_ indirect reference
+
+.. _circular: indirect_
+.. _indirect: circular_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ circular_
+ indirect reference
+ <target ids="circular" names="circular" refid="circular">
+ <problematic ids="id3 indirect" names="indirect" refid="id1">
+ .. _indirect: circular_
+ <system_message backrefs="id2 id3" ids="id1" level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ Indirect hyperlink target "circular" (id="circular") refers to target "indirect", forming a circular reference.
+"""],
+["""\
+Implicit
+--------
+
+Duplicate implicit targets.
+
+Implicit
+--------
+
+indirect_ internal
+
+.. _indirect: implicit_
+
+Direct internal reference: Implicit_
+""",
+"""\
+<document source="test data">
+ <section dupnames="implicit" ids="implicit">
+ <title>
+ Implicit
+ <paragraph>
+ Duplicate implicit targets.
+ <section dupnames="implicit" ids="id1">
+ <title>
+ Implicit
+ <system_message backrefs="id1" level="1" line="7" source="test data" type="INFO">
+ <paragraph>
+ Duplicate implicit target name: "implicit".
+ <paragraph>
+ <problematic ids="id3" refid="id2">
+ indirect_
+ internal
+ <target ids="indirect" names="indirect" refname="implicit">
+ <paragraph>
+ Direct internal reference:
+ <problematic ids="id5" refid="id4">
+ Implicit_
+ <system_message backrefs="id3" ids="id2" level="3" line="11" source="test data" type="ERROR">
+ <paragraph>
+ Indirect hyperlink target "indirect" (id="indirect") refers to target "implicit", which is a duplicate, and cannot be used as a unique reference.
+ <system_message backrefs="id5" ids="id4" level="3" line="13" source="test data" type="ERROR">
+ <paragraph>
+ Duplicate target name, cannot be used as a unique reference: "implicit".
+"""],
+["""\
+`direct external`__
+
+__ http://direct
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference anonymous="1" name="direct external" refuri="http://direct">
+ direct external
+ <target anonymous="1" ids="id1" refuri="http://direct">
+"""],
+["""\
+`indirect external`__
+
+__ xtarget_
+.. _xtarget: http://indirect
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference anonymous="1" name="indirect external" refuri="http://indirect">
+ indirect external
+ <target anonymous="1" ids="id1" refuri="http://indirect">
+ <target ids="xtarget" names="xtarget" refuri="http://indirect">
+"""],
+["""\
+__
+
+`direct internal`__
+""",
+"""\
+<document source="test data">
+ <target anonymous="1" refid="id1">
+ <paragraph ids="id1">
+ <reference anonymous="1" name="direct internal" refid="id1">
+ direct internal
+"""],
+["""\
+.. _ztarget:
+
+`indirect internal`__
+
+__ ztarget_
+""",
+"""\
+<document source="test data">
+ <target refid="ztarget">
+ <paragraph ids="ztarget" names="ztarget">
+ <reference anonymous="1" name="indirect internal" refid="ztarget">
+ indirect internal
+ <target anonymous="1" ids="id1" refid="ztarget">
+"""],
+["""\
+.. _ztarget:
+
+First
+
+.. _ztarget:
+
+Second
+
+`indirect internal`__
+
+__ ztarget_
+""",
+"""\
+<document source="test data">
+ <target dupnames="ztarget" refid="ztarget">
+ <paragraph ids="ztarget">
+ First
+ <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "ztarget".
+ <target dupnames="ztarget" refid="id1">
+ <paragraph ids="id1">
+ Second
+ <paragraph>
+ <problematic ids="id4" refid="id3">
+ `indirect internal`__
+ <target anonymous="1" ids="id2" refname="ztarget">
+ <system_message backrefs="id4" ids="id3" level="3" line="11" source="test data" type="ERROR">
+ <paragraph>
+ Indirect hyperlink target (id="id2") refers to target "ztarget", which is a duplicate, and cannot be used as a unique reference.
+"""],
+["""\
+The next anonymous hyperlink reference is parsed (and discarded) at
+some point, but nonetheless anonymous hyperlink references and targets
+match in this snippet.
+
+.. |invalid| replace:: anonymous__
+
+hyperlink__
+
+__ URL
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ The next anonymous hyperlink reference is parsed (and discarded) at
+ some point, but nonetheless anonymous hyperlink references and targets
+ match in this snippet.
+ <system_message level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ Substitution definition contains illegal element:
+ <literal_block xml:space="preserve">
+ <reference anonymous="1" name="anonymous">
+ anonymous
+ <literal_block xml:space="preserve">
+ .. |invalid| replace:: anonymous__
+ <paragraph>
+ <reference anonymous="1" name="hyperlink" refuri="URL">
+ hyperlink
+ <target anonymous="1" ids="id1" refuri="URL">
+"""],
+["""\
+An `embedded uri <http://direct>`_.
+
+Another reference to the same `embedded URI`_.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ An \n\
+ <reference name="embedded uri" refuri="http://direct">
+ embedded uri
+ <target ids="embedded-uri" names="embedded\ uri" refuri="http://direct">
+ .
+ <paragraph>
+ Another reference to the same \n\
+ <reference name="embedded URI" refuri="http://direct">
+ embedded URI
+ .
+"""],
+["""\
+An `anonymous embedded uri <http://direct>`__.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ An \n\
+ <reference name="anonymous embedded uri" refuri="http://direct">
+ anonymous embedded uri
+ .
+"""],
+["""\
+.. _target:
+
+.. [1] Footnote; target_
+""",
+"""\
+<document source="test data">
+ <target ids="target" names="target">
+ <footnote ids="id1" names="1">
+ <label>
+ 1
+ <paragraph>
+ Footnote; \n\
+ <reference name="target" refid="target">
+ target
+"""],
+["""\
+.. _target:
+
+.. [cit] Citation; target_
+""",
+"""\
+<document source="test data">
+ <target ids="target" names="target">
+ <citation ids="cit" names="cit">
+ <label>
+ cit
+ <paragraph>
+ Citation; \n\
+ <reference name="target" refid="target">
+ target
+"""],
+])
+
+totest['hyperlinks'] = ((PropagateTargets, AnonymousHyperlinks,
+ IndirectHyperlinks, ExternalTargets,
+ InternalTargets, DanglingReferences), [
+["""\
+.. _internal hyperlink:
+
+This paragraph referenced.
+
+By this `internal hyperlink`_ reference.
+""",
+"""\
+<document source="test data">
+ <target refid="internal-hyperlink">
+ <paragraph ids="internal-hyperlink" names="internal\ hyperlink">
+ This paragraph referenced.
+ <paragraph>
+ By this \n\
+ <reference name="internal hyperlink" refid="internal-hyperlink">
+ internal hyperlink
+ reference.
+"""],
+["""\
+.. _chained:
+.. _internal hyperlink:
+
+This paragraph referenced.
+
+By this `internal hyperlink`_ reference
+as well as by this chained_ reference.
+
+The results of the transform are not visible at the XML level.
+""",
+"""\
+<document source="test data">
+ <target refid="chained">
+ <target refid="internal-hyperlink">
+ <paragraph ids="internal-hyperlink chained" names="internal\ hyperlink chained">
+ This paragraph referenced.
+ <paragraph>
+ By this \n\
+ <reference name="internal hyperlink" refid="internal-hyperlink">
+ internal hyperlink
+ reference
+ as well as by this \n\
+ <reference name="chained" refid="chained">
+ chained
+ reference.
+ <paragraph>
+ The results of the transform are not visible at the XML level.
+"""],
+["""\
+.. _chained:
+__ http://anonymous
+
+Anonymous__ and chained_ both refer to the same URI.
+""",
+"""\
+<document source="test data">
+ <target refid="chained">
+ <target anonymous="1" ids="id1 chained" names="chained" refuri="http://anonymous">
+ <paragraph>
+ <reference anonymous="1" name="Anonymous" refuri="http://anonymous">
+ Anonymous
+ and \n\
+ <reference name="chained" refuri="http://anonymous">
+ chained
+ both refer to the same URI.
+"""],
+["""\
+.. _a:
+.. _b:
+
+x
+""",
+"""\
+<document source="test data">
+ <target refid="a">
+ <target refid="b">
+ <paragraph ids="b a" names="b a">
+ x
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Hyperlink target "a" is not referenced.
+ <system_message level="1" line="2" source="test data" type="INFO">
+ <paragraph>
+ Hyperlink target "b" is not referenced.
+"""],
+["""\
+.. _a:
+.. _b:
+
+a_
+""",
+"""\
+<document source="test data">
+ <target refid="a">
+ <target refid="b">
+ <paragraph ids="b a" names="b a">
+ <reference name="a" refid="a">
+ a
+ <system_message level="1" line="2" source="test data" type="INFO">
+ <paragraph>
+ Hyperlink target "b" is not referenced.
+"""],
+["""\
+.. _a:
+.. _b:
+
+b_
+""",
+"""\
+<document source="test data">
+ <target refid="a">
+ <target refid="b">
+ <paragraph ids="b a" names="b a">
+ <reference name="b" refid="b">
+ b
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Hyperlink target "a" is not referenced.
+"""],
+["""\
+.. _a:
+.. _b:
+
+a_\ b_
+""",
+"""\
+<document source="test data">
+ <target refid="a">
+ <target refid="b">
+ <paragraph ids="b a" names="b a">
+ <reference name="a" refid="a">
+ a
+ <reference name="b" refid="b">
+ b
+"""],
+["""\
+.. _external hyperlink: http://uri
+
+`External hyperlink`_ reference.
+""",
+"""\
+<document source="test data">
+ <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
+ <paragraph>
+ <reference name="External hyperlink" refuri="http://uri">
+ External hyperlink
+ reference.
+"""],
+["""\
+.. _external hyperlink: http://uri
+.. _indirect target: `external hyperlink`_
+""",
+"""\
+<document source="test data">
+ <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
+ <target ids="indirect-target" names="indirect\ target" refuri="http://uri">
+ <system_message level="1" line="2" source="test data" type="INFO">
+ <paragraph>
+ Hyperlink target "indirect target" is not referenced.
+"""],
+["""\
+.. _chained:
+.. _external hyperlink: http://uri
+
+`External hyperlink`_ reference
+and a chained_ reference too.
+""",
+"""\
+<document source="test data">
+ <target refid="chained">
+ <target ids="external-hyperlink chained" names="external\ hyperlink chained" refuri="http://uri">
+ <paragraph>
+ <reference name="External hyperlink" refuri="http://uri">
+ External hyperlink
+ reference
+ and a \n\
+ <reference name="chained" refuri="http://uri">
+ chained
+ reference too.
+"""],
+["""\
+.. _external hyperlink: http://uri
+.. _indirect hyperlink: `external hyperlink`_
+
+`Indirect hyperlink`_ reference.
+""",
+"""\
+<document source="test data">
+ <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
+ <target ids="indirect-hyperlink" names="indirect\ hyperlink" refuri="http://uri">
+ <paragraph>
+ <reference name="Indirect hyperlink" refuri="http://uri">
+ Indirect hyperlink
+ reference.
+"""],
+["""\
+.. _external hyperlink: http://uri
+.. _chained:
+.. _indirect hyperlink: `external hyperlink`_
+
+Chained_ `indirect hyperlink`_ reference.
+""",
+"""\
+<document source="test data">
+ <target ids="external-hyperlink" names="external\ hyperlink" refuri="http://uri">
+ <target refuri="http://uri">
+ <target ids="indirect-hyperlink chained" names="indirect\ hyperlink chained" refuri="http://uri">
+ <paragraph>
+ <reference name="Chained" refuri="http://uri">
+ Chained
+ \n\
+ <reference name="indirect hyperlink" refuri="http://uri">
+ indirect hyperlink
+ reference.
+"""],
+["""\
+.. __: http://full
+__
+__ http://simplified
+.. _external: http://indirect.external
+__ external_
+__
+
+`Full syntax anonymous external hyperlink reference`__,
+`chained anonymous external reference`__,
+`simplified syntax anonymous external hyperlink reference`__,
+`indirect anonymous hyperlink reference`__,
+`internal anonymous hyperlink reference`__.
+""",
+"""\
+<document source="test data">
+ <target anonymous="1" ids="id1" refuri="http://full">
+ <target anonymous="1" refid="id2">
+ <target anonymous="1" ids="id3 id2" refuri="http://simplified">
+ <target ids="external" names="external" refuri="http://indirect.external">
+ <target anonymous="1" ids="id4" refuri="http://indirect.external">
+ <target anonymous="1" refid="id5">
+ <paragraph ids="id5">
+ <reference anonymous="1" name="Full syntax anonymous external hyperlink reference" refuri="http://full">
+ Full syntax anonymous external hyperlink reference
+ ,
+ <reference anonymous="1" name="chained anonymous external reference" refuri="http://simplified">
+ chained anonymous external reference
+ ,
+ <reference anonymous="1" name="simplified syntax anonymous external hyperlink reference" refuri="http://simplified">
+ simplified syntax anonymous external hyperlink reference
+ ,
+ <reference anonymous="1" name="indirect anonymous hyperlink reference" refuri="http://indirect.external">
+ indirect anonymous hyperlink reference
+ ,
+ <reference anonymous="1" name="internal anonymous hyperlink reference" refid="id5">
+ internal anonymous hyperlink reference
+ .
+"""],
+["""\
+Duplicate external target_'s (different URIs):
+
+.. _target: first
+
+.. _target: second
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Duplicate external \n\
+ <problematic ids="id3" refid="id2">
+ target_
+ 's (different URIs):
+ <target dupnames="target" ids="target" refuri="first">
+ <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "target".
+ <target dupnames="target" ids="id1" refuri="second">
+ <system_message backrefs="id3" ids="id2" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Duplicate target name, cannot be used as a unique reference: "target".
+"""],
+["""\
+Duplicate external targets (different URIs) without reference:
+
+.. _target: first
+
+.. _target: second
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Duplicate external targets (different URIs) without reference:
+ <target dupnames="target" ids="target" refuri="first">
+ <system_message backrefs="id1" level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "target".
+ <target dupnames="target" ids="id1" refuri="second">
+"""],
+["""\
+Several__ anonymous__ hyperlinks__, but not enough targets.
+
+__ http://example.org
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id3" refid="id2">
+ Several__
+ \n\
+ <problematic ids="id4" refid="id2">
+ anonymous__
+ \n\
+ <problematic ids="id5" refid="id2">
+ hyperlinks__
+ , but not enough targets.
+ <target anonymous="1" ids="id1" refuri="http://example.org">
+ <system_message backrefs="id3 id4 id5" ids="id2" level="3" source="test data" type="ERROR">
+ <paragraph>
+ Anonymous hyperlink mismatch: 3 references but 1 targets.
+ See "backrefs" attribute for IDs.
+"""],
+["""\
+.. _external: http://uri
+.. _indirect: external_
+.. _internal:
+
+.. image:: picture.png
+ :target: external_
+
+.. image:: picture.png
+ :target: indirect_
+
+.. image:: picture.png
+ :target: internal_
+""",
+"""\
+<document source="test data">
+ <target ids="external" names="external" refuri="http://uri">
+ <target ids="indirect" names="indirect" refuri="http://uri">
+ <target refid="internal">
+ <reference ids="internal" name="external" names="internal" refuri="http://uri">
+ <image uri="picture.png">
+ <reference name="indirect" refuri="http://uri">
+ <image uri="picture.png">
+ <reference name="internal" refid="internal">
+ <image uri="picture.png">
+"""],
+["""\
+.. contents:: Table of Contents
+.. _indirect reference to the table of contents: `table of contents`_
+
+Section
+=======
+
+Testing an `indirect reference to the table of contents`_.
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
+ <title>
+ Table of Contents
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id1" refid="section">
+ Section
+ <target ids="indirect-reference-to-the-table-of-contents" names="indirect\ reference\ to\ the\ table\ of\ contents" refid="table-of-contents">
+ <section ids="section" names="section">
+ <title refid="id1">
+ Section
+ <paragraph>
+ Testing an
+ <reference name="indirect reference to the table of contents" refid="table-of-contents">
+ indirect reference to the table of contents
+ .
+"""],
+["""\
+.. _explicit target:
+
+Title
+-----
+
+Let's reference it (`explicit target`_) to avoid an irrelevant error.
+""",
+"""\
+<document source="test data">
+ <target refid="explicit-target">
+ <section ids="title explicit-target" names="title explicit\ target">
+ <title>
+ Title
+ <paragraph>
+ Let's reference it (
+ <reference name="explicit target" refid="explicit-target">
+ explicit target
+ ) to avoid an irrelevant error.
+"""],
+["""\
+target1_ should refer to target2_, not the Title.
+
+.. _target1:
+.. _target2: URI
+
+Title
+=====
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="target1" refuri="URI">
+ target1
+ should refer to \n\
+ <reference name="target2" refuri="URI">
+ target2
+ , not the Title.
+ <target refid="target1">
+ <target ids="target2 target1" names="target2 target1" refuri="URI">
+ <section ids="title" names="title">
+ <title>
+ Title
+"""],
+["""\
+Unknown reference_.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Unknown \n\
+ <problematic ids="id2" refid="id1">
+ reference_
+ .
+ <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Unknown target name: "reference".
+"""],
+["""\
+Duplicate manual footnote labels, with reference ([1]_):
+
+.. [1] Footnote.
+
+.. [1] Footnote.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Duplicate manual footnote labels, with reference (
+ <problematic ids="id5 id1" refid="id4">
+ [1]_
+ ):
+ <footnote dupnames="1" ids="id2">
+ <label>
+ 1
+ <paragraph>
+ Footnote.
+ <footnote dupnames="1" ids="id3">
+ <label>
+ 1
+ <system_message backrefs="id3" level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "1".
+ <paragraph>
+ Footnote.
+ <system_message backrefs="id5" ids="id4" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Duplicate target name, cannot be used as a unique reference: "1".
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_messages.py b/test/test_transforms/test_messages.py
new file mode 100755
index 000000000..6ff8c9987
--- /dev/null
+++ b/test/test_transforms/test_messages.py
@@ -0,0 +1,66 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for docutils.transforms.universal.Messages.
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.transforms.universal import Messages
+from docutils.transforms.references import Substitutions
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['system_message_sections'] = ((Substitutions, Messages), [
+["""\
+This |unknown substitution| will generate a system message, thanks to
+the ``Substitutions`` transform. The ``Messages`` transform will
+generate a "System Messages" section.
+
+(A second copy of the system message is tacked on to the end of the
+document by the test framework.)
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ This \n\
+ <problematic ids="id2" refid="id1">
+ |unknown substitution|
+ will generate a system message, thanks to
+ the \n\
+ <literal>
+ Substitutions
+ transform. The \n\
+ <literal>
+ Messages
+ transform will
+ generate a "System Messages" section.
+ <paragraph>
+ (A second copy of the system message is tacked on to the end of the
+ document by the test framework.)
+ <section classes="system-messages">
+ <title>
+ Docutils System Messages
+ <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Undefined substitution referenced: "unknown substitution".
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_peps.py b/test/test_transforms/test_peps.py
new file mode 100755
index 000000000..5e34aea80
--- /dev/null
+++ b/test/test_transforms/test_peps.py
@@ -0,0 +1,68 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for docutils.transforms.peps.
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.transforms.peps import TargetNotes
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['target_notes'] = ((TargetNotes,), [
+["""\
+No references or targets exist, therefore
+no "References" section should be generated.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ No references or targets exist, therefore
+ no "References" section should be generated.
+"""],
+["""\
+A target exists, here's the reference_.
+A "References" section should be generated.
+
+.. _reference: http://www.example.org
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A target exists, here's the \n\
+ <reference name="reference" refname="reference">
+ reference
+ \n\
+ <footnote_reference auto="1" ids="id3" refname="TARGET_NOTE: id2">
+ .
+ A "References" section should be generated.
+ <target ids="reference" names="reference" refuri="http://www.example.org">
+ <section ids="id1">
+ <title>
+ References
+ <footnote auto="1" ids="id2" names="TARGET_NOTE:\ id2">
+ <paragraph>
+ <reference refuri="http://www.example.org">
+ http://www.example.org
+"""],
+])
+
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_sectnum.py b/test/test_transforms/test_sectnum.py
new file mode 100755
index 000000000..60237cea1
--- /dev/null
+++ b/test/test_transforms/test_sectnum.py
@@ -0,0 +1,381 @@
+#! /usr/bin/env python
+
+# Author: David Goodger, Dmitry Jemerov
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for `docutils.transforms.parts.SectNum` (via
+`docutils.transforms.universal.LastReaderPending`).
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.transforms.references import Substitutions
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['section_numbers'] = ((Substitutions,), [
+["""\
+.. sectnum::
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+```````
+Paragraph 3.
+
+Title 4
+-------
+Paragraph 4.
+""",
+u"""\
+<document source="test data">
+ <section ids="title-1" names="title\ 1">
+ <title auto="1">
+ <generated classes="sectnum">
+ 1\u00a0\u00a0\u00a0
+ Title 1
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title auto="1">
+ <generated classes="sectnum">
+ 1.1\u00a0\u00a0\u00a0
+ Title 2
+ <paragraph>
+ Paragraph 2.
+ <section ids="title-3" names="title\ 3">
+ <title auto="1">
+ <generated classes="sectnum">
+ 1.1.1\u00a0\u00a0\u00a0
+ Title 3
+ <paragraph>
+ Paragraph 3.
+ <section ids="title-4" names="title\ 4">
+ <title auto="1">
+ <generated classes="sectnum">
+ 1.2\u00a0\u00a0\u00a0
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+.. sectnum::
+
+**Bold Title**
+==============
+Paragraph 1.
+""",
+u"""\
+<document source="test data">
+ <section ids="bold-title" names="bold\ title">
+ <title auto="1">
+ <generated classes="sectnum">
+ 1\u00a0\u00a0\u00a0
+ <strong>
+ Bold Title
+ <paragraph>
+ Paragraph 1.
+"""],
+["""\
+.. sectnum:: :depth: 2
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+```````
+Paragraph 3.
+
+Title 4
+-------
+Paragraph 4.
+""",
+u"""\
+<document source="test data">
+ <section ids="title-1" names="title\ 1">
+ <title auto="1">
+ <generated classes="sectnum">
+ 1\u00a0\u00a0\u00a0
+ Title 1
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title auto="1">
+ <generated classes="sectnum">
+ 1.1\u00a0\u00a0\u00a0
+ Title 2
+ <paragraph>
+ Paragraph 2.
+ <section ids="title-3" names="title\ 3">
+ <title>
+ Title 3
+ <paragraph>
+ Paragraph 3.
+ <section ids="title-4" names="title\ 4">
+ <title auto="1">
+ <generated classes="sectnum">
+ 1.2\u00a0\u00a0\u00a0
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+.. contents::
+.. sectnum:: :depth: 2
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+```````
+Paragraph 3.
+
+Title 4
+-------
+Paragraph 4.
+""",
+u"""\
+<document source="test data">
+ <topic classes="contents" ids="contents" names="contents">
+ <title>
+ Contents
+ <bullet_list classes="auto-toc">
+ <list_item>
+ <paragraph>
+ <reference ids="id1" refid="title-1">
+ <generated classes="sectnum">
+ 1\u00a0\u00a0\u00a0
+ Title 1
+ <bullet_list classes="auto-toc">
+ <list_item>
+ <paragraph>
+ <reference ids="id2" refid="title-2">
+ <generated classes="sectnum">
+ 1.1\u00a0\u00a0\u00a0
+ Title 2
+ <bullet_list>
+ <list_item>
+ <paragraph>
+ <reference ids="id3" refid="title-3">
+ Title 3
+ <list_item>
+ <paragraph>
+ <reference ids="id4" refid="title-4">
+ <generated classes="sectnum">
+ 1.2\u00a0\u00a0\u00a0
+ Title 4
+ <section ids="title-1" names="title\ 1">
+ <title auto="1" refid="id1">
+ <generated classes="sectnum">
+ 1\u00a0\u00a0\u00a0
+ Title 1
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title auto="1" refid="id2">
+ <generated classes="sectnum">
+ 1.1\u00a0\u00a0\u00a0
+ Title 2
+ <paragraph>
+ Paragraph 2.
+ <section ids="title-3" names="title\ 3">
+ <title refid="id3">
+ Title 3
+ <paragraph>
+ Paragraph 3.
+ <section ids="title-4" names="title\ 4">
+ <title auto="1" refid="id4">
+ <generated classes="sectnum">
+ 1.2\u00a0\u00a0\u00a0
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+.. sectnum::
+ :prefix: Arbitrary-
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+```````
+Paragraph 3.
+
+Title 4
+-------
+Paragraph 4.
+""",
+u"""\
+<document source="test data">
+ <section ids="title-1" names="title\ 1">
+ <title auto="1">
+ <generated classes="sectnum">
+ Arbitrary-1\u00a0\u00a0\u00a0
+ Title 1
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title auto="1">
+ <generated classes="sectnum">
+ Arbitrary-1.1\u00a0\u00a0\u00a0
+ Title 2
+ <paragraph>
+ Paragraph 2.
+ <section ids="title-3" names="title\ 3">
+ <title auto="1">
+ <generated classes="sectnum">
+ Arbitrary-1.1.1\u00a0\u00a0\u00a0
+ Title 3
+ <paragraph>
+ Paragraph 3.
+ <section ids="title-4" names="title\ 4">
+ <title auto="1">
+ <generated classes="sectnum">
+ Arbitrary-1.2\u00a0\u00a0\u00a0
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+.. sectnum::
+ :start: 3
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+```````
+Paragraph 3.
+
+Title 4
+-------
+Paragraph 4.
+""",
+u"""\
+<document source="test data">
+ <section ids="title-1" names="title\ 1">
+ <title auto="1">
+ <generated classes="sectnum">
+ 3\u00a0\u00a0\u00a0
+ Title 1
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title auto="1">
+ <generated classes="sectnum">
+ 3.1\u00a0\u00a0\u00a0
+ Title 2
+ <paragraph>
+ Paragraph 2.
+ <section ids="title-3" names="title\ 3">
+ <title auto="1">
+ <generated classes="sectnum">
+ 3.1.1\u00a0\u00a0\u00a0
+ Title 3
+ <paragraph>
+ Paragraph 3.
+ <section ids="title-4" names="title\ 4">
+ <title auto="1">
+ <generated classes="sectnum">
+ 3.2\u00a0\u00a0\u00a0
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+.. sectnum::
+ :prefix: (5.9.
+ :suffix: )
+ :start: 3
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+```````
+Paragraph 3.
+
+Title 4
+-------
+Paragraph 4.
+""",
+u"""\
+<document source="test data">
+ <section ids="title-1" names="title\ 1">
+ <title auto="1">
+ <generated classes="sectnum">
+ (5.9.3)\u00a0\u00a0\u00a0
+ Title 1
+ <paragraph>
+ Paragraph 1.
+ <section ids="title-2" names="title\ 2">
+ <title auto="1">
+ <generated classes="sectnum">
+ (5.9.3.1)\u00a0\u00a0\u00a0
+ Title 2
+ <paragraph>
+ Paragraph 2.
+ <section ids="title-3" names="title\ 3">
+ <title auto="1">
+ <generated classes="sectnum">
+ (5.9.3.1.1)\u00a0\u00a0\u00a0
+ Title 3
+ <paragraph>
+ Paragraph 3.
+ <section ids="title-4" names="title\ 4">
+ <title auto="1">
+ <generated classes="sectnum">
+ (5.9.3.2)\u00a0\u00a0\u00a0
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_strip_comments.py b/test/test_transforms/test_strip_comments.py
new file mode 100755
index 000000000..e3efc1e14
--- /dev/null
+++ b/test/test_transforms/test_strip_comments.py
@@ -0,0 +1,49 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@python.org
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for docutils.transforms.universal.StripComments.
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.transforms.universal import StripComments
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(
+ parser, suite_settings={'strip_comments': 1})
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['strip_comments'] = ((StripComments,), [
+["""\
+.. this is a comment
+
+Title
+=====
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <section ids="title" names="title">
+ <title>
+ Title
+ <paragraph>
+ Paragraph.
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_substitutions.py b/test/test_transforms/test_substitutions.py
new file mode 100755
index 000000000..196bec9a1
--- /dev/null
+++ b/test/test_transforms/test_substitutions.py
@@ -0,0 +1,353 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for docutils.transforms.references.Substitutions.
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.transforms.references import Substitutions
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['substitutions'] = ((Substitutions,), [
+["""\
+The |biohazard| symbol is deservedly scary-looking.
+
+.. |biohazard| image:: biohazard.png
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ The \n\
+ <image alt="biohazard" uri="biohazard.png">
+ symbol is deservedly scary-looking.
+ <substitution_definition names="biohazard">
+ <image alt="biohazard" uri="biohazard.png">
+"""],
+["""\
+Here's an |unknown| substitution.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Here's an \n\
+ <problematic ids="id2" refid="id1">
+ |unknown|
+ substitution.
+ <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Undefined substitution referenced: "unknown".
+"""],
+[u"""\
+Substitutions support case differences:
+
+.. |eacute| replace:: \u00E9
+.. |Eacute| replace:: \u00C9
+
+|Eacute|\\t\\ |eacute|, and even |EACUTE|.
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Substitutions support case differences:
+ <substitution_definition names="eacute">
+ \u00E9
+ <substitution_definition names="Eacute">
+ \u00C9
+ <paragraph>
+ \u00C9
+ t
+ \u00E9
+ , and even \n\
+ \u00C9
+ .
+"""],
+[u"""\
+Indirect substitution definitions with multiple references:
+
+|substitute| my coke for gin
+|substitute| you for my mum
+at least I'll get my washing done
+
+.. |substitute| replace:: |replace|
+.. |replace| replace:: swap
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Indirect substitution definitions with multiple references:
+ <paragraph>
+ swap
+ my coke for gin
+ swap
+ you for my mum
+ at least I'll get my washing done
+ <substitution_definition names="substitute">
+ swap
+ <substitution_definition names="replace">
+ swap
+"""],
+["""\
+.. |l| unicode:: U+00AB .. left chevron
+.. |r| unicode:: U+00BB .. right chevron
+.. |.| replace:: |l|\ ``.``\ |r|
+
+.. Delete either of the following lines, and there is no error.
+
+Regular expression |.| will match any character
+
+.. Note:: Note that |.| matches *exactly* one character
+""",
+u"""\
+<document source="test data">
+ <substitution_definition names="l">
+ \xab
+ <substitution_definition names="r">
+ \xbb
+ <substitution_definition names=".">
+ \xab
+ <literal>
+ .
+ \xbb
+ <comment xml:space="preserve">
+ Delete either of the following lines, and there is no error.
+ <paragraph>
+ Regular expression \n\
+ \xab
+ <literal>
+ .
+ \xbb
+ will match any character
+ <note>
+ <paragraph>
+ Note that \n\
+ \xab
+ <literal>
+ .
+ \xbb
+ matches \n\
+ <emphasis>
+ exactly
+ one character
+"""],
+["""\
+.. |sub| replace:: |sub|
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" names="sub" source="test data" type="ERROR">
+ <paragraph>
+ Circular substitution definition detected:
+ <literal_block xml:space="preserve">
+ .. |sub| replace:: |sub|
+"""],
+["""\
+.. |sub| replace:: |indirect1|
+.. |indirect1| replace:: |indirect2|
+.. |indirect2| replace:: |Sub|
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" names="sub" source="test data" type="ERROR">
+ <paragraph>
+ Circular substitution definition detected:
+ <literal_block xml:space="preserve">
+ .. |sub| replace:: |indirect1|
+ <system_message level="3" line="2" names="indirect1" source="test data" type="ERROR">
+ <paragraph>
+ Circular substitution definition detected:
+ <literal_block xml:space="preserve">
+ .. |indirect1| replace:: |indirect2|
+ <system_message level="3" line="3" names="indirect2" source="test data" type="ERROR">
+ <paragraph>
+ Circular substitution definition detected:
+ <literal_block xml:space="preserve">
+ .. |indirect2| replace:: |Sub|
+"""],
+["""\
+.. |indirect1| replace:: |indirect2|
+.. |indirect2| replace:: |Sub|
+.. |sub| replace:: |indirect1|
+
+Use |sub| and |indirect1| and |sub| again (and |sub| one more time).
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" names="indirect1" source="test data" type="ERROR">
+ <paragraph>
+ Circular substitution definition detected:
+ <literal_block xml:space="preserve">
+ .. |indirect1| replace:: |indirect2|
+ <system_message level="3" line="2" names="indirect2" source="test data" type="ERROR">
+ <paragraph>
+ Circular substitution definition detected:
+ <literal_block xml:space="preserve">
+ .. |indirect2| replace:: |Sub|
+ <system_message level="3" line="3" names="sub" source="test data" type="ERROR">
+ <paragraph>
+ Circular substitution definition detected:
+ <literal_block xml:space="preserve">
+ .. |sub| replace:: |indirect1|
+ <paragraph>
+ Use \n\
+ <problematic ids="id8" refid="id7">
+ and \n\
+ <problematic ids="id2" refid="id1">
+ |indirect1|
+ and \n\
+ <problematic ids="id4" refid="id3">
+ |sub|
+ again (and \n\
+ <problematic ids="id6" refid="id5">
+ |sub|
+ one more time).
+ <system_message backrefs="id2" ids="id1" level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ Circular substitution definition referenced: "indirect1".
+ <system_message backrefs="id4" ids="id3" level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ Circular substitution definition referenced: "sub".
+ <system_message backrefs="id6" ids="id5" level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ Circular substitution definition referenced: "sub".
+ <system_message backrefs="id8" ids="id7" level="3" source="test data" type="ERROR">
+ <paragraph>
+ Circular substitution definition referenced: "Sub".
+"""],
+])
+
+totest['unicode'] = ((Substitutions,), [
+["""\
+Insert an em-dash (|mdash|), a copyright symbol (|copy|), a non-breaking
+space (|nbsp|), a backwards-not-equals (|bne|), and a captial omega (|Omega|).
+
+.. |mdash| unicode:: 0x02014
+.. |copy| unicode:: \\u00A9
+.. |nbsp| unicode:: &#x000A0;
+.. |bne| unicode:: U0003D U020E5
+.. |Omega| unicode:: U+003A9
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Insert an em-dash (
+ \u2014
+ ), a copyright symbol (
+ \u00a9
+ ), a non-breaking
+ space (
+ \u00a0
+ ), a backwards-not-equals (
+ =
+ \u20e5
+ ), and a captial omega (
+ \u03a9
+ ).
+ <substitution_definition names="mdash">
+ \u2014
+ <substitution_definition names="copy">
+ \u00a9
+ <substitution_definition names="nbsp">
+ \u00a0
+ <substitution_definition names="bne">
+ =
+ \u20e5
+ <substitution_definition names="Omega">
+ \u03a9
+"""],
+["""
+Testing comments and extra text.
+
+Copyright |copy| 2003, |BogusMegaCorp (TM)|.
+
+.. |copy| unicode:: 0xA9 .. copyright sign
+.. |BogusMegaCorp (TM)| unicode:: BogusMegaCorp U+2122
+ .. with trademark sign
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Testing comments and extra text.
+ <paragraph>
+ Copyright \n\
+ \u00a9
+ 2003, \n\
+ BogusMegaCorp
+ \u2122
+ .
+ <substitution_definition names="copy">
+ \u00a9
+ <substitution_definition names="BogusMegaCorp\ (TM)">
+ BogusMegaCorp
+ \u2122
+"""],
+["""\
+Insert an em-dash |---| automatically trimming whitespace.
+Some substitutions |TM| only need trimming on one side.
+
+.. |---| unicode:: U+02014
+ :trim:
+.. |TM| unicode:: U+02122
+ :ltrim:
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Insert an em-dash
+ \u2014
+ automatically trimming whitespace.
+ Some substitutions
+ \u2122
+ only need trimming on one side.
+ <substitution_definition ltrim="1" names="---" rtrim="1">
+ \u2014
+ <substitution_definition ltrim="1" names="TM">
+ \u2122
+"""],
+["""\
+Substitution definition with an illegal element:
+
+.. |target| replace:: _`target`
+
+Make sure this substitution definition is not registered: |target|
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Substitution definition with an illegal element:
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ Substitution definition contains illegal element:
+ <literal_block xml:space="preserve">
+ <target ids="target" names="target">
+ target
+ <literal_block xml:space="preserve">
+ .. |target| replace:: _`target`
+ <paragraph>
+ Make sure this substitution definition is not registered: \n\
+ <problematic ids="id2" refid="id1">
+ |target|
+ <system_message backrefs="id2" ids="id1" level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ Undefined substitution referenced: "target".
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_target_notes.py b/test/test_transforms/test_target_notes.py
new file mode 100755
index 000000000..cf625572d
--- /dev/null
+++ b/test/test_transforms/test_target_notes.py
@@ -0,0 +1,84 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for `docutils.transforms.references.TargetNotes` (via
+`docutils.transforms.universal.LastReaderPending`).
+"""
+
+from __init__ import DocutilsTestSupport
+from docutils.transforms.references import PropagateTargets, \
+ AnonymousHyperlinks, IndirectHyperlinks, ExternalTargets, \
+ InternalTargets, DanglingReferences, Footnotes
+from docutils.parsers.rst import Parser
+
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['tables_of_contents'] = ((PropagateTargets, AnonymousHyperlinks,
+ IndirectHyperlinks,
+ ExternalTargets, InternalTargets,
+ DanglingReferences,
+ ), [
+["""\
+.. _target: http://exammple.org
+
+A reference to a target_.
+
+.. target-notes::
+""",
+"""\
+<document source="test data">
+ <target ids="target" names="target" refuri="http://exammple.org">
+ <paragraph>
+ A reference to a \n\
+ <reference name="target" refuri="http://exammple.org">
+ target
+ \n\
+ <footnote_reference auto="1" ids="id2" refid="id1">
+ .
+ <footnote auto="1" ids="id1" names="TARGET_NOTE:\\ id1">
+ <paragraph>
+ <reference refuri="http://exammple.org">
+ http://exammple.org
+"""],
+["""\
+.. _target: http://exammple.org
+
+A reference to a target_.
+
+.. target-notes:: :class: custom
+""",
+"""\
+<document source="test data">
+ <target ids="target" names="target" refuri="http://exammple.org">
+ <paragraph>
+ A reference to a \n\
+ <reference name="target" refuri="http://exammple.org">
+ target
+ <inline classes="custom">
+ \n\
+ <footnote_reference auto="1" classes="custom" ids="id2" refid="id1">
+ .
+ <footnote auto="1" ids="id1" names="TARGET_NOTE:\\ id1">
+ <paragraph>
+ <reference refuri="http://exammple.org">
+ http://exammple.org
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_transitions.py b/test/test_transforms/test_transitions.py
new file mode 100755
index 000000000..098c8bba3
--- /dev/null
+++ b/test/test_transforms/test_transitions.py
@@ -0,0 +1,308 @@
+#! /usr/bin/env python
+
+# Author: David Goodger
+# Contact: goodger@users.sourceforge.net
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Test module for misc.Transitions transform.
+"""
+
+from __init__ import DocutilsTestSupport # must be imported before docutils
+from docutils.transforms.misc import Transitions
+from docutils.parsers.rst import Parser
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+
+totest = {}
+
+totest['transitions'] = ((Transitions,), [
+["""\
+Section 1
+=========
+
+Subsection 1
+------------
+
+Some text.
+
+----------
+
+Section 2
+=========
+
+Some text.
+""",
+"""\
+<document source="test data">
+ <section ids="section-1" names="section\ 1">
+ <title>
+ Section 1
+ <section ids="subsection-1" names="subsection\ 1">
+ <title>
+ Subsection 1
+ <paragraph>
+ Some text.
+ <transition>
+ <section ids="section-2" names="section\ 2">
+ <title>
+ Section 2
+ <paragraph>
+ Some text.
+"""],
+["""\
+A paragraph.
+
+----------
+
+Section 1
+=========
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph.
+ <transition>
+ <section ids="section-1" names="section\ 1">
+ <title>
+ Section 1
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+--------
+
+A section or document may not begin with a transition.
+
+The DTD specifies that two transitions may not
+be adjacent:
+
+--------
+
+--------
+
+--------
+
+The DTD also specifies that a section or document
+may not end with a transition.
+
+--------
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Document or section may not begin with a transition.
+ <transition>
+ <paragraph>
+ A section or document may not begin with a transition.
+ <paragraph>
+ The DTD specifies that two transitions may not
+ be adjacent:
+ <transition>
+ <system_message level="3" line="10" source="test data" type="ERROR">
+ <paragraph>
+ At least one body element must separate transitions; adjacent transitions are not allowed.
+ <transition>
+ <system_message level="3" line="12" source="test data" type="ERROR">
+ <paragraph>
+ At least one body element must separate transitions; adjacent transitions are not allowed.
+ <transition>
+ <paragraph>
+ The DTD also specifies that a section or document
+ may not end with a transition.
+ <transition>
+ <system_message level="3" line="17" source="test data" type="ERROR">
+ <paragraph>
+ Document may not end with a transition.
+"""],
+["""\
+Sections with transitions at beginning and end.
+
+Section 1
+=========
+
+----------
+
+The next transition is legal:
+
+----------
+
+Section 2
+=========
+
+----------
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Sections with transitions at beginning and end.
+ <section ids="section-1" names="section\ 1">
+ <title>
+ Section 1
+ <system_message level="3" line="6" source="test data" type="ERROR">
+ <paragraph>
+ Document or section may not begin with a transition.
+ <transition>
+ <paragraph>
+ The next transition is legal:
+ <transition>
+ <section ids="section-2" names="section\ 2">
+ <title>
+ Section 2
+ <system_message level="3" line="15" source="test data" type="ERROR">
+ <paragraph>
+ Document or section may not begin with a transition.
+ <transition>
+ <system_message level="3" line="15" source="test data" type="ERROR">
+ <paragraph>
+ Document may not end with a transition.
+"""],
+["""\
+A paragraph and two transitions.
+
+----------
+
+----------
+""", # the same:
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph and two transitions.
+ <transition>
+ <system_message level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ At least one body element must separate transitions; adjacent transitions are not allowed.
+ <transition>
+ <system_message level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ Document may not end with a transition.
+"""],
+["""\
+A paragraph, two transitions, and a blank line.
+
+----------
+
+----------
+
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph, two transitions, and a blank line.
+ <transition>
+ <system_message level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ At least one body element must separate transitions; adjacent transitions are not allowed.
+ <transition>
+ <system_message level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ Document may not end with a transition.
+"""],
+["""\
+----------
+
+Document beginning with a transition.
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Document or section may not begin with a transition.
+ <transition>
+ <paragraph>
+ Document beginning with a transition.
+"""],
+["""\
+Section 1
+=========
+
+----------
+
+----------
+
+----------
+
+Section 2
+=========
+
+Some text.
+""",
+"""\
+<document source="test data">
+ <section ids="section-1" names="section\ 1">
+ <title>
+ Section 1
+ <system_message level="3" line="4" source="test data" type="ERROR">
+ <paragraph>
+ Document or section may not begin with a transition.
+ <transition>
+ <system_message level="3" line="6" source="test data" type="ERROR">
+ <paragraph>
+ At least one body element must separate transitions; adjacent transitions are not allowed.
+ <transition>
+ <system_message level="3" line="8" source="test data" type="ERROR">
+ <paragraph>
+ At least one body element must separate transitions; adjacent transitions are not allowed.
+ <transition>
+ <section ids="section-2" names="section\ 2">
+ <title>
+ Section 2
+ <paragraph>
+ Some text.
+"""],
+["""\
+----------
+
+----------
+
+----------
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Document or section may not begin with a transition.
+ <transition>
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ At least one body element must separate transitions; adjacent transitions are not allowed.
+ <transition>
+ <system_message level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ At least one body element must separate transitions; adjacent transitions are not allowed.
+ <transition>
+ <system_message level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ Document may not end with a transition.
+"""],
+["""\
+A paragraph.
+
+----------
+
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph.
+ <transition>
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ Document may not end with a transition.
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_transforms/test_writer_aux.py b/test/test_transforms/test_writer_aux.py
new file mode 100755
index 000000000..5ec040a69
--- /dev/null
+++ b/test/test_transforms/test_writer_aux.py
@@ -0,0 +1,57 @@
+#! /usr/bin/env python
+
+# Author: Felix Wiemann
+# Contact: Felix_Wiemann@ososo.de
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Test module for writer_aux transforms.
+"""
+
+from __init__ import DocutilsTestSupport # must be imported before docutils
+from docutils.transforms import writer_aux
+from docutils.parsers.rst import Parser
+
+def suite():
+ parser = Parser()
+ s = DocutilsTestSupport.TransformTestSuite(parser)
+ s.generateTests(totest)
+ return s
+
+
+totest = {}
+
+totest['compound'] = ((writer_aux.Compound,), [
+["""\
+.. class:: compound
+
+.. compound::
+
+ .. class:: paragraph1
+
+ Paragraph 1.
+
+ .. class:: paragraph2
+
+ Paragraph 2.
+
+ Block quote.
+""",
+"""\
+<document source="test data">
+ <paragraph classes="paragraph1 compound">
+ Paragraph 1.
+ <paragraph classes="paragraph2 continued">
+ Paragraph 2.
+ <block_quote classes="continued">
+ <paragraph>
+ Block quote.
+"""],
+])
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')