Add support for Markdown.
[docutils.git] / docutils / test / test_parsers / test_recommonmark / test_transitions.py
blob35649ed5aacbd91df85d206a611b56545aaa1eea
1 #! /usr/bin/env python
3 # $Id$
4 # Author: David Goodger <goodger@python.org>
5 # Copyright: This module has been placed in the public domain.
7 """
8 Tests for transitions (`thematic breaks`).
9 """
10 from __future__ import absolute_import
12 if __name__ == '__main__':
13 import __init__
14 from test_parsers import DocutilsTestSupport
17 def suite():
18 s = DocutilsTestSupport.RecommonmarkParserTestSuite()
19 s.generateTests(totest)
20 return s
22 totest = {}
24 # See DocutilsTestSupport.RecommonmarkParserTestSuite.generateTests for a
25 # description of the 'totest' data structure.
26 totest['transitions'] = [
27 ["""\
28 Test transition markers.
30 --------
32 Paragraph
33 """,
34 """\
35 <document source="test data">
36 <paragraph>
37 Test transition markers.
38 <transition>
39 <paragraph>
40 Paragraph
41 """],
42 ["""\
43 Section 1
44 =========
45 First text division of section 1.
47 --------
49 Second text division of section 1.
51 Section 2
52 ---------
53 Paragraph 2 in section 2.
54 """,
55 """\
56 <document source="test data">
57 <section ids="section-1" names="section\\ 1">
58 <title>
59 Section 1
60 <paragraph>
61 First text division of section 1.
62 <transition>
63 <paragraph>
64 Second text division of section 1.
65 <section ids="section-2" names="section\\ 2">
66 <title>
67 Section 2
68 <paragraph>
69 Paragraph 2 in section 2.
70 """],
71 # ["""\
72 # --------
74 # A section or document may not begin with a transition.
76 # The DTD specifies that two transitions may not
77 # be adjacent:
79 # --------
81 # --------
83 # --------
85 # The DTD also specifies that a section or document
86 # may not end with a transition.
88 # --------
89 # """,
90 # """\
91 # <document source="test data">
92 # <transition>
93 # <paragraph>
94 # A section or document may not begin with a transition.
95 # <paragraph>
96 # The DTD specifies that two transitions may not
97 # be adjacent:
98 # <transition>
99 # <transition>
100 # <transition>
101 # <paragraph>
102 # The DTD also specifies that a section or document
103 # may not end with a transition.
104 # <transition>
105 # """],
106 # TODO: should we allow transitions in block elements?
107 # +1 Other document formats allow this (HTML, markdown, LaTeX)
108 # and a quoted text may contain a transition.
109 # -1 Requires changing the document model.
110 # ["""\
111 # Test unexpected transition markers.
113 # > Block quote.
115 # > --------
117 # > Paragraph.
118 # """,
119 # """\
120 # <document source="test data">
121 # <paragraph>
122 # Test unexpected transition markers.
123 # <block_quote>
124 # <paragraph>
125 # Block quote.
126 # <transition>
127 # <paragraph>
128 # Paragraph.
129 # """],
130 ["""\
131 Short transition marker.
135 Too short transition marker.
139 Paragraph
140 """,
141 """\
142 <document source="test data">
143 <paragraph>
144 Short transition marker.
145 <transition>
146 <paragraph>
147 Too short transition marker.
148 <paragraph>
150 <paragraph>
151 Paragraph
152 """],
153 ["""\
154 Sections with transitions at beginning and end.
156 Section 1
157 =========
159 ----------
161 The next transition is legal:
163 ----------
165 Section 2
166 =========
168 ----------
169 """,
170 """\
171 <document source="test data">
172 <paragraph>
173 Sections with transitions at beginning and end.
174 <section ids="section-1" names="section\\ 1">
175 <title>
176 Section 1
177 <transition>
178 <paragraph>
179 The next transition is legal:
180 <transition>
181 <section ids="section-2" names="section\\ 2">
182 <title>
183 Section 2
184 <transition>
185 """],
186 ["""\
187 A paragraph, two transitions, and a blank line.
189 ----------
191 ----------
193 """,
194 """\
195 <document source="test data">
196 <paragraph>
197 A paragraph, two transitions, and a blank line.
198 <transition>
199 <transition>
200 """],
201 ["""\
202 A paragraph and two transitions.
204 ----------
206 ----------
207 """, # the same:
208 """\
209 <document source="test data">
210 <paragraph>
211 A paragraph and two transitions.
212 <transition>
213 <transition>
214 """],
215 ["""\
216 ----------
218 Document beginning with a transition.
219 """,
220 """\
221 <document source="test data">
222 <transition>
223 <paragraph>
224 Document beginning with a transition.
225 """],
226 ["""\
227 Section 1
228 =========
230 Subsection 1
231 ------------
233 Some text.
235 ----------
237 Section 2
238 =========
240 Some text.
241 """,
242 """\
243 <document source="test data">
244 <section ids="section-1" names="section\\ 1">
245 <title>
246 Section 1
247 <section ids="subsection-1" names="subsection\\ 1">
248 <title>
249 Subsection 1
250 <paragraph>
251 Some text.
252 <transition>
253 <section ids="section-2" names="section\\ 2">
254 <title>
255 Section 2
256 <paragraph>
257 Some text.
258 """],
259 ["""\
260 Section 1
261 =========
263 ----------
265 ----------
267 ----------
269 Section 2
270 =========
272 Some text.
273 """,
274 """\
275 <document source="test data">
276 <section ids="section-1" names="section\\ 1">
277 <title>
278 Section 1
279 <transition>
280 <transition>
281 <transition>
282 <section ids="section-2" names="section\\ 2">
283 <title>
284 Section 2
285 <paragraph>
286 Some text.
287 """],
288 ["""\
289 ----------
291 ----------
293 ----------
294 """,
295 """\
296 <document source="test data">
297 <transition>
298 <transition>
299 <transition>
300 """],
301 ["""\
302 A paragraph.
304 ----------
306 """,
307 """\
308 <document source="test data">
309 <paragraph>
310 A paragraph.
311 <transition>
312 """],
316 if __name__ == '__main__':
317 import unittest
318 unittest.main(defaultTest='suite')