latex2e writer : Move usepackage hyperref after stylesheet inclusion.
[docutils.git] / test / test_writers / test_html4css1_parts.py
blobeb366468240fe963044e41d3663fa81bde40a502
1 #! /usr/bin/env python
3 # $Id$
4 # Author: reggie dugard <reggie@users.sourceforge.net>
5 # Copyright: This module has been placed in the public domain.
7 """
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.
13 """
15 from __init__ import DocutilsTestSupport
16 from docutils import core
18 def suite():
19 s = DocutilsTestSupport.HtmlPublishPartsTestSuite()
20 s.generateTests(totest)
21 return s
24 totest = {}
26 totest['Title promotion'] = ({'stylesheet_path': '',
27 'embed_stylesheet': 0}, [
28 ["""\
29 Simple String
30 """,
31 """\
32 {'fragment': '''<p>Simple String</p>\\n''',
33 'html_body': '''<div class="document">
34 <p>Simple String</p>
35 </div>\\n''',
36 'html_head': '''...<title></title>\\n'''}
37 """],
38 ["""\
39 Simple String with *markup*
40 """,
41 """\
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>
45 </div>\\n''',
46 'html_head': '''...<title></title>\\n'''}
47 """],
48 ["""\
49 Simple String with an even simpler ``inline literal``
50 """,
51 """\
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>
55 </div>\\n''',
56 'html_head': '''...<title></title>\\n'''}
57 """],
58 ["""\
59 A simple `anonymous reference`__
61 __ http://www.test.com/test_url
62 """,
63 """\
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>
67 </div>\\n''',
68 'html_head': '''...<title></title>\\n'''}
69 """],
70 ["""\
71 One paragraph.
73 Two paragraphs.
74 """,
75 """\
76 {'fragment': '''<p>One paragraph.</p>
77 <p>Two paragraphs.</p>\\n''',
78 'html_body': '''<div class="document">
79 <p>One paragraph.</p>
80 <p>Two paragraphs.</p>
81 </div>\\n''',
82 'html_head': '''...<title></title>\\n'''}
83 """],
84 ["""\
85 A simple `named reference`_ with stuff in between the
86 reference and the target.
88 .. _`named reference`: http://www.test.com/test_url
89 """,
90 """\
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>
96 </div>\\n''',
97 'html_head': '''...<title></title>\\n'''}
98 """],
99 ["""\
100 +++++
101 Title
102 +++++
104 Subtitle
105 ========
107 Some stuff
109 Section
110 -------
112 Some more stuff
114 Another Section
115 ...............
117 And even more stuff
118 """,
119 """\
120 {'fragment': '''<p>Some stuff</p>
121 <div class="section" id="section">
122 <h1>Section</h1>
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>
127 </div>
128 </div>\\n''',
129 'html_body': '''<div class="document" id="title">
130 <h1 class="title">Title</h1>
131 <h2 class="subtitle" id="subtitle">Subtitle</h2>
132 <p>Some stuff</p>
133 <div class="section" id="section">
134 <h1>Section</h1>
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>
139 </div>
140 </div>
141 </div>\\n''',
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'''}
147 """],
148 ["""\
149 +++++
150 Title
151 +++++
153 :author: me
155 Some stuff
156 """,
157 """\
158 {'docinfo': '''<table class="docinfo" frame="void" rules="none">
159 <col class="docinfo-name" />
160 <col class="docinfo-content" />
161 <tbody valign="top">
162 <tr><th class="docinfo-name">Author:</th>
163 <td>me</td></tr>
164 </tbody>
165 </table>\\n''',
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" />
172 <tbody valign="top">
173 <tr><th class="docinfo-name">Author:</th>
174 <td>me</td></tr>
175 </tbody>
176 </table>
177 <p>Some stuff</p>
178 </div>\\n''',
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'''}
184 """]
187 totest['No title promotion'] = ({'doctitle_xform' : 0,
188 'stylesheet_path': '',
189 'embed_stylesheet': 0}, [
190 ["""\
191 Simple String
192 """,
193 """\
194 {'fragment': '''<p>Simple String</p>\\n''',
195 'html_body': '''<div class="document">
196 <p>Simple String</p>
197 </div>\\n''',
198 'html_head': '''...<title></title>\\n'''}
199 """],
200 ["""\
201 Simple String with *markup*
202 """,
203 """\
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>
207 </div>\\n''',
208 'html_head': '''...<title></title>\\n'''}
209 """],
210 ["""\
211 Simple String with an even simpler ``inline literal``
212 """,
213 """\
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>
217 </div>\\n''',
218 'html_head': '''...<title></title>\\n'''}
219 """],
220 ["""\
221 A simple `anonymous reference`__
223 __ http://www.test.com/test_url
224 """,
225 """\
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>
229 </div>\\n''',
230 'html_head': '''...<title></title>\\n'''}
231 """],
232 ["""\
233 A simple `named reference`_ with stuff in between the
234 reference and the target.
236 .. _`named reference`: http://www.test.com/test_url
237 """,
238 """\
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>
244 </div>\\n''',
245 'html_head': '''...<title></title>\\n'''}
246 """],
247 ["""\
248 +++++
249 Title
250 +++++
252 Not A Subtitle
253 ==============
255 Some stuff
257 Section
258 -------
260 Some more stuff
262 Another Section
263 ...............
265 And even more stuff
266 """,
267 """\
268 {'fragment': '''<div class="section" id="title">
269 <h1>Title</h1>
270 <div class="section" id="not-a-subtitle">
271 <h2>Not A Subtitle</h2>
272 <p>Some stuff</p>
273 <div class="section" id="section">
274 <h3>Section</h3>
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>
279 </div>
280 </div>
281 </div>
282 </div>\\n''',
283 'html_body': '''<div class="document">
284 <div class="section" id="title">
285 <h1>Title</h1>
286 <div class="section" id="not-a-subtitle">
287 <h2>Not A Subtitle</h2>
288 <p>Some stuff</p>
289 <div class="section" id="section">
290 <h3>Section</h3>
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>
295 </div>
296 </div>
297 </div>
298 </div>
299 </div>\\n''',
300 'html_head': '''...<title></title>\\n'''}
301 """],
302 ["""\
303 * bullet
304 * list
305 """,
306 """\
307 {'fragment': '''<ul class="simple">
308 <li>bullet</li>
309 <li>list</li>
310 </ul>\\n''',
311 'html_body': '''<div class="document">
312 <ul class="simple">
313 <li>bullet</li>
314 <li>list</li>
315 </ul>
316 </div>\\n''',
317 'html_head': '''...<title></title>\\n'''}
318 """],
319 ["""\
320 Not a docinfo.
322 :This: .. _target:
326 :simple:
327 :field: list
328 """,
329 """\
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" />
334 <tbody valign="top">
335 <tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p>
336 </td>
337 </tr>
338 <tr class="field"><th class="field-name">a:</th><td class="field-body"></td>
339 </tr>
340 <tr class="field"><th class="field-name">simple:</th><td class="field-body"></td>
341 </tr>
342 <tr class="field"><th class="field-name">field:</th><td class="field-body">list</td>
343 </tr>
344 </tbody>
345 </table>\\n''',
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" />
351 <tbody valign="top">
352 <tr class="field"><th class="field-name">This:</th><td class="field-body"><p class="first last" id="target">is</p>
353 </td>
354 </tr>
355 <tr class="field"><th class="field-name">a:</th><td class="field-body"></td>
356 </tr>
357 <tr class="field"><th class="field-name">simple:</th><td class="field-body"></td>
358 </tr>
359 <tr class="field"><th class="field-name">field:</th><td class="field-body">list</td>
360 </tr>
361 </tbody>
362 </table>
363 </div>\\n''',
364 'html_head': '''...<title></title>\\n'''}
365 """],
369 if __name__ == '__main__':
370 import unittest
371 unittest.main(defaultTest='suite')