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><string></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><string></title>\\n'''}
49 Simple String with an even simpler ``inline literal``
52 {'fragment': '''<p>Simple String with an even simpler <tt class="docutils literal">inline literal</tt></p>\\n''',
53 'html_body': '''<div class="document">
54 <p>Simple String with an even simpler <tt class="docutils literal">inline literal</tt></p>
56 'html_head': '''...<title><string></title>\\n'''}
59 Simple ``inline\xA0literal`` with NBSP
62 {'fragment': '''<p>Simple <tt class="docutils literal">inline literal</tt> with NBSP</p>\\n''',
63 'html_body': '''<div class="document">
64 <p>Simple <tt class="docutils literal">inline literal</tt> with NBSP</p>
66 'html_head': '''...<title><string></title>\\n'''}
69 A simple `anonymous reference`__
71 __ http://www.test.com/test_url
74 {'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
75 'html_body': '''<div class="document">
76 <p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>
78 'html_head': '''...<title><string></title>\\n'''}
86 {'fragment': '''<p>One paragraph.</p>
87 <p>Two paragraphs.</p>\\n''',
88 'html_body': '''<div class="document">
90 <p>Two paragraphs.</p>
92 'html_head': '''...<title><string></title>\\n'''}
95 A simple `named reference`_ with stuff in between the
96 reference and the target.
98 .. _`named reference`: http://www.test.com/test_url
101 {'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
102 reference and the target.</p>\\n''',
103 'html_body': '''<div class="document">
104 <p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
105 reference and the target.</p>
107 'html_head': '''...<title><string></title>\\n'''}
130 {'fragment': '''<p>Some stuff</p>
131 <div class="section" id="section">
133 <p>Some more stuff</p>
134 <div class="section" id="another-section">
135 <h2>Another Section</h2>
136 <p>And even more stuff</p>
139 'html_body': '''<div class="document" id="title">
140 <h1 class="title">Title</h1>
141 <h2 class="subtitle" id="subtitle">Subtitle</h2>
143 <div class="section" id="section">
145 <p>Some more stuff</p>
146 <div class="section" id="another-section">
147 <h2>Another Section</h2>
148 <p>And even more stuff</p>
152 'html_head': '''...<title>Title</title>\\n''',
153 'html_subtitle': '''<h2 class="subtitle" id="subtitle">Subtitle</h2>\\n''',
154 'html_title': '''<h1 class="title">Title</h1>\\n''',
155 'subtitle': '''Subtitle''',
156 'title': '''Title'''}
168 {'docinfo': '''<table class="docinfo" frame="void" rules="none">
169 <col class="docinfo-name" />
170 <col class="docinfo-content" />
172 <tr><th class="docinfo-name">Author:</th>
176 'fragment': '''<p>Some stuff</p>\\n''',
177 'html_body': '''<div class="document" id="title">
178 <h1 class="title">Title</h1>
179 <table class="docinfo" frame="void" rules="none">
180 <col class="docinfo-name" />
181 <col class="docinfo-content" />
183 <tr><th class="docinfo-name">Author:</th>
189 'html_head': '''...<title>Title</title>
190 <meta name="author" content="me" />\\n''',
191 'html_title': '''<h1 class="title">Title</h1>\\n''',
192 'meta': '''<meta name="author" content="me" />\\n''',
193 'title': '''Title'''}
197 totest
['No title promotion'] = ({'doctitle_xform' : 0,
198 'stylesheet_path': '',
199 'embed_stylesheet': 0}, [
204 {'fragment': '''<p>Simple String</p>\\n''',
205 'html_body': '''<div class="document">
208 'html_head': '''...<title><string></title>\\n'''}
211 Simple String with *markup*
214 {'fragment': '''<p>Simple String with <em>markup</em></p>\\n''',
215 'html_body': '''<div class="document">
216 <p>Simple String with <em>markup</em></p>
218 'html_head': '''...<title><string></title>\\n'''}
221 Simple String with an even simpler ``inline literal``
224 {'fragment': '''<p>Simple String with an even simpler <tt class="docutils literal">inline literal</tt></p>\\n''',
225 'html_body': '''<div class="document">
226 <p>Simple String with an even simpler <tt class="docutils literal">inline literal</tt></p>
228 'html_head': '''...<title><string></title>\\n'''}
231 A simple `anonymous reference`__
233 __ http://www.test.com/test_url
236 {'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>\\n''',
237 'html_body': '''<div class="document">
238 <p>A simple <a class="reference external" href="http://www.test.com/test_url">anonymous reference</a></p>
240 'html_head': '''...<title><string></title>\\n'''}
243 A simple `named reference`_ with stuff in between the
244 reference and the target.
246 .. _`named reference`: http://www.test.com/test_url
249 {'fragment': '''<p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
250 reference and the target.</p>\\n''',
251 'html_body': '''<div class="document">
252 <p>A simple <a class="reference external" href="http://www.test.com/test_url">named reference</a> with stuff in between the
253 reference and the target.</p>
255 'html_head': '''...<title><string></title>\\n'''}
278 {'fragment': '''<div class="section" id="title">
280 <div class="section" id="not-a-subtitle">
281 <h2>Not A Subtitle</h2>
283 <div class="section" id="section">
285 <p>Some more stuff</p>
286 <div class="section" id="another-section">
287 <h4>Another Section</h4>
288 <p>And even more stuff</p>
293 'html_body': '''<div class="document">
294 <div class="section" id="title">
296 <div class="section" id="not-a-subtitle">
297 <h2>Not A Subtitle</h2>
299 <div class="section" id="section">
301 <p>Some more stuff</p>
302 <div class="section" id="another-section">
303 <h4>Another Section</h4>
304 <p>And even more stuff</p>
310 'html_head': '''...<title><string></title>\\n'''}
317 {'fragment': '''<ul class="simple">
321 'html_body': '''<div class="document">
327 'html_head': '''...<title><string></title>\\n'''}
340 {'fragment': '''<table border="1" class="docutils align-right">
354 'html_body': '''<div class="document">
355 <table border="1" class="docutils align-right">
370 'html_head': '''...<title><string></title>\\n'''}
383 {'fragment': '''<p>Not a docinfo.</p>
384 <table class="docutils field-list" frame="void" rules="none">
385 <col class="field-name" />
386 <col class="field-body" />
388 <tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p>
391 <tr class="field"><th class="field-name">a:</th><td class="field-body"></td>
393 <tr class="field"><th class="field-name">simple:</th><td class="field-body"></td>
395 <tr class="field"><th class="field-name">field:</th><td class="field-body">list</td>
399 'html_body': '''<div class="document">
400 <p>Not a docinfo.</p>
401 <table class="docutils field-list" frame="void" rules="none">
402 <col class="field-name" />
403 <col class="field-body" />
405 <tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p>
408 <tr class="field"><th class="field-name">a:</th><td class="field-body"></td>
410 <tr class="field"><th class="field-name">simple:</th><td class="field-body"></td>
412 <tr class="field"><th class="field-name">field:</th><td class="field-body">list</td>
417 'html_head': '''...<title><string></title>\\n'''}
423 :simple field list with loooong field: names
426 {'fragment': '''<p>Not a docinfo.</p>
427 <table class="docutils field-list" frame="void" rules="none">
428 <col class="field-name" />
429 <col class="field-body" />
431 <tr class="field"><th class="field-name">This is:</th><td class="field-body">a</td>
433 <tr class="field"><th class="field-name" colspan="2">simple field list with loooong field:</th></tr>
434 <tr class="field"><td> </td><td class="field-body">names</td>
438 'html_body': '''<div class="document">
439 <p>Not a docinfo.</p>
440 <table class="docutils field-list" frame="void" rules="none">
441 <col class="field-name" />
442 <col class="field-body" />
444 <tr class="field"><th class="field-name">This is:</th><td class="field-body">a</td>
446 <tr class="field"><th class="field-name" colspan="2">simple field list with loooong field:</th></tr>
447 <tr class="field"><td> </td><td class="field-body">names</td>
452 'html_head': '''...<title><string></title>\\n'''}
457 if __name__
== '__main__':
459 unittest
.main(defaultTest
='suite')