3
# Author: reggie dugard
4
# Contact: reggie@users.sourceforge.net
5
# Revision: $Revision: 3968 $
6
# Date: $Date: 2005-10-29 14:28:44 +0200 (Sat, 29 Oct 2005) $
7
# Copyright: This module has been placed in the public domain.
10
Test for fragment code in HTML writer.
12
Note: the 'body' and 'whole' entries have been removed from the parts
13
dictionaries (redundant), along with 'meta' and 'stylesheet' entries with
14
standard values, and any entries with empty values.
17
from __init__ import DocutilsTestSupport
18
from docutils import core
21
s = DocutilsTestSupport.HtmlPublishPartsTestSuite()
22
s.generateTests(totest)
28
totest['Title promotion'] = ({'stylesheet_path': '',
29
'embed_stylesheet': 0}, [
34
{'fragment': '''<p>Simple String</p>\\n''',
35
'html_body': '''<div class="document">
38
'html_head': '''...<title></title>\\n'''}
41
Simple String with *markup*
44
{'fragment': '''<p>Simple String with <em>markup</em></p>\\n''',
45
'html_body': '''<div class="document">
46
<p>Simple String with <em>markup</em></p>
48
'html_head': '''...<title></title>\\n'''}
51
Simple String with an even simpler ``inline literal``
54
{'fragment': '''<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>\\n''',
55
'html_body': '''<div class="document">
56
<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>
58
'html_head': '''...<title></title>\\n'''}
61
A simple `anonymous reference`__
63
__ http://www.test.com/test_url
66
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
67
'html_body': '''<div class="document">
68
<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>
70
'html_head': '''...<title></title>\\n'''}
78
{'fragment': '''<p>One paragraph.</p>
79
<p>Two paragraphs.</p>\\n''',
80
'html_body': '''<div class="document">
82
<p>Two paragraphs.</p>
84
'html_head': '''...<title></title>\\n'''}
87
A simple `named reference`_ with stuff in between the
88
reference and the target.
90
.. _`named reference`: http://www.test.com/test_url
93
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
94
reference and the target.</p>\\n''',
95
'html_body': '''<div class="document">
96
<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
97
reference and the target.</p>
99
'html_head': '''...<title></title>\\n'''}
122
{'fragment': '''<p>Some stuff</p>
123
<div class="section">
124
<h1><a id="section" name="section">Section</a></h1>
125
<p>Some more stuff</p>
126
<div class="section">
127
<h2><a id="another-section" name="another-section">Another Section</a></h2>
128
<p>And even more stuff</p>
131
'html_body': '''<div class="document" id="title">
132
<h1 class="title">Title</h1>
133
<h2 class="subtitle" id="subtitle">Subtitle</h2>
135
<div class="section">
136
<h1><a id="section" name="section">Section</a></h1>
137
<p>Some more stuff</p>
138
<div class="section">
139
<h2><a id="another-section" name="another-section">Another Section</a></h2>
140
<p>And even more stuff</p>
144
'html_head': '''...<title>Title</title>\\n''',
145
'html_subtitle': '''<h2 class="subtitle" id="subtitle">Subtitle</h2>\\n''',
146
'html_title': '''<h1 class="title">Title</h1>\\n''',
147
'subtitle': '''Subtitle''',
148
'title': '''Title'''}
160
{'docinfo': '''<table class="docinfo" frame="void" rules="none">
161
<col class="docinfo-name" />
162
<col class="docinfo-content" />
164
<tr><th class="docinfo-name">Author:</th>
168
'fragment': '''<p>Some stuff</p>\\n''',
169
'html_body': '''<div class="document" id="title">
170
<h1 class="title">Title</h1>
171
<table class="docinfo" frame="void" rules="none">
172
<col class="docinfo-name" />
173
<col class="docinfo-content" />
175
<tr><th class="docinfo-name">Author:</th>
181
'html_head': '''...<title>Title</title>
182
<meta name="author" content="me" />\\n''',
183
'html_title': '''<h1 class="title">Title</h1>\\n''',
184
'meta': '''<meta name="author" content="me" />\\n''',
185
'title': '''Title'''}
189
totest['No title promotion'] = ({'doctitle_xform' : 0,
190
'stylesheet_path': '',
191
'embed_stylesheet': 0}, [
196
{'fragment': '''<p>Simple String</p>\\n''',
197
'html_body': '''<div class="document">
200
'html_head': '''...<title></title>\\n'''}
203
Simple String with *markup*
206
{'fragment': '''<p>Simple String with <em>markup</em></p>\\n''',
207
'html_body': '''<div class="document">
208
<p>Simple String with <em>markup</em></p>
210
'html_head': '''...<title></title>\\n'''}
213
Simple String with an even simpler ``inline literal``
216
{'fragment': '''<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>\\n''',
217
'html_body': '''<div class="document">
218
<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>
220
'html_head': '''...<title></title>\\n'''}
223
A simple `anonymous reference`__
225
__ http://www.test.com/test_url
228
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
229
'html_body': '''<div class="document">
230
<p>A simple <a class="reference" href="http://www.test.com/test_url">anonymous reference</a></p>
232
'html_head': '''...<title></title>\\n'''}
235
A simple `named reference`_ with stuff in between the
236
reference and the target.
238
.. _`named reference`: http://www.test.com/test_url
241
{'fragment': '''<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
242
reference and the target.</p>\\n''',
243
'html_body': '''<div class="document">
244
<p>A simple <a class="reference" href="http://www.test.com/test_url">named reference</a> with stuff in between the
245
reference and the target.</p>
247
'html_head': '''...<title></title>\\n'''}
270
{'fragment': '''<div class="section">
271
<h1><a id="title" name="title">Title</a></h1>
272
<div class="section">
273
<h2><a id="not-a-subtitle" name="not-a-subtitle">Not A Subtitle</a></h2>
275
<div class="section">
276
<h3><a id="section" name="section">Section</a></h3>
277
<p>Some more stuff</p>
278
<div class="section">
279
<h4><a id="another-section" name="another-section">Another Section</a></h4>
280
<p>And even more stuff</p>
285
'html_body': '''<div class="document">
286
<div class="section">
287
<h1><a id="title" name="title">Title</a></h1>
288
<div class="section">
289
<h2><a id="not-a-subtitle" name="not-a-subtitle">Not A Subtitle</a></h2>
291
<div class="section">
292
<h3><a id="section" name="section">Section</a></h3>
293
<p>Some more stuff</p>
294
<div class="section">
295
<h4><a id="another-section" name="another-section">Another Section</a></h4>
296
<p>And even more stuff</p>
302
'html_head': '''...<title></title>\\n'''}
309
{'fragment': '''<ul class="simple">
313
'html_body': '''<div class="document">
319
'html_head': '''...<title></title>\\n'''}
332
{'fragment': '''<p>Not a docinfo.</p>
333
<table class="docutils field-list" frame="void" rules="none">
334
<col class="field-name" />
335
<col class="field-body" />
337
<tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p>
340
<tr class="field"><th class="field-name">a:</th><td class="field-body"></td>
342
<tr class="field"><th class="field-name">simple:</th><td class="field-body"></td>
344
<tr class="field"><th class="field-name">field:</th><td class="field-body">list</td>
348
'html_body': '''<div class="document">
349
<p>Not a docinfo.</p>
350
<table class="docutils field-list" frame="void" rules="none">
351
<col class="field-name" />
352
<col class="field-body" />
354
<tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p>
357
<tr class="field"><th class="field-name">a:</th><td class="field-body"></td>
359
<tr class="field"><th class="field-name">simple:</th><td class="field-body"></td>
361
<tr class="field"><th class="field-name">field:</th><td class="field-body">list</td>
366
'html_head': '''...<title></title>\\n'''}
371
if __name__ == '__main__':
373
unittest.main(defaultTest='suite')