3
# $Id: test_html4css1_parts.py 5045 2007-04-10 16:35:39Z wiemann $
4
# Author: reggie dugard <reggie@users.sourceforge.net>
5
# Copyright: This module has been placed in the public domain.
8
Test for fragment code in HTML writer.
10
Note: the 'body' and 'whole' entries have been removed from the parts
11
dictionaries (redundant), along with 'meta' and 'stylesheet' entries with
12
standard values, and any entries with empty values.
15
from __init__ import DocutilsTestSupport
16
from docutils import core
19
s = DocutilsTestSupport.HtmlPublishPartsTestSuite()
20
s.generateTests(totest)
26
totest['Title promotion'] = ({'stylesheet_path': '',
27
'embed_stylesheet': 0}, [
32
{'fragment': '''<p>Simple String</p>\\n''',
33
'html_body': '''<div class="document">
36
'html_head': '''...<title></title>\\n'''}
39
Simple String with *markup*
42
{'fragment': '''<p>Simple String with <em>markup</em></p>\\n''',
43
'html_body': '''<div class="document">
44
<p>Simple String with <em>markup</em></p>
46
'html_head': '''...<title></title>\\n'''}
49
Simple String with an even simpler ``inline literal``
52
{'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''',
53
'html_body': '''<div class="document">
54
<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>
56
'html_head': '''...<title></title>\\n'''}
59
A simple `anonymous reference`__
61
__ http://www.test.com/test_url
64
{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
65
'html_body': '''<div class="document">
66
<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>
68
'html_head': '''...<title></title>\\n'''}
76
{'fragment': '''<p>One paragraph.</p>
77
<p>Two paragraphs.</p>\\n''',
78
'html_body': '''<div class="document">
80
<p>Two paragraphs.</p>
82
'html_head': '''...<title></title>\\n'''}
85
A simple `named reference`_ with stuff in between the
86
reference and the target.
88
.. _`named reference`: http://www.test.com/test_url
91
{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
92
reference and the target.</p>\\n''',
93
'html_body': '''<div class="document">
94
<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
95
reference and the target.</p>
97
'html_head': '''...<title></title>\\n'''}
120
{'fragment': '''<p>Some stuff</p>
121
<div class="section" id="section">
123
<p>Some more stuff</p>
124
<div class="section" id="another-section">
125
<h2>Another Section</h2>
126
<p>And even more stuff</p>
129
'html_body': '''<div class="document" id="title">
130
<h1 class="title">Title</h1>
131
<h2 class="subtitle" id="subtitle">Subtitle</h2>
133
<div class="section" id="section">
135
<p>Some more stuff</p>
136
<div class="section" id="another-section">
137
<h2>Another Section</h2>
138
<p>And even more stuff</p>
142
'html_head': '''...<title>Title</title>\\n''',
143
'html_subtitle': '''<h2 class="subtitle" id="subtitle">Subtitle</h2>\\n''',
144
'html_title': '''<h1 class="title">Title</h1>\\n''',
145
'subtitle': '''Subtitle''',
146
'title': '''Title'''}
158
{'docinfo': '''<table class="docinfo" frame="void" rules="none">
159
<col class="docinfo-name" />
160
<col class="docinfo-content" />
162
<tr><th class="docinfo-name">Author:</th>
166
'fragment': '''<p>Some stuff</p>\\n''',
167
'html_body': '''<div class="document" id="title">
168
<h1 class="title">Title</h1>
169
<table class="docinfo" frame="void" rules="none">
170
<col class="docinfo-name" />
171
<col class="docinfo-content" />
173
<tr><th class="docinfo-name">Author:</th>
179
'html_head': '''...<title>Title</title>
180
<meta name="author" content="me" />\\n''',
181
'html_title': '''<h1 class="title">Title</h1>\\n''',
182
'meta': '''<meta name="author" content="me" />\\n''',
183
'title': '''Title'''}
187
totest['No title promotion'] = ({'doctitle_xform' : 0,
188
'stylesheet_path': '',
189
'embed_stylesheet': 0}, [
194
{'fragment': '''<p>Simple String</p>\\n''',
195
'html_body': '''<div class="document">
198
'html_head': '''...<title></title>\\n'''}
201
Simple String with *markup*
204
{'fragment': '''<p>Simple String with <em>markup</em></p>\\n''',
205
'html_body': '''<div class="document">
206
<p>Simple String with <em>markup</em></p>
208
'html_head': '''...<title></title>\\n'''}
211
Simple String with an even simpler ``inline literal``
214
{'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''',
215
'html_body': '''<div class="document">
216
<p>Simple String with an even simpler <tt class="docutils literal"><span class="pre">inline</span> <span class="pre">literal</span></tt></p>
218
'html_head': '''...<title></title>\\n'''}
221
A simple `anonymous reference`__
223
__ http://www.test.com/test_url
226
{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
227
'html_body': '''<div class="document">
228
<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>
230
'html_head': '''...<title></title>\\n'''}
233
A simple `named reference`_ with stuff in between the
234
reference and the target.
236
.. _`named reference`: http://www.test.com/test_url
239
{'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
240
reference and the target.</p>\\n''',
241
'html_body': '''<div class="document">
242
<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
243
reference and the target.</p>
245
'html_head': '''...<title></title>\\n'''}
268
{'fragment': '''<div class="section" id="title">
270
<div class="section" id="not-a-subtitle">
271
<h2>Not A Subtitle</h2>
273
<div class="section" id="section">
275
<p>Some more stuff</p>
276
<div class="section" id="another-section">
277
<h4>Another Section</h4>
278
<p>And even more stuff</p>
283
'html_body': '''<div class="document">
284
<div class="section" id="title">
286
<div class="section" id="not-a-subtitle">
287
<h2>Not A Subtitle</h2>
289
<div class="section" id="section">
291
<p>Some more stuff</p>
292
<div class="section" id="another-section">
293
<h4>Another Section</h4>
294
<p>And even more stuff</p>
300
'html_head': '''...<title></title>\\n'''}
307
{'fragment': '''<ul class="simple">
311
'html_body': '''<div class="document">
317
'html_head': '''...<title></title>\\n'''}
330
{'fragment': '''<p>Not a docinfo.</p>
331
<table class="docutils field-list" frame="void" rules="none">
332
<col class="field-name" />
333
<col class="field-body" />
335
<tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p>
338
<tr class="field"><th class="field-name">a:</th><td class="field-body"></td>
340
<tr class="field"><th class="field-name">simple:</th><td class="field-body"></td>
342
<tr class="field"><th class="field-name">field:</th><td class="field-body">list</td>
346
'html_body': '''<div class="document">
347
<p>Not a docinfo.</p>
348
<table class="docutils field-list" frame="void" rules="none">
349
<col class="field-name" />
350
<col class="field-body" />
352
<tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p>
355
<tr class="field"><th class="field-name">a:</th><td class="field-body"></td>
357
<tr class="field"><th class="field-name">simple:</th><td class="field-body"></td>
359
<tr class="field"><th class="field-name">field:</th><td class="field-body">list</td>
364
'html_head': '''...<title></title>\\n'''}
369
if __name__ == '__main__':
371
unittest.main(defaultTest='suite')