summaryrefslogtreecommitdiff
path: root/test/test_parsers
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_parsers')
-rw-r--r--test/test_parsers/__init__.py14
-rw-r--r--test/test_parsers/test_rst/__init__.py14
-rw-r--r--test/test_parsers/test_rst/includes/include9.txt3
-rwxr-xr-xtest/test_parsers/test_rst/test_SimpleTableParser.py123
-rwxr-xr-xtest/test_parsers/test_rst/test_TableParser.py207
-rwxr-xr-xtest/test_parsers/test_rst/test_block_quotes.py273
-rwxr-xr-xtest/test_parsers/test_rst/test_bullet_lists.py181
-rwxr-xr-xtest/test_parsers/test_rst/test_citations.py139
-rwxr-xr-xtest/test_parsers/test_rst/test_comments.py319
-rwxr-xr-xtest/test_parsers/test_rst/test_definition_lists.py395
-rw-r--r--test/test_parsers/test_rst/test_directives/__init__.py14
-rw-r--r--test/test_parsers/test_rst/test_directives/empty.txt0
-rw-r--r--test/test_parsers/test_rst/test_directives/include 11.txt1
-rw-r--r--test/test_parsers/test_rst/test_directives/include1.txt4
-rw-r--r--test/test_parsers/test_rst/test_directives/include10.txt7
-rw-r--r--test/test_parsers/test_rst/test_directives/include2.txt5
-rw-r--r--test/test_parsers/test_rst/test_directives/include3.txt3
-rw-r--r--test/test_parsers/test_rst/test_directives/include8.txt3
-rw-r--r--test/test_parsers/test_rst/test_directives/includes/include4.txt3
-rw-r--r--test/test_parsers/test_rst/test_directives/includes/include5.txt3
-rw-r--r--test/test_parsers/test_rst/test_directives/includes/more/include6.txt3
-rw-r--r--test/test_parsers/test_rst/test_directives/includes/sibling/include7.txt1
-rw-r--r--test/test_parsers/test_rst/test_directives/raw1.txt1
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_admonitions.py184
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_compound.py106
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_container.py76
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_contents.py241
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_date.py53
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_decorations.py93
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_default_role.py84
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_figures.py294
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_images.py413
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_include.py412
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_line_blocks.py81
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_meta.py232
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_raw.py154
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_replace.py135
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_role.py230
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_rubrics.py74
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_sidebars.py73
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_tables.py997
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_target_notes.py64
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_test_directives.py208
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_topics.py240
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_unicode.py172
-rwxr-xr-xtest/test_parsers/test_rst/test_directives/test_unknown.py67
-rw-r--r--test/test_parsers/test_rst/test_directives/utf-16.csvbin0 -> 386 bytes
-rwxr-xr-xtest/test_parsers/test_rst/test_doctest_blocks.py74
-rwxr-xr-xtest/test_parsers/test_rst/test_east_asian_text.py324
-rwxr-xr-xtest/test_parsers/test_rst/test_enumerated_lists.py908
-rwxr-xr-xtest/test_parsers/test_rst/test_field_lists.py551
-rwxr-xr-xtest/test_parsers/test_rst/test_footnotes.py332
-rwxr-xr-xtest/test_parsers/test_rst/test_functions.py38
-rwxr-xr-xtest/test_parsers/test_rst/test_inline_markup.py924
-rwxr-xr-xtest/test_parsers/test_rst/test_interpreted.py305
-rwxr-xr-xtest/test_parsers/test_rst/test_line_blocks.py310
-rwxr-xr-xtest/test_parsers/test_rst/test_literal_blocks.py371
-rwxr-xr-xtest/test_parsers/test_rst/test_option_lists.py756
-rwxr-xr-xtest/test_parsers/test_rst/test_outdenting.py90
-rwxr-xr-xtest/test_parsers/test_rst/test_paragraphs.py89
-rwxr-xr-xtest/test_parsers/test_rst/test_section_headers.py897
-rwxr-xr-xtest/test_parsers/test_rst/test_substitutions.py298
-rwxr-xr-xtest/test_parsers/test_rst/test_tables.py1261
-rwxr-xr-xtest/test_parsers/test_rst/test_targets.py440
-rwxr-xr-xtest/test_parsers/test_rst/test_transitions.py309
65 files changed, 14676 insertions, 0 deletions
diff --git a/test/test_parsers/__init__.py b/test/test_parsers/__init__.py
new file mode 100644
index 000000000..46fc50e06
--- /dev/null
+++ b/test/test_parsers/__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_parsers/test_rst/__init__.py b/test/test_parsers/test_rst/__init__.py
new file mode 100644
index 000000000..46fc50e06
--- /dev/null
+++ b/test/test_parsers/test_rst/__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_parsers/test_rst/includes/include9.txt b/test/test_parsers/test_rst/includes/include9.txt
new file mode 100644
index 000000000..9164722b3
--- /dev/null
+++ b/test/test_parsers/test_rst/includes/include9.txt
@@ -0,0 +1,3 @@
+In ../includes/include9.txt.
+
+.. include:: ../test_directives/include2.txt
diff --git a/test/test_parsers/test_rst/test_SimpleTableParser.py b/test/test_parsers/test_rst/test_SimpleTableParser.py
new file mode 100755
index 000000000..aee037206
--- /dev/null
+++ b/test/test_parsers/test_rst/test_SimpleTableParser.py
@@ -0,0 +1,123 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.SimpleTableParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['simple_tables'] = [
+["""\
+============ ============
+A table with two columns.
+============ ============
+""",
+([12, 12],
+ [],
+ [[[0, 0, 1, ['A table with']],
+ [0, 0, 1, ['two columns.']]]])],
+["""\
+============ ============
+A table with two columns
+and two rows.
+============ ============
+""",
+([12, 12],
+ [],
+ [[[0, 0, 1, ['A table with']],
+ [0, 0, 1, ['two columns']]],
+ [[0, 0, 2, ['and']],
+ [0, 0, 2, ['two rows.']]]])],
+["""\
+========== ===========
+A table with four rows,
+-----------------------
+and two columns.
+First and last rows
+contain column spans.
+=======================
+""",
+([10, 11],
+ [],
+ [[[0, 1, 1, ['A table with four rows,']]],
+ [[0, 0, 3, ['and two']],
+ [0, 0, 3, ['columns.']]],
+ [[0, 0, 4, ['First and']],
+ [0, 0, 4, ['last rows']]],
+ [[0, 1, 5, ['contain column spans.']]]])],
+["""\
+======= ===== ======
+A bad table cell 2
+cell 3 cell 4
+============ ======
+""",
+'TableMarkupError: Text in column margin at line offset 1.'],
+["""\
+=========== ================
+A table with two header rows,
+-----------------------------
+the first with a span.
+=========== ================
+Two body rows,
+the second with a span.
+=============================
+""",
+([11, 16],
+ [[[0, 1, 1, ['A table with two header rows,']]],
+ [[0, 0, 3, ['the first']],
+ [0, 0, 3, ['with a span.']]]],
+ [[[0, 0, 5, ['Two body']],
+ [0, 0, 5, ['rows,']]],
+ [[0, 1, 6, ['the second with a span.']]]])],
+["""\
+============ =============
+A table with two head/body
+============ =============
+row separators.
+============ =============
+That's bad.
+============ =============
+""",
+'TableMarkupError: Multiple head/body row separators in table '
+'(at line offset 2 and 4); only one allowed.'],
+["""\
+============ ============
+============ ============
+""",
+([12, 12],
+ [],
+ [[[0, 0, 1, []],
+ [0, 0, 1, []]]])],
+# ["""\
+# ============== ==========
+# Table with row separators
+# ============== ==========
+# and blank
+# -------------- ----------
+# entries
+# -------------- ----------
+# in first
+# -------------- ----------
+# columns.
+# ============== ==========
+# """,
+# '']
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_TableParser.py b/test/test_parsers/test_rst/test_TableParser.py
new file mode 100755
index 000000000..84e4b7563
--- /dev/null
+++ b/test/test_parsers/test_rst/test_TableParser.py
@@ -0,0 +1,207 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.GridTableParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['grid_tables'] = [
+["""\
++-------------------------------------+
+| A table with one cell and one line. |
++-------------------------------------+
+""",
+[(0, 0, 2, 38, ['A table with one cell and one line.'])],
+([37],
+ [],
+ [[(0, 0, 1, ['A table with one cell and one line.'])]])],
+["""\
++--------------+--------------+
+| A table with | two columns. |
++--------------+--------------+
+""",
+[(0, 0, 2, 15, ['A table with']),
+ (0, 15, 2, 30, ['two columns.'])],
+([14, 14],
+ [],
+ [[(0, 0, 1, ['A table with']),
+ (0, 0, 1, ['two columns.'])]])],
+["""\
++--------------+-------------+
+| A table with | two columns |
++--------------+-------------+
+| and | two rows. |
++--------------+-------------+
+""",
+[(0, 0, 2, 15, ['A table with']),
+ (0, 15, 2, 29, ['two columns']),
+ (2, 0, 4, 15, ['and']),
+ (2, 15, 4, 29, ['two rows.'])],
+([14, 13],
+ [],
+ [[(0, 0, 1, ['A table with']),
+ (0, 0, 1, ['two columns'])],
+ [(0, 0, 3, ['and']),
+ (0, 0, 3, ['two rows.'])]])],
+["""\
++--------------------------+
+| A table with three rows, |
++------------+-------------+
+| and two | columns. |
++------------+-------------+
+| First and last rows |
+| contain column spans. |
++--------------------------+
+""",
+[(0, 0, 2, 27, ['A table with three rows,']),
+ (2, 0, 4, 13, ['and two']),
+ (2, 13, 4, 27, ['columns.']),
+ (4, 0, 7, 27, ['First and last rows', 'contain column spans.'])],
+([12, 13],
+ [],
+ [[(0, 1, 1, ['A table with three rows,']),
+ None],
+ [(0, 0, 3, ['and two']),
+ (0, 0, 3, ['columns.'])],
+ [(0, 1, 5, ['First and last rows', 'contain column spans.']),
+ None]])],
+["""\
++------------+-------------+---------------+
+| A table | two rows in | and row spans |
+| with three +-------------+ to left and |
+| columns, | the middle, | right. |
++------------+-------------+---------------+
+""",
+[(0, 0, 4, 13, ['A table', 'with three', 'columns,']),
+ (0, 13, 2, 27, ['two rows in']),
+ (0, 27, 4, 43, ['and row spans', 'to left and', 'right.']),
+ (2, 13, 4, 27, ['the middle,'])],
+([12, 13, 15],
+ [],
+ [[(1, 0, 1, ['A table', 'with three', 'columns,']),
+ (0, 0, 1, ['two rows in']),
+ (1, 0, 1, ['and row spans', 'to left and', 'right.'])],
+ [None,
+ (0, 0, 3, ['the middle,']),
+ None]])],
+["""\
++------------+-------------+---------------+
+| A table | | two rows in | and funny |
+| with 3 +--+-------------+-+ stuff. |
+| columns, | the middle, | | |
++------------+-------------+---------------+
+""",
+[(0, 0, 4, 13, ['A table |', 'with 3 +--', 'columns,']),
+ (0, 13, 2, 27, ['two rows in']),
+ (0, 27, 4, 43, [' and funny', '-+ stuff.', ' |']),
+ (2, 13, 4, 27, ['the middle,'])],
+([12, 13, 15],
+ [],
+ [[(1, 0, 1, ['A table |', 'with 3 +--', 'columns,']),
+ (0, 0, 1, ['two rows in']),
+ (1, 0, 1, [' and funny', '-+ stuff.', ' |'])],
+ [None,
+ (0, 0, 3, ['the middle,']),
+ None]])],
+["""\
++-----------+-------------------------+
+| W/NW cell | N/NE cell |
+| +-------------+-----------+
+| | Middle cell | E/SE cell |
++-----------+-------------+ |
+| S/SE cell | |
++-------------------------+-----------+
+""",
+[(0, 0, 4, 12, ['W/NW cell', '', '']),
+ (0, 12, 2, 38, ['N/NE cell']),
+ (2, 12, 4, 26, ['Middle cell']),
+ (2, 26, 6, 38, ['E/SE cell', '', '']),
+ (4, 0, 6, 26, ['S/SE cell'])],
+([11, 13, 11],
+ [],
+ [[(1, 0, 1, ['W/NW cell', '', '']),
+ (0, 1, 1, ['N/NE cell']),
+ None],
+ [None,
+ (0, 0, 3, ['Middle cell']),
+ (1, 0, 3, ['E/SE cell', '', ''])],
+ [(0, 1, 5, ['S/SE cell']),
+ None,
+ None]])],
+["""\
++--------------+-------------+
+| A bad table. | |
++--------------+ |
+| Cells must be rectangles. |
++----------------------------+
+""",
+'TableMarkupError: Malformed table; parse incomplete.',
+'TableMarkupError: Malformed table; parse incomplete.'],
+["""\
++-------------------------------+
+| A table with two header rows, |
++------------+------------------+
+| the first | with a span. |
++============+==================+
+| Two body | rows, |
++------------+------------------+
+| the second with a span. |
++-------------------------------+
+""",
+[(0, 0, 2, 32, ['A table with two header rows,']),
+ (2, 0, 4, 13, ['the first']),
+ (2, 13, 4, 32, ['with a span.']),
+ (4, 0, 6, 13, ['Two body']),
+ (4, 13, 6, 32, ['rows,']),
+ (6, 0, 8, 32, ['the second with a span.'])],
+([12, 18],
+ [[(0, 1, 1, ['A table with two header rows,']),
+ None],
+ [(0, 0, 3, ['the first']),
+ (0, 0, 3, ['with a span.'])]],
+ [[(0, 0, 5, ['Two body']),
+ (0, 0, 5, ['rows,'])],
+ [(0, 1, 7, ['the second with a span.']),
+ None]])],
+["""\
++-------------------------------+
+| A table with two head/body |
++=============+=================+
+| row | separators. |
++=============+=================+
+| That's bad. | |
++-------------+-----------------+
+""",
+'TableMarkupError: Multiple head/body row separators in table '
+'(at line offset 2 and 4); only one allowed.',
+'TableMarkupError: Multiple head/body row separators in table '
+'(at line offset 2 and 4); only one allowed.'],
+["""\
++-------------------------------------+
+| |
++-------------------------------------+
+""",
+[(0, 0, 2, 38, [''])],
+([37],
+ [],
+ [[(0, 0, 1, [''])]])],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_block_quotes.py b/test/test_parsers/test_rst/test_block_quotes.py
new file mode 100755
index 000000000..dd7561723
--- /dev/null
+++ b/test/test_parsers/test_rst/test_block_quotes.py
@@ -0,0 +1,273 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['block_quotes'] = [
+["""\
+Line 1.
+Line 2.
+
+ Indented.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Line 1.
+ Line 2.
+ <block_quote>
+ <paragraph>
+ Indented.
+"""],
+["""\
+Line 1.
+Line 2.
+
+ Indented 1.
+
+ Indented 2.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Line 1.
+ Line 2.
+ <block_quote>
+ <paragraph>
+ Indented 1.
+ <block_quote>
+ <paragraph>
+ Indented 2.
+"""],
+["""\
+Line 1.
+Line 2.
+ Unexpectedly indented.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Line 1.
+ Line 2.
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ Unexpected indentation.
+ <block_quote>
+ <paragraph>
+ Unexpectedly indented.
+"""],
+["""\
+Line 1.
+Line 2.
+
+ Indented.
+no blank line
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Line 1.
+ Line 2.
+ <block_quote>
+ <paragraph>
+ Indented.
+ <system_message level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Block quote ends without a blank line; unexpected unindent.
+ <paragraph>
+ no blank line
+"""],
+["""\
+Here is a paragraph.
+
+ Indent 8 spaces.
+
+ Indent 4 spaces.
+
+Is this correct? Should it generate a warning?
+Yes, it is correct, no warning necessary.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Here is a paragraph.
+ <block_quote>
+ <block_quote>
+ <paragraph>
+ Indent 8 spaces.
+ <paragraph>
+ Indent 4 spaces.
+ <paragraph>
+ Is this correct? Should it generate a warning?
+ Yes, it is correct, no warning necessary.
+"""],
+["""\
+Paragraph.
+
+ Block quote.
+
+ -- Attribution
+
+Paragraph.
+
+ Block quote.
+
+ --Attribution
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph.
+ <block_quote>
+ <paragraph>
+ Block quote.
+ <attribution>
+ Attribution
+ <paragraph>
+ Paragraph.
+ <block_quote>
+ <paragraph>
+ Block quote.
+ <attribution>
+ Attribution
+"""],
+[u"""\
+Alternative: true em-dash.
+
+ Block quote.
+
+ \u2014 Attribution
+
+Alternative: three hyphens.
+
+ Block quote.
+
+ --- Attribution
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Alternative: true em-dash.
+ <block_quote>
+ <paragraph>
+ Block quote.
+ <attribution>
+ Attribution
+ <paragraph>
+ Alternative: three hyphens.
+ <block_quote>
+ <paragraph>
+ Block quote.
+ <attribution>
+ Attribution
+"""],
+["""\
+Paragraph.
+
+ Block quote.
+
+ -- Attribution line one
+ and line two
+
+Paragraph.
+
+ Block quote.
+
+ -- Attribution line one
+ and line two
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph.
+ <block_quote>
+ <paragraph>
+ Block quote.
+ <attribution>
+ Attribution line one
+ and line two
+ <paragraph>
+ Paragraph.
+ <block_quote>
+ <paragraph>
+ Block quote.
+ <attribution>
+ Attribution line one
+ and line two
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+Paragraph.
+
+ -- Not an attribution
+
+Paragraph.
+
+ Block quote.
+
+ \-- Not an attribution
+
+Paragraph.
+
+ Block quote.
+
+ -- Not an attribution line one
+ and line two
+ and line three
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph.
+ <block_quote>
+ <paragraph>
+ -- Not an attribution
+ <paragraph>
+ Paragraph.
+ <block_quote>
+ <paragraph>
+ Block quote.
+ <paragraph>
+ -- Not an attribution
+ <paragraph>
+ Paragraph.
+ <block_quote>
+ <paragraph>
+ Block quote.
+ <definition_list>
+ <definition_list_item>
+ <term>
+ -- Not an attribution line one
+ <definition>
+ <definition_list>
+ <definition_list_item>
+ <term>
+ and line two
+ <definition>
+ <paragraph>
+ and line three
+"""],
+]
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_bullet_lists.py b/test/test_parsers/test_rst/test_bullet_lists.py
new file mode 100755
index 000000000..12ede6cf1
--- /dev/null
+++ b/test/test_parsers/test_rst/test_bullet_lists.py
@@ -0,0 +1,181 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['bullet_lists'] = [
+["""\
+- item
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ item
+"""],
+["""\
+* item 1
+
+* item 2
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="*">
+ <list_item>
+ <paragraph>
+ item 1
+ <list_item>
+ <paragraph>
+ item 2
+"""],
+["""\
+No blank line between:
+
++ item 1
++ item 2
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ No blank line between:
+ <bullet_list bullet="+">
+ <list_item>
+ <paragraph>
+ item 1
+ <list_item>
+ <paragraph>
+ item 2
+"""],
+["""\
+- item 1, para 1.
+
+ item 1, para 2.
+
+- item 2
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ item 1, para 1.
+ <paragraph>
+ item 1, para 2.
+ <list_item>
+ <paragraph>
+ item 2
+"""],
+["""\
+- item 1, line 1
+ item 1, line 2
+- item 2
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ item 1, line 1
+ item 1, line 2
+ <list_item>
+ <paragraph>
+ item 2
+"""],
+["""\
+Different bullets:
+
+- item 1
+
++ item 2
+
+* item 3
+- item 4
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Different bullets:
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ item 1
+ <bullet_list bullet="+">
+ <list_item>
+ <paragraph>
+ item 2
+ <bullet_list bullet="*">
+ <list_item>
+ <paragraph>
+ item 3
+ <system_message level="2" line="8" source="test data" type="WARNING">
+ <paragraph>
+ Bullet list ends without a blank line; unexpected unindent.
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ item 4
+"""],
+["""\
+- item
+no blank line
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ item
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Bullet list ends without a blank line; unexpected unindent.
+ <paragraph>
+ no blank line
+"""],
+["""\
+-
+
+empty item above
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ empty item above
+"""],
+["""\
+-
+empty item above, no blank line
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="-">
+ <list_item>
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Bullet list ends without a blank line; unexpected unindent.
+ <paragraph>
+ empty item above, no blank line
+"""],
+]
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_citations.py b/test/test_parsers/test_rst/test_citations.py
new file mode 100755
index 000000000..c50e28e0b
--- /dev/null
+++ b/test/test_parsers/test_rst/test_citations.py
@@ -0,0 +1,139 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['citations'] = [
+["""\
+.. [citation] This is a citation.
+""",
+"""\
+<document source="test data">
+ <citation ids="citation" names="citation">
+ <label>
+ citation
+ <paragraph>
+ This is a citation.
+"""],
+["""\
+.. [citation1234] This is a citation with year.
+""",
+"""\
+<document source="test data">
+ <citation ids="citation1234" names="citation1234">
+ <label>
+ citation1234
+ <paragraph>
+ This is a citation with year.
+"""],
+["""\
+.. [citation] This is a citation
+ on multiple lines.
+""",
+"""\
+<document source="test data">
+ <citation ids="citation" names="citation">
+ <label>
+ citation
+ <paragraph>
+ This is a citation
+ on multiple lines.
+"""],
+["""\
+.. [citation1] This is a citation
+ on multiple lines with more space.
+
+.. [citation2] This is a citation
+ on multiple lines with less space.
+""",
+"""\
+<document source="test data">
+ <citation ids="citation1" names="citation1">
+ <label>
+ citation1
+ <paragraph>
+ This is a citation
+ on multiple lines with more space.
+ <citation ids="citation2" names="citation2">
+ <label>
+ citation2
+ <paragraph>
+ This is a citation
+ on multiple lines with less space.
+"""],
+["""\
+.. [citation]
+ This is a citation on multiple lines
+ whose block starts on line 2.
+""",
+"""\
+<document source="test data">
+ <citation ids="citation" names="citation">
+ <label>
+ citation
+ <paragraph>
+ This is a citation on multiple lines
+ whose block starts on line 2.
+"""],
+["""\
+.. [citation]
+
+That was an empty citation.
+""",
+"""\
+<document source="test data">
+ <citation ids="citation" names="citation">
+ <label>
+ citation
+ <paragraph>
+ That was an empty citation.
+"""],
+["""\
+.. [citation]
+No blank line.
+""",
+"""\
+<document source="test data">
+ <citation ids="citation" names="citation">
+ <label>
+ citation
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Explicit markup ends without a blank line; unexpected unindent.
+ <paragraph>
+ No blank line.
+"""],
+["""\
+.. [citation label with spaces] this isn't a citation
+
+.. [*citationlabelwithmarkup*] this isn't a citation
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ [citation label with spaces] this isn't a citation
+ <comment xml:space="preserve">
+ [*citationlabelwithmarkup*] this isn't a citation
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_comments.py b/test/test_parsers/test_rst/test_comments.py
new file mode 100755
index 000000000..a90135ec5
--- /dev/null
+++ b/test/test_parsers/test_rst/test_comments.py
@@ -0,0 +1,319 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['comments'] = [
+["""\
+.. A comment
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ A comment
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. A comment
+ block.
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ A comment
+ block.
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+..
+ A comment consisting of multiple lines
+ starting on the line after the
+ explicit markup start.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ A comment consisting of multiple lines
+ starting on the line after the
+ explicit markup start.
+"""],
+["""\
+.. A comment.
+.. Another.
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ A comment.
+ <comment xml:space="preserve">
+ Another.
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. A comment
+no blank line
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ A comment
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Explicit markup ends without a blank line; unexpected unindent.
+ <paragraph>
+ no blank line
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. A comment.
+.. Another.
+no blank line
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ A comment.
+ <comment xml:space="preserve">
+ Another.
+ <system_message level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Explicit markup ends without a blank line; unexpected unindent.
+ <paragraph>
+ no blank line
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. A comment::
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ A comment::
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+..
+ comment::
+
+The extra newline before the comment text prevents
+the parser from recognizing a directive.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ comment::
+ <paragraph>
+ The extra newline before the comment text prevents
+ the parser from recognizing a directive.
+"""],
+["""\
+..
+ _comment: http://example.org
+
+The extra newline before the comment text prevents
+the parser from recognizing a hyperlink target.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ _comment: http://example.org
+ <paragraph>
+ The extra newline before the comment text prevents
+ the parser from recognizing a hyperlink target.
+"""],
+["""\
+..
+ [comment] Not a citation.
+
+The extra newline before the comment text prevents
+the parser from recognizing a citation.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ [comment] Not a citation.
+ <paragraph>
+ The extra newline before the comment text prevents
+ the parser from recognizing a citation.
+"""],
+["""\
+..
+ |comment| image:: bogus.png
+
+The extra newline before the comment text prevents
+the parser from recognizing a substitution definition.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ |comment| image:: bogus.png
+ <paragraph>
+ The extra newline before the comment text prevents
+ the parser from recognizing a substitution definition.
+"""],
+["""\
+.. Next is an empty comment, which serves to end this comment and
+ prevents the following block quote being swallowed up.
+
+..
+
+ A block quote.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ Next is an empty comment, which serves to end this comment and
+ prevents the following block quote being swallowed up.
+ <comment xml:space="preserve">
+ <block_quote>
+ <paragraph>
+ A block quote.
+"""],
+["""\
+term 1
+ definition 1
+
+ .. a comment
+
+term 2
+ definition 2
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term 1
+ <definition>
+ <paragraph>
+ definition 1
+ <comment xml:space="preserve">
+ a comment
+ <definition_list_item>
+ <term>
+ term 2
+ <definition>
+ <paragraph>
+ definition 2
+"""],
+["""\
+term 1
+ definition 1
+
+.. a comment
+
+term 2
+ definition 2
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term 1
+ <definition>
+ <paragraph>
+ definition 1
+ <comment xml:space="preserve">
+ a comment
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term 2
+ <definition>
+ <paragraph>
+ definition 2
+"""],
+["""\
++ bullet paragraph 1
+
+ bullet paragraph 2
+
+ .. comment between bullet paragraphs 2 and 3
+
+ bullet paragraph 3
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="+">
+ <list_item>
+ <paragraph>
+ bullet paragraph 1
+ <paragraph>
+ bullet paragraph 2
+ <comment xml:space="preserve">
+ comment between bullet paragraphs 2 and 3
+ <paragraph>
+ bullet paragraph 3
+"""],
+["""\
++ bullet paragraph 1
+
+ .. comment between bullet paragraphs 1 (leader) and 2
+
+ bullet paragraph 2
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="+">
+ <list_item>
+ <paragraph>
+ bullet paragraph 1
+ <comment xml:space="preserve">
+ comment between bullet paragraphs 1 (leader) and 2
+ <paragraph>
+ bullet paragraph 2
+"""],
+["""\
++ bullet
+
+ .. trailing comment
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="+">
+ <list_item>
+ <paragraph>
+ bullet
+ <comment xml:space="preserve">
+ trailing comment
+"""],
+]
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_definition_lists.py b/test/test_parsers/test_rst/test_definition_lists.py
new file mode 100755
index 000000000..d9f3211c0
--- /dev/null
+++ b/test/test_parsers/test_rst/test_definition_lists.py
@@ -0,0 +1,395 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['definition_lists'] = [
+["""\
+term
+ definition
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term
+ <definition>
+ <paragraph>
+ definition
+"""],
+["""\
+term
+ definition
+
+paragraph
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term
+ <definition>
+ <paragraph>
+ definition
+ <paragraph>
+ paragraph
+"""],
+["""\
+term
+ definition
+no blank line
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term
+ <definition>
+ <paragraph>
+ definition
+ <system_message level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Definition list ends without a blank line; unexpected unindent.
+ <paragraph>
+ no blank line
+"""],
+["""\
+A paragraph::
+ A literal block without a blank line first?
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ A paragraph::
+ <definition>
+ <system_message level="1" line="2" source="test data" type="INFO">
+ <paragraph>
+ Blank line missing before literal block (after the "::")? Interpreted as a definition list item.
+ <paragraph>
+ A literal block without a blank line first?
+"""],
+["""\
+this is not a term;
+a term may only be one line long
+ this is not a definition
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ this is not a term;
+ a term may only be one line long
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ Unexpected indentation.
+ <block_quote>
+ <paragraph>
+ this is not a definition
+"""],
+["""\
+term 1
+ definition 1
+
+term 2
+ definition 2
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term 1
+ <definition>
+ <paragraph>
+ definition 1
+ <definition_list_item>
+ <term>
+ term 2
+ <definition>
+ <paragraph>
+ definition 2
+"""],
+["""\
+term 1
+ definition 1 (no blank line below)
+term 2
+ definition 2
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term 1
+ <definition>
+ <paragraph>
+ definition 1 (no blank line below)
+ <definition_list_item>
+ <term>
+ term 2
+ <definition>
+ <paragraph>
+ definition 2
+"""],
+["""\
+term 1
+ definition 1 (no blank line below)
+term 2
+ definition 2
+No blank line after the definition list.
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term 1
+ <definition>
+ <paragraph>
+ definition 1 (no blank line below)
+ <definition_list_item>
+ <term>
+ term 2
+ <definition>
+ <paragraph>
+ definition 2
+ <system_message level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Definition list ends without a blank line; unexpected unindent.
+ <paragraph>
+ No blank line after the definition list.
+"""],
+["""\
+term 1
+ definition 1
+
+ term 1a
+ definition 1a
+
+ term 1b
+ definition 1b
+
+term 2
+ definition 2
+
+paragraph
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term 1
+ <definition>
+ <paragraph>
+ definition 1
+ <definition_list>
+ <definition_list_item>
+ <term>
+ term 1a
+ <definition>
+ <paragraph>
+ definition 1a
+ <definition_list_item>
+ <term>
+ term 1b
+ <definition>
+ <paragraph>
+ definition 1b
+ <definition_list_item>
+ <term>
+ term 2
+ <definition>
+ <paragraph>
+ definition 2
+ <paragraph>
+ paragraph
+"""],
+["""\
+Term : classifier
+ The ' : ' indicates a classifier in
+ definition list item terms only.
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ Term
+ <classifier>
+ classifier
+ <definition>
+ <paragraph>
+ The ' : ' indicates a classifier in
+ definition list item terms only.
+"""],
+["""\
+Term: not a classifier
+ Because there's no space before the colon.
+Term :not a classifier
+ Because there's no space after the colon.
+Term \: not a classifier
+ Because the colon is escaped.
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ Term: not a classifier
+ <definition>
+ <paragraph>
+ Because there's no space before the colon.
+ <definition_list_item>
+ <term>
+ Term :not a classifier
+ <definition>
+ <paragraph>
+ Because there's no space after the colon.
+ <definition_list_item>
+ <term>
+ Term : not a classifier
+ <definition>
+ <paragraph>
+ Because the colon is escaped.
+"""],
+["""\
+``Term : not a classifier``
+ Because the ' : ' is inside an inline literal.
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ <literal>
+ Term : not a classifier
+ <definition>
+ <paragraph>
+ Because the ' : ' is inside an inline literal.
+"""],
+["""\
+Term `with *inline ``text **errors : classifier `with *errors ``too
+ Definition `with *inline ``text **markup errors.
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ Term \n\
+ <problematic ids="id2" refid="id1">
+ `
+ with \n\
+ <problematic ids="id4" refid="id3">
+ *
+ inline \n\
+ <problematic ids="id6" refid="id5">
+ ``
+ text \n\
+ <problematic ids="id8" refid="id7">
+ **
+ errors
+ <classifier>
+ classifier \n\
+ <problematic ids="id10" refid="id9">
+ `
+ with \n\
+ <problematic ids="id12" refid="id11">
+ *
+ errors \n\
+ <problematic ids="id14" refid="id13">
+ ``
+ too
+ <definition>
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline interpreted text or phrase reference start-string without end-string.
+ <system_message backrefs="id4" ids="id3" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline emphasis start-string without end-string.
+ <system_message backrefs="id6" ids="id5" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline literal start-string without end-string.
+ <system_message backrefs="id8" ids="id7" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline strong start-string without end-string.
+ <system_message backrefs="id10" ids="id9" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline interpreted text or phrase reference start-string without end-string.
+ <system_message backrefs="id12" ids="id11" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline emphasis start-string without end-string.
+ <system_message backrefs="id14" ids="id13" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline literal start-string without end-string.
+ <paragraph>
+ Definition \n\
+ <problematic ids="id16" refid="id15">
+ `
+ with \n\
+ <problematic ids="id18" refid="id17">
+ *
+ inline \n\
+ <problematic ids="id20" refid="id19">
+ ``
+ text \n\
+ <problematic ids="id22" refid="id21">
+ **
+ markup errors.
+ <system_message backrefs="id16" ids="id15" level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Inline interpreted text or phrase reference start-string without end-string.
+ <system_message backrefs="id18" ids="id17" level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Inline emphasis start-string without end-string.
+ <system_message backrefs="id20" ids="id19" level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Inline literal start-string without end-string.
+ <system_message backrefs="id22" ids="id21" level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Inline strong start-string without end-string.
+"""],
+["""\
+Term : classifier one : classifier two
+ Definition
+""",
+"""\
+<document source="test data">
+ <definition_list>
+ <definition_list_item>
+ <term>
+ Term
+ <classifier>
+ classifier one
+ <classifier>
+ classifier two
+ <definition>
+ <paragraph>
+ Definition
+"""],
+]
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/__init__.py b/test/test_parsers/test_rst/test_directives/__init__.py
new file mode 100644
index 000000000..46fc50e06
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/__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_parsers/test_rst/test_directives/empty.txt b/test/test_parsers/test_rst/test_directives/empty.txt
new file mode 100644
index 000000000..e69de29bb
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/empty.txt
diff --git a/test/test_parsers/test_rst/test_directives/include 11.txt b/test/test_parsers/test_rst/test_directives/include 11.txt
new file mode 100644
index 000000000..7b57bd29e
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/include 11.txt
@@ -0,0 +1 @@
+some text
diff --git a/test/test_parsers/test_rst/test_directives/include1.txt b/test/test_parsers/test_rst/test_directives/include1.txt
new file mode 100644
index 000000000..82f605320
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/include1.txt
@@ -0,0 +1,4 @@
+Inclusion 1
+-----------
+
+This file is used by ``test_include.py``.
diff --git a/test/test_parsers/test_rst/test_directives/include10.txt b/test/test_parsers/test_rst/test_directives/include10.txt
new file mode 100644
index 000000000..8eb5b1720
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/include10.txt
@@ -0,0 +1,7 @@
+.. |bad| unicode:: 0xFFFFFFFFF
+
+hi
+-----
+
+hi
+-----
diff --git a/test/test_parsers/test_rst/test_directives/include2.txt b/test/test_parsers/test_rst/test_directives/include2.txt
new file mode 100644
index 000000000..3149a7bf6
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/include2.txt
@@ -0,0 +1,5 @@
+Here are some paragraphs
+that can appear at any level.
+
+This file (include2.txt) is used by
+``test_include.py``.
diff --git a/test/test_parsers/test_rst/test_directives/include3.txt b/test/test_parsers/test_rst/test_directives/include3.txt
new file mode 100644
index 000000000..9996a4452
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/include3.txt
@@ -0,0 +1,3 @@
+In include3.txt
+
+.. include:: includes/include4.txt
diff --git a/test/test_parsers/test_rst/test_directives/include8.txt b/test/test_parsers/test_rst/test_directives/include8.txt
new file mode 100644
index 000000000..e7fc57a3d
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/include8.txt
@@ -0,0 +1,3 @@
+In include8.txt
+
+.. include:: ../includes/include9.txt
diff --git a/test/test_parsers/test_rst/test_directives/includes/include4.txt b/test/test_parsers/test_rst/test_directives/includes/include4.txt
new file mode 100644
index 000000000..384772a77
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/includes/include4.txt
@@ -0,0 +1,3 @@
+In includes/include4.txt
+
+.. include:: include5.txt
diff --git a/test/test_parsers/test_rst/test_directives/includes/include5.txt b/test/test_parsers/test_rst/test_directives/includes/include5.txt
new file mode 100644
index 000000000..64b3e3aa2
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/includes/include5.txt
@@ -0,0 +1,3 @@
+In includes/include5.txt
+
+.. include:: more/include6.txt
diff --git a/test/test_parsers/test_rst/test_directives/includes/more/include6.txt b/test/test_parsers/test_rst/test_directives/includes/more/include6.txt
new file mode 100644
index 000000000..8ac403b01
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/includes/more/include6.txt
@@ -0,0 +1,3 @@
+In includes/more/include6.txt
+
+.. include:: ../sibling/include7.txt
diff --git a/test/test_parsers/test_rst/test_directives/includes/sibling/include7.txt b/test/test_parsers/test_rst/test_directives/includes/sibling/include7.txt
new file mode 100644
index 000000000..fe85aa963
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/includes/sibling/include7.txt
@@ -0,0 +1 @@
+In includes/sibling/include7.txt
diff --git a/test/test_parsers/test_rst/test_directives/raw1.txt b/test/test_parsers/test_rst/test_directives/raw1.txt
new file mode 100644
index 000000000..7ea03651b
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/raw1.txt
@@ -0,0 +1 @@
+<p>This file is used by <tt>test_raw.py</tt>.</p>
diff --git a/test/test_parsers/test_rst/test_directives/test_admonitions.py b/test/test_parsers/test_rst/test_directives/test_admonitions.py
new file mode 100755
index 000000000..aaa5aa8d3
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_admonitions.py
@@ -0,0 +1,184 @@
+#! /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 admonitions.py directives.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['admonitions'] = [
+["""\
+.. Attention:: Directives at large.
+
+.. Note:: This is a note.
+
+.. Tip:: 15% if the
+ service is good.
+
+.. Hint:: It's bigger than a bread box.
+
+- .. WARNING:: Strong prose may provoke extreme mental exertion.
+ Reader discretion is strongly advised.
+- .. Error:: Does not compute.
+
+.. Caution::
+
+ Don't take any wooden nickels.
+
+.. DANGER:: Mad scientist at work!
+
+.. Important::
+ - Wash behind your ears.
+ - Clean up your room.
+ - Call your mother.
+ - Back up your data.
+""",
+"""\
+<document source="test data">
+ <attention>
+ <paragraph>
+ Directives at large.
+ <note>
+ <paragraph>
+ This is a note.
+ <tip>
+ <paragraph>
+ 15% if the
+ service is good.
+ <hint>
+ <paragraph>
+ It's bigger than a bread box.
+ <bullet_list bullet="-">
+ <list_item>
+ <warning>
+ <paragraph>
+ Strong prose may provoke extreme mental exertion.
+ Reader discretion is strongly advised.
+ <list_item>
+ <error>
+ <paragraph>
+ Does not compute.
+ <caution>
+ <paragraph>
+ Don't take any wooden nickels.
+ <danger>
+ <paragraph>
+ Mad scientist at work!
+ <important>
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ Wash behind your ears.
+ <list_item>
+ <paragraph>
+ Clean up your room.
+ <list_item>
+ <paragraph>
+ Call your mother.
+ <list_item>
+ <paragraph>
+ Back up your data.
+"""],
+["""\
+.. note:: One-line notes.
+.. note:: One after the other.
+.. note:: No blank lines in-between.
+""",
+"""\
+<document source="test data">
+ <note>
+ <paragraph>
+ One-line notes.
+ <note>
+ <paragraph>
+ One after the other.
+ <note>
+ <paragraph>
+ No blank lines in-between.
+"""],
+["""\
+.. note::
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ The "note" admonition is empty; content required.
+ <literal_block xml:space="preserve">
+ .. note::
+"""],
+["""\
+.. admonition:: Admonition
+
+ This is a generic admonition.
+""",
+"""\
+<document source="test data">
+ <admonition classes="admonition-admonition">
+ <title>
+ Admonition
+ <paragraph>
+ This is a generic admonition.
+"""],
+["""\
+.. admonition:: And, by the way...
+
+ You can make up your own admonition too.
+""",
+"""\
+<document source="test data">
+ <admonition classes="admonition-and-by-the-way">
+ <title>
+ And, by the way...
+ <paragraph>
+ You can make up your own admonition too.
+"""],
+["""\
+.. admonition:: Admonition
+ :class: emergency
+
+ Test the "class" override.
+""",
+"""\
+<document source="test data">
+ <admonition classes="emergency">
+ <title>
+ Admonition
+ <paragraph>
+ Test the "class" override.
+"""],
+["""\
+.. admonition::
+
+ Generic admonitions require a title.
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "admonition" directive:
+ 1 argument(s) required, 0 supplied.
+ <literal_block xml:space="preserve">
+ .. admonition::
+
+ Generic admonitions require a title.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_compound.py b/test/test_parsers/test_rst/test_directives/test_compound.py
new file mode 100755
index 000000000..eea4dd53b
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_compound.py
@@ -0,0 +1,106 @@
+#! /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 the 'compound' directive from body.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['compound'] = [
+["""\
+.. compound::
+
+ Compound paragraphs are single logical paragraphs
+ which contain embedded
+
+ * lists
+ * tables
+ * literal blocks
+ * and other body elements
+
+ and are split into multiple physical paragraphs.
+""",
+"""\
+<document source="test data">
+ <compound>
+ <paragraph>
+ Compound paragraphs are single logical paragraphs
+ which contain embedded
+ <bullet_list bullet="*">
+ <list_item>
+ <paragraph>
+ lists
+ <list_item>
+ <paragraph>
+ tables
+ <list_item>
+ <paragraph>
+ literal blocks
+ <list_item>
+ <paragraph>
+ and other body elements
+ <paragraph>
+ and are split into multiple physical paragraphs.
+"""],
+["""\
+.. compound::
+
+ This is an extremely interesting compound paragraph containing a
+ simple paragraph, a literal block with some useless log messages::
+
+ Connecting... OK
+ Transmitting data... OK
+ Disconnecting... OK
+
+ and another simple paragraph which is actually just a continuation
+ of the first simple paragraph, with the literal block in between.
+""",
+"""\
+<document source="test data">
+ <compound>
+ <paragraph>
+ This is an extremely interesting compound paragraph containing a
+ simple paragraph, a literal block with some useless log messages:
+ <literal_block xml:space="preserve">
+ Connecting... OK
+ Transmitting data... OK
+ Disconnecting... OK
+ <paragraph>
+ and another simple paragraph which is actually just a continuation
+ of the first simple paragraph, with the literal block in between.
+"""],
+["""\
+.. compound:: arg1 arg2
+
+ text
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "compound" directive:
+ no arguments permitted; blank line required before content block.
+ <literal_block xml:space="preserve">
+ .. compound:: arg1 arg2
+ \n\
+ text
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_container.py b/test/test_parsers/test_rst/test_directives/test_container.py
new file mode 100755
index 000000000..3c740611a
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_container.py
@@ -0,0 +1,76 @@
+#! /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 the 'container' directive from body.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['container'] = [
+["""\
+.. container::
+
+ "container" is a generic element, an extension mechanism for
+ users & applications.
+
+ Containers may contain arbitrary body elements.
+""",
+"""\
+<document source="test data">
+ <container>
+ <paragraph>
+ "container" is a generic element, an extension mechanism for
+ users & applications.
+ <paragraph>
+ Containers may contain arbitrary body elements.
+"""],
+["""\
+.. container:: custom
+
+ Some text.
+""",
+"""\
+<document source="test data">
+ <container classes="custom">
+ <paragraph>
+ Some text.
+"""],
+["""\
+.. container:: one two three
+ four
+
+ Multiple classes.
+
+ Multi-line argument.
+
+ Multiple paragraphs in the container.
+""",
+"""\
+<document source="test data">
+ <container classes="one two three four">
+ <paragraph>
+ Multiple classes.
+ <paragraph>
+ Multi-line argument.
+ <paragraph>
+ Multiple paragraphs in the container.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_contents.py b/test/test_parsers/test_rst/test_directives/test_contents.py
new file mode 100755
index 000000000..cb7bbec0f
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_contents.py
@@ -0,0 +1,241 @@
+#! /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 parts.py contents directive.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['contents'] = [
+["""\
+.. contents::
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="contents" names="contents">
+ <title>
+ Contents
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.parts.Contents
+ .details:
+"""],
+["""\
+.. contents:: Table of Contents
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
+ <title>
+ Table of Contents
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.parts.Contents
+ .details:
+"""],
+["""\
+.. contents::
+ Table of Contents
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
+ <title>
+ Table of Contents
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.parts.Contents
+ .details:
+"""],
+["""\
+.. contents:: Table
+ of
+ Contents
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
+ <title>
+ Table
+ of
+ Contents
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.parts.Contents
+ .details:
+"""],
+["""\
+.. contents:: *Table* of ``Contents``
+""",
+"""\
+<document source="test data">
+ <topic classes="contents" ids="table-of-contents" names="table\ of\ contents">
+ <title>
+ <emphasis>
+ Table
+ of
+ <literal>
+ Contents
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.parts.Contents
+ .details:
+"""],
+["""\
+.. contents::
+ :depth: 2
+ :local:
+""",
+"""\
+<document source="test data">
+ <topic classes="contents local" ids="contents" names="contents">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.parts.Contents
+ .details:
+ depth: 2
+ local: None
+"""],
+["""\
+.. contents::
+ :local: arg
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "contents" directive:
+ invalid option value: (option: "local"; value: 'arg')
+ no argument is allowed; "arg" supplied.
+ <literal_block xml:space="preserve">
+ .. contents::
+ :local: arg
+"""],
+["""\
+.. contents:: Table of Contents
+ :local:
+ :depth: 2
+ :backlinks: none
+""",
+"""\
+<document source="test data">
+ <topic classes="contents local" ids="table-of-contents" names="table\ of\ contents">
+ <title>
+ Table of Contents
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.parts.Contents
+ .details:
+ backlinks: None
+ depth: 2
+ local: None
+"""],
+["""\
+.. contents::
+ :depth: two
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "contents" directive:
+ invalid option value: (option: "depth"; value: 'two')
+ invalid literal for int(): two.
+ <literal_block xml:space="preserve">
+ .. contents::
+ :depth: two
+"""],
+["""\
+.. contents::
+ :width: 2
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "contents" directive:
+ unknown option: "width".
+ <literal_block xml:space="preserve">
+ .. contents::
+ :width: 2
+"""],
+["""\
+.. contents::
+ :backlinks: no way!
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "contents" directive:
+ invalid option value: (option: "backlinks"; value: 'no way!')
+ "no way!" unknown; choose from "top", "entry", or "none".
+ <literal_block xml:space="preserve">
+ .. contents::
+ :backlinks: no way!
+"""],
+["""\
+.. contents::
+ :backlinks:
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "contents" directive:
+ invalid option value: (option: "backlinks"; value: None)
+ must supply an argument; choose from "top", "entry", or "none".
+ <literal_block xml:space="preserve">
+ .. contents::
+ :backlinks:
+"""],
+["""\
+* .. contents::
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="*">
+ <list_item>
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ The "contents" directive may not be used within topics or body elements.
+ <literal_block xml:space="preserve">
+ .. contents::
+"""],
+["""\
+.. sidebar:: containing contents
+
+ .. contents::
+""",
+"""\
+<document source="test data">
+ <sidebar>
+ <title>
+ containing contents
+ <topic classes="contents" ids="contents" names="contents">
+ <title>
+ Contents
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.parts.Contents
+ .details:
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_date.py b/test/test_parsers/test_rst/test_directives/test_date.py
new file mode 100755
index 000000000..0364331b1
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_date.py
@@ -0,0 +1,53 @@
+#! /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 the misc.py "date" directive.
+"""
+
+from __init__ import DocutilsTestSupport
+import time
+
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['date'] = [
+["""\
+.. |date| date::
+
+Today's date is |date|.
+""",
+"""\
+<document source="test data">
+ <substitution_definition names="date">
+ %s
+ <paragraph>
+ Today's date is \n\
+ <substitution_reference refname="date">
+ date
+ .
+""" % time.strftime('%Y-%m-%d')],
+["""\
+.. |date| date:: %a, %d %b %Y
+""",
+"""\
+<document source="test data">
+ <substitution_definition names="date">
+ %s
+""" % time.strftime('%a, %d %b %Y')],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_decorations.py b/test/test_parsers/test_rst/test_directives/test_decorations.py
new file mode 100755
index 000000000..c770c6a49
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_decorations.py
@@ -0,0 +1,93 @@
+#! /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 the "header" & "footer" directives.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['headers'] = [
+["""\
+.. header:: a paragraph for the header
+""",
+"""\
+<document source="test data">
+ <decoration>
+ <header>
+ <paragraph>
+ a paragraph for the header
+"""],
+["""\
+.. header::
+""",
+"""\
+<document source="test data">
+ <decoration>
+ <header>
+ <paragraph>
+ Problem with the "header" directive: no content supplied.
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Content block expected for the "header" directive; none found.
+ <literal_block xml:space="preserve">
+ .. header::
+"""],
+["""\
+.. header:: first part of the header
+.. header:: second part of the header
+""",
+"""\
+<document source="test data">
+ <decoration>
+ <header>
+ <paragraph>
+ first part of the header
+ <paragraph>
+ second part of the header
+"""],
+]
+
+totest['footers'] = [
+["""\
+.. footer:: a paragraph for the footer
+""",
+"""\
+<document source="test data">
+ <decoration>
+ <footer>
+ <paragraph>
+ a paragraph for the footer
+"""],
+["""\
+.. footer:: even if a footer is declared first
+.. header:: the header appears first
+""",
+"""\
+<document source="test data">
+ <decoration>
+ <header>
+ <paragraph>
+ the header appears first
+ <footer>
+ <paragraph>
+ even if a footer is declared first
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_default_role.py b/test/test_parsers/test_rst/test_directives/test_default_role.py
new file mode 100755
index 000000000..fc9343247
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_default_role.py
@@ -0,0 +1,84 @@
+#! /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 misc.py "default-role" directive.
+"""
+
+from __init__ import DocutilsTestSupport
+
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['default-role'] = [
+["""\
+.. default-role:: subscript
+
+This is a `subscript`.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ This is a \n\
+ <subscript>
+ subscript
+ .
+"""],
+["""\
+Must define a custom role before using it.
+
+.. default-role:: custom
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Must define a custom role before using it.
+ <system_message level="1" line="3" source="test data" type="INFO">
+ <paragraph>
+ No role entry for "custom" in module "docutils.parsers.rst.languages.en".
+ Trying "custom" as canonical role name.
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ Unknown interpreted text role "custom".
+ <literal_block xml:space="preserve">
+ .. default-role:: custom
+"""],
+["""\
+.. role:: custom
+.. default-role:: custom
+
+This text uses the `default role`.
+
+.. default-role::
+
+Returned the `default role` to its standard default.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ This text uses the \n\
+ <inline classes="custom">
+ default role
+ .
+ <paragraph>
+ Returned the \n\
+ <title_reference>
+ default role
+ to its standard default.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_figures.py b/test/test_parsers/test_rst/test_directives/test_figures.py
new file mode 100755
index 000000000..91fd91596
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_figures.py
@@ -0,0 +1,294 @@
+#! /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 images.py figure directives.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['figures'] = [
+["""\
+.. figure:: picture.png
+""",
+"""\
+<document source="test data">
+ <figure>
+ <image uri="picture.png">
+"""],
+["""\
+.. figure:: picture.png
+
+ A picture with a caption.
+""",
+"""\
+<document source="test data">
+ <figure>
+ <image uri="picture.png">
+ <caption>
+ A picture with a caption.
+"""],
+["""\
+.. figure:: picture.png
+
+ - A picture with an invalid caption.
+""",
+"""\
+<document source="test data">
+ <figure>
+ <image uri="picture.png">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Figure caption must be a paragraph or empty comment.
+ <literal_block xml:space="preserve">
+ .. figure:: picture.png
+ \n\
+ - A picture with an invalid caption.
+"""],
+["""\
+.. figure:: picture.png
+
+ ..
+
+ A picture with a legend but no caption.
+""",
+"""\
+<document source="test data">
+ <figure>
+ <image uri="picture.png">
+ <legend>
+ <paragraph>
+ A picture with a legend but no caption.
+"""],
+["""\
+.. Figure:: picture.png
+ :height: 100
+ :width: 200
+ :scale: 50
+
+ A picture with image options and a caption.
+""",
+"""\
+<document source="test data">
+ <figure>
+ <image height="100" scale="50" uri="picture.png" width="200">
+ <caption>
+ A picture with image options and a caption.
+"""],
+["""\
+.. Figure:: picture.png
+ :height: 100
+ :alt: alternate text
+ :width: 200
+ :scale: 50
+ :figwidth: 300
+ :figclass: class1 class2
+
+ A picture with image options on individual lines, and this caption.
+""",
+"""\
+<document source="test data">
+ <figure classes="class1 class2" width="300">
+ <image alt="alternate text" height="100" scale="50" uri="picture.png" width="200">
+ <caption>
+ A picture with image options on individual lines, and this caption.
+"""],
+["""\
+.. figure:: picture.png
+ :align: center
+
+ A figure with explicit alignment.
+""",
+"""\
+<document source="test data">
+ <figure align="center">
+ <image uri="picture.png">
+ <caption>
+ A figure with explicit alignment.
+"""],
+["""\
+.. figure:: picture.png
+ :align: top
+
+ A figure with wrong alignment.
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "figure" directive:
+ invalid option value: (option: "align"; value: 'top')
+ "top" unknown; choose from "left", "center", or "right".
+ <literal_block xml:space="preserve">
+ .. figure:: picture.png
+ :align: top
+
+ A figure with wrong alignment.
+"""],
+["""\
+This figure lacks a caption. It may still have a
+"Figure 1."-style caption appended in the output.
+
+.. figure:: picture.png
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ This figure lacks a caption. It may still have a
+ "Figure 1."-style caption appended in the output.
+ <figure>
+ <image uri="picture.png">
+"""],
+["""\
+.. figure:: picture.png
+
+ A picture with a caption and a legend.
+
+ +-----------------------+-----------------------+
+ | Symbol | Meaning |
+ +=======================+=======================+
+ | .. image:: tent.png | Campground |
+ +-----------------------+-----------------------+
+ | .. image:: waves.png | Lake |
+ +-----------------------+-----------------------+
+ | .. image:: peak.png | Mountain |
+ +-----------------------+-----------------------+
+""",
+"""\
+<document source="test data">
+ <figure>
+ <image uri="picture.png">
+ <caption>
+ A picture with a caption and a legend.
+ <legend>
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="23">
+ <colspec colwidth="23">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ Symbol
+ <entry>
+ <paragraph>
+ Meaning
+ <tbody>
+ <row>
+ <entry>
+ <image uri="tent.png">
+ <entry>
+ <paragraph>
+ Campground
+ <row>
+ <entry>
+ <image uri="waves.png">
+ <entry>
+ <paragraph>
+ Lake
+ <row>
+ <entry>
+ <image uri="peak.png">
+ <entry>
+ <paragraph>
+ Mountain
+"""],
+["""\
+.. figure:: picture.png
+
+ ..
+
+ A picture with a legend but no caption.
+ (The empty comment replaces the caption, which must
+ be a single paragraph.)
+""",
+"""\
+<document source="test data">
+ <figure>
+ <image uri="picture.png">
+ <legend>
+ <paragraph>
+ A picture with a legend but no caption.
+ (The empty comment replaces the caption, which must
+ be a single paragraph.)
+"""],
+["""\
+Testing for line-leaks:
+
+.. figure:: picture.png
+
+ A picture with a caption.
+.. figure:: picture.png
+
+ A picture with a caption.
+.. figure:: picture.png
+
+ A picture with a caption.
+.. figure:: picture.png
+.. figure:: picture.png
+.. figure:: picture.png
+.. figure:: picture.png
+
+ A picture with a caption.
+
+.. figure:: picture.png
+
+.. figure:: picture.png
+
+ A picture with a caption.
+
+.. figure:: picture.png
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Testing for line-leaks:
+ <figure>
+ <image uri="picture.png">
+ <caption>
+ A picture with a caption.
+ <figure>
+ <image uri="picture.png">
+ <caption>
+ A picture with a caption.
+ <figure>
+ <image uri="picture.png">
+ <caption>
+ A picture with a caption.
+ <figure>
+ <image uri="picture.png">
+ <figure>
+ <image uri="picture.png">
+ <figure>
+ <image uri="picture.png">
+ <figure>
+ <image uri="picture.png">
+ <caption>
+ A picture with a caption.
+ <figure>
+ <image uri="picture.png">
+ <figure>
+ <image uri="picture.png">
+ <caption>
+ A picture with a caption.
+ <figure>
+ <image uri="picture.png">
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_images.py b/test/test_parsers/test_rst/test_directives/test_images.py
new file mode 100755
index 000000000..50f555ba1
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_images.py
@@ -0,0 +1,413 @@
+#! /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 images.py image directives.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['images'] = [
+["""\
+.. image:: picture.png
+""",
+"""\
+<document source="test data">
+ <image uri="picture.png">
+"""],
+["""\
+.. image::
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ 1 argument(s) required, 0 supplied.
+ <literal_block xml:space="preserve">
+ .. image::
+"""],
+["""\
+.. image:: one two three.png
+""",
+"""\
+<document source="test data">
+ <image uri="onetwothree.png">
+"""],
+["""\
+.. image:: picture.png
+ :height: 100
+ :width: 200
+ :scale: 50
+""",
+"""\
+<document source="test data">
+ <image height="100" scale="50" uri="picture.png" width="200">
+"""],
+["""\
+.. image::
+ picture.png
+ :height: 100
+ :width: 200
+ :scale: 50
+""",
+"""\
+<document source="test data">
+ <image height="100" scale="50" uri="picture.png" width="200">
+"""],
+["""\
+.. image::
+ :height: 100
+ :width: 200
+ :scale: 50
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ 1 argument(s) required, 0 supplied.
+ <literal_block xml:space="preserve">
+ .. image::
+ :height: 100
+ :width: 200
+ :scale: 50
+"""],
+["""\
+.. image:: a/very/long/path/to/
+ picture.png
+ :height: 100
+ :width: 200
+ :scale: 50
+""",
+"""\
+<document source="test data">
+ <image height="100" scale="50" uri="a/very/long/path/to/picture.png" width="200">
+"""],
+["""\
+.. image:: picture.png
+ :width: 200px
+ :height: 100 em
+""",
+"""\
+<document source="test data">
+ <image height="100em" uri="picture.png" width="200px">
+"""],
+["""\
+.. image:: picture.png
+ :width: 50%
+ :height: 10mm
+""",
+"""\
+<document source="test data">
+ <image height="10mm" uri="picture.png" width="50%">
+"""],
+["""\
+.. image:: picture.png
+ :width: 50%
+ :height: 40%
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ invalid option value: (option: "height"; value: \'40%\')
+ not a positive measure of one of the following units:
+ "em" "ex" "px" "in" "cm" "mm" "pt" "pc" "".
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :width: 50%
+ :height: 40%
+"""],
+["""\
+.. image:: picture.png
+ :height: 100
+ :width: 200
+ :scale: 50
+ :alt: Alternate text for the picture
+""",
+"""\
+<document source="test data">
+ <image alt="Alternate text for the picture" height="100" scale="50" uri="picture.png" width="200">
+"""],
+["""\
+.. image:: picture.png
+ :scale: - 50
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ invalid option value: (option: "scale"; value: '- 50')
+ negative value; must be positive or zero.
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :scale: - 50
+"""],
+["""\
+.. image:: picture.png
+ :scale:
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ invalid option value: (option: "scale"; value: None)
+ %s.
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :scale:
+""" % DocutilsTestSupport.exception_data('int(None)')[1][0]],
+["""\
+.. image:: picture.png
+ :scale 50
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ invalid option block.
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :scale 50
+"""],
+["""\
+.. image:: picture.png
+ scale: 50
+""",
+"""\
+<document source="test data">
+ <image uri="picture.pngscale:50">
+"""],
+["""\
+.. image:: picture.png
+ :: 50
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ invalid option block.
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :: 50
+"""],
+["""\
+.. image:: picture.png
+ :sale: 50
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ unknown option: "sale".
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :sale: 50
+"""],
+["""\
+.. image:: picture.png
+ :scale is: 50
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ invalid option data: extension option field name may not contain multiple words.
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :scale is: 50
+"""],
+["""\
+.. image:: picture.png
+ :scale: fifty
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ invalid option value: (option: "scale"; value: 'fifty')
+ invalid literal for int(): fifty.
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :scale: fifty
+"""],
+["""\
+.. image:: picture.png
+ :scale: 50
+ :scale: 50
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ invalid option data: duplicate option "scale".
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :scale: 50
+ :scale: 50
+"""],
+["""\
+.. image:: picture.png
+ :alt:
+
+(Empty "alt" option.)
+""",
+"""\
+<document source="test data">
+ <image alt="" uri="picture.png">
+ <paragraph>
+ (Empty "alt" option.)
+"""],
+["""\
+.. image:: picture.png
+ :target: bigpicture.png
+""",
+"""\
+<document source="test data">
+ <reference refuri="bigpicture.png">
+ <image uri="picture.png">
+"""],
+["""\
+.. image:: picture.png
+ :target: indirect_
+""",
+"""\
+<document source="test data">
+ <reference name="indirect" refname="indirect">
+ <image uri="picture.png">
+"""],
+["""\
+.. image:: picture.png
+ :target: a/multi/
+ line/uri
+
+.. image:: picture.png
+ :target: `a multi line
+ internal reference`_
+""",
+"""\
+<document source="test data">
+ <reference refuri="a/multi/line/uri">
+ <image uri="picture.png">
+ <reference name="a multi line internal reference" refname="a multi line internal reference">
+ <image uri="picture.png">
+"""],
+["""\
+.. image:: picture.png
+ :target:
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ invalid option value: (option: "target"; value: None)
+ argument required but none supplied.
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :target:
+"""],
+["""\
+.. image:: picture.png
+ :align: left
+""",
+"""\
+<document source="test data">
+ <image align="left" uri="picture.png">
+"""],
+["""\
+.. image:: picture.png
+ :align: top
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive: "top" is not a valid value for the "align" option. Valid values for "align" are: "left", "center", "right".
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :align: top
+"""],
+["""\
+.. |img| image:: picture.png
+ :align: top
+""",
+"""\
+<document source="test data">
+ <substitution_definition names="img">
+ <image align="top" alt="img" uri="picture.png">
+"""],
+["""\
+.. |img| image:: picture.png
+ :align: left
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive: "left" is not a valid value for the "align" option within a substitution definition. Valid values for "align" are: "top", "middle", "bottom".
+ <literal_block xml:space="preserve">
+ image:: picture.png
+ :align: left
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "img" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |img| image:: picture.png
+ :align: left
+"""],
+[u"""\
+.. image:: picture.png
+ :align: \xe4
+""",
+u"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ invalid option value: (option: "align"; value: u\'\\xe4\')
+ "\xe4" unknown; choose from "top", "middle", "bottom", "left", "center", or "right".
+ <literal_block xml:space="preserve">
+ .. image:: picture.png
+ :align: \xe4
+"""],
+["""
+.. image:: test.png
+ :target: Uppercase_
+
+.. _Uppercase: http://docutils.sourceforge.net/
+""",
+"""\
+<document source="test data">
+ <reference name="Uppercase" refname="uppercase">
+ <image uri="test.png">
+ <target ids="uppercase" names="uppercase" refuri="http://docutils.sourceforge.net/">
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_include.py b/test/test_parsers/test_rst/test_directives/test_include.py
new file mode 100755
index 000000000..c9b5f7378
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_include.py
@@ -0,0 +1,412 @@
+#! /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 misc.py "include" directive.
+"""
+
+import os.path
+import sys
+from __init__ import DocutilsTestSupport
+from docutils.parsers.rst import states
+
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+mydir = 'test_parsers/test_rst/test_directives/'
+include1 = os.path.join(mydir, 'include1.txt')
+include1rel = DocutilsTestSupport.utils.relative_path(None, include1)
+include2 = os.path.join(mydir, 'include2.txt')
+include3 = os.path.join(mydir, 'include3.txt')
+include8 = os.path.join(mydir, 'include8.txt')
+include10 = os.path.join(mydir, 'include10.txt')
+include10rel = DocutilsTestSupport.utils.relative_path(None, include10)
+include11 = os.path.join(mydir, 'include 11.txt')
+include11rel = DocutilsTestSupport.utils.relative_path(None, include11)
+utf_16_file = os.path.join(mydir, 'utf-16.csv')
+utf_16_file_rel = DocutilsTestSupport.utils.relative_path(None, utf_16_file)
+nonexistent = os.path.join(os.path.dirname(states.__file__),
+ 'include', 'nonexistent')
+nonexistent_rel = DocutilsTestSupport.utils.relative_path(
+ os.path.join(DocutilsTestSupport.testroot, 'dummy'), nonexistent)
+
+totest = {}
+
+totest['include'] = [
+["""\
+Include Test
+============
+
+.. include:: %s
+
+A paragraph.
+""" % include1,
+"""\
+<document source="test data">
+ <section ids="include-test" names="include\ test">
+ <title>
+ Include Test
+ <section ids="inclusion-1" names="inclusion\ 1">
+ <title>
+ Inclusion 1
+ <paragraph>
+ This file is used by \n\
+ <literal>
+ test_include.py
+ .
+ <paragraph>
+ A paragraph.
+"""],
+["""\
+Include Test
+============
+
+.. include:: %s
+ :literal:
+
+A paragraph.
+""" % include1,
+"""\
+<document source="test data">
+ <section ids="include-test" names="include\ test">
+ <title>
+ Include Test
+ <literal_block source="%s" xml:space="preserve">
+ Inclusion 1
+ -----------
+ \n\
+ This file is used by ``test_include.py``.
+ <paragraph>
+ A paragraph.
+""" % include1rel],
+["""\
+Let's test the parse context.
+
+ This paragraph is in a block quote.
+
+ .. include:: %s
+
+The included paragraphs should also be in the block quote.
+""" % include2,
+"""\
+<document source="test data">
+ <paragraph>
+ Let's test the parse context.
+ <block_quote>
+ <paragraph>
+ This paragraph is in a block quote.
+ <paragraph>
+ Here are some paragraphs
+ that can appear at any level.
+ <paragraph>
+ This file (include2.txt) is used by
+ <literal>
+ test_include.py
+ .
+ <paragraph>
+ The included paragraphs should also be in the block quote.
+"""],
+["""\
+Include Test
+============
+
+.. include:: nonexistent.txt
+
+A paragraph.
+""",
+"""\
+<document source="test data">
+ <section ids="include-test" names="include\ test">
+ <title>
+ Include Test
+ <system_message level="4" line="4" source="test data" type="SEVERE">
+ <paragraph>
+ Problems with "include" directive path:
+ IOError: [Errno 2] No such file or directory: 'nonexistent.txt'.
+ <literal_block xml:space="preserve">
+ .. include:: nonexistent.txt
+ <paragraph>
+ A paragraph.
+"""],
+["""\
+Include Test
+============
+
+.. include:: %s
+
+.. include:: %s
+
+A paragraph.
+""" % (include1, include1),
+"""\
+<document source="test data">
+ <section ids="include-test" names="include\ test">
+ <title>
+ Include Test
+ <section dupnames="inclusion\ 1" ids="inclusion-1">
+ <title>
+ Inclusion 1
+ <paragraph>
+ This file is used by
+ <literal>
+ test_include.py
+ .
+ <section dupnames="inclusion\ 1" ids="id1">
+ <title>
+ Inclusion 1
+ <system_message backrefs="id1" level="1" line="2" source="%s" type="INFO">
+ <paragraph>
+ Duplicate implicit target name: "inclusion 1".
+ <paragraph>
+ This file is used by
+ <literal>
+ test_include.py
+ .
+ <paragraph>
+ A paragraph.
+""" % include1rel],
+["""\
+Include Test
+============
+
+.. include:: %s
+
+----------
+
+.. include:: %s
+
+A paragraph.
+""" % (include1, include1),
+"""\
+<document source="test data">
+ <section ids="include-test" names="include\ test">
+ <title>
+ Include Test
+ <section dupnames="inclusion\ 1" ids="inclusion-1">
+ <title>
+ Inclusion 1
+ <paragraph>
+ This file is used by \n\
+ <literal>
+ test_include.py
+ .
+ <transition>
+ <section dupnames="inclusion\ 1" ids="id1">
+ <title>
+ Inclusion 1
+ <system_message backrefs="id1" level="1" line="2" source="%s" type="INFO">
+ <paragraph>
+ Duplicate implicit target name: "inclusion 1".
+ <paragraph>
+ This file is used by \n\
+ <literal>
+ test_include.py
+ .
+ <paragraph>
+ A paragraph.
+""" % include1rel],
+["""\
+In test data
+
+.. include:: %s
+""" % include3,
+"""\
+<document source="test data">
+ <paragraph>
+ In test data
+ <paragraph>
+ In include3.txt
+ <paragraph>
+ In includes/include4.txt
+ <paragraph>
+ In includes/include5.txt
+ <paragraph>
+ In includes/more/include6.txt
+ <paragraph>
+ In includes/sibling/include7.txt
+"""],
+["""\
+In test data
+
+Section
+=======
+
+(Section contents in nested parse; slice of input_lines ViewList.)
+
+.. include:: %s
+""" % include3,
+"""\
+<document source="test data">
+ <paragraph>
+ In test data
+ <section ids="section" names="section">
+ <title>
+ Section
+ <paragraph>
+ (Section contents in nested parse; slice of input_lines ViewList.)
+ <paragraph>
+ In include3.txt
+ <paragraph>
+ In includes/include4.txt
+ <paragraph>
+ In includes/include5.txt
+ <paragraph>
+ In includes/more/include6.txt
+ <paragraph>
+ In includes/sibling/include7.txt
+"""],
+["""\
+Testing relative includes:
+
+.. include:: %s
+""" % include8,
+"""\
+<document source="test data">
+ <paragraph>
+ Testing relative includes:
+ <paragraph>
+ In include8.txt
+ <paragraph>
+ In ../includes/include9.txt.
+ <paragraph>
+ Here are some paragraphs
+ that can appear at any level.
+ <paragraph>
+ This file (include2.txt) is used by
+ <literal>
+ test_include.py
+ .
+"""],
+["""\
+Encoding:
+
+.. include:: %s
+ :encoding: utf-16
+""" % utf_16_file_rel,
+u"""\
+<document source="test data">
+ <paragraph>
+ Encoding:
+ <paragraph>
+ "Treat", "Quantity", "Description"
+ "Albatr\xb0\xdf", 2.99, "\xa1On a \\u03c3\\u03c4\\u03b9\\u03ba!"
+ "Crunchy Frog", 1.49, "If we took the b\xf6nes out, it wouldn\\u2019t be
+ crunchy, now would it?"
+ "Gannet Ripple", 1.99, "\xbfOn a \\u03c3\\u03c4\\u03b9\\u03ba?"
+"""],
+["""\
+Include file is UTF-16-encoded, and is not valid ASCII.
+
+.. include:: %s
+ :encoding: ascii
+""" % utf_16_file_rel,
+"""\
+<document source="test data">
+ <paragraph>
+ Include file is UTF-16-encoded, and is not valid ASCII.
+ <system_message level="4" line="3" source="test data" type="SEVERE">
+ <paragraph>
+ Problem with "include" directive:
+ UnicodeError: Unable to decode input data. Tried the following encodings: 'ascii'.
+ (UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe in position 0: ordinal not in range(128))
+ <literal_block xml:space="preserve">
+ .. include:: %s
+ :encoding: ascii
+""" % utf_16_file_rel],
+# @@@ BUG with errors reported with incorrect "source" & "line":
+# ["""\
+# Testing bad charent includes:
+#
+# .. include:: %s
+# """ % include10,
+# """\
+# <document source="test data">
+# <paragraph>
+# Testing bad charent includes:
+# <system_message level="3" line="1" source="%s" type="ERROR">
+# <paragraph>
+# Invalid character code: 0xFFFFFFFFF
+# int() literal too large: FFFFFFFFF
+# <literal_block xml:space="preserve">
+# unicode:: 0xFFFFFFFFF
+# <system_message level="2" line="1" source="%s" type="WARNING">
+# <paragraph>
+# Substitution definition "bad" empty or invalid.
+# <literal_block xml:space="preserve">
+# .. |bad| unicode:: 0xFFFFFFFFF
+# """ % (include10rel, include10rel)],
+["""\
+Include file with whitespace in the path:
+
+.. include:: %s
+""" % include11rel,
+"""\
+<document source="test data">
+ <paragraph>
+ Include file with whitespace in the path:
+ <paragraph>
+ some text
+"""],
+["""\
+Standard include data file:
+
+.. include:: <isogrk4.txt>
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Standard include data file:
+ <comment xml:space="preserve">
+ This data file has been placed in the public domain.
+ <comment xml:space="preserve">
+ Derived from the Unicode character mappings available from
+ <http://www.w3.org/2003/entities/xml/>.
+ Processed by unicode2rstsubs.py, part of Docutils:
+ <http://docutils.sourceforge.net>.
+ <substitution_definition names="b.Gammad">
+ \\u03dc
+ <substitution_definition names="b.gammad">
+ \\u03dd
+"""],
+["""\
+Nonexistent standard include data file:
+
+.. include:: <nonexistent>
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Nonexistent standard include data file:
+ <system_message level="4" line="3" source="test data" type="SEVERE">
+ <paragraph>
+ Problems with "include" directive path:
+ IOError: [Errno 2] No such file or directory: '%s'.
+ <literal_block xml:space="preserve">
+ .. include:: <nonexistent>
+""" % nonexistent_rel],
+]
+
+
+# Skip tests whose output contains "UnicodeDecodeError" if we are not
+# using Python 2.3 or higher.
+if sys.version_info < (2, 3):
+ for i in range(len(totest['include'])):
+ if totest['include'][i][1].find('UnicodeDecodeError') != -1:
+ del totest['include'][i]
+ print ("Test totest['include'][%s] skipped; "
+ "Python 2.3+ required for expected output." % i)
+ # Assume we have only one of these tests.
+ break
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_line_blocks.py b/test/test_parsers/test_rst/test_directives/test_line_blocks.py
new file mode 100755
index 000000000..131ceaa05
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_line_blocks.py
@@ -0,0 +1,81 @@
+#! /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 the body.py 'line-block' directive.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['line_blocks'] = [
+["""\
+.. line-block::
+
+ This is a line block.
+ Newlines are *preserved*.
+ As is initial whitespace.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ This is a line block.
+ <line>
+ Newlines are \n\
+ <emphasis>
+ preserved
+ .
+ <line_block>
+ <line>
+ As is initial whitespace.
+"""],
+["""\
+.. line-block::
+
+ Inline markup *may not span
+ multiple lines* of a line block.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ Inline markup \n\
+ <problematic ids="id2" refid="id1">
+ *
+ may not span
+ <line_block>
+ <line>
+ multiple lines* of a line block.
+ <system_message backrefs="id2" ids="id1" level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Inline emphasis start-string without end-string.
+"""],
+["""\
+.. line-block::
+""",
+"""\
+<document source="test data">
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Content block expected for the "line-block" directive; none found.
+ <literal_block xml:space="preserve">
+ .. line-block::
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_meta.py b/test/test_parsers/test_rst/test_directives/test_meta.py
new file mode 100755
index 000000000..7c8b34002
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_meta.py
@@ -0,0 +1,232 @@
+#! /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 html meta directives.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['meta'] = [
+["""\
+.. meta::
+ :description: The reStructuredText plaintext markup language
+ :keywords: plaintext,markup language
+""",
+"""\
+<document source="test data">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.components.Filter
+ .details:
+ component: 'writer'
+ format: 'html'
+ nodes:
+ <meta content="The reStructuredText plaintext markup language" name="description">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.components.Filter
+ .details:
+ component: 'writer'
+ format: 'html'
+ nodes:
+ <meta content="plaintext,markup language" name="keywords">
+"""],
+["""\
+.. meta::
+ :description lang=en: An amusing story
+ :description lang=fr: Un histoire amusant
+""",
+"""\
+<document source="test data">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.components.Filter
+ .details:
+ component: 'writer'
+ format: 'html'
+ nodes:
+ <meta content="An amusing story" lang="en" name="description">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.components.Filter
+ .details:
+ component: 'writer'
+ format: 'html'
+ nodes:
+ <meta content="Un histoire amusant" lang="fr" name="description">
+"""],
+["""\
+.. meta::
+ :http-equiv=Content-Type: text/html; charset=ISO-8859-1
+""",
+"""\
+<document source="test data">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.components.Filter
+ .details:
+ component: 'writer'
+ format: 'html'
+ nodes:
+ <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type">
+"""],
+["""\
+.. meta::
+ :name: content
+ over multiple lines
+""",
+"""\
+<document source="test data">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.components.Filter
+ .details:
+ component: 'writer'
+ format: 'html'
+ nodes:
+ <meta content="content over multiple lines" name="name">
+"""],
+["""\
+Paragraph
+
+.. meta::
+ :name: content
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.components.Filter
+ .details:
+ component: 'writer'
+ format: 'html'
+ nodes:
+ <meta content="content" name="name">
+"""],
+["""\
+.. meta::
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Empty meta directive.
+ <literal_block xml:space="preserve">
+ .. meta::
+"""],
+["""\
+.. meta::
+ :empty:
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="2" source="test data" type="INFO">
+ <paragraph>
+ No content for meta tag "empty".
+ <literal_block xml:space="preserve">
+ :empty:
+"""],
+["""\
+.. meta::
+ not a field list
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Invalid meta directive.
+ <literal_block xml:space="preserve">
+ .. meta::
+ not a field list
+"""],
+["""\
+.. meta::
+ :name: content
+ not a field
+ :name: content
+""",
+"""\
+<document source="test data">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.components.Filter
+ .details:
+ component: 'writer'
+ format: 'html'
+ nodes:
+ <meta content="content" name="name">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Invalid meta directive.
+ <literal_block xml:space="preserve">
+ .. meta::
+ :name: content
+ not a field
+ :name: content
+"""],
+["""\
+.. meta::
+ :name: content
+ :name: content
+ not a field
+""",
+"""\
+<document source="test data">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.components.Filter
+ .details:
+ component: 'writer'
+ format: 'html'
+ nodes:
+ <meta content="content" name="name">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.components.Filter
+ .details:
+ component: 'writer'
+ format: 'html'
+ nodes:
+ <meta content="content" name="name">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Invalid meta directive.
+ <literal_block xml:space="preserve">
+ .. meta::
+ :name: content
+ :name: content
+ not a field
+"""],
+["""\
+.. meta::
+ :name notattval: content
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="2" source="test data" type="ERROR">
+ <paragraph>
+ Error parsing meta tag attribute "notattval": missing "=".
+ <literal_block xml:space="preserve">
+ :name notattval: content
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_raw.py b/test/test_parsers/test_rst/test_directives/test_raw.py
new file mode 100755
index 000000000..9e1a17974
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_raw.py
@@ -0,0 +1,154 @@
+#! /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 misc.py "raw" directive.
+"""
+
+import os.path
+import sys
+from __init__ import DocutilsTestSupport
+
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+mydir = 'test_parsers/test_rst/test_directives/'
+raw1 = os.path.join(mydir, 'raw1.txt')
+utf_16_file = os.path.join(mydir, 'utf-16.csv')
+utf_16_file_rel = DocutilsTestSupport.utils.relative_path(None, utf_16_file)
+
+totest = {}
+
+totest['raw'] = [
+["""\
+.. raw:: html
+
+ <span>This is some plain old raw text.</span>
+""",
+"""\
+<document source="test data">
+ <raw format="html" xml:space="preserve">
+ <span>This is some plain old raw text.</span>
+"""],
+["""\
+.. raw:: html
+ :file: %s
+""" % raw1,
+"""\
+<document source="test data">
+ <raw format="html" source="%s" xml:space="preserve">
+ <p>This file is used by <tt>test_raw.py</tt>.</p>
+""" % DocutilsTestSupport.utils.relative_path(None, raw1)],
+["""\
+.. raw:: html
+ :file: rawfile.html
+ :url: http://example.org/
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ The "file" and "url" options may not be simultaneously specified for the "raw" directive.
+ <literal_block xml:space="preserve">
+ .. raw:: html
+ :file: rawfile.html
+ :url: http://example.org/
+"""],
+["""\
+.. raw:: html
+ :file: rawfile.html
+
+ <p>Can't have both content and file attribute.</p>
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ "raw" directive may not both specify an external file and have content.
+ <literal_block xml:space="preserve">
+ .. raw:: html
+ :file: rawfile.html
+
+ <p>Can't have both content and file attribute.</p>
+"""],
+[r"""
+.. raw:: latex html
+
+ \[ \sum_{n=1}^\infty \frac{1}{n} \text{ etc.} \]
+""",
+"""\
+<document source="test data">
+ <raw format="latex html" xml:space="preserve">
+ \\[ \\sum_{n=1}^\\infty \\frac{1}{n} \\text{ etc.} \\]
+"""],
+["""\
+.. raw:: html
+ :file: %s
+ :encoding: utf-16
+""" % utf_16_file_rel,
+"""\
+<document source="test data">
+ <raw format="html" source="%s" xml:space="preserve">
+ "Treat", "Quantity", "Description"
+ "Albatr\xb0\xdf", 2.99, "\xa1On a \\u03c3\\u03c4\\u03b9\\u03ba!"
+ "Crunchy Frog", 1.49, "If we took the b\xf6nes out, it wouldn\\u2019t be
+ crunchy, now would it?"
+ "Gannet Ripple", 1.99, "\xbfOn a \\u03c3\\u03c4\\u03b9\\u03ba?"
+""" % utf_16_file_rel],
+["""\
+Raw input file is UTF-16-encoded, and is not valid ASCII.
+
+.. raw:: html
+ :file: %s
+ :encoding: ascii
+""" % utf_16_file_rel,
+"""\
+<document source="test data">
+ <paragraph>
+ Raw input file is UTF-16-encoded, and is not valid ASCII.
+ <system_message level="4" line="3" source="test data" type="SEVERE">
+ <paragraph>
+ Problem with "raw" directive:
+ UnicodeError: Unable to decode input data. Tried the following encodings: \'ascii\'.
+ (UnicodeDecodeError: 'ascii' codec can't decode byte 0xfe in position 0: ordinal not in range(128))
+ <literal_block xml:space="preserve">
+ .. raw:: html
+ :file: %s
+ :encoding: ascii
+""" % utf_16_file_rel],
+["""\
+.. raw:: html
+ :encoding: utf-8
+
+ Should the parser complain becau\xdfe there is no :file:? BUG?
+""",
+"""\
+<document source="test data">
+ <raw format="html" xml:space="preserve">
+ Should the parser complain becau\xdfe there is no :file:? BUG?
+"""],
+]
+
+# Skip tests whose output contains "UnicodeDecodeError" if we are not
+# using Python 2.3 or higher.
+if sys.version_info < (2, 3):
+ for i in range(len(totest['raw'])):
+ if totest['raw'][i][1].find('UnicodeDecodeError') != -1:
+ del totest['raw'][i]
+ print ("Test totest['raw'][%s] skipped; "
+ "Python 2.3+ required for expected output." % i)
+ # Assume we have only one of these tests.
+ break
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_replace.py b/test/test_parsers/test_rst/test_directives/test_replace.py
new file mode 100755
index 000000000..f5fd2495b
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_replace.py
@@ -0,0 +1,135 @@
+#! /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 misc.py "replace" directive.
+"""
+
+from __init__ import DocutilsTestSupport
+
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['replace'] = [
+["""\
+Test the |name| directive.
+
+.. |name| replace:: "**replace**"
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Test the \n\
+ <substitution_reference refname="name">
+ name
+ directive.
+ <substitution_definition names="name">
+ "
+ <strong>
+ replace
+ "
+"""],
+["""\
+.. |name| replace:: paragraph 1
+
+ paragraph 2
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "replace" directive: may contain a single paragraph only.
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "name" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |name| replace:: paragraph 1
+
+ paragraph 2
+"""],
+["""\
+.. |name| replace::
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ The "replace" directive is empty; content required.
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "name" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |name| replace::
+"""],
+["""\
+.. |Python| replace:: Python, *the* best language around
+
+.. _Python: http://www.python.org/
+
+I recommend you try |Python|_.
+""",
+"""\
+<document source="test data">
+ <substitution_definition names="Python">
+ Python,
+ <emphasis>
+ the
+ best language around
+ <target ids="python" names="python" refuri="http://www.python.org/">
+ <paragraph>
+ I recommend you try
+ <reference refname="python">
+ <substitution_reference refname="Python">
+ Python
+ .
+"""],
+["""\
+.. |name| replace:: *error in **inline ``markup
+""",
+"""\
+<document source="test data">
+ <system_message ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline emphasis start-string without end-string.
+ <system_message ids="id3" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline strong start-string without end-string.
+ <system_message ids="id5" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline literal start-string without end-string.
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "replace" directive: may contain a single paragraph only.
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "name" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |name| replace:: *error in **inline ``markup
+"""],
+["""\
+.. replace:: not valid outside of a substitution definition
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Invalid context: the "replace" directive can only be used within a substitution definition.
+ <literal_block xml:space="preserve">
+ .. replace:: not valid outside of a substitution definition
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_role.py b/test/test_parsers/test_rst/test_directives/test_role.py
new file mode 100755
index 000000000..0cd10c967
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_role.py
@@ -0,0 +1,230 @@
+#! /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 misc.py "role" directive.
+"""
+
+from __init__ import DocutilsTestSupport
+
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['role'] = [
+["""\
+.. role:: custom
+.. role:: special
+
+:custom:`interpreted` and :special:`interpreted`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <inline classes="custom">
+ interpreted
+ and \n\
+ <inline classes="special">
+ interpreted
+"""],
+["""\
+.. role:: custom
+ :class: custom-class
+.. role:: special
+ :class: special-class
+
+:custom:`interpreted` and :special:`interpreted`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <inline classes="custom-class">
+ interpreted
+ and \n\
+ <inline classes="special-class">
+ interpreted
+"""],
+["""\
+Must define :custom:`interpreted` before using it.
+
+.. role:: custom
+
+Now that it's defined, :custom:`interpreted` works.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Must define
+ <problematic ids="id2" refid="id1">
+ :custom:`interpreted`
+ before using it.
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ No role entry for "custom" in module "docutils.parsers.rst.languages.en".
+ Trying "custom" as canonical role name.
+ <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Unknown interpreted text role "custom".
+ <paragraph>
+ Now that it's defined, \n\
+ <inline classes="custom">
+ interpreted
+ works.
+"""],
+["""\
+.. role:: custom(emphasis)
+
+:custom:`text`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <emphasis classes="custom">
+ text
+"""],
+["""\
+.. role:: custom ( emphasis )
+
+:custom:`text`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <emphasis classes="custom">
+ text
+"""],
+["""\
+.. role:: custom(emphasis)
+ :class: special
+
+:custom:`text`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <emphasis classes="special">
+ text
+"""],
+["""\
+.. role:: custom(unknown-role)
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ No role entry for "unknown-role" in module "docutils.parsers.rst.languages.en".
+ Trying "unknown-role" as canonical role name.
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Unknown interpreted text role "unknown-role".
+ <literal_block xml:space="preserve">
+ .. role:: custom(unknown-role)
+"""],
+["""\
+.. role:: custom
+ :class: 1
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "role" directive:
+ invalid option value: (option: "class"; value: '1')
+ cannot make "1" into a class name.
+ <literal_block xml:space="preserve">
+ .. role:: custom
+ :class: 1
+"""],
+["""\
+.. role:: 1
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Invalid argument for "role" directive:
+ cannot make "1" into a class name.
+ <literal_block xml:space="preserve">
+ .. role:: 1
+"""],
+["""\
+Test
+----
+
+.. role:: fileref(emphasis)
+
+Testing a :fileref:`role` in a nested parse.
+""",
+"""\
+<document source="test data">
+ <section ids="test" names="test">
+ <title>
+ Test
+ <paragraph>
+ Testing a \n\
+ <emphasis classes="fileref">
+ role
+ in a nested parse.
+"""],
+]
+
+totest['raw_role'] = [
+["""\
+.. role:: html(raw)
+ :format: html
+
+Here's some :html:`<i>raw HTML data</i>`.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Here's some \n\
+ <raw classes="html" format="html" xml:space="preserve">
+ <i>raw HTML data</i>
+ .
+"""],
+["""\
+.. role:: itex(raw)
+ :format: latex html
+
+Here's some itex markup: :itex:`$x^\\infty$`.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Here's some itex markup: \n\
+ <raw classes="itex" format="latex html" xml:space="preserve">
+ $x^\\infty$
+ .
+"""],
+["""\
+Can't use the :raw:`role` directly.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Can't use the \n\
+ <problematic ids="id2" refid="id1">
+ :raw:`role`
+ directly.
+ <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ No format (Writer name) is associated with this role: "raw".
+ The "raw" role cannot be used directly.
+ Instead, use the "role" directive to create a new role with an associated format.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_rubrics.py b/test/test_parsers/test_rst/test_directives/test_rubrics.py
new file mode 100755
index 000000000..271802736
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_rubrics.py
@@ -0,0 +1,74 @@
+#! /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 the "rubric" directive.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['rubrics'] = [
+["""\
+.. rubric:: This is a rubric
+""",
+"""\
+<document source="test data">
+ <rubric>
+ This is a rubric
+"""],
+["""\
+.. rubric::
+.. rubric:: A rubric has no content
+
+ Invalid content
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "rubric" directive:
+ 1 argument(s) required, 0 supplied.
+ <literal_block xml:space="preserve">
+ .. rubric::
+ <system_message level="3" line="2" source="test data" type="ERROR">
+ <paragraph>
+ Error in "rubric" directive:
+ no content permitted.
+ <literal_block xml:space="preserve">
+ .. rubric:: A rubric has no content
+ \n\
+ Invalid content
+"""],
+["""\
+.. rubric:: A rubric followed by a block quote
+..
+
+ Block quote
+""",
+"""\
+<document source="test data">
+ <rubric>
+ A rubric followed by a block quote
+ <comment xml:space="preserve">
+ <block_quote>
+ <paragraph>
+ Block quote
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_sidebars.py b/test/test_parsers/test_rst/test_directives/test_sidebars.py
new file mode 100755
index 000000000..a84fc248d
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_sidebars.py
@@ -0,0 +1,73 @@
+#! /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 the "sidebar" directive.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['sidebars'] = [
+["""\
+.. sidebar:: Outer
+
+ .. sidebar:: Nested
+
+ Body.
+""",
+"""\
+<document source="test data">
+ <sidebar>
+ <title>
+ Outer
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ The "sidebar" directive may not be used within a sidebar element.
+ <literal_block xml:space="preserve">
+ .. sidebar:: Nested
+ \n\
+ Body.
+"""],
+["""\
+.. sidebar:: Outer
+
+ .. topic:: Topic
+
+ .. sidebar:: Inner
+
+ text
+""",
+"""\
+<document source="test data">
+ <sidebar>
+ <title>
+ Outer
+ <topic>
+ <title>
+ Topic
+ <system_message level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ The "sidebar" directive may not be used within topics or body elements.
+ <literal_block xml:space="preserve">
+ .. sidebar:: Inner
+ \n\
+ text
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_tables.py b/test/test_parsers/test_rst/test_directives/test_tables.py
new file mode 100755
index 000000000..da88510e7
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_tables.py
@@ -0,0 +1,997 @@
+#! /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 tables.py directives.
+"""
+
+from __init__ import DocutilsTestSupport
+
+import os
+try:
+ import csv
+except ImportError:
+ csv = None
+
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+mydir = 'test_parsers/test_rst/test_directives/'
+utf_16_csv = os.path.join(mydir, 'utf-16.csv')
+utf_16_csv_rel = DocutilsTestSupport.utils.relative_path(None, utf_16_csv)
+empty_txt = os.path.join(mydir, 'empty.txt')
+
+totest = {}
+
+totest['table'] = [
+["""\
+.. table:: Truth table for "not"
+ :class: custom
+
+ ===== =====
+ A not A
+ ===== =====
+ False True
+ True False
+ ===== =====
+""",
+"""\
+<document source="test data">
+ <table classes="custom">
+ <title>
+ Truth table for "not"
+ <tgroup cols="2">
+ <colspec colwidth="5">
+ <colspec colwidth="5">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ A
+ <entry>
+ <paragraph>
+ not A
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ False
+ <entry>
+ <paragraph>
+ True
+ <row>
+ <entry>
+ <paragraph>
+ True
+ <entry>
+ <paragraph>
+ False
+"""],
+["""\
+.. table:: title with an *error
+
+ ====== =====
+ Simple table
+ ====== =====
+""",
+"""\
+<document source="test data">
+ <table>
+ <title>
+ title with an \n\
+ <problematic ids="id2" refid="id1">
+ *
+ error
+ <tgroup cols="2">
+ <colspec colwidth="6">
+ <colspec colwidth="5">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Simple
+ <entry>
+ <paragraph>
+ table
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline emphasis start-string without end-string.
+"""],
+]
+
+if not csv:
+ print ('Tests of "csv-table" directive skipped; '
+ 'Python 2.3 or higher required.')
+else:
+ totest['csv-table'] = [
+["""\
+.. csv-table:: inline with integral header
+ :widths: 10, 20, 30
+ :header-rows: 1
+ :stub-columns: 1
+
+ "Treat", "Quantity", "Description"
+ "Albatross", 2.99, "On a stick!"
+ "Crunchy Frog", 1.49, "If we took the bones out, it wouldn\'t be
+ crunchy, now would it?"
+ "Gannet Ripple", 1.99, "On a stick!"
+""",
+"""\
+<document source="test data">
+ <table>
+ <title>
+ inline with integral header
+ <tgroup cols="3">
+ <colspec colwidth="10" stub="1">
+ <colspec colwidth="20">
+ <colspec colwidth="30">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ Treat
+ <entry>
+ <paragraph>
+ Quantity
+ <entry>
+ <paragraph>
+ Description
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Albatross
+ <entry>
+ <paragraph>
+ 2.99
+ <entry>
+ <paragraph>
+ On a stick!
+ <row>
+ <entry>
+ <paragraph>
+ Crunchy Frog
+ <entry>
+ <paragraph>
+ 1.49
+ <entry>
+ <paragraph>
+ If we took the bones out, it wouldn't be
+ crunchy, now would it?
+ <row>
+ <entry>
+ <paragraph>
+ Gannet Ripple
+ <entry>
+ <paragraph>
+ 1.99
+ <entry>
+ <paragraph>
+ On a stick!
+"""],
+["""\
+.. csv-table:: inline with separate header
+ :header: "Treat", Quantity, "Description"
+ :widths: 10,20,30
+
+ "Albatross", 2.99, "On a stick!"
+""",
+"""\
+<document source="test data">
+ <table>
+ <title>
+ inline with separate header
+ <tgroup cols="3">
+ <colspec colwidth="10">
+ <colspec colwidth="20">
+ <colspec colwidth="30">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ Treat
+ <entry>
+ <paragraph>
+ Quantity
+ <entry>
+ <paragraph>
+ Description
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Albatross
+ <entry>
+ <paragraph>
+ 2.99
+ <entry>
+ <paragraph>
+ On a stick!
+"""],
+["""\
+.. csv-table:: complex internal structure
+ :header: "Treat", Quantity, "
+ * Description,
+ * Definition, or
+ * Narrative"
+
+ "
+ * Ice cream
+ * Sorbet
+ * Albatross", 2.99, "On a stick!"
+""",
+"""\
+<document source="test data">
+ <table>
+ <title>
+ complex internal structure
+ <tgroup cols="3">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ Treat
+ <entry>
+ <paragraph>
+ Quantity
+ <entry>
+ <bullet_list bullet="*">
+ <list_item>
+ <paragraph>
+ Description,
+ <list_item>
+ <paragraph>
+ Definition, or
+ <list_item>
+ <paragraph>
+ Narrative
+ <tbody>
+ <row>
+ <entry>
+ <bullet_list bullet="*">
+ <list_item>
+ <paragraph>
+ Ice cream
+ <list_item>
+ <paragraph>
+ Sorbet
+ <list_item>
+ <paragraph>
+ Albatross
+ <entry>
+ <paragraph>
+ 2.99
+ <entry>
+ <paragraph>
+ On a stick!
+"""],
+["""\
+.. csv-table:: short rows
+
+ one, 2, three
+ 4, five
+""",
+"""\
+<document source="test data">
+ <table>
+ <title>
+ short rows
+ <tgroup cols="3">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ one
+ <entry>
+ <paragraph>
+ 2
+ <entry>
+ <paragraph>
+ three
+ <row>
+ <entry>
+ <paragraph>
+ 4
+ <entry>
+ <paragraph>
+ five
+ <entry>
+"""],
+["""\
+.. csv-table:: short rows
+ :header-rows: 1
+
+ header col 1, header col 2
+ one, 2, three
+ 4
+""",
+"""\
+<document source="test data">
+ <table>
+ <title>
+ short rows
+ <tgroup cols="3">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ header col 1
+ <entry>
+ <paragraph>
+ header col 2
+ <entry>
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ one
+ <entry>
+ <paragraph>
+ 2
+ <entry>
+ <paragraph>
+ three
+ <row>
+ <entry>
+ <paragraph>
+ 4
+ <entry>
+ <entry>
+"""],
+[u"""\
+.. csv-table:: non-ASCII characters
+
+ Heiz\xf6lr\xfccksto\xdfabd\xe4mpfung
+""",
+u"""\
+<document source="test data">
+ <table>
+ <title>
+ non-ASCII characters
+ <tgroup cols="1">
+ <colspec colwidth="100">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Heiz\xf6lr\xfccksto\xdfabd\xe4mpfung
+"""],
+["""\
+.. csv-table:: empty
+""",
+"""\
+<document source="test data">
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ The "csv-table" directive requires content; none supplied.
+ <literal_block xml:space="preserve">
+ .. csv-table:: empty
+"""],
+["""\
+.. csv-table:: insufficient header row data
+ :header-rows: 2
+
+ some, csv, data
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ 2 header row(s) specified but only 1 row(s) of data supplied ("csv-table" directive).
+ <literal_block xml:space="preserve">
+ .. csv-table:: insufficient header row data
+ :header-rows: 2
+ \n\
+ some, csv, data
+"""],
+["""\
+.. csv-table:: insufficient body data
+ :header-rows: 1
+
+ some, csv, data
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Insufficient data supplied (1 row(s)); no data remaining for table body, required by "csv-table" directive.
+ <literal_block xml:space="preserve">
+ .. csv-table:: insufficient body data
+ :header-rows: 1
+ \n\
+ some, csv, data
+"""],
+["""\
+.. csv-table:: content and external
+ :file: bogus.csv
+
+ some, csv, data
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ "csv-table" directive may not both specify an external file and have content.
+ <literal_block xml:space="preserve">
+ .. csv-table:: content and external
+ :file: bogus.csv
+ \n\
+ some, csv, data
+"""],
+["""\
+.. csv-table:: external file and url
+ :file: bogus.csv
+ :url: http://example.org/bogus.csv
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ The "file" and "url" options may not be simultaneously specified for the "csv-table" directive.
+ <literal_block xml:space="preserve">
+ .. csv-table:: external file and url
+ :file: bogus.csv
+ :url: http://example.org/bogus.csv
+"""],
+["""\
+.. csv-table:: error in the *title
+
+ some, csv, data
+""",
+"""\
+<document source="test data">
+ <table>
+ <title>
+ error in the \n\
+ <problematic ids="id2" refid="id1">
+ *
+ title
+ <tgroup cols="3">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ some
+ <entry>
+ <paragraph>
+ csv
+ <entry>
+ <paragraph>
+ data
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline emphasis start-string without end-string.
+"""],
+["""\
+.. csv-table:: no such file
+ :file: bogus.csv
+""",
+"""\
+<document source="test data">
+ <system_message level="4" line="1" source="test data" type="SEVERE">
+ <paragraph>
+ Problems with "csv-table" directive path:
+ [Errno 2] No such file or directory: 'bogus.csv'.
+ <literal_block xml:space="preserve">
+ .. csv-table:: no such file
+ :file: bogus.csv
+"""],
+["""\
+.. csv-table:: bad URL
+ :url: bogus.csv
+""",
+"""\
+<document source="test data">
+ <system_message level="4" line="1" source="test data" type="SEVERE">
+ <paragraph>
+ Problems with "csv-table" directive URL "bogus.csv":
+ unknown url type: bogus.csv.
+ <literal_block xml:space="preserve">
+ .. csv-table:: bad URL
+ :url: bogus.csv
+"""],
+["""\
+.. csv-table:: column mismatch
+ :widths: 10,20
+
+ some, csv, data
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ "csv-table" widths do not match the number of columns in table (3).
+ <literal_block xml:space="preserve">
+ .. csv-table:: column mismatch
+ :widths: 10,20
+ \n\
+ some, csv, data
+"""],
+["""\
+.. csv-table:: bad column widths
+ :widths: 10,y,z
+
+ some, csv, data
+
+.. csv-table:: bad column widths
+ :widths: 0 0 0
+
+ some, csv, data
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "csv-table" directive:
+ invalid option value: (option: "widths"; value: '10,y,z')
+ invalid literal for int(): y.
+ <literal_block xml:space="preserve">
+ .. csv-table:: bad column widths
+ :widths: 10,y,z
+ \n\
+ some, csv, data
+ <system_message level="3" line="6" source="test data" type="ERROR">
+ <paragraph>
+ Error in "csv-table" directive:
+ invalid option value: (option: "widths"; value: '0 0 0')
+ negative or zero value; must be positive.
+ <literal_block xml:space="preserve">
+ .. csv-table:: bad column widths
+ :widths: 0 0 0
+ \n\
+ some, csv, data
+"""],
+["""\
+.. csv-table:: good delimiter
+ :delim: /
+
+ some/csv/data
+
+.. csv-table:: good delimiter
+ :delim: \\
+
+ some\\csv\\data
+
+.. csv-table:: good delimiter
+ :delim: 0x5c
+
+ some\\csv\\data
+
+.. csv-table:: good delimiter
+ :delim: space
+
+ some csv data
+""",
+"""\
+<document source="test data">
+ <table>
+ <title>
+ good delimiter
+ <tgroup cols="3">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ some
+ <entry>
+ <paragraph>
+ csv
+ <entry>
+ <paragraph>
+ data
+ <table>
+ <title>
+ good delimiter
+ <tgroup cols="3">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ some
+ <entry>
+ <paragraph>
+ csv
+ <entry>
+ <paragraph>
+ data
+ <table>
+ <title>
+ good delimiter
+ <tgroup cols="3">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ some
+ <entry>
+ <paragraph>
+ csv
+ <entry>
+ <paragraph>
+ data
+ <table>
+ <title>
+ good delimiter
+ <tgroup cols="3">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ some
+ <entry>
+ <paragraph>
+ csv
+ <entry>
+ <paragraph>
+ data
+"""],
+["""\
+.. csv-table:: bad delimiter
+ :delim: multiple
+
+.. csv-table:: bad delimiter
+ :delim: U+9999999999999
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "csv-table" directive:
+ invalid option value: (option: "delim"; value: 'multiple')
+ 'multiple' invalid; must be a single character or a Unicode code.
+ <literal_block xml:space="preserve">
+ .. csv-table:: bad delimiter
+ :delim: multiple
+ <system_message level="3" line="4" source="test data" type="ERROR">
+ <paragraph>
+ Error in "csv-table" directive:
+ invalid option value: (option: "delim"; value: 'U+9999999999999')
+ code too large (long int too large to convert to int).
+ <literal_block xml:space="preserve">
+ .. csv-table:: bad delimiter
+ :delim: U+9999999999999
+"""],
+["""\
+.. csv-table:: bad CSV data
+
+ "bad", \"csv, data
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error with CSV data in "csv-table" directive:
+ newline inside string
+ <literal_block xml:space="preserve">
+ .. csv-table:: bad CSV data
+ \n\
+ "bad", \"csv, data
+"""],
+["""\
+.. csv-table:: bad CSV header data
+ :header: "bad", \"csv, data
+
+ good, csv, data
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error with CSV data in "csv-table" directive:
+ newline inside string
+ <literal_block xml:space="preserve">
+ .. csv-table:: bad CSV header data
+ :header: "bad", \"csv, data
+ \n\
+ good, csv, data
+"""],
+["""\
+.. csv-table:: bad encoding
+ :file: %s
+ :encoding: latin-1
+
+(7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.)
+""" % utf_16_csv,
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error with CSV data in "csv-table" directive:
+ string with NUL bytes
+ <literal_block xml:space="preserve">
+ .. csv-table:: bad encoding
+ :file: %s
+ :encoding: latin-1
+ <paragraph>
+ (7- and 8-bit text encoded as UTF-16 has lots of null/zero bytes.)
+""" % utf_16_csv],
+["""\
+.. csv-table:: good encoding
+ :file: %s
+ :encoding: utf-16
+ :header-rows: 1
+""" % utf_16_csv,
+u"""\
+<document source="test data">
+ <table>
+ <title>
+ good encoding
+ <tgroup cols="3">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <colspec colwidth="33">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ Treat
+ <entry>
+ <paragraph>
+ Quantity
+ <entry>
+ <paragraph>
+ Description
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Albatr\u00b0\u00df
+ <entry>
+ <paragraph>
+ 2.99
+ <entry>
+ <paragraph>
+ \u00a1On a \u03c3\u03c4\u03b9\u03ba!
+ <row>
+ <entry>
+ <paragraph>
+ Crunchy Frog
+ <entry>
+ <paragraph>
+ 1.49
+ <entry>
+ <paragraph>
+ If we took the b\u00f6nes out, it wouldn\u2019t be
+ crunchy, now would it?
+ <row>
+ <entry>
+ <paragraph>
+ Gannet Ripple
+ <entry>
+ <paragraph>
+ 1.99
+ <entry>
+ <paragraph>
+ \u00bfOn a \u03c3\u03c4\u03b9\u03ba?
+"""],
+["""\
+.. csv-table:: no CSV data
+ :file: %s
+""" % empty_txt,
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ No table data detected in CSV file.
+ <literal_block xml:space="preserve">
+ .. csv-table:: no CSV data
+ :file: %s
+""" % empty_txt],
+]
+
+totest['list-table'] = [
+["""\
+.. list-table:: list table with integral header
+ :widths: 10 20 30
+ :header-rows: 1
+ :stub-columns: 1
+
+ * - Treat
+ - Quantity
+ - Description
+ * - Albatross
+ - 2.99
+ - On a stick!
+ * - Crunchy Frog
+ - 1.49
+ - If we took the bones out, it wouldn\'t be
+ crunchy, now would it?
+ * - Gannet Ripple
+ - 1.99
+ - On a stick!
+""",
+"""\
+<document source="test data">
+ <table>
+ <title>
+ list table with integral header
+ <tgroup cols="3">
+ <colspec colwidth="10" stub="1">
+ <colspec colwidth="20">
+ <colspec colwidth="30">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ Treat
+ <entry>
+ <paragraph>
+ Quantity
+ <entry>
+ <paragraph>
+ Description
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Albatross
+ <entry>
+ <paragraph>
+ 2.99
+ <entry>
+ <paragraph>
+ On a stick!
+ <row>
+ <entry>
+ <paragraph>
+ Crunchy Frog
+ <entry>
+ <paragraph>
+ 1.49
+ <entry>
+ <paragraph>
+ If we took the bones out, it wouldn\'t be
+ crunchy, now would it?
+ <row>
+ <entry>
+ <paragraph>
+ Gannet Ripple
+ <entry>
+ <paragraph>
+ 1.99
+ <entry>
+ <paragraph>
+ On a stick!
+"""],
+["""\
+.. list-table::
+
+ not a bullet list
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error parsing content block for the "list-table" directive: exactly one bullet list expected.
+ <literal_block xml:space="preserve">
+ .. list-table::
+ \n\
+ not a bullet list
+"""],
+["""\
+.. list-table::
+
+ * not a second-level bullet list
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error parsing content block for the "list-table" directive: two-level bullet list expected, but row 1 does not contain a second-level bullet list.
+ <literal_block xml:space="preserve">
+ .. list-table::
+ \n\
+ * not a second-level bullet list
+"""],
+["""\
+.. list-table::
+
+ * - columns not uniform
+ * - first row has one,
+ - second row has two
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error parsing content block for the "list-table" directive: uniform two-level bullet list expected, but row 2 does not contain the same number of items as row 1 (2 vs 1).
+ <literal_block xml:space="preserve">
+ .. list-table::
+ \n\
+ * - columns not uniform
+ * - first row has one,
+ - second row has two
+"""],
+["""\
+.. list-table::
+ :widths: 10 20
+
+ * - ":widths:" option doesn't match columns
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ "list-table" widths do not match the number of columns in table (1).
+ <literal_block xml:space="preserve">
+ .. list-table::
+ :widths: 10 20
+ \n\
+ * - ":widths:" option doesn\'t match columns
+"""],
+["""\
+.. list-table::
+ :stub-columns: 3
+
+ * - column 1
+ - column 2
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ 3 stub column(s) specified but only 2 columns(s) of data supplied ("list-table" directive).
+ <literal_block xml:space="preserve">
+ .. list-table::
+ :stub-columns: 3
+ \n\
+ * - column 1
+ - column 2
+"""],
+["""\
+.. list-table::
+ :stub-columns: 2
+
+ * - column 1
+ - column 2
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Insufficient data supplied (2 columns(s)); no data remaining for table body, required by "list-table" directive.
+ <literal_block xml:space="preserve">
+ .. list-table::
+ :stub-columns: 2
+ \n\
+ * - column 1
+ - column 2
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_target_notes.py b/test/test_parsers/test_rst/test_directives/test_target_notes.py
new file mode 100755
index 000000000..18dc1d207
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_target_notes.py
@@ -0,0 +1,64 @@
+#! /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 the target-notes directives.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['target-notes'] = [
+["""\
+.. target-notes::
+""",
+"""\
+<document source="test data">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.references.TargetNotes
+ .details:
+"""],
+["""\
+.. target-notes:: :class: custom
+""",
+"""\
+<document source="test data">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.references.TargetNotes
+ .details:
+ class: ['custom']
+"""],
+["""\
+.. target-notes::
+ :class:
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "target-notes" directive:
+ invalid option value: (option: "class"; value: None)
+ argument required but none supplied.
+ <literal_block xml:space="preserve">
+ .. target-notes::
+ :class:
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_test_directives.py b/test/test_parsers/test_rst/test_directives/test_test_directives.py
new file mode 100755
index 000000000..b90b26473
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_test_directives.py
@@ -0,0 +1,208 @@
+#! /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 misc.py test directives.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['test_directives'] = [
+["""\
+.. reStructuredText-test-directive::
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Directive processed. Type="reStructuredText-test-directive", arguments=[], options={}, content: None
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. reStructuredText-test-directive ::
+
+An optional space before the "::".
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Directive processed. Type="reStructuredText-test-directive", arguments=[], options={}, content: None
+ <paragraph>
+ An optional space before the "::".
+"""],
+["""\
+.. reStructuredText-test-directive:: argument
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Directive processed. Type="reStructuredText-test-directive", arguments=['argument'], options={}, content: None
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. reStructuredText-test-directive:: argument
+ :option: value
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Directive processed. Type="reStructuredText-test-directive", arguments=['argument'], options={'option': 'value'}, content: None
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. reStructuredText-test-directive:: :option: value
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Directive processed. Type="reStructuredText-test-directive", arguments=[], options={'option': 'value'}, content: None
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. reStructuredText-test-directive:: :option:
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "reStructuredText-test-directive" directive:
+ invalid option value: (option: "option"; value: None)
+ argument required but none supplied.
+ <literal_block xml:space="preserve">
+ .. reStructuredText-test-directive:: :option:
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. reStructuredText-test-directive::
+
+ Directive block contains one paragraph, with a blank line before.
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Directive processed. Type="reStructuredText-test-directive", arguments=[], options={}, content:
+ <literal_block xml:space="preserve">
+ Directive block contains one paragraph, with a blank line before.
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. reStructuredText-test-directive::
+
+
+ Directive block contains one paragraph, with two blank lines before.
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Directive processed. Type="reStructuredText-test-directive", arguments=[], options={}, content:
+ <literal_block xml:space="preserve">
+ Directive block contains one paragraph, with two blank lines before.
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. reStructuredText-test-directive::
+ Directive block contains one paragraph, no blank line before.
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Directive processed. Type="reStructuredText-test-directive", arguments=['Directive block contains one paragraph, no blank line before.'], options={}, content: None
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. reStructuredText-test-directive::
+ block
+no blank line.
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Directive processed. Type="reStructuredText-test-directive", arguments=['block'], options={}, content: None
+ <system_message level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Explicit markup ends without a blank line; unexpected unindent.
+ <paragraph>
+ no blank line.
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. reStructuredText-test-directive:: argument
+ :option: * value1
+ * value2
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Directive processed. Type="reStructuredText-test-directive", arguments=['argument'], options={'option': '* value1\\n* value2'}, content: None
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+.. reStructuredText-test-directive::
+
+ Directive \\block \\*contains* \\\\backslashes.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Directive processed. Type="reStructuredText-test-directive", arguments=[], options={}, content:
+ <literal_block xml:space="preserve">
+ Directive \\block \\*contains* \\\\backslashes.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_topics.py b/test/test_parsers/test_rst/test_directives/test_topics.py
new file mode 100755
index 000000000..4d0fae27b
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_topics.py
@@ -0,0 +1,240 @@
+#! /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 the "topic" directive.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['topics'] = [
+["""\
+.. topic::
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "topic" directive:
+ 1 argument(s) required, 0 supplied.
+ <literal_block xml:space="preserve">
+ .. topic::
+"""],
+["""\
+.. topic:: Title
+""",
+"""\
+<document source="test data">
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Content block expected for the "topic" directive; none found.
+ <literal_block xml:space="preserve">
+ .. topic:: Title
+"""],
+["""\
+.. topic:: Title
+
+ Body.
+""",
+"""\
+<document source="test data">
+ <topic>
+ <title>
+ Title
+ <paragraph>
+ Body.
+"""],
+["""\
+.. topic::
+
+ Title
+
+ Body.
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "topic" directive:
+ 1 argument(s) required, 0 supplied.
+ <literal_block xml:space="preserve">
+ .. topic::
+ \n\
+ Title
+ \n\
+ Body.
+"""],
+["""\
+.. topic:: Title
+ Body.
+""",
+"""\
+<document source="test data">
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Content block expected for the "topic" directive; none found.
+ <literal_block xml:space="preserve">
+ .. topic:: Title
+ Body.
+"""],
+["""\
+.. topic::
+
+ Title
+ Body.
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "topic" directive:
+ 1 argument(s) required, 0 supplied.
+ <literal_block xml:space="preserve">
+ .. topic::
+ \n\
+ Title
+ Body.
+"""],
+["""\
+.. topic:: Title
+
+ .. topic:: Nested
+
+ Body.
+""",
+"""\
+<document source="test data">
+ <topic>
+ <title>
+ Title
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ The "topic" directive may not be used within topics or body elements.
+ <literal_block xml:space="preserve">
+ .. topic:: Nested
+ \n\
+ Body.
+"""],
+["""\
+.. topic:: Title
+
+ .. topic:: Nested
+
+ Body.
+ More.
+""",
+"""\
+<document source="test data">
+ <topic>
+ <title>
+ Title
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ The "topic" directive may not be used within topics or body elements.
+ <literal_block xml:space="preserve">
+ .. topic:: Nested
+ \n\
+ Body.
+ <system_message level="2" line="6" source="test data" type="WARNING">
+ <paragraph>
+ Explicit markup ends without a blank line; unexpected unindent.
+ <paragraph>
+ More.
+"""],
+["""\
+.. topic:: Title
+
+ .. topic:: Nested
+
+ Body.
+
+ More.
+
+More.
+""",
+"""\
+<document source="test data">
+ <topic>
+ <title>
+ Title
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ The "topic" directive may not be used within topics or body elements.
+ <literal_block xml:space="preserve">
+ .. topic:: Nested
+ \n\
+ Body.
+ <paragraph>
+ More.
+ <paragraph>
+ More.
+"""],
+["""\
+.. topic:: First
+
+ Body
+
+.. topic:: Second
+
+ Body.
+""",
+"""\
+<document source="test data">
+ <topic>
+ <title>
+ First
+ <paragraph>
+ Body
+ <topic>
+ <title>
+ Second
+ <paragraph>
+ Body.
+"""],
+["""\
+.. sidebar:: Title
+ :subtitle: Outer
+
+ .. topic:: Nested
+
+ Body.
+
+ More.
+
+More.
+""",
+"""\
+<document source="test data">
+ <sidebar>
+ <title>
+ Title
+ <subtitle>
+ Outer
+ <topic>
+ <title>
+ Nested
+ <paragraph>
+ Body.
+ <paragraph>
+ More.
+ <paragraph>
+ More.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_unicode.py b/test/test_parsers/test_rst/test_directives/test_unicode.py
new file mode 100755
index 000000000..bd028cf42
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_unicode.py
@@ -0,0 +1,172 @@
+#! /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 misc.py "unicode" directive.
+"""
+
+from __init__ import DocutilsTestSupport
+
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['unicode'] = [
+["""
+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 (
+ <substitution_reference refname="mdash">
+ mdash
+ ), a copyright symbol (
+ <substitution_reference refname="copy">
+ copy
+ ), a non-breaking
+ space (
+ <substitution_reference refname="nbsp">
+ nbsp
+ ), a backwards-not-equals (
+ <substitution_reference refname="bne">
+ bne
+ ), and a captial omega (
+ <substitution_reference refname="Omega">
+ Omega
+ ).
+ <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
+"""],
+["""
+Bad input:
+
+.. |empty| unicode::
+.. |empty too| unicode:: .. comment doesn't count as content
+.. |not hex| unicode:: 0xHEX
+.. |not all hex| unicode:: UABCX
+.. unicode:: not in a substitution definition
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Bad input:
+ <system_message level="3" line="4" source="test data" type="ERROR">
+ <paragraph>
+ Error in "unicode" directive:
+ 1 argument(s) required, 0 supplied.
+ <literal_block xml:space="preserve">
+ unicode::
+ <system_message level="2" line="4" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "empty" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |empty| unicode::
+ <system_message level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "empty too" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |empty too| unicode:: .. comment doesn't count as content
+ <substitution_definition names="not\ hex">
+ 0xHEX
+ <substitution_definition names="not\ all\ hex">
+ UABCX
+ <system_message level="3" line="8" source="test data" type="ERROR">
+ <paragraph>
+ Invalid context: the "unicode" directive can only be used within a substitution definition.
+ <literal_block xml:space="preserve">
+ .. unicode:: not in a substitution definition
+"""],
+["""
+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
+ <substitution_reference refname="copy">
+ copy
+ 2003,
+ <substitution_reference refname="BogusMegaCorp (TM)">
+ BogusMegaCorp (TM)
+ .
+ <substitution_definition names="copy">
+ \u00A9
+ <substitution_definition names="BogusMegaCorp\ (TM)">
+ BogusMegaCorp
+ \u2122
+"""],
+["""
+.. |too big for int| unicode:: 0x111111111111111111
+.. |too big for unicode| unicode:: 0x11111111
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="2" source="test data" type="ERROR">
+ <paragraph>
+ Invalid character code: 0x111111111111111111
+ ValueError: %s
+ <literal_block xml:space="preserve">
+ unicode:: 0x111111111111111111
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "too big for int" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |too big for int| unicode:: 0x111111111111111111
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ Invalid character code: 0x11111111
+ %s
+ <literal_block xml:space="preserve">
+ unicode:: 0x11111111
+ <system_message level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "too big for unicode" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |too big for unicode| unicode:: 0x11111111
+""" % ([DocutilsTestSupport.exception_data(
+ 'unichr(int("111111111111111111", 16))')[0],
+ 'code too large (%s)' % DocutilsTestSupport.exception_data(
+ 'unichr(int("111111111111111111", 16))')[0]]
+ [isinstance(DocutilsTestSupport.exception_data(
+ 'unichr(int("111111111111111111", 16))')[0], OverflowError)],
+ DocutilsTestSupport.exception_data('unichr(int("11111111", 16))')[2])]
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/test_unknown.py b/test/test_parsers/test_rst/test_directives/test_unknown.py
new file mode 100755
index 000000000..3c859faa3
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/test_unknown.py
@@ -0,0 +1,67 @@
+#! /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 unknown directives.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['unknown'] = [
+["""\
+.. reStructuredText-unknown-directive::
+
+.. reStructuredText-unknown-directive:: argument
+
+.. reStructuredText-unknown-directive::
+ block
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ No directive entry for "reStructuredText-unknown-directive" in module "docutils.parsers.rst.languages.en".
+ Trying "reStructuredText-unknown-directive" as canonical directive name.
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Unknown directive type "reStructuredText-unknown-directive".
+ <literal_block xml:space="preserve">
+ .. reStructuredText-unknown-directive::
+ <system_message level="1" line="3" source="test data" type="INFO">
+ <paragraph>
+ No directive entry for "reStructuredText-unknown-directive" in module "docutils.parsers.rst.languages.en".
+ Trying "reStructuredText-unknown-directive" as canonical directive name.
+ <system_message level="3" line="3" source="test data" type="ERROR">
+ <paragraph>
+ Unknown directive type "reStructuredText-unknown-directive".
+ <literal_block xml:space="preserve">
+ .. reStructuredText-unknown-directive:: argument
+ <system_message level="1" line="5" source="test data" type="INFO">
+ <paragraph>
+ No directive entry for "reStructuredText-unknown-directive" in module "docutils.parsers.rst.languages.en".
+ Trying "reStructuredText-unknown-directive" as canonical directive name.
+ <system_message level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ Unknown directive type "reStructuredText-unknown-directive".
+ <literal_block xml:space="preserve">
+ .. reStructuredText-unknown-directive::
+ block
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_directives/utf-16.csv b/test/test_parsers/test_rst/test_directives/utf-16.csv
new file mode 100644
index 000000000..ba60d155e
--- /dev/null
+++ b/test/test_parsers/test_rst/test_directives/utf-16.csv
Binary files differ
diff --git a/test/test_parsers/test_rst/test_doctest_blocks.py b/test/test_parsers/test_rst/test_doctest_blocks.py
new file mode 100755
index 000000000..c9637c6d6
--- /dev/null
+++ b/test/test_parsers/test_rst/test_doctest_blocks.py
@@ -0,0 +1,74 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['doctest_blocks'] = [
+["""\
+Paragraph.
+
+>>> print "Doctest block."
+Doctest block.
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph.
+ <doctest_block xml:space="preserve">
+ >>> print "Doctest block."
+ Doctest block.
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+Paragraph.
+
+>>> print " Indented output."
+ Indented output.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph.
+ <doctest_block xml:space="preserve">
+ >>> print " Indented output."
+ Indented output.
+"""],
+["""\
+Paragraph.
+
+ >>> print " Indented block & output."
+ Indented block & output.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph.
+ <block_quote>
+ <doctest_block xml:space="preserve">
+ >>> print " Indented block & output."
+ Indented block & output.
+"""],
+]
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_east_asian_text.py b/test/test_parsers/test_rst/test_east_asian_text.py
new file mode 100755
index 000000000..1ac27743e
--- /dev/null
+++ b/test/test_parsers/test_rst/test_east_asian_text.py
@@ -0,0 +1,324 @@
+#! /usr/bin/env python
+# -*- coding: utf-8 -*-
+
+# Author: David Goodger
+# Contact: goodger@python.org
+# Revision: $Revision$
+# Date: $Date$
+# Copyright: This module has been placed in the public domain.
+
+"""
+Tests for East Asian text with double-width characters.
+"""
+
+from __init__ import DocutilsTestSupport
+
+import unicodedata
+try:
+ east_asian_width = unicodedata.east_asian_width
+except AttributeError:
+ east_asian_width = None
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+if not east_asian_width:
+ print ('test_east_asian_text.py tests skipped; '
+ 'Python 2.4 or higher required.')
+else:
+ totest['double-width'] = [
+[u"""\
+タイトル1
+=========
+
+タイトル2
+========
+""",
+u"""\
+<document source="test data">
+ <section ids="id1" names="タイトル1">
+ <title>
+ タイトル1
+ <section ids="id2" names="タイトル2">
+ <title>
+ タイトル2
+ <system_message level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Title underline too short.
+ <literal_block xml:space="preserve">
+ タイトル2
+ ========
+"""],
+[ur"""
++-----------------------+
+| * ヒョウ:ダイ1ギョウ |
+| * ダイ2ギョウ |
++-----------------------+
+| \* ダイ1ギョウ |
+| * ダイ2ギョウ |
++-----------------------+
+""",
+u"""\
+<document source="test data">
+ <table>
+ <tgroup cols="1">
+ <colspec colwidth="23">
+ <tbody>
+ <row>
+ <entry>
+ <bullet_list bullet="*">
+ <list_item>
+ <paragraph>
+ ヒョウ:ダイ1ギョウ
+ <list_item>
+ <paragraph>
+ ダイ2ギョウ
+ <row>
+ <entry>
+ <paragraph>
+ * ダイ1ギョウ
+ * ダイ2ギョウ
+"""],
+[u"""\
+Complex spanning pattern (no edge knows all rows/cols):
+
++--------+---------------------+
+| 北西・ | 北・北東セル |
+| 西セル +--------------+------+
+| | 真ん中のセル | 東・ |
++--------+--------------+ 南東 |
+| 南西・南セル | セル |
++-----------------------+------+
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Complex spanning pattern (no edge knows all rows/cols):
+ <table>
+ <tgroup cols="3">
+ <colspec colwidth="8">
+ <colspec colwidth="14">
+ <colspec colwidth="6">
+ <tbody>
+ <row>
+ <entry morerows="1">
+ <paragraph>
+ 北西・
+ 西セル
+ <entry morecols="1">
+ <paragraph>
+ 北・北東セル
+ <row>
+ <entry>
+ <paragraph>
+ 真ん中のセル
+ <entry morerows="1">
+ <paragraph>
+ 東・
+ 南東
+ セル
+ <row>
+ <entry morecols="1">
+ <paragraph>
+ 南西・南セル
+"""],
+[u"""\
+========= =========
+ダイ1ラン ダイ2ラン
+========= =========
+
+======== =========
+ダイ1ラン ダイ2ラン
+======== =========
+""",
+u"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="9">
+ <colspec colwidth="9">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ ダイ1ラン
+ <entry>
+ <paragraph>
+ ダイ2ラン
+ <system_message level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ Malformed table.
+ Text in column margin at line offset 1.
+ <literal_block xml:space="preserve">
+ ======== =========
+ ダイ1ラン ダイ2ラン
+ ======== =========
+"""],
+[u"""\
+Some ambiguous-width characters:
+
+= ===================================
+© copyright sign
+® registered sign
+« left pointing guillemet
+» right pointing guillemet
+– en-dash
+— em-dash
+‘ single turned comma quotation mark
+’ single comma quotation mark
+‚ low single comma quotation mark
+“ double turned comma quotation mark
+” double comma quotation mark
+„ low double comma quotation mark
+† dagger
+‡ double dagger
+… ellipsis
+™ trade mark sign
+⇔ left-right double arrow
+= ===================================
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Some ambiguous-width characters:
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="1">
+ <colspec colwidth="35">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ \xa9
+ <entry>
+ <paragraph>
+ copyright sign
+ <row>
+ <entry>
+ <paragraph>
+ \xae
+ <entry>
+ <paragraph>
+ registered sign
+ <row>
+ <entry>
+ <paragraph>
+ \xab
+ <entry>
+ <paragraph>
+ left pointing guillemet
+ <row>
+ <entry>
+ <paragraph>
+ \xbb
+ <entry>
+ <paragraph>
+ right pointing guillemet
+ <row>
+ <entry>
+ <paragraph>
+ \\u2013
+ <entry>
+ <paragraph>
+ en-dash
+ <row>
+ <entry>
+ <paragraph>
+ \\u2014
+ <entry>
+ <paragraph>
+ em-dash
+ <row>
+ <entry>
+ <paragraph>
+ \\u2018
+ <entry>
+ <paragraph>
+ single turned comma quotation mark
+ <row>
+ <entry>
+ <paragraph>
+ \\u2019
+ <entry>
+ <paragraph>
+ single comma quotation mark
+ <row>
+ <entry>
+ <paragraph>
+ \\u201a
+ <entry>
+ <paragraph>
+ low single comma quotation mark
+ <row>
+ <entry>
+ <paragraph>
+ \\u201c
+ <entry>
+ <paragraph>
+ double turned comma quotation mark
+ <row>
+ <entry>
+ <paragraph>
+ \\u201d
+ <entry>
+ <paragraph>
+ double comma quotation mark
+ <row>
+ <entry>
+ <paragraph>
+ \\u201e
+ <entry>
+ <paragraph>
+ low double comma quotation mark
+ <row>
+ <entry>
+ <paragraph>
+ \\u2020
+ <entry>
+ <paragraph>
+ dagger
+ <row>
+ <entry>
+ <paragraph>
+ \\u2021
+ <entry>
+ <paragraph>
+ double dagger
+ <row>
+ <entry>
+ <paragraph>
+ \\u2026
+ <entry>
+ <paragraph>
+ ellipsis
+ <row>
+ <entry>
+ <paragraph>
+ \\u2122
+ <entry>
+ <paragraph>
+ trade mark sign
+ <row>
+ <entry>
+ <paragraph>
+ \\u21d4
+ <entry>
+ <paragraph>
+ left-right double arrow
+"""],
+]
+'''
+[u"""\
+""",
+u"""\
+"""],
+'''
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_enumerated_lists.py b/test/test_parsers/test_rst/test_enumerated_lists.py
new file mode 100755
index 000000000..0375b33e9
--- /dev/null
+++ b/test/test_parsers/test_rst/test_enumerated_lists.py
@@ -0,0 +1,908 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['enumerated_lists'] = [
+["""\
+1. Item one.
+
+2. Item two.
+
+3. Item three.
+""",
+"""\
+<document source="test data">
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item one.
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+"""],
+["""\
+No blank lines betwen items:
+
+1. Item one.
+2. Item two.
+3. Item three.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ No blank lines betwen items:
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item one.
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+"""],
+["""\
+1.
+empty item above, no blank line
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ 1.
+ empty item above, no blank line
+"""],
+["""\
+Scrambled:
+
+3. Item three.
+
+2. Item two.
+
+1. Item one.
+
+3. Item three.
+2. Item two.
+1. Item one.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Scrambled:
+ <enumerated_list enumtype="arabic" prefix="" start="3" suffix=".">
+ <list_item>
+ <paragraph>
+ Item three.
+ <system_message level="1" line="3" source="test data" type="INFO">
+ <paragraph>
+ Enumerated list start value not ordinal-1: "3" (ordinal 3)
+ <enumerated_list enumtype="arabic" prefix="" start="2" suffix=".">
+ <list_item>
+ <paragraph>
+ Item two.
+ <system_message level="1" line="5" source="test data" type="INFO">
+ <paragraph>
+ Enumerated list start value not ordinal-1: "2" (ordinal 2)
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item one.
+ <paragraph>
+ 3. Item three.
+ 2. Item two.
+ 1. Item one.
+"""],
+["""\
+Skipping item 3:
+
+1. Item 1.
+2. Item 2.
+4. Item 4.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Skipping item 3:
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item 1.
+ <system_message level="2" line="4" source="test data" type="WARNING">
+ <paragraph>
+ Enumerated list ends without a blank line; unexpected unindent.
+ <paragraph>
+ 2. Item 2.
+ 4. Item 4.
+"""],
+["""\
+Start with non-ordinal-1:
+
+0. Item zero.
+1. Item one.
+2. Item two.
+3. Item three.
+
+And again:
+
+2. Item two.
+3. Item three.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Start with non-ordinal-1:
+ <enumerated_list enumtype="arabic" prefix="" start="0" suffix=".">
+ <list_item>
+ <paragraph>
+ Item zero.
+ <list_item>
+ <paragraph>
+ Item one.
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+ <system_message level="1" line="3" source="test data" type="INFO">
+ <paragraph>
+ Enumerated list start value not ordinal-1: "0" (ordinal 0)
+ <paragraph>
+ And again:
+ <enumerated_list enumtype="arabic" prefix="" start="2" suffix=".">
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+ <system_message level="1" line="10" source="test data" type="INFO">
+ <paragraph>
+ Enumerated list start value not ordinal-1: "2" (ordinal 2)
+"""],
+["""\
+1. Item one: line 1,
+ line 2.
+2. Item two: line 1,
+ line 2.
+3. Item three: paragraph 1, line 1,
+ line 2.
+
+ Paragraph 2.
+""",
+"""\
+<document source="test data">
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item one: line 1,
+ line 2.
+ <list_item>
+ <paragraph>
+ Item two: line 1,
+ line 2.
+ <list_item>
+ <paragraph>
+ Item three: paragraph 1, line 1,
+ line 2.
+ <paragraph>
+ Paragraph 2.
+"""],
+["""\
+Different enumeration sequences:
+
+1. Item 1.
+2. Item 2.
+3. Item 3.
+
+A. Item A.
+B. Item B.
+C. Item C.
+
+a. Item a.
+b. Item b.
+c. Item c.
+
+I. Item I.
+II. Item II.
+III. Item III.
+
+i. Item i.
+ii. Item ii.
+iii. Item iii.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Different enumeration sequences:
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item 1.
+ <list_item>
+ <paragraph>
+ Item 2.
+ <list_item>
+ <paragraph>
+ Item 3.
+ <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item A.
+ <list_item>
+ <paragraph>
+ Item B.
+ <list_item>
+ <paragraph>
+ Item C.
+ <enumerated_list enumtype="loweralpha" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item a.
+ <list_item>
+ <paragraph>
+ Item b.
+ <list_item>
+ <paragraph>
+ Item c.
+ <enumerated_list enumtype="upperroman" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item I.
+ <list_item>
+ <paragraph>
+ Item II.
+ <list_item>
+ <paragraph>
+ Item III.
+ <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item i.
+ <list_item>
+ <paragraph>
+ Item ii.
+ <list_item>
+ <paragraph>
+ Item iii.
+"""],
+["""\
+Bad Roman numerals:
+
+i. i
+
+ii. ii
+
+iii. iii
+
+iiii. iiii
+ second line
+
+(LCD) is an acronym made up of Roman numerals
+
+(livid) is a word made up of Roman numerals
+
+(CIVIL) is another such word
+
+(I) I
+
+(IVXLCDM) IVXLCDM
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Bad Roman numerals:
+ <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ i
+ <list_item>
+ <paragraph>
+ ii
+ <list_item>
+ <paragraph>
+ iii
+ <definition_list>
+ <definition_list_item>
+ <term>
+ iiii. iiii
+ <definition>
+ <paragraph>
+ second line
+ <paragraph>
+ (LCD) is an acronym made up of Roman numerals
+ <paragraph>
+ (livid) is a word made up of Roman numerals
+ <paragraph>
+ (CIVIL) is another such word
+ <enumerated_list enumtype="upperroman" prefix="(" suffix=")">
+ <list_item>
+ <paragraph>
+ I
+ <paragraph>
+ (IVXLCDM) IVXLCDM
+"""],
+["""\
+Potentially ambiguous cases:
+
+A. Item A.
+B. Item B.
+C. Item C.
+
+I. Item I.
+II. Item II.
+III. Item III.
+
+a. Item a.
+b. Item b.
+c. Item c.
+
+i. Item i.
+ii. Item ii.
+iii. Item iii.
+
+Phew! Safe!
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Potentially ambiguous cases:
+ <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item A.
+ <list_item>
+ <paragraph>
+ Item B.
+ <list_item>
+ <paragraph>
+ Item C.
+ <enumerated_list enumtype="upperroman" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item I.
+ <list_item>
+ <paragraph>
+ Item II.
+ <list_item>
+ <paragraph>
+ Item III.
+ <enumerated_list enumtype="loweralpha" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item a.
+ <list_item>
+ <paragraph>
+ Item b.
+ <list_item>
+ <paragraph>
+ Item c.
+ <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item i.
+ <list_item>
+ <paragraph>
+ Item ii.
+ <list_item>
+ <paragraph>
+ Item iii.
+ <paragraph>
+ Phew! Safe!
+"""],
+["""\
+Definitely ambiguous:
+
+A. Item A.
+B. Item B.
+C. Item C.
+D. Item D.
+E. Item E.
+F. Item F.
+G. Item G.
+H. Item H.
+I. Item I.
+II. Item II.
+III. Item III.
+
+a. Item a.
+b. Item b.
+c. Item c.
+d. Item d.
+e. Item e.
+f. Item f.
+g. Item g.
+h. Item h.
+i. Item i.
+ii. Item ii.
+iii. Item iii.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Definitely ambiguous:
+ <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item A.
+ <list_item>
+ <paragraph>
+ Item B.
+ <list_item>
+ <paragraph>
+ Item C.
+ <list_item>
+ <paragraph>
+ Item D.
+ <list_item>
+ <paragraph>
+ Item E.
+ <list_item>
+ <paragraph>
+ Item F.
+ <list_item>
+ <paragraph>
+ Item G.
+ <list_item>
+ <paragraph>
+ Item H.
+ <system_message level="2" line="11" source="test data" type="WARNING">
+ <paragraph>
+ Enumerated list ends without a blank line; unexpected unindent.
+ <enumerated_list enumtype="upperroman" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item I.
+ <list_item>
+ <paragraph>
+ Item II.
+ <list_item>
+ <paragraph>
+ Item III.
+ <enumerated_list enumtype="loweralpha" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item a.
+ <list_item>
+ <paragraph>
+ Item b.
+ <list_item>
+ <paragraph>
+ Item c.
+ <list_item>
+ <paragraph>
+ Item d.
+ <list_item>
+ <paragraph>
+ Item e.
+ <list_item>
+ <paragraph>
+ Item f.
+ <list_item>
+ <paragraph>
+ Item g.
+ <list_item>
+ <paragraph>
+ Item h.
+ <system_message level="2" line="23" source="test data" type="WARNING">
+ <paragraph>
+ Enumerated list ends without a blank line; unexpected unindent.
+ <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item i.
+ <list_item>
+ <paragraph>
+ Item ii.
+ <list_item>
+ <paragraph>
+ Item iii.
+"""],
+["""\
+Different enumeration formats:
+
+1. Item 1.
+2. Item 2.
+3. Item 3.
+
+1) Item 1).
+2) Item 2).
+3) Item 3).
+
+(1) Item (1).
+(2) Item (2).
+(3) Item (3).
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Different enumeration formats:
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item 1.
+ <list_item>
+ <paragraph>
+ Item 2.
+ <list_item>
+ <paragraph>
+ Item 3.
+ <enumerated_list enumtype="arabic" prefix="" suffix=")">
+ <list_item>
+ <paragraph>
+ Item 1).
+ <list_item>
+ <paragraph>
+ Item 2).
+ <list_item>
+ <paragraph>
+ Item 3).
+ <enumerated_list enumtype="arabic" prefix="(" suffix=")">
+ <list_item>
+ <paragraph>
+ Item (1).
+ <list_item>
+ <paragraph>
+ Item (2).
+ <list_item>
+ <paragraph>
+ Item (3).
+"""],
+["""\
+Nested enumerated lists:
+
+1. Item 1.
+
+ A) Item A).
+ B) Item B).
+ C) Item C).
+
+2. Item 2.
+
+ (a) Item (a).
+
+ I) Item I).
+ II) Item II).
+ III) Item III).
+
+ (b) Item (b).
+
+ (c) Item (c).
+
+ (i) Item (i).
+ (ii) Item (ii).
+ (iii) Item (iii).
+
+3. Item 3.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Nested enumerated lists:
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item 1.
+ <enumerated_list enumtype="upperalpha" prefix="" suffix=")">
+ <list_item>
+ <paragraph>
+ Item A).
+ <list_item>
+ <paragraph>
+ Item B).
+ <list_item>
+ <paragraph>
+ Item C).
+ <list_item>
+ <paragraph>
+ Item 2.
+ <enumerated_list enumtype="loweralpha" prefix="(" suffix=")">
+ <list_item>
+ <paragraph>
+ Item (a).
+ <enumerated_list enumtype="upperroman" prefix="" suffix=")">
+ <list_item>
+ <paragraph>
+ Item I).
+ <list_item>
+ <paragraph>
+ Item II).
+ <list_item>
+ <paragraph>
+ Item III).
+ <list_item>
+ <paragraph>
+ Item (b).
+ <list_item>
+ <paragraph>
+ Item (c).
+ <enumerated_list enumtype="lowerroman" prefix="(" suffix=")">
+ <list_item>
+ <paragraph>
+ Item (i).
+ <list_item>
+ <paragraph>
+ Item (ii).
+ <list_item>
+ <paragraph>
+ Item (iii).
+ <list_item>
+ <paragraph>
+ Item 3.
+"""],
+[u"""\
+A. Einstein was a great influence on
+B. Physicist, who was a colleague of
+C. Chemist. They all worked in
+Princeton, NJ.
+
+Using a non-breaking space as a workaround:
+
+A.\u00a0Einstein was a great influence on
+B. Physicist, who was a colleague of
+C. Chemist. They all worked in
+Princeton, NJ.
+""",
+"""\
+<document source="test data">
+ <enumerated_list enumtype="upperalpha" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Einstein was a great influence on
+ <list_item>
+ <paragraph>
+ Physicist, who was a colleague of
+ <system_message level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Enumerated list ends without a blank line; unexpected unindent.
+ <paragraph>
+ C. Chemist. They all worked in
+ Princeton, NJ.
+ <paragraph>
+ Using a non-breaking space as a workaround:
+ <paragraph>
+ A.\xa0Einstein was a great influence on
+ B. Physicist, who was a colleague of
+ C. Chemist. They all worked in
+ Princeton, NJ.
+"""],
+["""\
+1. Item one: line 1,
+ line 2.
+2. Item two: line 1,
+ line 2.
+3. Item three: paragraph 1, line 1,
+ line 2.
+
+ Paragraph 2.
+""",
+"""\
+<document source="test data">
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item one: line 1,
+ line 2.
+ <list_item>
+ <paragraph>
+ Item two: line 1,
+ <system_message level="2" line="4" source="test data" type="WARNING">
+ <paragraph>
+ Enumerated list ends without a blank line; unexpected unindent.
+ <block_quote>
+ <paragraph>
+ line 2.
+ <system_message level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Block quote ends without a blank line; unexpected unindent.
+ <enumerated_list enumtype="arabic" prefix="" start="3" suffix=".">
+ <list_item>
+ <paragraph>
+ Item three: paragraph 1, line 1,
+ <system_message level="1" line="5" source="test data" type="INFO">
+ <paragraph>
+ Enumerated list start value not ordinal-1: "3" (ordinal 3)
+ <system_message level="2" line="6" source="test data" type="WARNING">
+ <paragraph>
+ Enumerated list ends without a blank line; unexpected unindent.
+ <block_quote>
+ <paragraph>
+ line 2.
+ <block_quote>
+ <paragraph>
+ Paragraph 2.
+"""],
+["""\
+1. Item one.
+
+#. Item two.
+
+#. Item three.
+""",
+"""\
+<document source="test data">
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item one.
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+"""],
+["""\
+a. Item one.
+#. Item two.
+#. Item three.
+""",
+"""\
+<document source="test data">
+ <enumerated_list enumtype="loweralpha" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item one.
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+"""],
+["""\
+i. Item one.
+ii. Item two.
+#. Item three.
+""",
+"""\
+<document source="test data">
+ <enumerated_list enumtype="lowerroman" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item one.
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+"""],
+["""\
+#. Item one.
+#. Item two.
+#. Item three.
+""",
+"""\
+<document source="test data">
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item one.
+ <list_item>
+ <paragraph>
+ Item two.
+ <list_item>
+ <paragraph>
+ Item three.
+"""],
+["""\
+1. Item one.
+#. Item two.
+3. Item three.
+""",
+"""\
+<document source="test data">
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item one.
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Enumerated list ends without a blank line; unexpected unindent.
+ <paragraph>
+ #. Item two.
+ 3. Item three.
+"""],
+["""\
+z.
+x
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ z.
+ x
+"""],
+["""\
+3-space indent, with a trailing space:
+
+1. \n\
+ foo
+
+3-space indent, no trailing space:
+
+1.
+ foo
+
+2-space indent:
+
+1.
+ foo
+
+1-space indent:
+
+1.
+ foo
+
+0-space indent, not a list item:
+
+1.
+foo
+
+No item content:
+
+1.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ 3-space indent, with a trailing space:
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ foo
+ <paragraph>
+ 3-space indent, no trailing space:
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ foo
+ <paragraph>
+ 2-space indent:
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ foo
+ <paragraph>
+ 1-space indent:
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ foo
+ <paragraph>
+ 0-space indent, not a list item:
+ <paragraph>
+ 1.
+ foo
+ <paragraph>
+ No item content:
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_field_lists.py b/test/test_parsers/test_rst/test_field_lists.py
new file mode 100755
index 000000000..2e715770c
--- /dev/null
+++ b/test/test_parsers/test_rst/test_field_lists.py
@@ -0,0 +1,551 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['field_lists'] = [
+["""\
+One-liners:
+
+:Author: Me
+
+:Version: 1
+
+:Date: 2001-08-11
+
+:Parameter i: integer
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ One-liners:
+ <field_list>
+ <field>
+ <field_name>
+ Author
+ <field_body>
+ <paragraph>
+ Me
+ <field>
+ <field_name>
+ Version
+ <field_body>
+ <paragraph>
+ 1
+ <field>
+ <field_name>
+ Date
+ <field_body>
+ <paragraph>
+ 2001-08-11
+ <field>
+ <field_name>
+ Parameter i
+ <field_body>
+ <paragraph>
+ integer
+"""],
+["""\
+One-liners, no blank lines:
+
+:Author: Me
+:Version: 1
+:Date: 2001-08-11
+:Parameter i: integer
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ One-liners, no blank lines:
+ <field_list>
+ <field>
+ <field_name>
+ Author
+ <field_body>
+ <paragraph>
+ Me
+ <field>
+ <field_name>
+ Version
+ <field_body>
+ <paragraph>
+ 1
+ <field>
+ <field_name>
+ Date
+ <field_body>
+ <paragraph>
+ 2001-08-11
+ <field>
+ <field_name>
+ Parameter i
+ <field_body>
+ <paragraph>
+ integer
+"""],
+["""\
+:field:
+empty item above, no blank line
+""",
+"""\
+<document source="test data">
+ <field_list>
+ <field>
+ <field_name>
+ field
+ <field_body>
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Field list ends without a blank line; unexpected unindent.
+ <paragraph>
+ empty item above, no blank line
+"""],
+["""\
+Field bodies starting on the next line:
+
+:Author:
+ Me
+:Version:
+ 1
+:Date:
+ 2001-08-11
+:Parameter i:
+ integer
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Field bodies starting on the next line:
+ <field_list>
+ <field>
+ <field_name>
+ Author
+ <field_body>
+ <paragraph>
+ Me
+ <field>
+ <field_name>
+ Version
+ <field_body>
+ <paragraph>
+ 1
+ <field>
+ <field_name>
+ Date
+ <field_body>
+ <paragraph>
+ 2001-08-11
+ <field>
+ <field_name>
+ Parameter i
+ <field_body>
+ <paragraph>
+ integer
+"""],
+["""\
+One-paragraph, multi-liners:
+
+:Authors: Me,
+ Myself,
+ and I
+:Version: 1
+ or so
+:Date: 2001-08-11
+ (Saturday)
+:Parameter i: counter
+ (integer)
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ One-paragraph, multi-liners:
+ <field_list>
+ <field>
+ <field_name>
+ Authors
+ <field_body>
+ <paragraph>
+ Me,
+ Myself,
+ and I
+ <field>
+ <field_name>
+ Version
+ <field_body>
+ <paragraph>
+ 1
+ or so
+ <field>
+ <field_name>
+ Date
+ <field_body>
+ <paragraph>
+ 2001-08-11
+ (Saturday)
+ <field>
+ <field_name>
+ Parameter i
+ <field_body>
+ <paragraph>
+ counter
+ (integer)
+"""],
+["""\
+One-paragraph, multi-liners, not lined up:
+
+:Authors: Me,
+ Myself,
+ and I
+:Version: 1
+ or so
+:Date: 2001-08-11
+ (Saturday)
+:Parameter i: counter
+ (integer)
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ One-paragraph, multi-liners, not lined up:
+ <field_list>
+ <field>
+ <field_name>
+ Authors
+ <field_body>
+ <paragraph>
+ Me,
+ Myself,
+ and I
+ <field>
+ <field_name>
+ Version
+ <field_body>
+ <paragraph>
+ 1
+ or so
+ <field>
+ <field_name>
+ Date
+ <field_body>
+ <paragraph>
+ 2001-08-11
+ (Saturday)
+ <field>
+ <field_name>
+ Parameter i
+ <field_body>
+ <paragraph>
+ counter
+ (integer)
+"""],
+["""\
+Multiple body elements:
+
+:Authors: - Me
+ - Myself
+ - I
+
+:Abstract:
+ This is a field list item's body,
+ containing multiple elements.
+
+ Here's a literal block::
+
+ def f(x):
+ return x**2 + x
+
+ Even nested field lists are possible:
+
+ :Date: 2001-08-11
+ :Day: Saturday
+ :Time: 15:07
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Multiple body elements:
+ <field_list>
+ <field>
+ <field_name>
+ Authors
+ <field_body>
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ Me
+ <list_item>
+ <paragraph>
+ Myself
+ <list_item>
+ <paragraph>
+ I
+ <field>
+ <field_name>
+ Abstract
+ <field_body>
+ <paragraph>
+ This is a field list item's body,
+ containing multiple elements.
+ <paragraph>
+ Here's a literal block:
+ <literal_block xml:space="preserve">
+ def f(x):
+ return x**2 + x
+ <paragraph>
+ Even nested field lists are possible:
+ <field_list>
+ <field>
+ <field_name>
+ Date
+ <field_body>
+ <paragraph>
+ 2001-08-11
+ <field>
+ <field_name>
+ Day
+ <field_body>
+ <paragraph>
+ Saturday
+ <field>
+ <field_name>
+ Time
+ <field_body>
+ <paragraph>
+ 15:07
+"""],
+["""\
+Nested field lists on one line:
+
+:field1: :field2: :field3: body
+:field4: :field5: :field6: body
+ :field7: body
+ :field8: body
+ :field9: body line 1
+ body line 2
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Nested field lists on one line:
+ <field_list>
+ <field>
+ <field_name>
+ field1
+ <field_body>
+ <field_list>
+ <field>
+ <field_name>
+ field2
+ <field_body>
+ <field_list>
+ <field>
+ <field_name>
+ field3
+ <field_body>
+ <paragraph>
+ body
+ <field>
+ <field_name>
+ field4
+ <field_body>
+ <field_list>
+ <field>
+ <field_name>
+ field5
+ <field_body>
+ <field_list>
+ <field>
+ <field_name>
+ field6
+ <field_body>
+ <paragraph>
+ body
+ <field>
+ <field_name>
+ field7
+ <field_body>
+ <paragraph>
+ body
+ <field>
+ <field_name>
+ field8
+ <field_body>
+ <paragraph>
+ body
+ <field>
+ <field_name>
+ field9
+ <field_body>
+ <paragraph>
+ body line 1
+ body line 2
+"""],
+["""\
+:Parameter i j k: multiple arguments
+""",
+"""\
+<document source="test data">
+ <field_list>
+ <field>
+ <field_name>
+ Parameter i j k
+ <field_body>
+ <paragraph>
+ multiple arguments
+"""],
+["""\
+:Field *name* `with` **inline** ``markup``: inline markup in
+ field name is parsed.
+""",
+"""\
+<document source="test data">
+ <field_list>
+ <field>
+ <field_name>
+ Field \n\
+ <emphasis>
+ name
+ \n\
+ <title_reference>
+ with
+ \n\
+ <strong>
+ inline
+ \n\
+ <literal>
+ markup
+ <field_body>
+ <paragraph>
+ inline markup in
+ field name is parsed.
+"""],
+["""\
+:Field name with *bad inline markup: should generate warning.
+""",
+"""\
+<document source="test data">
+ <field_list>
+ <field>
+ <field_name>
+ Field name with \n\
+ <problematic ids="id2" refid="id1">
+ *
+ bad inline markup
+ <field_body>
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline emphasis start-string without end-string.
+ <paragraph>
+ should generate warning.
+"""],
+[r"""Some edge cases:
+
+:Empty:
+:Author: Me
+No blank line before this paragraph.
+
+: Field: marker must not begin with whitespace.
+
+:Field : marker must not end with whitespace.
+
+Field: marker is missing its open-colon.
+
+:Field marker is missing its close-colon.
+
+:Field\: names\: with\: colons\:: are possible.
+
+:\\Field\ names with backslashes\\: are possible, too.
+
+:\\: A backslash.
+
+:Not a\\\: field list.
+
+:Not a \: field list either.
+
+:\: Not a field list either.
+
+:\:
+ A definition list, not a field list.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Some edge cases:
+ <field_list>
+ <field>
+ <field_name>
+ Empty
+ <field_body>
+ <field>
+ <field_name>
+ Author
+ <field_body>
+ <paragraph>
+ Me
+ <system_message level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Field list ends without a blank line; unexpected unindent.
+ <paragraph>
+ No blank line before this paragraph.
+ <paragraph>
+ : Field: marker must not begin with whitespace.
+ <paragraph>
+ :Field : marker must not end with whitespace.
+ <paragraph>
+ Field: marker is missing its open-colon.
+ <paragraph>
+ :Field marker is missing its close-colon.
+ <field_list>
+ <field>
+ <field_name>
+ Field: names: with: colons:
+ <field_body>
+ <paragraph>
+ are possible.
+ <field>
+ <field_name>
+ \\Field names with backslashes\\
+ <field_body>
+ <paragraph>
+ are possible, too.
+ <field>
+ <field_name>
+ \\
+ <field_body>
+ <paragraph>
+ A backslash.
+ <paragraph>
+ :Not a\\: field list.
+ <paragraph>
+ :Not a : field list either.
+ <paragraph>
+ :: Not a field list either.
+ <definition_list>
+ <definition_list_item>
+ <term>
+ ::
+ <definition>
+ <paragraph>
+ A definition list, not a field list.
+"""],
+]
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_footnotes.py b/test/test_parsers/test_rst/test_footnotes.py
new file mode 100755
index 000000000..cca255cbc
--- /dev/null
+++ b/test/test_parsers/test_rst/test_footnotes.py
@@ -0,0 +1,332 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['footnotes'] = [
+["""\
+.. [1] This is a footnote.
+""",
+"""\
+<document source="test data">
+ <footnote ids="id1" names="1">
+ <label>
+ 1
+ <paragraph>
+ This is a footnote.
+"""],
+["""\
+.. [1] This is a footnote
+ on multiple lines.
+""",
+"""\
+<document source="test data">
+ <footnote ids="id1" names="1">
+ <label>
+ 1
+ <paragraph>
+ This is a footnote
+ on multiple lines.
+"""],
+["""\
+.. [1] This is a footnote
+ on multiple lines with more space.
+
+.. [2] This is a footnote
+ on multiple lines with less space.
+""",
+"""\
+<document source="test data">
+ <footnote ids="id1" names="1">
+ <label>
+ 1
+ <paragraph>
+ This is a footnote
+ on multiple lines with more space.
+ <footnote ids="id2" names="2">
+ <label>
+ 2
+ <paragraph>
+ This is a footnote
+ on multiple lines with less space.
+"""],
+["""\
+.. [1]
+ This is a footnote on multiple lines
+ whose block starts on line 2.
+""",
+"""\
+<document source="test data">
+ <footnote ids="id1" names="1">
+ <label>
+ 1
+ <paragraph>
+ This is a footnote on multiple lines
+ whose block starts on line 2.
+"""],
+["""\
+.. [1]
+
+That was an empty footnote.
+""",
+"""\
+<document source="test data">
+ <footnote ids="id1" names="1">
+ <label>
+ 1
+ <paragraph>
+ That was an empty footnote.
+"""],
+["""\
+.. [1]
+No blank line.
+""",
+"""\
+<document source="test data">
+ <footnote ids="id1" names="1">
+ <label>
+ 1
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Explicit markup ends without a blank line; unexpected unindent.
+ <paragraph>
+ No blank line.
+"""],
+]
+
+totest['auto_numbered_footnotes'] = [
+["""\
+[#]_ 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">
+ is the first auto-numbered footnote reference.
+ <footnote_reference auto="1" ids="id2">
+ is the second auto-numbered footnote reference.
+ <footnote auto="1" ids="id3">
+ <paragraph>
+ Auto-numbered footnote 1.
+ <footnote auto="1" ids="id4">
+ <paragraph>
+ Auto-numbered footnote 2.
+ <footnote auto="1" ids="id5">
+ <paragraph>
+ Auto-numbered footnote 3.
+ <paragraph>
+ <footnote_reference auto="1" ids="id6">
+ 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 targets generated by
+the footnotes: first_, second_, third_.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <footnote_reference auto="1" ids="id1" refname="third">
+ is a reference to the third auto-numbered footnote.
+ <footnote auto="1" ids="first" names="first">
+ <paragraph>
+ First auto-numbered footnote.
+ <footnote auto="1" ids="second" names="second">
+ <paragraph>
+ Second auto-numbered footnote.
+ <footnote auto="1" ids="third" names="third">
+ <paragraph>
+ Third auto-numbered footnote.
+ <paragraph>
+ <footnote_reference auto="1" ids="id2" refname="second">
+ is a reference to the second auto-numbered footnote.
+ <footnote_reference auto="1" ids="id3" refname="first">
+ is a reference to the first auto-numbered footnote.
+ <footnote_reference auto="1" ids="id4" refname="third">
+ is another reference to the third auto-numbered footnote.
+ <paragraph>
+ Here are some internal cross-references to the 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" refname="four">
+ should be 4, \n\
+ <footnote_reference auto="1" ids="id2">
+ should be 1,
+ <footnote_reference auto="1" ids="id3">
+ should be 3, \n\
+ <footnote_reference auto="1" ids="id4">
+ is one too many,
+ <footnote_reference auto="1" ids="id5" refname="two">
+ should be 2, and \n\
+ <footnote_reference auto="1" ids="id6" refname="six">
+ doesn't exist.
+ <footnote auto="1" ids="id7">
+ <paragraph>
+ Auto-numbered footnote 1.
+ <footnote auto="1" ids="two" names="two">
+ <paragraph>
+ Auto-numbered footnote 2.
+ <footnote auto="1" ids="id8">
+ <paragraph>
+ Auto-numbered footnote 3.
+ <footnote auto="1" ids="four" names="four">
+ <paragraph>
+ Auto-numbered footnote 4.
+ <footnote auto="1" dupnames="five" ids="five">
+ <paragraph>
+ Auto-numbered footnote 5.
+ <footnote auto="1" dupnames="five" ids="id9">
+ <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).
+"""],
+["""\
+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 [#six]_ 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.
+.. [#five] Auto-numbered footnote 5 again (duplicate).
+.. [#] Auto-numbered footnote 6.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Mixed manually-numbered, anonymous auto-numbered,
+ and labelled auto-numbered footnotes:
+ <paragraph>
+ <footnote_reference auto="1" ids="id1" refname="four">
+ should be 4, \n\
+ <footnote_reference auto="1" ids="id2">
+ should be 2,
+ <footnote_reference ids="id3" refname="1">
+ 1
+ is 1, \n\
+ <footnote_reference ids="id4" refname="3">
+ 3
+ is 3,
+ <footnote_reference auto="1" ids="id5">
+ should be 6, \n\
+ <footnote_reference auto="1" ids="id6">
+ is one too many,
+ <footnote_reference auto="1" ids="id7" refname="five">
+ should be 5, and \n\
+ <footnote_reference auto="1" ids="id8" refname="six">
+ doesn't exist.
+ <footnote ids="id9" names="1">
+ <label>
+ 1
+ <paragraph>
+ Manually-numbered footnote 1.
+ <footnote auto="1" ids="id10">
+ <paragraph>
+ Auto-numbered footnote 2.
+ <footnote auto="1" ids="four" names="four">
+ <paragraph>
+ Auto-numbered footnote 4.
+ <footnote ids="id11" names="3">
+ <label>
+ 3
+ <paragraph>
+ Manually-numbered footnote 3
+ <footnote auto="1" dupnames="five" ids="five">
+ <paragraph>
+ Auto-numbered footnote 5.
+ <footnote auto="1" dupnames="five" ids="id12">
+ <system_message backrefs="id12" level="2" line="14" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "five".
+ <paragraph>
+ Auto-numbered footnote 5 again (duplicate).
+ <footnote auto="1" ids="id13">
+ <paragraph>
+ Auto-numbered footnote 6.
+"""],
+]
+
+totest['auto_symbol_footnotes'] = [
+["""\
+.. [*] This is an auto-symbol footnote.
+""",
+"""\
+<document source="test data">
+ <footnote auto="*" ids="id1">
+ <paragraph>
+ This is an auto-symbol footnote.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_functions.py b/test/test_parsers/test_rst/test_functions.py
new file mode 100755
index 000000000..e6694b2c5
--- /dev/null
+++ b/test/test_parsers/test_rst/test_functions.py
@@ -0,0 +1,38 @@
+#! /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 states.py.
+"""
+
+import unittest
+from __init__ import DocutilsTestSupport
+states = DocutilsTestSupport.states
+
+
+class FuctionTests(unittest.TestCase):
+
+ escaped = r'escapes: \*one, \\*two, \\\*three'
+ nulled = 'escapes: \x00*one, \x00\\*two, \x00\\\x00*three'
+ unescaped = r'escapes: *one, \*two, \*three'
+
+ def test_escape2null(self):
+ nulled = states.escape2null(self.escaped)
+ self.assertEquals(nulled, self.nulled)
+ nulled = states.escape2null(self.escaped + '\\')
+ self.assertEquals(nulled, self.nulled + '\x00')
+
+ def test_unescape(self):
+ unescaped = states.unescape(self.nulled)
+ self.assertEquals(unescaped, self.unescaped)
+ restored = states.unescape(self.nulled, 1)
+ self.assertEquals(restored, self.escaped)
+
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/test/test_parsers/test_rst/test_inline_markup.py b/test/test_parsers/test_rst/test_inline_markup.py
new file mode 100755
index 000000000..7185d723d
--- /dev/null
+++ b/test/test_parsers/test_rst/test_inline_markup.py
@@ -0,0 +1,924 @@
+#! /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 inline markup in docutils/parsers/rst/states.py.
+Interpreted text tests are in a separate module, test_interpreted.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['emphasis'] = [
+["""\
+*emphasis*
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <emphasis>
+ emphasis
+"""],
+["""\
+*emphasized sentence
+across lines*
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <emphasis>
+ emphasized sentence
+ across lines
+"""],
+["""\
+*emphasis without closing asterisk
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ *
+ emphasis without closing asterisk
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline emphasis start-string without end-string.
+"""],
+["""\
+'*emphasis*' and 1/*emphasis*/2 and 3-*emphasis*-4 and 5:*emphasis*:6
+but not '*' or '"*"' or x*2* or 2*x* or \\*args or *
+or *the\\* *stars\\\\\\* *inside*
+
+(however, '*args' will trigger a warning and may be problematic)
+
+what about *this**?
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ '
+ <emphasis>
+ emphasis
+ ' and 1/
+ <emphasis>
+ emphasis
+ /2 and 3-
+ <emphasis>
+ emphasis
+ -4 and 5:
+ <emphasis>
+ emphasis
+ :6
+ but not '*' or '"*"' or x*2* or 2*x* or *args or *
+ or \n\
+ <emphasis>
+ the* *stars\* *inside
+ <paragraph>
+ (however, '
+ <problematic ids="id2" refid="id1">
+ *
+ args' will trigger a warning and may be problematic)
+ <system_message backrefs="id2" ids="id1" level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Inline emphasis start-string without end-string.
+ <paragraph>
+ what about \n\
+ <emphasis>
+ this*
+ ?
+"""],
+["""\
+Emphasized asterisk: *\\**
+
+Emphasized double asterisk: *\\***
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Emphasized asterisk: \n\
+ <emphasis>
+ *
+ <paragraph>
+ Emphasized double asterisk: \n\
+ <emphasis>
+ **
+"""],
+]
+
+totest['strong'] = [
+["""\
+**strong**
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <strong>
+ strong
+"""],
+["""\
+(**strong**) but not (**) or '(** ' or x**2 or \\**kwargs or **
+
+(however, '**kwargs' will trigger a warning and may be problematic)
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ (
+ <strong>
+ strong
+ ) but not (**) or '(** ' or x**2 or **kwargs or **
+ <paragraph>
+ (however, '
+ <problematic ids="id2" refid="id1">
+ **
+ kwargs' will trigger a warning and may be problematic)
+ <system_message backrefs="id2" ids="id1" level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Inline strong start-string without end-string.
+"""],
+["""\
+Strong asterisk: *****
+
+Strong double asterisk: ******
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Strong asterisk: \n\
+ <strong>
+ *
+ <paragraph>
+ Strong double asterisk: \n\
+ <strong>
+ **
+"""],
+["""\
+**strong without closing asterisks
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ **
+ strong without closing asterisks
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline strong start-string without end-string.
+"""],
+]
+
+totest['literal'] = [
+["""\
+``literal``
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <literal>
+ literal
+"""],
+["""\
+``\\literal``
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <literal>
+ \\literal
+"""],
+["""\
+``lite\\ral``
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <literal>
+ lite\\ral
+"""],
+["""\
+``literal\\``
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <literal>
+ literal\\
+"""],
+["""\
+``literal ``TeX quotes'' & \\backslash`` but not "``" or ``
+
+(however, ``standalone TeX quotes'' will trigger a warning
+and may be problematic)
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <literal>
+ literal ``TeX quotes'' & \\backslash
+ but not "``" or ``
+ <paragraph>
+ (however, \n\
+ <problematic ids="id2" refid="id1">
+ ``
+ standalone TeX quotes'' will trigger a warning
+ and may be problematic)
+ <system_message backrefs="id2" ids="id1" level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Inline literal start-string without end-string.
+"""],
+["""\
+Find the ```interpreted text``` in this paragraph!
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Find the \n\
+ <literal>
+ `interpreted text`
+ in this paragraph!
+"""],
+["""\
+``literal without closing backquotes
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ ``
+ literal without closing backquotes
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline literal start-string without end-string.
+"""],
+["""\
+Python ``list``\\s use square bracket syntax.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Python \n\
+ <literal>
+ list
+ s use square bracket syntax.
+"""],
+]
+
+totest['references'] = [
+["""\
+ref_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="ref" refname="ref">
+ ref
+"""],
+["""\
+ref__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference anonymous="1" name="ref">
+ ref
+"""],
+["""\
+ref_, r_, r_e-f_, -ref_, and anonymousref__,
+but not _ref_ or __attr__ or object.__attr__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="ref" refname="ref">
+ ref
+ , \n\
+ <reference name="r" refname="r">
+ r
+ , \n\
+ <reference name="r_e-f" refname="r_e-f">
+ r_e-f
+ , -
+ <reference name="ref" refname="ref">
+ ref
+ , and \n\
+ <reference anonymous="1" name="anonymousref">
+ anonymousref
+ ,
+ but not _ref_ or __attr__ or object.__attr__
+"""],
+]
+
+totest['phrase_references'] = [
+["""\
+`phrase reference`_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="phrase reference" refname="phrase reference">
+ phrase reference
+"""],
+["""\
+`anonymous reference`__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference anonymous="1" name="anonymous reference">
+ anonymous reference
+"""],
+["""\
+`phrase reference
+across lines`_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="phrase reference across lines" refname="phrase reference across lines">
+ phrase reference
+ across lines
+"""],
+["""\
+`phrase\`_ reference`_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="phrase`_ reference" refname="phrase`_ reference">
+ phrase`_ reference
+"""],
+["""\
+Invalid phrase reference:
+
+:role:`phrase reference`_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Invalid phrase reference:
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ :role:`phrase reference`_
+ <system_message backrefs="id2" ids="id1" level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Mismatch: both interpreted text role prefix and reference suffix.
+"""],
+["""\
+Invalid phrase reference:
+
+`phrase reference`:role:_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Invalid phrase reference:
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ `phrase reference`:role:_
+ <system_message backrefs="id2" ids="id1" level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Mismatch: both interpreted text role suffix and reference suffix.
+"""],
+["""\
+`phrase reference_ without closing backquote
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ `
+ phrase \n\
+ <reference name="reference" refname="reference">
+ reference
+ without closing backquote
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline interpreted text or phrase reference start-string without end-string.
+"""],
+["""\
+`anonymous phrase reference__ without closing backquote
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ `
+ anonymous phrase \n\
+ <reference anonymous="1" name="reference">
+ reference
+ without closing backquote
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline interpreted text or phrase reference start-string without end-string.
+"""],
+]
+
+totest['embedded_URIs'] = [
+["""\
+`phrase reference <http://example.com>`_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="phrase reference" refuri="http://example.com">
+ phrase reference
+ <target ids="phrase-reference" names="phrase\ reference" refuri="http://example.com">
+"""],
+["""\
+`anonymous reference <http://example.com>`__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="anonymous reference" refuri="http://example.com">
+ anonymous reference
+"""],
+["""\
+`embedded URI on next line
+<http://example.com>`__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="embedded URI on next line" refuri="http://example.com">
+ embedded URI on next line
+"""],
+["""\
+`embedded URI across lines <http://example.com/
+long/path>`__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="embedded URI across lines" refuri="http://example.com/long/path">
+ embedded URI across lines
+"""],
+["""\
+`embedded URI with whitespace <http://example.com/
+long/path /and /whitespace>`__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="embedded URI with whitespace" refuri="http://example.com/long/path/and/whitespace">
+ embedded URI with whitespace
+"""],
+["""\
+`embedded email address <jdoe@example.com>`__
+
+`embedded email address broken across lines <jdoe
+@example.com>`__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference name="embedded email address" refuri="mailto:jdoe@example.com">
+ embedded email address
+ <paragraph>
+ <reference name="embedded email address broken across lines" refuri="mailto:jdoe@example.com">
+ embedded email address broken across lines
+"""],
+["""\
+`embedded URI with too much whitespace < http://example.com/
+long/path /and /whitespace >`__
+
+`embedded URI with too much whitespace at end <http://example.com/
+long/path /and /whitespace >`__
+
+`embedded URI with no preceding whitespace<http://example.com>`__
+
+`escaped URI \\<http://example.com>`__
+
+See `HTML Anchors: \\<a>`_.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference anonymous="1" name="embedded URI with too much whitespace < http://example.com/ long/path /and /whitespace >">
+ embedded URI with too much whitespace < http://example.com/
+ long/path /and /whitespace >
+ <paragraph>
+ <reference anonymous="1" name="embedded URI with too much whitespace at end <http://example.com/ long/path /and /whitespace >">
+ embedded URI with too much whitespace at end <http://example.com/
+ long/path /and /whitespace >
+ <paragraph>
+ <reference anonymous="1" name="embedded URI with no preceding whitespace<http://example.com>">
+ embedded URI with no preceding whitespace<http://example.com>
+ <paragraph>
+ <reference anonymous="1" name="escaped URI <http://example.com>">
+ escaped URI <http://example.com>
+ <paragraph>
+ See \n\
+ <reference name="HTML Anchors: <a>" refname="html anchors: <a>">
+ HTML Anchors: <a>
+ .
+"""],
+["""\
+Relative URIs' reference text can be omitted:
+
+`<reference>`_
+
+`<anonymous>`__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Relative URIs' reference text can be omitted:
+ <paragraph>
+ <reference name="reference" refuri="reference">
+ reference
+ <target ids="reference" names="reference" refuri="reference">
+ <paragraph>
+ <reference name="anonymous" refuri="anonymous">
+ anonymous
+"""],
+]
+
+totest['inline_targets'] = [
+["""\
+_`target`
+
+Here is _`another target` in some text. And _`yet
+another target`, spanning lines.
+
+_`Here is a TaRgeT` with case and spacial difficulties.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <target ids="target" names="target">
+ target
+ <paragraph>
+ Here is \n\
+ <target ids="another-target" names="another\ target">
+ another target
+ in some text. And \n\
+ <target ids="yet-another-target" names="yet\ another\ target">
+ yet
+ another target
+ , spanning lines.
+ <paragraph>
+ <target ids="here-is-a-target" names="here\ is\ a\ target">
+ Here is a TaRgeT
+ with case and spacial difficulties.
+"""],
+["""\
+But this isn't a _target; targets require backquotes.
+
+And _`this`_ is just plain confusing.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ But this isn't a _target; targets require backquotes.
+ <paragraph>
+ And \n\
+ <problematic ids="id2" refid="id1">
+ _`
+ this`_ is just plain confusing.
+ <system_message backrefs="id2" ids="id1" level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Inline target start-string without end-string.
+"""],
+["""\
+_`inline target without closing backquote
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ _`
+ inline target without closing backquote
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline target start-string without end-string.
+"""],
+]
+
+totest['footnote_reference'] = [
+["""\
+[1]_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <footnote_reference ids="id1" refname="1">
+ 1
+"""],
+["""\
+[#]_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <footnote_reference auto="1" ids="id1">
+"""],
+["""\
+[#label]_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <footnote_reference auto="1" ids="id1" refname="label">
+"""],
+["""\
+[*]_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <footnote_reference auto="*" ids="id1">
+"""],
+]
+
+totest['citation_reference'] = [
+["""\
+[citation]_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <citation_reference ids="id1" refname="citation">
+ citation
+"""],
+["""\
+[citation]_ and [cit-ation]_ and [cit.ation]_ and [CIT1]_ but not [CIT 1]_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <citation_reference ids="id1" refname="citation">
+ citation
+ and \n\
+ <citation_reference ids="id2" refname="cit-ation">
+ cit-ation
+ and \n\
+ <citation_reference ids="id3" refname="cit.ation">
+ cit.ation
+ and \n\
+ <citation_reference ids="id4" refname="cit1">
+ CIT1
+ but not [CIT 1]_
+"""],
+]
+
+totest['substitution_references'] = [
+["""\
+|subref|
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <substitution_reference refname="subref">
+ subref
+"""],
+["""\
+|subref|_ and |subref|__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference refname="subref">
+ <substitution_reference refname="subref">
+ subref
+ and \n\
+ <reference anonymous="1">
+ <substitution_reference refname="subref">
+ subref
+"""],
+["""\
+|substitution reference|
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <substitution_reference refname="substitution reference">
+ substitution reference
+"""],
+["""\
+|substitution
+reference|
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <substitution_reference refname="substitution reference">
+ substitution
+ reference
+"""],
+["""\
+|substitution reference without closing verbar
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ |
+ substitution reference without closing verbar
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline substitution_reference start-string without end-string.
+"""],
+["""\
+first | then || and finally |||
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ first | then || and finally |||
+"""],
+]
+
+totest['standalone_hyperlink'] = [
+["""\
+http://www.standalone.hyperlink.com
+
+http:/one-slash-only.absolute.path
+
+[http://example.com]
+
+(http://example.com)
+
+<http://example.com>
+
+http://[1080:0:0:0:8:800:200C:417A]/IPv6address.html
+
+http://[3ffe:2a00:100:7031::1] (the final "]" is ambiguous in text)
+
+http://[3ffe:2a00:100:7031::1]/
+
+mailto:someone@somewhere.com
+
+news:comp.lang.python
+
+An email address in a sentence: someone@somewhere.com.
+
+ftp://ends.with.a.period.
+
+(a.question.mark@end?)
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference refuri="http://www.standalone.hyperlink.com">
+ http://www.standalone.hyperlink.com
+ <paragraph>
+ <reference refuri="http:/one-slash-only.absolute.path">
+ http:/one-slash-only.absolute.path
+ <paragraph>
+ [
+ <reference refuri="http://example.com">
+ http://example.com
+ ]
+ <paragraph>
+ (
+ <reference refuri="http://example.com">
+ http://example.com
+ )
+ <paragraph>
+ <
+ <reference refuri="http://example.com">
+ http://example.com
+ >
+ <paragraph>
+ <reference refuri="http://[1080:0:0:0:8:800:200C:417A]/IPv6address.html">
+ http://[1080:0:0:0:8:800:200C:417A]/IPv6address.html
+ <paragraph>
+ <reference refuri="http://[3ffe:2a00:100:7031::1">
+ http://[3ffe:2a00:100:7031::1
+ ] (the final "]" is ambiguous in text)
+ <paragraph>
+ <reference refuri="http://[3ffe:2a00:100:7031::1]/">
+ http://[3ffe:2a00:100:7031::1]/
+ <paragraph>
+ <reference refuri="mailto:someone@somewhere.com">
+ mailto:someone@somewhere.com
+ <paragraph>
+ <reference refuri="news:comp.lang.python">
+ news:comp.lang.python
+ <paragraph>
+ An email address in a sentence: \n\
+ <reference refuri="mailto:someone@somewhere.com">
+ someone@somewhere.com
+ .
+ <paragraph>
+ <reference refuri="ftp://ends.with.a.period">
+ ftp://ends.with.a.period
+ .
+ <paragraph>
+ (
+ <reference refuri="mailto:a.question.mark@end">
+ a.question.mark@end
+ ?)
+"""],
+["""\
+Valid URLs with escaped markup characters:
+
+http://example.com/\\*content\\*/whatever
+
+http://example.com/\\*content*/whatever
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Valid URLs with escaped markup characters:
+ <paragraph>
+ <reference refuri="http://example.com/*content*/whatever">
+ http://example.com/*content*/whatever
+ <paragraph>
+ <reference refuri="http://example.com/*content*/whatever">
+ http://example.com/*content*/whatever
+"""],
+["""\
+Valid URLs may end with punctuation inside "<>":
+
+<http://example.org/ends-with-dot.>
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Valid URLs may end with punctuation inside "<>":
+ <paragraph>
+ <
+ <reference refuri="http://example.org/ends-with-dot.">
+ http://example.org/ends-with-dot.
+ >
+"""],
+["""\
+Valid URLs with interesting endings:
+
+http://example.org/ends-with-pluses++
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Valid URLs with interesting endings:
+ <paragraph>
+ <reference refuri="http://example.org/ends-with-pluses++">
+ http://example.org/ends-with-pluses++
+"""],
+["""\
+None of these are standalone hyperlinks (their "schemes"
+are not recognized): signal:noise, a:b.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ None of these are standalone hyperlinks (their "schemes"
+ are not recognized): signal:noise, a:b.
+"""],
+["""\
+Escaped email addresses are not recognized: test\@example.org
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Escaped email addresses are not recognized: test@example.org
+"""],
+]
+
+totest['miscellaneous'] = [
+["""\
+__This__ should be left alone.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ __This__ should be left alone.
+"""],
+[r"""
+Character-level m\ *a*\ **r**\ ``k``\ `u`:title:\p
+with backslash-escaped whitespace, including new\
+lines.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Character-level m
+ <emphasis>
+ a
+ <strong>
+ r
+ <literal>
+ k
+ <title_reference>
+ u
+ p
+ with backslash-escaped whitespace, including newlines.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_interpreted.py b/test/test_parsers/test_rst/test_interpreted.py
new file mode 100755
index 000000000..a5392d497
--- /dev/null
+++ b/test/test_parsers/test_rst/test_interpreted.py
@@ -0,0 +1,305 @@
+#! /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 interpreted text in docutils/parsers/rst/states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['basics'] = [
+["""\
+`interpreted`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <title_reference>
+ interpreted
+"""],
+["""\
+:title:`interpreted`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <title_reference>
+ interpreted
+"""],
+["""\
+`interpreted`:title:
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <title_reference>
+ interpreted
+"""],
+["""\
+`interpreted \`title``
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <title_reference>
+ interpreted `title`
+"""],
+["""\
+:title:`:not-role: interpreted`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <title_reference>
+ :not-role: interpreted
+"""],
+["""\
+`interpreted` but not \\`interpreted` [`] or ({[`] or [`]}) or `
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <title_reference>
+ interpreted
+ but not `interpreted` [`] or ({[`] or [`]}) or `
+"""],
+["""\
+`interpreted`-text `interpreted`: text `interpreted`:text `text`'s interpreted
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <title_reference>
+ interpreted
+ -text \n\
+ <title_reference>
+ interpreted
+ : text \n\
+ <title_reference>
+ interpreted
+ :text \n\
+ <title_reference>
+ text
+ 's interpreted
+"""],
+["""\
+`interpreted without closing backquote
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ `
+ interpreted without closing backquote
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline interpreted text or phrase reference start-string without end-string.
+"""],
+["""\
+`interpreted`:not a role if it contains whitespace:
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <title_reference>
+ interpreted
+ :not a role if it contains whitespace:
+"""],
+["""\
+:title:`` (empty interpteted text not recognized)
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ :title:`` (empty interpteted text not recognized)
+"""],
+["""\
+Explicit roles for standard inline markup:
+:emphasis:`emphasis`,
+:strong:`strong`,
+:literal:`inline literal text`.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Explicit roles for standard inline markup:
+ <emphasis>
+ emphasis
+ ,
+ <strong>
+ strong
+ ,
+ <literal>
+ inline literal text
+ .
+"""],
+["""\
+Simple explicit roles:
+:ab:`abbreviation`,
+:ac:`acronym`,
+:sup:`superscript`,
+:sub:`subscript`,
+:title:`title reference`.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Simple explicit roles:
+ <abbreviation>
+ abbreviation
+ ,
+ <acronym>
+ acronym
+ ,
+ <superscript>
+ superscript
+ ,
+ <subscript>
+ subscript
+ ,
+ <title_reference>
+ title reference
+ .
+"""],
+]
+
+totest['references'] = [
+["""\
+:PEP:`0`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference refuri="http://www.python.org/peps/pep-0000.html">
+ PEP 0
+"""],
+["""\
+:PEP:`-1`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ :PEP:`-1`
+ <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ PEP number must be a number from 0 to 9999; "-1" is invalid.
+"""],
+["""\
+:RFC:`2822`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <reference refuri="http://www.faqs.org/rfcs/rfc2822.html">
+ RFC 2822
+"""],
+["""\
+:RFC:`0`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ :RFC:`0`
+ <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ RFC number must be a number greater than or equal to 1; "0" is invalid.
+"""],
+]
+
+totest['unknown_roles'] = [
+["""\
+:role:`interpreted`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ :role:`interpreted`
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ No role entry for "role" in module "docutils.parsers.rst.languages.en".
+ Trying "role" as canonical role name.
+ <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Unknown interpreted text role "role".
+"""],
+["""\
+`interpreted`:role:
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ `interpreted`:role:
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ No role entry for "role" in module "docutils.parsers.rst.languages.en".
+ Trying "role" as canonical role name.
+ <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Unknown interpreted text role "role".
+"""],
+["""\
+:role:`interpreted`:role:
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ :role:`interpreted`:role:
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Multiple roles in interpreted text (both prefix and suffix present; only one allowed).
+"""],
+["""\
+:very.long-role_name:`interpreted`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ :very.long-role_name:`interpreted`
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ No role entry for "very.long-role_name" in module "docutils.parsers.rst.languages.en".
+ Trying "very.long-role_name" as canonical role name.
+ <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Unknown interpreted text role "very.long-role_name".
+"""],
+["""\
+:restructuredtext-unimplemented-role:`interpreted`
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ :restructuredtext-unimplemented-role:`interpreted`
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ No role entry for "restructuredtext-unimplemented-role" in module "docutils.parsers.rst.languages.en".
+ Trying "restructuredtext-unimplemented-role" as canonical role name.
+ <system_message backrefs="id2" ids="id1" level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Interpreted text role "restructuredtext-unimplemented-role" not implemented.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_line_blocks.py b/test/test_parsers/test_rst/test_line_blocks.py
new file mode 100755
index 000000000..10eaa8354
--- /dev/null
+++ b/test/test_parsers/test_rst/test_line_blocks.py
@@ -0,0 +1,310 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['line_blocks'] = [
+["""\
+| This is a line block.
+| Line breaks are *preserved*.
+
+| This is a second line block.
+
+| This is a third.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ This is a line block.
+ <line>
+ Line breaks are \n\
+ <emphasis>
+ preserved
+ .
+ <line_block>
+ <line>
+ This is a second line block.
+ <line_block>
+ <line>
+ This is a third.
+"""],
+["""\
+| In line blocks,
+| Initial indentation is *also* preserved.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ In line blocks,
+ <line_block>
+ <line>
+ Initial indentation is \n\
+ <emphasis>
+ also
+ preserved.
+"""],
+["""\
+| Individual lines in line blocks
+ *may* wrap, as indicated by the lack of a vertical bar prefix.
+| These are called "continuation lines".
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ Individual lines in line blocks
+ <emphasis>
+ may
+ wrap, as indicated by the lack of a vertical bar prefix.
+ <line>
+ These are called "continuation lines".
+"""],
+["""\
+| Inline markup in line blocks may also wrap *to
+ continuation lines*.
+| But not to following lines.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ Inline markup in line blocks may also wrap \n\
+ <emphasis>
+ to
+ continuation lines
+ .
+ <line>
+ But not to following lines.
+"""],
+["""\
+\\| This is not a line block.
+The vertical bar is simply part of a paragraph.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ | This is not a line block.
+ The vertical bar is simply part of a paragraph.
+"""],
+["""\
+| This line block is incomplete.
+There should be a blank line before this paragraph.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ This line block is incomplete.
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Line block ends without a blank line.
+ <paragraph>
+ There should be a blank line before this paragraph.
+"""],
+["""\
+| This line block contains
+|
+| blank lines.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ This line block contains
+ <line>
+ <line>
+ blank lines.
+"""],
+["""\
+| The blank lines in this block
+| \n\
+| \n\
+| have bogus spaces.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ The blank lines in this block
+ <line>
+ <line>
+ <line>
+ have bogus spaces.
+"""],
+["""\
+| Initial indentation is also significant and preserved:
+|
+| Indented 4 spaces
+| Not indented
+| Indented 2 spaces
+| Indented 4 spaces
+| Only one space
+|
+| Continuation lines may be indented less
+ than their base lines.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ Initial indentation is also significant and preserved:
+ <line>
+ <line_block>
+ <line>
+ Indented 4 spaces
+ <line>
+ Not indented
+ <line_block>
+ <line_block>
+ <line>
+ Indented 2 spaces
+ <line_block>
+ <line>
+ Indented 4 spaces
+ <line>
+ Only one space
+ <line>
+ <line_block>
+ <line>
+ Continuation lines may be indented less
+ than their base lines.
+"""],
+["""\
+|
+| This block begins and ends with blank lines.
+|
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ <line>
+ This block begins and ends with blank lines.
+ <line>
+"""],
+["""\
+This is not
+| a line block.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ This is not
+ | a line block.
+"""],
+["""\
+| The first line is indented.
+| The second line is more indented.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ The first line is indented.
+ <line_block>
+ <line>
+ The second line is more indented.
+"""],
+["""\
+| The first line is indented.
+| The second line is less indented.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line_block>
+ <line>
+ The first line is indented.
+ <line>
+ The second line is less indented.
+"""],
+["""\
+|This is not
+|a line block
+
+| This is an
+|incomplete line block.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ <problematic ids="id2" refid="id1">
+ |
+ This is not
+ <problematic ids="id4" refid="id3">
+ |
+ a line block
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline substitution_reference start-string without end-string.
+ <system_message backrefs="id4" ids="id3" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline substitution_reference start-string without end-string.
+ <line_block>
+ <line>
+ This is an
+ <system_message level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Line block ends without a blank line.
+ <paragraph>
+ <problematic ids="id6" refid="id5">
+ |
+ incomplete line block.
+ <system_message backrefs="id6" ids="id5" level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Inline substitution_reference start-string without end-string.
+"""],
+["""\
+| Inline markup *may not
+| wrap* over several lines.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ Inline markup \n\
+ <problematic ids="id2" refid="id1">
+ *
+ may not
+ <line>
+ wrap* over several lines.
+ <system_message backrefs="id2" ids="id1" level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Inline emphasis start-string without end-string.
+"""],
+["""\
+| * Block level markup
+| * is not recognized.
+""",
+"""\
+<document source="test data">
+ <line_block>
+ <line>
+ * Block level markup
+ <line>
+ * is not recognized.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_literal_blocks.py b/test/test_parsers/test_rst/test_literal_blocks.py
new file mode 100755
index 000000000..332e0eb27
--- /dev/null
+++ b/test/test_parsers/test_rst/test_literal_blocks.py
@@ -0,0 +1,371 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['indented_literal_blocks'] = [
+["""\
+A paragraph::
+
+ A literal block.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ A literal block.
+"""],
+["""\
+A paragraph with a space after the colons:: \n\
+
+ A literal block.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph with a space after the colons:
+ <literal_block xml:space="preserve">
+ A literal block.
+"""],
+["""\
+A paragraph::
+
+ A literal block.
+
+Another paragraph::
+
+ Another literal block.
+ With two blank lines following.
+
+
+A final paragraph.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ A literal block.
+ <paragraph>
+ Another paragraph:
+ <literal_block xml:space="preserve">
+ Another literal block.
+ With two blank lines following.
+ <paragraph>
+ A final paragraph.
+"""],
+["""\
+A paragraph
+on more than
+one line::
+
+ A literal block.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph
+ on more than
+ one line:
+ <literal_block xml:space="preserve">
+ A literal block.
+"""],
+["""\
+A paragraph
+on more than
+one line::
+ A literal block
+ with no blank line above.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph
+ on more than
+ one line:
+ <system_message level="3" line="4" source="test data" type="ERROR">
+ <paragraph>
+ Unexpected indentation.
+ <literal_block xml:space="preserve">
+ A literal block
+ with no blank line above.
+"""],
+["""\
+A paragraph::
+
+ A literal block.
+no blank line
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ A literal block.
+ <system_message level="2" line="4" source="test data" type="WARNING">
+ <paragraph>
+ Literal block ends without a blank line; unexpected unindent.
+ <paragraph>
+ no blank line
+"""],
+[r"""
+A paragraph\\::
+
+ A literal block.
+
+A paragraph\::
+
+ Not a literal block.
+""",
+r"""<document source="test data">
+ <paragraph>
+ A paragraph\:
+ <literal_block xml:space="preserve">
+ A literal block.
+ <paragraph>
+ A paragraph::
+ <block_quote>
+ <paragraph>
+ Not a literal block.
+"""],
+[r"""
+\\::
+
+ A literal block.
+
+\::
+
+ Not a literal block.
+""",
+r"""<document source="test data">
+ <paragraph>
+ \:
+ <literal_block xml:space="preserve">
+ A literal block.
+ <paragraph>
+ ::
+ <block_quote>
+ <paragraph>
+ Not a literal block.
+"""],
+["""\
+A paragraph: ::
+
+ A literal block.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ A literal block.
+"""],
+["""\
+A paragraph:
+
+::
+
+ A literal block.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ A literal block.
+"""],
+["""\
+A paragraph:
+::
+
+ A literal block.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="2" source="test data" type="INFO">
+ <paragraph>
+ Possible title underline, too short for the title.
+ Treating it as ordinary text because it's so short.
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ A literal block.
+"""],
+["""\
+A paragraph:
+
+::
+
+ A literal block.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ A literal block.
+"""],
+["""\
+A paragraph::
+
+Not a literal block.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <system_message level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Literal block expected; none found.
+ <paragraph>
+ Not a literal block.
+"""],
+["""\
+A paragraph::
+
+ A wonky literal block.
+ Literal line 2.
+
+ Literal line 3.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ A wonky literal block.
+ Literal line 2.
+ \n\
+ Literal line 3.
+"""],
+["""\
+EOF, even though a literal block is indicated::
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ EOF, even though a literal block is indicated:
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Literal block expected; none found.
+"""],
+]
+
+totest['quoted_literal_blocks'] = [
+["""\
+A paragraph::
+
+> A literal block.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ > A literal block.
+"""],
+["""\
+A paragraph::
+
+
+> A literal block.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ > A literal block.
+"""],
+["""\
+A paragraph::
+
+> A literal block.
+> Line 2.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ > A literal block.
+ > Line 2.
+"""],
+["""\
+A paragraph::
+
+> A literal block.
+ Indented line.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ > A literal block.
+ <system_message level="3" line="4" source="test data" type="ERROR">
+ <paragraph>
+ Unexpected indentation.
+ <block_quote>
+ <paragraph>
+ Indented line.
+"""],
+["""\
+A paragraph::
+
+> A literal block.
+Text.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ > A literal block.
+ <system_message level="3" line="4" source="test data" type="ERROR">
+ <paragraph>
+ Inconsistent literal block quoting.
+ <paragraph>
+ Text.
+"""],
+["""\
+A paragraph::
+
+> A literal block.
+$ Inconsistent line.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph:
+ <literal_block xml:space="preserve">
+ > A literal block.
+ <system_message level="3" line="4" source="test data" type="ERROR">
+ <paragraph>
+ Inconsistent literal block quoting.
+ <paragraph>
+ $ Inconsistent line.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_option_lists.py b/test/test_parsers/test_rst/test_option_lists.py
new file mode 100755
index 000000000..a5afc498b
--- /dev/null
+++ b/test/test_parsers/test_rst/test_option_lists.py
@@ -0,0 +1,756 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['option_lists'] = [
+["""\
+Short options:
+
+-a option -a
+
+-b file option -b
+
+-c name option -c
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Short options:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -a
+ <description>
+ <paragraph>
+ option -a
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -b
+ <option_argument delimiter=" ">
+ file
+ <description>
+ <paragraph>
+ option -b
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -c
+ <option_argument delimiter=" ">
+ name
+ <description>
+ <paragraph>
+ option -c
+"""],
+["""\
+Long options:
+
+--aaaa option --aaaa
+--bbbb=file option --bbbb
+--cccc name option --cccc
+--d-e-f-g option --d-e-f-g
+--h_i_j_k option --h_i_j_k
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Long options:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --aaaa
+ <description>
+ <paragraph>
+ option --aaaa
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --bbbb
+ <option_argument delimiter="=">
+ file
+ <description>
+ <paragraph>
+ option --bbbb
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --cccc
+ <option_argument delimiter=" ">
+ name
+ <description>
+ <paragraph>
+ option --cccc
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --d-e-f-g
+ <description>
+ <paragraph>
+ option --d-e-f-g
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --h_i_j_k
+ <description>
+ <paragraph>
+ option --h_i_j_k
+"""],
+["""\
+Old GNU-style options:
+
++a option +a
+
++b file option +b
+
++c name option +c
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Old GNU-style options:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ +a
+ <description>
+ <paragraph>
+ option +a
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ +b
+ <option_argument delimiter=" ">
+ file
+ <description>
+ <paragraph>
+ option +b
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ +c
+ <option_argument delimiter=" ">
+ name
+ <description>
+ <paragraph>
+ option +c
+"""],
+["""\
+VMS/DOS-style options:
+
+/A option /A
+/B file option /B
+/CCC option /CCC
+/DDD string option /DDD
+/EEE=int option /EEE
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ VMS/DOS-style options:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ /A
+ <description>
+ <paragraph>
+ option /A
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ /B
+ <option_argument delimiter=" ">
+ file
+ <description>
+ <paragraph>
+ option /B
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ /CCC
+ <description>
+ <paragraph>
+ option /CCC
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ /DDD
+ <option_argument delimiter=" ">
+ string
+ <description>
+ <paragraph>
+ option /DDD
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ /EEE
+ <option_argument delimiter="=">
+ int
+ <description>
+ <paragraph>
+ option /EEE
+"""],
+["""\
+Mixed short, long, and VMS/DOS options:
+
+-a option -a
+--bbbb=file option -bbbb
+/C option /C
+--dddd name option --dddd
+-e string option -e
+/F file option /F
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Mixed short, long, and VMS/DOS options:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -a
+ <description>
+ <paragraph>
+ option -a
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --bbbb
+ <option_argument delimiter="=">
+ file
+ <description>
+ <paragraph>
+ option -bbbb
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ /C
+ <description>
+ <paragraph>
+ option /C
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --dddd
+ <option_argument delimiter=" ">
+ name
+ <description>
+ <paragraph>
+ option --dddd
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -e
+ <option_argument delimiter=" ">
+ string
+ <description>
+ <paragraph>
+ option -e
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ /F
+ <option_argument delimiter=" ">
+ file
+ <description>
+ <paragraph>
+ option /F
+"""],
+["""\
+Aliased options:
+
+-a, --aaaa, /A option -a, --aaaa, /A
+-b file, --bbbb=file, /B file option -b, --bbbb, /B
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Aliased options:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -a
+ <option>
+ <option_string>
+ --aaaa
+ <option>
+ <option_string>
+ /A
+ <description>
+ <paragraph>
+ option -a, --aaaa, /A
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -b
+ <option_argument delimiter=" ">
+ file
+ <option>
+ <option_string>
+ --bbbb
+ <option_argument delimiter="=">
+ file
+ <option>
+ <option_string>
+ /B
+ <option_argument delimiter=" ">
+ file
+ <description>
+ <paragraph>
+ option -b, --bbbb, /B
+"""],
+["""\
+Multiple lines in descriptions, aligned:
+
+-a option -a, line 1
+ line 2
+-b file option -b, line 1
+ line 2
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Multiple lines in descriptions, aligned:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -a
+ <description>
+ <paragraph>
+ option -a, line 1
+ line 2
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -b
+ <option_argument delimiter=" ">
+ file
+ <description>
+ <paragraph>
+ option -b, line 1
+ line 2
+"""],
+["""\
+Multiple lines in descriptions, not aligned:
+
+-a option -a, line 1
+ line 2
+-b file option -b, line 1
+ line 2
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Multiple lines in descriptions, not aligned:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -a
+ <description>
+ <paragraph>
+ option -a, line 1
+ line 2
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -b
+ <option_argument delimiter=" ">
+ file
+ <description>
+ <paragraph>
+ option -b, line 1
+ line 2
+"""],
+["""\
+Descriptions begin on next line:
+
+-a
+ option -a, line 1
+ line 2
+-b file
+ option -b, line 1
+ line 2
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Descriptions begin on next line:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -a
+ <description>
+ <paragraph>
+ option -a, line 1
+ line 2
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -b
+ <option_argument delimiter=" ">
+ file
+ <description>
+ <paragraph>
+ option -b, line 1
+ line 2
+"""],
+["""\
+Multiple body elements in descriptions:
+
+-a option -a, para 1
+
+ para 2
+-b file
+ option -b, para 1
+
+ para 2
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Multiple body elements in descriptions:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -a
+ <description>
+ <paragraph>
+ option -a, para 1
+ <paragraph>
+ para 2
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -b
+ <option_argument delimiter=" ">
+ file
+ <description>
+ <paragraph>
+ option -b, para 1
+ <paragraph>
+ para 2
+"""],
+["""\
+--option
+empty item above, no blank line
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ --option
+ empty item above, no blank line
+"""],
+["""\
+An option list using equals:
+
+--long1=arg1 Description 1
+--long2=arg2 Description 2
+
+An option list using spaces:
+
+--long1 arg1 Description 1
+--long2 arg2 Description 2
+
+An option list using mixed delimiters:
+
+--long1=arg1 Description 1
+--long2 arg2 Description 2
+
+An option list using mixed delimiters in one line:
+
+--long1=arg1, --long2 arg2 Description
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ An option list using equals:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --long1
+ <option_argument delimiter="=">
+ arg1
+ <description>
+ <paragraph>
+ Description 1
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --long2
+ <option_argument delimiter="=">
+ arg2
+ <description>
+ <paragraph>
+ Description 2
+ <paragraph>
+ An option list using spaces:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --long1
+ <option_argument delimiter=" ">
+ arg1
+ <description>
+ <paragraph>
+ Description 1
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --long2
+ <option_argument delimiter=" ">
+ arg2
+ <description>
+ <paragraph>
+ Description 2
+ <paragraph>
+ An option list using mixed delimiters:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --long1
+ <option_argument delimiter="=">
+ arg1
+ <description>
+ <paragraph>
+ Description 1
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --long2
+ <option_argument delimiter=" ">
+ arg2
+ <description>
+ <paragraph>
+ Description 2
+ <paragraph>
+ An option list using mixed delimiters in one line:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --long1
+ <option_argument delimiter="=">
+ arg1
+ <option>
+ <option_string>
+ --long2
+ <option_argument delimiter=" ">
+ arg2
+ <description>
+ <paragraph>
+ Description
+"""],
+["""\
+Some edge cases:
+
+--option=arg arg too many arguments
+
+--option=arg,arg not supported (yet?)
+
+--option=arg=arg too many arguments
+
+--option arg arg too many arguments
+
+-a letter arg2 too many arguments
+
+/A letter arg2 too many arguments
+
+--option= argument missing
+
+--=argument option missing
+
+-- everything missing
+
+- this should be a bullet list item
+
+These next ones should be simple paragraphs:
+
+-1
+
+--option
+
+--1
+
+-1 and this one too.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Some edge cases:
+ <paragraph>
+ --option=arg arg too many arguments
+ <paragraph>
+ --option=arg,arg not supported (yet?)
+ <paragraph>
+ --option=arg=arg too many arguments
+ <paragraph>
+ --option arg arg too many arguments
+ <paragraph>
+ -a letter arg2 too many arguments
+ <paragraph>
+ /A letter arg2 too many arguments
+ <paragraph>
+ --option= argument missing
+ <paragraph>
+ --=argument option missing
+ <paragraph>
+ -- everything missing
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ this should be a bullet list item
+ <paragraph>
+ These next ones should be simple paragraphs:
+ <paragraph>
+ -1
+ <paragraph>
+ --option
+ <paragraph>
+ --1
+ <paragraph>
+ -1 and this one too.
+"""],
+["""\
+Complex optargs:
+
+--source-url=<URL> Use the supplied <URL> verbatim.
+--output-encoding=<name[:handler]>, -o<name[:handler]>
+ Specify the text encoding for output.
+-f <[path]filename> Send output to file.
+-d <src dest> Use diff from <src> to <dest>.
+--bogus=<x y z> Bogus 3D coordinates.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Complex optargs:
+ <option_list>
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --source-url
+ <option_argument delimiter="=">
+ <URL>
+ <description>
+ <paragraph>
+ Use the supplied <URL> verbatim.
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --output-encoding
+ <option_argument delimiter="=">
+ <name[:handler]>
+ <option>
+ <option_string>
+ -o
+ <option_argument delimiter="">
+ <name[:handler]>
+ <description>
+ <paragraph>
+ Specify the text encoding for output.
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -f
+ <option_argument delimiter=" ">
+ <[path]filename>
+ <description>
+ <paragraph>
+ Send output to file.
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ -d
+ <option_argument delimiter=" ">
+ <src dest>
+ <description>
+ <paragraph>
+ Use diff from <src> to <dest>.
+ <option_list_item>
+ <option_group>
+ <option>
+ <option_string>
+ --bogus
+ <option_argument delimiter="=">
+ <x y z>
+ <description>
+ <paragraph>
+ Bogus 3D coordinates.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_outdenting.py b/test/test_parsers/test_rst/test_outdenting.py
new file mode 100755
index 000000000..1522b7f30
--- /dev/null
+++ b/test/test_parsers/test_rst/test_outdenting.py
@@ -0,0 +1,90 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['outdenting'] = [
+["""\
+Anywhere a paragraph would have an effect on the current
+indentation level, a comment or list item should also.
+
++ bullet
+
+This paragraph ends the bullet list item before a block quote.
+
+ Block quote.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Anywhere a paragraph would have an effect on the current
+ indentation level, a comment or list item should also.
+ <bullet_list bullet="+">
+ <list_item>
+ <paragraph>
+ bullet
+ <paragraph>
+ This paragraph ends the bullet list item before a block quote.
+ <block_quote>
+ <paragraph>
+ Block quote.
+"""],
+["""\
++ bullet
+
+.. Comments swallow up all indented text following.
+
+ (Therefore this is not a) block quote.
+
+- bullet
+
+ If we want a block quote after this bullet list item,
+ we need to use an empty comment:
+
+..
+
+ Block quote.
+""",
+"""\
+<document source="test data">
+ <bullet_list bullet="+">
+ <list_item>
+ <paragraph>
+ bullet
+ <comment xml:space="preserve">
+ Comments swallow up all indented text following.
+ \n\
+ (Therefore this is not a) block quote.
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ bullet
+ <paragraph>
+ If we want a block quote after this bullet list item,
+ we need to use an empty comment:
+ <comment xml:space="preserve">
+ <block_quote>
+ <paragraph>
+ Block quote.
+"""],
+]
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_paragraphs.py b/test/test_parsers/test_rst/test_paragraphs.py
new file mode 100755
index 000000000..8ec8cbbc5
--- /dev/null
+++ b/test/test_parsers/test_rst/test_paragraphs.py
@@ -0,0 +1,89 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['paragraphs'] = [
+["""\
+A paragraph.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph.
+"""],
+["""\
+Paragraph 1.
+
+Paragraph 2.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph 1.
+ <paragraph>
+ Paragraph 2.
+"""],
+["""\
+Line 1.
+Line 2.
+Line 3.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Line 1.
+ Line 2.
+ Line 3.
+"""],
+["""\
+Paragraph 1, Line 1.
+Line 2.
+Line 3.
+
+Paragraph 2, Line 1.
+Line 2.
+Line 3.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph 1, Line 1.
+ Line 2.
+ Line 3.
+ <paragraph>
+ Paragraph 2, Line 1.
+ Line 2.
+ Line 3.
+"""],
+["""\
+A. Einstein was a really
+smart dude.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A. Einstein was a really
+ smart dude.
+"""],
+]
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_section_headers.py b/test/test_parsers/test_rst/test_section_headers.py
new file mode 100755
index 000000000..3c5a21170
--- /dev/null
+++ b/test/test_parsers/test_rst/test_section_headers.py
@@ -0,0 +1,897 @@
+#! /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 states.py."""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['section_headers'] = [
+["""\
+Title
+=====
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <section ids="title" names="title">
+ <title>
+ Title
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+Title
+=====
+Paragraph (no blank line).
+""",
+"""\
+<document source="test data">
+ <section ids="title" names="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.
+"""],
+["""\
+Test unexpected section titles.
+
+ Title
+ =====
+ Paragraph.
+
+ -----
+ Title
+ -----
+ Paragraph.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Test unexpected section titles.
+ <block_quote>
+ <system_message level="4" line="4" source="test data" type="SEVERE">
+ <paragraph>
+ Unexpected section title.
+ <literal_block xml:space="preserve">
+ Title
+ =====
+ <paragraph>
+ Paragraph.
+ <system_message level="4" line="7" source="test data" type="SEVERE">
+ <paragraph>
+ Unexpected section title or transition.
+ <literal_block xml:space="preserve">
+ -----
+ <system_message level="4" line="9" source="test data" type="SEVERE">
+ <paragraph>
+ Unexpected section title.
+ <literal_block xml:space="preserve">
+ Title
+ -----
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+Title
+====
+
+Test short underline.
+""",
+"""\
+<document source="test data">
+ <section ids="title" names="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.
+"""],
+["""\
+=====
+Title
+=====
+
+Test overline title.
+""",
+"""\
+<document source="test data">
+ <section ids="title" names="title">
+ <title>
+ Title
+ <paragraph>
+ Test overline title.
+"""],
+["""\
+=======
+ Title
+=======
+
+Test overline title with inset.
+""",
+"""\
+<document source="test data">
+ <section ids="title" names="title">
+ <title>
+ Title
+ <paragraph>
+ Test overline title with inset.
+"""],
+["""\
+========================
+ Test Missing Underline
+""",
+"""\
+<document source="test data">
+ <system_message level="4" line="1" source="test data" type="SEVERE">
+ <paragraph>
+ Incomplete section title.
+ <literal_block xml:space="preserve">
+ ========================
+ Test Missing Underline
+"""],
+["""\
+========================
+ Test Missing Underline
+
+""",
+"""\
+<document source="test data">
+ <system_message level="4" line="1" source="test data" type="SEVERE">
+ <paragraph>
+ Missing matching underline for section title overline.
+ <literal_block xml:space="preserve">
+ ========================
+ Test Missing Underline
+"""],
+["""\
+=======
+ Title
+
+Test missing underline, with paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="4" line="1" source="test data" type="SEVERE">
+ <paragraph>
+ Missing matching underline for section title overline.
+ <literal_block xml:space="preserve">
+ =======
+ Title
+ <paragraph>
+ Test missing underline, with paragraph.
+"""],
+["""\
+=======
+ Long Title
+=======
+
+Test long title and space normalization.
+""",
+"""\
+<document source="test data">
+ <section ids="long-title" names="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.
+"""],
+["""\
+=======
+ Title
+-------
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <system_message level="4" line="1" source="test data" type="SEVERE">
+ <paragraph>
+ Title overline & underline mismatch.
+ <literal_block xml:space="preserve">
+ =======
+ Title
+ -------
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+========================
+
+========================
+
+Test missing titles; blank line in-between.
+
+========================
+
+========================
+""",
+"""\
+<document source="test data">
+ <transition>
+ <transition>
+ <paragraph>
+ Test missing titles; blank line in-between.
+ <transition>
+ <transition>
+"""],
+["""\
+========================
+========================
+
+Test missing titles; nothing in-between.
+
+========================
+========================
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Invalid section title or transition marker.
+ <literal_block xml:space="preserve">
+ ========================
+ ========================
+ <paragraph>
+ Test missing titles; nothing in-between.
+ <system_message level="3" line="6" source="test data" type="ERROR">
+ <paragraph>
+ Invalid section title or transition marker.
+ <literal_block xml:space="preserve">
+ ========================
+ ========================
+"""],
+["""\
+.. Test return to existing, highest-level section (Title 3).
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+=======
+Paragraph 3.
+
+Title 4
+-------
+Paragraph 4.
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ Test return to existing, highest-level section (Title 3).
+ <section ids="title-1" names="title\ 1">
+ <title>
+ Title 1
+ <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.
+ <section ids="title-4" names="title\ 4">
+ <title>
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+Test return to existing, highest-level section (Title 3, with overlines).
+
+=======
+Title 1
+=======
+Paragraph 1.
+
+-------
+Title 2
+-------
+Paragraph 2.
+
+=======
+Title 3
+=======
+Paragraph 3.
+
+-------
+Title 4
+-------
+Paragraph 4.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Test return to existing, highest-level section (Title 3, with overlines).
+ <section ids="title-1" names="title\ 1">
+ <title>
+ Title 1
+ <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.
+ <section ids="title-4" names="title\ 4">
+ <title>
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+Test return to existing, higher-level section (Title 4).
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+```````
+Paragraph 3.
+
+Title 4
+-------
+Paragraph 4.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Test return to existing, higher-level section (Title 4).
+ <section ids="title-1" names="title\ 1">
+ <title>
+ Title 1
+ <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.
+ <section ids="title-4" names="title\ 4">
+ <title>
+ Title 4
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+Test bad subsection order (Title 4).
+
+Title 1
+=======
+Paragraph 1.
+
+Title 2
+-------
+Paragraph 2.
+
+Title 3
+=======
+Paragraph 3.
+
+Title 4
+```````
+Paragraph 4.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Test bad subsection order (Title 4).
+ <section ids="title-1" names="title\ 1">
+ <title>
+ Title 1
+ <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.
+ <system_message level="4" line="15" source="test data" type="SEVERE">
+ <paragraph>
+ Title level inconsistent:
+ <literal_block xml:space="preserve">
+ Title 4
+ ```````
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+Test bad subsection order (Title 4, with overlines).
+
+=======
+Title 1
+=======
+Paragraph 1.
+
+-------
+Title 2
+-------
+Paragraph 2.
+
+=======
+Title 3
+=======
+Paragraph 3.
+
+```````
+Title 4
+```````
+Paragraph 4.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Test bad subsection order (Title 4, with overlines).
+ <section ids="title-1" names="title\ 1">
+ <title>
+ Title 1
+ <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.
+ <system_message level="4" line="19" source="test data" type="SEVERE">
+ <paragraph>
+ Title level inconsistent:
+ <literal_block xml:space="preserve">
+ ```````
+ Title 4
+ ```````
+ <paragraph>
+ Paragraph 4.
+"""],
+["""\
+Title containing *inline* ``markup``
+====================================
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <section ids="title-containing-inline-markup" names="title\ containing\ inline\ markup">
+ <title>
+ Title containing \n\
+ <emphasis>
+ inline
+ \n\
+ <literal>
+ markup
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+1. Numbered Title
+=================
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <section ids="numbered-title" names="1.\ numbered\ title">
+ <title>
+ 1. Numbered Title
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+1. Item 1.
+2. Item 2.
+3. Numbered Title
+=================
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <enumerated_list enumtype="arabic" prefix="" suffix=".">
+ <list_item>
+ <paragraph>
+ Item 1.
+ <list_item>
+ <paragraph>
+ Item 2.
+ <system_message level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Enumerated list ends without a blank line; unexpected unindent.
+ <section ids="numbered-title" names="3.\ numbered\ title">
+ <title>
+ 3. Numbered Title
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+ABC
+===
+
+Short title.
+""",
+"""\
+<document source="test data">
+ <section ids="abc" names="abc">
+ <title>
+ ABC
+ <paragraph>
+ Short title.
+"""],
+["""\
+ABC
+==
+
+Underline too short.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="2" source="test data" type="INFO">
+ <paragraph>
+ Possible title underline, too short for the title.
+ Treating it as ordinary text because it's so short.
+ <paragraph>
+ ABC
+ ==
+ <paragraph>
+ Underline too short.
+"""],
+["""\
+==
+ABC
+==
+
+Over & underline too short.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Possible incomplete section title.
+ Treating the overline as ordinary text because it's so short.
+ <paragraph>
+ ==
+ ABC
+ ==
+ <paragraph>
+ Over & underline too short.
+"""],
+["""\
+==
+ABC
+
+Overline too short, no underline.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Possible incomplete section title.
+ Treating the overline as ordinary text because it's so short.
+ <paragraph>
+ ==
+ ABC
+ <paragraph>
+ Overline too short, no underline.
+"""],
+["""\
+==
+ABC
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Possible incomplete section title.
+ Treating the overline as ordinary text because it's so short.
+ <paragraph>
+ ==
+ ABC
+"""],
+["""\
+==
+ Not a title: a definition list item.
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Possible incomplete section title.
+ Treating the overline as ordinary text because it's so short.
+ <definition_list>
+ <definition_list_item>
+ <term>
+ ==
+ <definition>
+ <paragraph>
+ Not a title: a definition list item.
+"""],
+["""\
+==
+ Not a title: a definition list item.
+--
+ Another definition list item. It's in a different list,
+ but that's an acceptable limitation given that this will
+ probably never happen in real life.
+
+ The next line will trigger a warning:
+==
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Possible incomplete section title.
+ Treating the overline as ordinary text because it's so short.
+ <definition_list>
+ <definition_list_item>
+ <term>
+ ==
+ <definition>
+ <paragraph>
+ Not a title: a definition list item.
+ <system_message level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ Definition list ends without a blank line; unexpected unindent.
+ <system_message level="1" line="3" source="test data" type="INFO">
+ <paragraph>
+ Possible incomplete section title.
+ Treating the overline as ordinary text because it's so short.
+ <definition_list>
+ <definition_list_item>
+ <term>
+ --
+ <definition>
+ <paragraph>
+ Another definition list item. It's in a different list,
+ but that's an acceptable limitation given that this will
+ probably never happen in real life.
+ <paragraph>
+ The next line will trigger a warning:
+ <system_message level="2" line="9" source="test data" type="WARNING">
+ <paragraph>
+ Definition list ends without a blank line; unexpected unindent.
+ <paragraph>
+ ==
+"""],
+["""\
+Paragraph
+
+ ==
+ ABC
+ ==
+
+ Over & underline too short.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph
+ <block_quote>
+ <system_message level="1" line="3" source="test data" type="INFO">
+ <paragraph>
+ Unexpected possible title overline or transition.
+ Treating it as ordinary text because it's so short.
+ <paragraph>
+ ==
+ ABC
+ ==
+ <paragraph>
+ Over & underline too short.
+"""],
+["""\
+Paragraph
+
+ ABC
+ ==
+
+ Underline too short.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Paragraph
+ <block_quote>
+ <paragraph>
+ ABC
+ ==
+ <paragraph>
+ Underline too short.
+"""],
+["""\
+...
+...
+
+...
+---
+
+...
+...
+...
+""",
+"""\
+<document source="test data">
+ <system_message level="1" line="1" source="test data" type="INFO">
+ <paragraph>
+ Possible incomplete section title.
+ Treating the overline as ordinary text because it's so short.
+ <section dupnames="..." ids="id1">
+ <title>
+ ...
+ <system_message level="1" line="4" source="test data" type="INFO">
+ <paragraph>
+ Possible incomplete section title.
+ Treating the overline as ordinary text because it's so short.
+ <section dupnames="..." ids="id2">
+ <title>
+ ...
+ <system_message backrefs="id2" level="1" line="5" source="test data" type="INFO">
+ <paragraph>
+ Duplicate implicit target name: "...".
+ <system_message level="1" line="7" source="test data" type="INFO">
+ <paragraph>
+ Possible incomplete section title.
+ Treating the overline as ordinary text because it's so short.
+ <system_message level="1" line="7" source="test data" type="INFO">
+ <paragraph>
+ Possible incomplete section title.
+ Treating the overline as ordinary text because it's so short.
+ <section dupnames="..." ids="id3">
+ <title>
+ ...
+ <system_message backrefs="id3" level="1" line="8" source="test data" type="INFO">
+ <paragraph>
+ Duplicate implicit target name: "...".
+ <paragraph>
+ ...
+"""],
+["""\
+..
+Hi
+..
+
+...
+Yo
+...
+
+Ho
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ <system_message level="2" line="2" source="test data" type="WARNING">
+ <paragraph>
+ Explicit markup ends without a blank line; unexpected unindent.
+ <section ids="hi" names="hi">
+ <title>
+ Hi
+ <section ids="yo" names="yo">
+ <title>
+ Yo
+ <paragraph>
+ Ho
+"""],
+["""\
+Empty Section
+=============
+""",
+"""\
+<document source="test data">
+ <section ids="empty-section" names="empty\ section">
+ <title>
+ Empty Section
+"""],
+["""\
+===
+One
+===
+
+The bubble-up parser strategy conflicts with short titles
+(<= 3 char-long over- & underlines).
+
+===
+Two
+===
+
+The parser currently contains a work-around kludge.
+Without it, the parser ends up in an infinite loop.
+""",
+"""\
+<document source="test data">
+ <section ids="one" names="one">
+ <title>
+ One
+ <paragraph>
+ The bubble-up parser strategy conflicts with short titles
+ (<= 3 char-long over- & underlines).
+ <section ids="two" names="two">
+ <title>
+ Two
+ <paragraph>
+ The parser currently contains a work-around kludge.
+ Without it, the parser ends up in an infinite loop.
+"""],
+["""\
+""",
+"""\
+<document source="test data">
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_substitutions.py b/test/test_parsers/test_rst/test_substitutions.py
new file mode 100755
index 000000000..fb8af4c2d
--- /dev/null
+++ b/test/test_parsers/test_rst/test_substitutions.py
@@ -0,0 +1,298 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['substitution_definitions'] = [
+["""\
+Here's an image substitution definition:
+
+.. |symbol| image:: symbol.png
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Here's an image substitution definition:
+ <substitution_definition names="symbol">
+ <image alt="symbol" uri="symbol.png">
+"""],
+["""\
+Embedded directive starts on the next line:
+
+.. |symbol|
+ image:: symbol.png
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Embedded directive starts on the next line:
+ <substitution_definition names="symbol">
+ <image alt="symbol" uri="symbol.png">
+"""],
+["""\
+Trailing spaces should not be significant:
+
+.. |symbol| image:: \n\
+ symbol.png
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Trailing spaces should not be significant:
+ <substitution_definition names="symbol">
+ <image alt="symbol" uri="symbol.png">
+"""],
+["""\
+Here's a series of substitution definitions:
+
+.. |symbol 1| image:: symbol1.png
+.. |SYMBOL 2| image:: symbol2.png
+ :height: 50
+ :width: 100
+.. |symbol 3| image:: symbol3.png
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Here's a series of substitution definitions:
+ <substitution_definition names="symbol\ 1">
+ <image alt="symbol 1" uri="symbol1.png">
+ <substitution_definition names="SYMBOL\ 2">
+ <image alt="SYMBOL 2" height="50" uri="symbol2.png" width="100">
+ <substitution_definition names="symbol\ 3">
+ <image alt="symbol 3" uri="symbol3.png">
+"""],
+["""\
+.. |very long substitution text,
+ split across lines| image:: symbol.png
+""",
+"""\
+<document source="test data">
+ <substitution_definition names="very\ long\ substitution\ text,\ split\ across\ lines">
+ <image alt="very long substitution text, split across lines" uri="symbol.png">
+"""],
+["""\
+.. |symbol 1| image:: symbol.png
+
+ Followed by a block quote.
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Error in "image" directive:
+ no content permitted.
+ <literal_block xml:space="preserve">
+ image:: symbol.png
+ \n\
+ Followed by a block quote.
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "symbol 1" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |symbol 1| image:: symbol.png
+ \n\
+ Followed by a block quote.
+"""],
+["""\
+.. |symbol 1| image:: symbol.png
+
+Followed by a paragraph.
+
+.. |symbol 2| image:: symbol.png
+
+..
+
+ Followed by a block quote.
+""",
+"""\
+<document source="test data">
+ <substitution_definition names="symbol\ 1">
+ <image alt="symbol 1" uri="symbol.png">
+ <paragraph>
+ Followed by a paragraph.
+ <substitution_definition names="symbol\ 2">
+ <image alt="symbol 2" uri="symbol.png">
+ <comment xml:space="preserve">
+ <block_quote>
+ <paragraph>
+ Followed by a block quote.
+"""],
+[u"""\
+Substitutions support case differences:
+
+.. |eacute| replace:: \u00E9
+.. |Eacute| replace:: \u00C9
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Substitutions support case differences:
+ <substitution_definition names="eacute">
+ \u00E9
+ <substitution_definition names="Eacute">
+ \u00C9
+"""],
+["""\
+Raw substitution, backslashes should be preserved:
+
+.. |alpha| raw:: latex
+
+ $\\\\alpha$
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Raw substitution, backslashes should be preserved:
+ <substitution_definition names="alpha">
+ <raw format="latex" xml:space="preserve">
+ $\\\\alpha$
+"""],
+["""\
+Here are some duplicate substitution definitions:
+
+.. |symbol| image:: symbol.png
+.. |symbol| image:: symbol.png
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Here are some duplicate substitution definitions:
+ <substitution_definition dupnames="symbol">
+ <image alt="symbol" uri="symbol.png">
+ <system_message level="3" line="4" source="test data" type="ERROR">
+ <paragraph>
+ Duplicate substitution definition name: "symbol".
+ <substitution_definition names="symbol">
+ <image alt="symbol" uri="symbol.png">
+"""],
+["""\
+Here are some bad cases:
+
+.. |symbol| image:: symbol.png
+No blank line after.
+
+.. |empty|
+
+.. |unknown| directive:: symbol.png
+
+.. |invalid 1| there's no directive here
+.. |invalid 2| there's no directive here
+ With some block quote text, line 1.
+ And some more, line 2.
+
+.. |invalid 3| there's no directive here
+
+.. | bad name | bad data
+
+.. |
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Here are some bad cases:
+ <substitution_definition names="symbol">
+ <image alt="symbol" uri="symbol.png">
+ <system_message level="2" line="4" source="test data" type="WARNING">
+ <paragraph>
+ Explicit markup ends without a blank line; unexpected unindent.
+ <paragraph>
+ No blank line after.
+ <system_message level="2" line="6" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "empty" missing contents.
+ <literal_block xml:space="preserve">
+ .. |empty|
+ <system_message level="1" line="8" source="test data" type="INFO">
+ <paragraph>
+ No directive entry for "directive" in module "docutils.parsers.rst.languages.en".
+ Trying "directive" as canonical directive name.
+ <system_message level="3" line="8" source="test data" type="ERROR">
+ <paragraph>
+ Unknown directive type "directive".
+ <literal_block xml:space="preserve">
+ directive:: symbol.png
+ <system_message level="2" line="8" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "unknown" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |unknown| directive:: symbol.png
+ <system_message level="2" line="10" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "invalid 1" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |invalid 1| there's no directive here
+ <system_message level="2" line="11" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "invalid 2" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |invalid 2| there's no directive here
+ With some block quote text, line 1.
+ And some more, line 2.
+ <system_message level="2" line="15" source="test data" type="WARNING">
+ <paragraph>
+ Substitution definition "invalid 3" empty or invalid.
+ <literal_block xml:space="preserve">
+ .. |invalid 3| there's no directive here
+ <comment xml:space="preserve">
+ | bad name | bad data
+ <comment xml:space="preserve">
+ |
+"""],
+["""\
+Elements that are prohibited inside of substitution definitions:
+
+.. |target| replace:: _`target`
+.. |reference| replace:: anonymous__
+.. |auto-numbered footnote| replace:: [#]_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Elements that are prohibited inside of substitution definitions:
+ <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`
+ <system_message level="3" line="4" 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">
+ .. |reference| replace:: anonymous__
+ <system_message level="3" line="5" source="test data" type="ERROR">
+ <paragraph>
+ Substitution definition contains illegal element:
+ <literal_block xml:space="preserve">
+ <footnote_reference auto="1" ids="id1">
+ <literal_block xml:space="preserve">
+ .. |auto-numbered footnote| replace:: [#]_
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_tables.py b/test/test_parsers/test_rst/test_tables.py
new file mode 100755
index 000000000..81c423bc4
--- /dev/null
+++ b/test/test_parsers/test_rst/test_tables.py
@@ -0,0 +1,1261 @@
+#! /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 states.py.
+"""
+
+import os
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+mydir = 'test_parsers/test_rst/'
+include2 = os.path.join(mydir, 'test_directives/include2.txt')
+
+totest = {}
+
+totest['grid_tables'] = [
+["""\
++-------------------------------------+
+| A table with one cell and one line. |
++-------------------------------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="1">
+ <colspec colwidth="37">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with one cell and one line.
+"""],
+["""\
++-----------------------+
+| A table with one cell |
+| and two lines. |
++-----------------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="1">
+ <colspec colwidth="23">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with one cell
+ and two lines.
+"""],
+["""\
++-----------------------+
+| A malformed table. |
++-----------------------+
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Malformed table.
+ <literal_block xml:space="preserve">
+ +-----------------------+
+ | A malformed table. |
+ +-----------------------+
+"""],
+["""\
++------------------------+
+| A well-formed | table. |
++------------------------+
+
++------------------------+
+| This +----------+ too! |
++------------------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="1">
+ <colspec colwidth="24">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A well-formed | table.
+ <table>
+ <tgroup cols="1">
+ <colspec colwidth="24">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ This +----------+ too!
+"""],
+["""\
++--------------+--------------+
+| A table with | two columns. |
++--------------+--------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="14">
+ <colspec colwidth="14">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with
+ <entry>
+ <paragraph>
+ two columns.
+"""],
+["""\
++--------------+
+| A table with |
++--------------+
+| two rows. |
++--------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="1">
+ <colspec colwidth="14">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with
+ <row>
+ <entry>
+ <paragraph>
+ two rows.
+"""],
+["""\
++--------------+-------------+
+| A table with | two columns |
++--------------+-------------+
+| and | two rows. |
++--------------+-------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="14">
+ <colspec colwidth="13">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with
+ <entry>
+ <paragraph>
+ two columns
+ <row>
+ <entry>
+ <paragraph>
+ and
+ <entry>
+ <paragraph>
+ two rows.
+"""],
+["""\
++--------------+---------------+
+| A table with | two columns, |
++--------------+---------------+
+| two rows, and a column span. |
++------------------------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="14">
+ <colspec colwidth="15">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with
+ <entry>
+ <paragraph>
+ two columns,
+ <row>
+ <entry morecols="1">
+ <paragraph>
+ two rows, and a column span.
+"""],
+["""\
++--------------------------+
+| A table with three rows, |
++------------+-------------+
+| and two | columns. |
++------------+-------------+
+| First and last rows |
+| contains column spans. |
++--------------------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="12">
+ <colspec colwidth="13">
+ <tbody>
+ <row>
+ <entry morecols="1">
+ <paragraph>
+ A table with three rows,
+ <row>
+ <entry>
+ <paragraph>
+ and two
+ <entry>
+ <paragraph>
+ columns.
+ <row>
+ <entry morecols="1">
+ <paragraph>
+ First and last rows
+ contains column spans.
+"""],
+["""\
++--------------+--------------+
+| A table with | two columns, |
++--------------+ and a row |
+| two rows, | span. |
++--------------+--------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="14">
+ <colspec colwidth="14">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with
+ <entry morerows="1">
+ <paragraph>
+ two columns,
+ and a row
+ span.
+ <row>
+ <entry>
+ <paragraph>
+ two rows,
+"""],
+["""\
++------------+-------------+---------------+
+| A table | two rows in | and row spans |
+| with three +-------------+ to left and |
+| columns, | the middle, | right. |
++------------+-------------+---------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="3">
+ <colspec colwidth="12">
+ <colspec colwidth="13">
+ <colspec colwidth="15">
+ <tbody>
+ <row>
+ <entry morerows="1">
+ <paragraph>
+ A table
+ with three
+ columns,
+ <entry>
+ <paragraph>
+ two rows in
+ <entry morerows="1">
+ <paragraph>
+ and row spans
+ to left and
+ right.
+ <row>
+ <entry>
+ <paragraph>
+ the middle,
+"""],
+["""\
+Complex spanning pattern (no edge knows all rows/cols):
+
++-----------+-------------------------+
+| W/NW cell | N/NE cell |
+| +-------------+-----------+
+| | Middle cell | E/SE cell |
++-----------+-------------+ |
+| S/SE cell | |
++-------------------------+-----------+
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Complex spanning pattern (no edge knows all rows/cols):
+ <table>
+ <tgroup cols="3">
+ <colspec colwidth="11">
+ <colspec colwidth="13">
+ <colspec colwidth="11">
+ <tbody>
+ <row>
+ <entry morerows="1">
+ <paragraph>
+ W/NW cell
+ <entry morecols="1">
+ <paragraph>
+ N/NE cell
+ <row>
+ <entry>
+ <paragraph>
+ Middle cell
+ <entry morerows="1">
+ <paragraph>
+ E/SE cell
+ <row>
+ <entry morecols="1">
+ <paragraph>
+ S/SE cell
+"""],
+["""\
++------------------------+------------+----------+----------+
+| Header row, column 1 | Header 2 | Header 3 | Header 4 |
++========================+============+==========+==========+
+| body row 1, column 1 | column 2 | column 3 | column 4 |
++------------------------+------------+----------+----------+
+| body row 2 | Cells may span columns. |
++------------------------+------------+---------------------+
+| body row 3 | Cells may | - Table cells |
++------------------------+ span rows. | - contain |
+| body row 4 | | - body elements. |
++------------------------+------------+---------------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="4">
+ <colspec colwidth="24">
+ <colspec colwidth="12">
+ <colspec colwidth="10">
+ <colspec colwidth="10">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ Header row, column 1
+ <entry>
+ <paragraph>
+ Header 2
+ <entry>
+ <paragraph>
+ Header 3
+ <entry>
+ <paragraph>
+ Header 4
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ body row 1, column 1
+ <entry>
+ <paragraph>
+ column 2
+ <entry>
+ <paragraph>
+ column 3
+ <entry>
+ <paragraph>
+ column 4
+ <row>
+ <entry>
+ <paragraph>
+ body row 2
+ <entry morecols="2">
+ <paragraph>
+ Cells may span columns.
+ <row>
+ <entry>
+ <paragraph>
+ body row 3
+ <entry morerows="1">
+ <paragraph>
+ Cells may
+ span rows.
+ <entry morecols="1" morerows="1">
+ <bullet_list bullet="-">
+ <list_item>
+ <paragraph>
+ Table cells
+ <list_item>
+ <paragraph>
+ contain
+ <list_item>
+ <paragraph>
+ body elements.
+ <row>
+ <entry>
+ <paragraph>
+ body row 4
+"""],
+["""\
++-----------------+--------+
+| A simple table | cell 2 |
++-----------------+--------+
+| cell 3 | cell 4 |
++-----------------+--------+
+No blank line after table.
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="17">
+ <colspec colwidth="8">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A simple table
+ <entry>
+ <paragraph>
+ cell 2
+ <row>
+ <entry>
+ <paragraph>
+ cell 3
+ <entry>
+ <paragraph>
+ cell 4
+ <system_message level="2" line="6" source="test data" type="WARNING">
+ <paragraph>
+ Blank line required after table.
+ <paragraph>
+ No blank line after table.
+"""],
+["""\
++-----------------+--------+
+| A simple table | cell 2 |
++-----------------+--------+
+| cell 3 | cell 4 |
++-----------------+--------+
+ Unexpected indent and no blank line after table.
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="17">
+ <colspec colwidth="8">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A simple table
+ <entry>
+ <paragraph>
+ cell 2
+ <row>
+ <entry>
+ <paragraph>
+ cell 3
+ <entry>
+ <paragraph>
+ cell 4
+ <system_message level="3" line="6" source="test data" type="ERROR">
+ <paragraph>
+ Unexpected indentation.
+ <system_message level="2" line="6" source="test data" type="WARNING">
+ <paragraph>
+ Blank line required after table.
+ <block_quote>
+ <paragraph>
+ Unexpected indent and no blank line after table.
+"""],
+["""\
++--------------+-------------+
+| A bad table. | |
++--------------+ |
+| Cells must be rectangles. |
++----------------------------+
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Malformed table.
+ Malformed table; parse incomplete.
+ <literal_block xml:space="preserve">
+ +--------------+-------------+
+ | A bad table. | |
+ +--------------+ |
+ | Cells must be rectangles. |
+ +----------------------------+
+"""],
+["""\
++------------------------------+
+| This table contains another. |
+| |
+| +-------------------------+ |
+| | A table within a table. | |
+| +-------------------------+ |
++------------------------------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="1">
+ <colspec colwidth="30">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ This table contains another.
+ <table>
+ <tgroup cols="1">
+ <colspec colwidth="25">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table within a table.
+"""],
+["""\
++------------------+--------+
+| A simple table | |
++------------------+--------+
+| with empty cells | |
++------------------+--------+
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="18">
+ <colspec colwidth="8">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A simple table
+ <entry>
+ <row>
+ <entry>
+ <paragraph>
+ with empty cells
+ <entry>
+"""],
+[("""\
++------------------------------------------------------------------------------+
+| .. include:: |
+%s
++------------------------------------------------------------------------------+
+| (The first cell of this table may expand |
+| to accommodate long filesystem paths.) |
++------------------------------------------------------------------------------+
+""") % ('\n'.join(['| %-70s |' % include2[part * 70 : (part + 1) * 70]
+ for part in range(len(include2) / 70 + 1)])),
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="1">
+ <colspec colwidth="78">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Here are some paragraphs
+ that can appear at any level.
+ <paragraph>
+ This file (include2.txt) is used by
+ <literal>
+ test_include.py
+ .
+ <row>
+ <entry>
+ <paragraph>
+ (The first cell of this table may expand
+ to accommodate long filesystem paths.)
+"""],
+[("""\
+Something before.
+
++------------------------------------------------------------------------------+
+| .. include:: |
+%s
++------------------------------------------------------------------------------+
+
+Something afterwards.
+
+And more.
+""") % ('\n'.join(['| %-70s |' % include2[part * 70 : (part + 1) * 70]
+ for part in range(len(include2) / 70 + 1)])),
+"""\
+<document source="test data">
+ <paragraph>
+ Something before.
+ <table>
+ <tgroup cols="1">
+ <colspec colwidth="78">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Here are some paragraphs
+ that can appear at any level.
+ <paragraph>
+ This file (include2.txt) is used by
+ <literal>
+ test_include.py
+ .
+ <paragraph>
+ Something afterwards.
+ <paragraph>
+ And more.
+"""],
+]
+
+totest['simple_tables'] = [
+["""\
+============ ============
+A table with two columns.
+============ ============
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="12">
+ <colspec colwidth="12">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with
+ <entry>
+ <paragraph>
+ two columns.
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+============ ============
+A table with two columns
+and two rows.
+============ ============
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="12">
+ <colspec colwidth="12">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with
+ <entry>
+ <paragraph>
+ two columns
+ <row>
+ <entry>
+ <paragraph>
+ and
+ <entry>
+ <paragraph>
+ two rows.
+"""],
+["""\
+============ ==============
+A table with two columns,
+two rows, and a column span.
+============================
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="12">
+ <colspec colwidth="14">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with
+ <entry>
+ <paragraph>
+ two columns,
+ <row>
+ <entry morecols="1">
+ <paragraph>
+ two rows, and a column span.
+"""],
+["""\
+== =========== ===========
+1 A table with three rows,
+-- ------------------------
+2 and three columns.
+3 First and third rows
+ contain column spans.
+
+ This row is a multi-line row, and overflows to the right.
+-- ------------------------
+4 One last row.
+== =========== ===========
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="3">
+ <colspec colwidth="2">
+ <colspec colwidth="11">
+ <colspec colwidth="44">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ 1
+ <entry morecols="1">
+ <paragraph>
+ A table with three rows,
+ <row>
+ <entry>
+ <paragraph>
+ 2
+ <entry>
+ <paragraph>
+ and three
+ <entry>
+ <paragraph>
+ columns.
+ <row>
+ <entry>
+ <paragraph>
+ 3
+ <entry morecols="1">
+ <paragraph>
+ First and third rows
+ contain column spans.
+ <paragraph>
+ This row is a multi-line row, and overflows to the right.
+ <row>
+ <entry>
+ <paragraph>
+ 4
+ <entry>
+ <paragraph>
+ One last
+ <entry>
+ <paragraph>
+ row.
+"""],
+["""\
+======= ========= ========
+A table with three columns.
+================== ========
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="3">
+ <colspec colwidth="7">
+ <colspec colwidth="9">
+ <colspec colwidth="8">
+ <tbody>
+ <row>
+ <entry morecols="1">
+ <paragraph>
+ A table with three
+ <entry>
+ <paragraph>
+ columns.
+"""],
+["""\
+============== ======
+A simple table with
+no bottom border
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Malformed table.
+ No bottom table border found.
+ <literal_block xml:space="preserve">
+ ============== ======
+ A simple table with
+ no bottom border
+"""],
+["""\
+============== ======
+A simple table cell 2
+cell 3 cell 4
+============== ======
+No blank line after table.
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Malformed table.
+ No bottom table border found or no blank line after table bottom.
+ <literal_block xml:space="preserve">
+ ============== ======
+ A simple table cell 2
+ cell 3 cell 4
+ ============== ======
+ <system_message level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Blank line required after table.
+ <paragraph>
+ No blank line after table.
+"""],
+["""\
+============== ======
+A simple table cell 2
+============== ======
+cell 3 cell 4
+============== ======
+No blank line after table.
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="14">
+ <colspec colwidth="6">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ A simple table
+ <entry>
+ <paragraph>
+ cell 2
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ cell 3
+ <entry>
+ <paragraph>
+ cell 4
+ <system_message level="2" line="6" source="test data" type="WARNING">
+ <paragraph>
+ Blank line required after table.
+ <paragraph>
+ No blank line after table.
+"""],
+["""\
+============== ======
+A simple table cell 2
+cell 3 cell 4
+============== ======
+ Unexpected indent and no blank line after table.
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Malformed table.
+ No bottom table border found or no blank line after table bottom.
+ <literal_block xml:space="preserve">
+ ============== ======
+ A simple table cell 2
+ cell 3 cell 4
+ ============== ======
+ <system_message level="2" line="5" source="test data" type="WARNING">
+ <paragraph>
+ Blank line required after table.
+ <block_quote>
+ <paragraph>
+ Unexpected indent and no blank line after table.
+"""],
+["""\
+============== ======
+A bad table cell 2
+cell 3 cell 4
+============ ========
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Malformed table.
+ Column span alignment problem at line offset 3.
+ <literal_block xml:space="preserve">
+ ============== ======
+ A bad table cell 2
+ cell 3 cell 4
+ ============ ========
+"""],
+["""\
+======== =========
+A bad table cell 2
+cell 3 cell 4
+======== =========
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Malformed table.
+ Text in column margin at line offset 1.
+ <literal_block xml:space="preserve">
+ ======== =========
+ A bad table cell 2
+ cell 3 cell 4
+ ======== =========
+"""],
+["""\
+== ============================
+1 This table contains another.
+2 ======= ====== ========
+ A table within a table.
+ ======= ====== ========
+
+ The outer table does have to
+ have at least two columns
+ though.
+== ============================
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="2">
+ <colspec colwidth="28">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ 1
+ <entry>
+ <paragraph>
+ This table contains another.
+ <row>
+ <entry>
+ <paragraph>
+ 2
+ <entry>
+ <table>
+ <tgroup cols="3">
+ <colspec colwidth="7">
+ <colspec colwidth="6">
+ <colspec colwidth="8">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table
+ <entry>
+ <paragraph>
+ within
+ <entry>
+ <paragraph>
+ a table.
+ <paragraph>
+ The outer table does have to
+ have at least two columns
+ though.
+"""],
+["""\
+================ ======
+A simple table
+with empty cells
+================ ======
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="16">
+ <colspec colwidth="6">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A simple table
+ <entry>
+ <row>
+ <entry>
+ <paragraph>
+ with empty cells
+ <entry>
+"""],
+["""\
+============== ========
+ A table with
+============== ========
+ centered cells.
+
+============== ========
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="14">
+ <colspec colwidth="8">
+ <thead>
+ <row>
+ <entry>
+ <paragraph>
+ A table
+ <entry>
+ <paragraph>
+ with
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ centered
+ <entry>
+ <paragraph>
+ cells.
+"""],
+["""\
+============== ======
+A simple table this text extends to the right
+cell 3 the bottom border below is too long
+============== ========
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Malformed table.
+ Bottom/header table border does not match top border.
+ <literal_block xml:space="preserve">
+ ============== ======
+ A simple table this text extends to the right
+ cell 3 the bottom border below is too long
+ ============== ========
+"""],
+["""\
+============ =================
+A table with row separators.
+------------ -----------------
+
+Blank line before.
+------------ -----------------
+
+Blank lines before and after.
+
+------------ -----------------
+Blank line after.
+
+============ =================
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="12">
+ <colspec colwidth="17">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with
+ <entry>
+ <paragraph>
+ row separators.
+ <row>
+ <entry>
+ <paragraph>
+ Blank line
+ <entry>
+ <paragraph>
+ before.
+ <row>
+ <entry>
+ <paragraph>
+ Blank lines
+ <entry>
+ <paragraph>
+ before and after.
+ <row>
+ <entry>
+ <paragraph>
+ Blank line
+ <entry>
+ <paragraph>
+ after.
+"""],
+["""\
+============ ====================
+A table with many row separators.
+------------ --------------------
+------------ --------------------
+
+------------ --------------------
+============ ====================
+""",
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="12">
+ <colspec colwidth="20">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ A table with
+ <entry>
+ <paragraph>
+ many row separators.
+ <row>
+ <entry>
+ <entry>
+ <row>
+ <entry>
+ <entry>
+ <row>
+ <entry>
+ <entry>
+"""],
+["""\
+== =========== ===========
+1 Span columns 2 & 3
+-- ------------------------
+2 Span columns 2 & 3
+ ------------------------
+3
+== =========== ===========
+
+== =========== ===========
+1 Span cols 1&2 but not 3
+--------------- -----------
+2 Span cols 1&2 but not 3
+---------------
+3 no spans here
+== =========== ===========
+
+== =========== ===========
+1 Not a span Not a span
+ ----------- -----------
+2
+== =========== ===========
+""",
+"""\
+<document source="test data">
+ <system_message level="3" line="1" source="test data" type="ERROR">
+ <paragraph>
+ Malformed table.
+ Text in column margin at line offset 3.
+ <literal_block xml:space="preserve">
+ == =========== ===========
+ 1 Span columns 2 & 3
+ -- ------------------------
+ 2 Span columns 2 & 3
+ ------------------------
+ 3
+ == =========== ===========
+ <system_message level="3" line="9" source="test data" type="ERROR">
+ <paragraph>
+ Malformed table.
+ Column span incomplete at line offset 4.
+ <literal_block xml:space="preserve">
+ == =========== ===========
+ 1 Span cols 1&2 but not 3
+ --------------- -----------
+ 2 Span cols 1&2 but not 3
+ ---------------
+ 3 no spans here
+ == =========== ===========
+ <table>
+ <tgroup cols="3">
+ <colspec colwidth="2">
+ <colspec colwidth="11">
+ <colspec colwidth="11">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ 1
+ <entry>
+ <system_message level="4" line="20" source="test data" type="SEVERE">
+ <paragraph>
+ Unexpected section title.
+ <literal_block xml:space="preserve">
+ Not a span
+ -----------
+ <entry>
+ <system_message level="4" line="20" source="test data" type="SEVERE">
+ <paragraph>
+ Unexpected section title.
+ <literal_block xml:space="preserve">
+ Not a span
+ -----------
+ <row>
+ <entry>
+ <paragraph>
+ 2
+ <entry>
+ <entry>
+"""],
+["""\
+========= =====================================================================
+Inclusion .. include::
+%s
+Note The first row of this table may expand
+ to accommodate long filesystem paths.
+========= =====================================================================
+""" % ('\n'.join([' %-65s' % include2[part * 65 : (part + 1) * 65]
+ for part in range(len(include2) / 65 + 1)])),
+"""\
+<document source="test data">
+ <table>
+ <tgroup cols="2">
+ <colspec colwidth="9">
+ <colspec colwidth="69">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ Inclusion
+ <entry>
+ <paragraph>
+ Here are some paragraphs
+ that can appear at any level.
+ <paragraph>
+ This file (include2.txt) is used by
+ <literal>
+ test_include.py
+ .
+ <row>
+ <entry>
+ <paragraph>
+ Note
+ <entry>
+ <paragraph>
+ The first row of this table may expand
+ to accommodate long filesystem paths.
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_targets.py b/test/test_parsers/test_rst/test_targets.py
new file mode 100755
index 000000000..362bf2cca
--- /dev/null
+++ b/test/test_parsers/test_rst/test_targets.py
@@ -0,0 +1,440 @@
+#! /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 states.py.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+totest['targets'] = [
+["""\
+.. _target:
+
+(Internal hyperlink target.)
+""",
+"""\
+<document source="test data">
+ <target ids="target" names="target">
+ <paragraph>
+ (Internal hyperlink target.)
+"""],
+["""\
+.. _optional space before colon :
+""",
+"""\
+<document source="test data">
+ <target ids="optional-space-before-colon" names="optional\ space\ before\ colon">
+"""],
+["""\
+External hyperlink targets:
+
+.. _one-liner: http://structuredtext.sourceforge.net
+
+.. _starts-on-this-line: http://
+ structuredtext.
+ sourceforge.net
+
+.. _entirely-below:
+ http://structuredtext.
+ sourceforge.net
+
+.. _not-indirect: uri\\_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ External hyperlink targets:
+ <target ids="one-liner" names="one-liner" refuri="http://structuredtext.sourceforge.net">
+ <target ids="starts-on-this-line" names="starts-on-this-line" refuri="http://structuredtext.sourceforge.net">
+ <target ids="entirely-below" names="entirely-below" refuri="http://structuredtext.sourceforge.net">
+ <target ids="not-indirect" names="not-indirect" refuri="uri_">
+"""],
+["""\
+Indirect hyperlink targets:
+
+.. _target1: reference_
+
+.. _target2: `phrase-link reference`_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Indirect hyperlink targets:
+ <target ids="target1" names="target1" refname="reference">
+ <target ids="target2" names="target2" refname="phrase-link reference">
+"""],
+["""\
+.. _a long target name:
+
+.. _`a target name: including a colon (quoted)`:
+
+.. _a target name\: including a colon (escaped):
+""",
+"""\
+<document source="test data">
+ <target ids="a-long-target-name" names="a\ long\ target\ name">
+ <target ids="a-target-name-including-a-colon-quoted" names="a\ target\ name:\ including\ a\ colon\ (quoted)">
+ <target ids="a-target-name-including-a-colon-escaped" names="a\ target\ name:\ including\ a\ colon\ (escaped)">
+"""],
+["""\
+.. _a very long target name,
+ split across lines:
+.. _`and another,
+ with backquotes`:
+""",
+"""\
+<document source="test data">
+ <target ids="a-very-long-target-name-split-across-lines" names="a\ very\ long\ target\ name,\ split\ across\ lines">
+ <target ids="and-another-with-backquotes" names="and\ another,\ with\ backquotes">
+"""],
+["""\
+External hyperlink:
+
+.. _target: http://www.python.org/
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ External hyperlink:
+ <target ids="target" names="target" refuri="http://www.python.org/">
+"""],
+["""\
+.. _email: jdoe@example.com
+
+.. _multi-line email: jdoe
+ @example.com
+""",
+"""\
+<document source="test data">
+ <target ids="email" names="email" refuri="mailto:jdoe@example.com">
+ <target ids="multi-line-email" names="multi-line\ email" refuri="mailto:jdoe@example.com">
+"""],
+["""\
+Duplicate external targets (different URIs):
+
+.. _target: first
+
+.. _target: second
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Duplicate external targets (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">
+"""],
+["""\
+Duplicate external targets (same URIs):
+
+.. _target: first
+
+.. _target: first
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Duplicate external targets (same URIs):
+ <target ids="target" names="target" refuri="first">
+ <system_message backrefs="id1" level="1" line="5" source="test data" type="INFO">
+ <paragraph>
+ Duplicate explicit target name: "target".
+ <target dupnames="target" ids="id1" refuri="first">
+"""],
+["""\
+Duplicate implicit targets.
+
+Title
+=====
+
+Paragraph.
+
+Title
+=====
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Duplicate implicit targets.
+ <section dupnames="title" ids="title">
+ <title>
+ Title
+ <paragraph>
+ Paragraph.
+ <section dupnames="title" ids="id1">
+ <title>
+ Title
+ <system_message backrefs="id1" level="1" line="9" source="test data" type="INFO">
+ <paragraph>
+ Duplicate implicit target name: "title".
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+Duplicate implicit/explicit targets.
+
+Title
+=====
+
+.. _title:
+
+Paragraph.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Duplicate implicit/explicit targets.
+ <section dupnames="title" ids="title">
+ <title>
+ Title
+ <system_message backrefs="id1" level="1" line="6" source="test data" type="INFO">
+ <paragraph>
+ Duplicate implicit target name: "title".
+ <target ids="id1" names="title">
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+Duplicate explicit targets.
+
+.. _title:
+
+First.
+
+.. _title:
+
+Second.
+
+.. _title:
+
+Third.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Duplicate explicit targets.
+ <target dupnames="title" ids="title">
+ <paragraph>
+ First.
+ <system_message backrefs="id1" level="2" line="7" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "title".
+ <target dupnames="title" ids="id1">
+ <paragraph>
+ Second.
+ <system_message backrefs="id2" level="2" line="11" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "title".
+ <target dupnames="title" ids="id2">
+ <paragraph>
+ Third.
+"""],
+["""\
+Duplicate targets:
+
+Target
+======
+
+Implicit section header target.
+
+.. [target] Citation target.
+
+.. [#target] Autonumber-labeled footnote target.
+
+.. _target:
+
+Explicit internal target.
+
+.. _target: Explicit_external_target
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Duplicate targets:
+ <section dupnames="target" ids="target">
+ <title>
+ Target
+ <paragraph>
+ Implicit section header target.
+ <citation dupnames="target" ids="id1">
+ <label>
+ target
+ <system_message backrefs="id1" level="1" line="8" source="test data" type="INFO">
+ <paragraph>
+ Duplicate implicit target name: "target".
+ <paragraph>
+ Citation target.
+ <footnote auto="1" dupnames="target" ids="id2">
+ <system_message backrefs="id2" level="2" line="10" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "target".
+ <paragraph>
+ Autonumber-labeled footnote target.
+ <system_message backrefs="id3" level="2" line="12" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "target".
+ <target dupnames="target" ids="id3">
+ <paragraph>
+ Explicit internal target.
+ <system_message backrefs="id4" level="2" line="16" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "target".
+ <target dupnames="target" ids="id4" refuri="Explicit_external_target">
+"""],
+["""\
+.. _unescaped colon at end:: no good
+
+.. _:: no good either
+
+.. _escaped colon\:: OK
+
+.. _`unescaped colon, quoted:`: OK
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ _unescaped colon at end:: no good
+ <system_message level="2" line="1" source="test data" type="WARNING">
+ <paragraph>
+ malformed hyperlink target.
+ <comment xml:space="preserve">
+ _:: no good either
+ <system_message level="2" line="3" source="test data" type="WARNING">
+ <paragraph>
+ malformed hyperlink target.
+ <target ids="escaped-colon" names="escaped\ colon:" refuri="OK">
+ <target ids="unescaped-colon-quoted" names="unescaped\ colon,\ quoted:" refuri="OK">
+"""],
+]
+
+totest['anonymous_targets'] = [
+["""\
+Anonymous external hyperlink target:
+
+.. __: http://w3c.org/
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Anonymous external hyperlink target:
+ <target anonymous="1" ids="id1" refuri="http://w3c.org/">
+"""],
+["""\
+Anonymous external hyperlink target:
+
+__ http://w3c.org/
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Anonymous external hyperlink target:
+ <target anonymous="1" ids="id1" refuri="http://w3c.org/">
+"""],
+["""\
+Anonymous indirect hyperlink target:
+
+.. __: reference_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Anonymous indirect hyperlink target:
+ <target anonymous="1" ids="id1" refname="reference">
+"""],
+["""\
+Anonymous external hyperlink target, not indirect:
+
+__ uri\\_
+
+__ this URI ends with an underscore_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Anonymous external hyperlink target, not indirect:
+ <target anonymous="1" ids="id1" refuri="uri_">
+ <target anonymous="1" ids="id2" refuri="thisURIendswithanunderscore_">
+"""],
+["""\
+Anonymous indirect hyperlink targets:
+
+__ reference_
+__ `a very long
+ reference`_
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Anonymous indirect hyperlink targets:
+ <target anonymous="1" ids="id1" refname="reference">
+ <target anonymous="1" ids="id2" refname="a very long reference">
+"""],
+["""\
+Mixed anonymous & named indirect hyperlink targets:
+
+__ reference_
+.. __: reference_
+__ reference_
+.. _target1: reference_
+no blank line
+
+.. _target2: reference_
+__ reference_
+.. __: reference_
+__ reference_
+no blank line
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Mixed anonymous & named indirect hyperlink targets:
+ <target anonymous="1" ids="id1" refname="reference">
+ <target anonymous="1" ids="id2" refname="reference">
+ <target anonymous="1" ids="id3" refname="reference">
+ <target ids="target1" names="target1" refname="reference">
+ <system_message level="2" line="7" source="test data" type="WARNING">
+ <paragraph>
+ Explicit markup ends without a blank line; unexpected unindent.
+ <paragraph>
+ no blank line
+ <target ids="target2" names="target2" refname="reference">
+ <target anonymous="1" ids="id4" refname="reference">
+ <target anonymous="1" ids="id5" refname="reference">
+ <target anonymous="1" ids="id6" refname="reference">
+ <system_message level="2" line="13" source="test data" type="WARNING">
+ <paragraph>
+ Explicit markup ends without a blank line; unexpected unindent.
+ <paragraph>
+ no blank line
+"""],
+["""\
+.. _
+""",
+"""\
+<document source="test data">
+ <comment xml:space="preserve">
+ _
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')
diff --git a/test/test_parsers/test_rst/test_transitions.py b/test/test_parsers/test_rst/test_transitions.py
new file mode 100755
index 000000000..c60a28e96
--- /dev/null
+++ b/test/test_parsers/test_rst/test_transitions.py
@@ -0,0 +1,309 @@
+#! /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 transition markers.
+"""
+
+from __init__ import DocutilsTestSupport
+
+def suite():
+ s = DocutilsTestSupport.ParserTestSuite()
+ s.generateTests(totest)
+ return s
+
+totest = {}
+
+# See DocutilsTestSupport.ParserTestSuite.generateTests for a
+# description of the 'totest' data structure.
+totest['transitions'] = [
+["""\
+Test transition markers.
+
+--------
+
+Paragraph
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Test transition markers.
+ <transition>
+ <paragraph>
+ Paragraph
+"""],
+["""\
+Section 1
+=========
+First text division of section 1.
+
+--------
+
+Second text division of section 1.
+
+Section 2
+---------
+Paragraph 2 in section 2.
+""",
+"""\
+<document source="test data">
+ <section ids="section-1" names="section\ 1">
+ <title>
+ Section 1
+ <paragraph>
+ First text division of section 1.
+ <transition>
+ <paragraph>
+ Second text division of section 1.
+ <section ids="section-2" names="section\ 2">
+ <title>
+ Section 2
+ <paragraph>
+ Paragraph 2 in section 2.
+"""],
+["""\
+--------
+
+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">
+ <transition>
+ <paragraph>
+ A section or document may not begin with a transition.
+ <paragraph>
+ The DTD specifies that two transitions may not
+ be adjacent:
+ <transition>
+ <transition>
+ <transition>
+ <paragraph>
+ The DTD also specifies that a section or document
+ may not end with a transition.
+ <transition>
+"""],
+["""\
+Test unexpected transition markers.
+
+ Block quote.
+
+ --------
+
+ Paragraph.
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Test unexpected transition markers.
+ <block_quote>
+ <paragraph>
+ Block quote.
+ <system_message level="4" line="5" source="test data" type="SEVERE">
+ <paragraph>
+ Unexpected section title or transition.
+ <literal_block xml:space="preserve">
+ --------
+ <paragraph>
+ Paragraph.
+"""],
+["""\
+Short transition marker.
+
+---
+
+Paragraph
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Short transition marker.
+ <paragraph>
+ ---
+ <paragraph>
+ Paragraph
+"""],
+["""\
+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
+ <transition>
+ <paragraph>
+ The next transition is legal:
+ <transition>
+ <section ids="section-2" names="section\ 2">
+ <title>
+ Section 2
+ <transition>
+"""],
+["""\
+A paragraph, two transitions, and a blank line.
+
+----------
+
+----------
+
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph, two transitions, and a blank line.
+ <transition>
+ <transition>
+"""],
+["""\
+A paragraph and two transitions.
+
+----------
+
+----------
+""", # the same:
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph and two transitions.
+ <transition>
+ <transition>
+"""],
+["""\
+----------
+
+Document beginning with a transition.
+""",
+"""\
+<document source="test data">
+ <transition>
+ <paragraph>
+ Document beginning with a transition.
+"""],
+["""\
+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.
+"""],
+["""\
+Section 1
+=========
+
+----------
+
+----------
+
+----------
+
+Section 2
+=========
+
+Some text.
+""",
+"""\
+<document source="test data">
+ <section ids="section-1" names="section\ 1">
+ <title>
+ Section 1
+ <transition>
+ <transition>
+ <transition>
+ <section ids="section-2" names="section\ 2">
+ <title>
+ Section 2
+ <paragraph>
+ Some text.
+"""],
+["""\
+----------
+
+----------
+
+----------
+""",
+"""\
+<document source="test data">
+ <transition>
+ <transition>
+ <transition>
+"""],
+["""\
+A paragraph.
+
+----------
+
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ A paragraph.
+ <transition>
+"""],
+]
+
+
+if __name__ == '__main__':
+ import unittest
+ unittest.main(defaultTest='suite')