|
From: <mi...@us...> - 2020-01-30 00:44:17
|
Revision: 8472
http://sourceforge.net/p/docutils/code/8472
Author: milde
Date: 2020-01-30 00:44:15 +0000 (Thu, 30 Jan 2020)
Log Message:
-----------
html5: Use semantic tags <header>, <footer>, <section>, <aside>.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/html5_polyglot/minimal.css
trunk/docutils/docutils/writers/html5_polyglot/plain.css
trunk/docutils/test/functional/expected/footnotes_html5.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2020-01-27 15:14:57 UTC (rev 8471)
+++ trunk/docutils/HISTORY.txt 2020-01-30 00:44:15 UTC (rev 8472)
@@ -32,7 +32,10 @@
- Fix [ 383 ]: Smart quotes around opening and separator characters.
+* docutils/writers/html5_polyglot/
+ - Use semantic HTML5 tags <header>, <footer>, <section>.
+
Release 0.16
============
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2020-01-27 15:14:57 UTC (rev 8471)
+++ trunk/docutils/docutils/writers/_html_base.py 2020-01-30 00:44:15 UTC (rev 8472)
@@ -720,6 +720,7 @@
or 'docutils document without title')
self.head.append('<title>%s</title>\n' % self.encode(title))
+ # TODO: use new HTML5 element <main>?
def depart_document(self, node):
self.head_prefix.extend([self.doctype,
self.head_prefix_template %
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2020-01-27 15:14:57 UTC (rev 8471)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2020-01-30 00:44:15 UTC (rev 8472)
@@ -189,14 +189,31 @@
def depart_date(self, node):
self.depart_docinfo_item()
- # TODO: use HTML5 <footer> element?
- # def visit_footer(self, node):
- # def depart_footer(self, node):
+ # use HTML5 <footer> element
+ def visit_footer(self, node):
+ self.context.append(len(self.body))
- # TODO: use the new HTML5 element <aside>? (Also for footnote text)
- # def visit_footnote(self, node):
- # def depart_footnote(self, node):
+ def depart_footer(self, node):
+ start = self.context.pop()
+ footer = [self.starttag(node, 'footer')]
+ footer.extend(self.body[start:])
+ footer.append('\n</footer>\n')
+ self.footer.extend(footer)
+ self.body_suffix[:0] = footer
+ del self.body[start:]
+ def visit_header(self, node):
+ self.context.append(len(self.body))
+
+ def depart_header(self, node):
+ start = self.context.pop()
+ header = [self.starttag(node, 'header')]
+ header.extend(self.body[start:])
+ header.append('</header>\n')
+ self.body_prefix.extend(header)
+ self.header.extend(header)
+ del self.body[start:]
+
# Meta tags: 'lang' attribute replaced by 'xml:lang' in XHTML 1.1
# HTML5/polyglot recommends using both
def visit_meta(self, node):
@@ -214,6 +231,22 @@
def depart_organization(self, node):
self.depart_docinfo_item()
- # TODO: use the new HTML5 element <section>?
- # def visit_section(self, node):
- # def depart_section(self, node):
+ # use the new HTML5 element <section>
+ def visit_section(self, node):
+ self.section_level += 1
+ self.body.append(
+ self.starttag(node, 'section'))
+
+ def depart_section(self, node):
+ self.section_level -= 1
+ self.body.append('</section>\n')
+
+ # use the new HTML5 element <aside>
+ def visit_sidebar(self, node):
+ self.body.append(
+ self.starttag(node, 'aside', CLASS='sidebar'))
+ self.in_sidebar = True
+
+ def depart_sidebar(self, node):
+ self.body.append('</aside>\n')
+ self.in_sidebar = False
Modified: trunk/docutils/docutils/writers/html5_polyglot/minimal.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2020-01-27 15:14:57 UTC (rev 8471)
+++ trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2020-01-30 00:44:15 UTC (rev 8472)
@@ -219,7 +219,6 @@
/* Admonitions and System Messages */
div.admonition,
div.system-message,
-div.sidebar,
aside.sidebar {
margin: 1em 1.5em;
border: medium outset;
@@ -230,7 +229,6 @@
}
/* Sidebar */
-div.sidebar,
aside.sidebar {
width: 30%;
max-width: 26em;
@@ -273,10 +271,8 @@
}
/* Document Header and Footer */
-/* div.header, */
-/* header { border-bottom: 1px solid black; } */
-/* div.footer, */
-/* footer { border-top: 1px solid black; } */
+header { border-bottom: 1px solid black; }
+footer { border-top: 1px solid black; }
/* new HTML5 block elements: set display for older browsers */
header, section, footer, aside, nav, main, article, figure {
Modified: trunk/docutils/docutils/writers/html5_polyglot/plain.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/plain.css 2020-01-27 15:14:57 UTC (rev 8471)
+++ trunk/docutils/docutils/writers/html5_polyglot/plain.css 2020-01-30 00:44:15 UTC (rev 8472)
@@ -73,9 +73,8 @@
/* ===== */
/* Definition Lists */
-
-/* lists nested in definition lists */
-/* (:only-child is new in CSS 3) */
+/* Indent lists nested in definition lists */
+/* (:only-child is new in CSS 3) */
dd > ul:only-child, dd > ol:only-child { padding-left: 1em; }
/* Description Lists */
@@ -256,12 +255,9 @@
/* Compound Paragraph */
/* Container */
-/* can be styled in a custom stylesheet */
-
/* Document Header and Footer */
-footer, header,
-div.footer, div.header {
+footer, header {
font-size: smaller;
clear: both;
padding: 0.5em 2%;
Modified: trunk/docutils/test/functional/expected/footnotes_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/footnotes_html5.html 2020-01-27 15:14:57 UTC (rev 8471)
+++ trunk/docutils/test/functional/expected/footnotes_html5.html 2020-01-30 00:44:15 UTC (rev 8472)
@@ -43,7 +43,7 @@
nonexistent footnote:<a class="footnote-reference superscript" href="#footnote-6" id="footnote-reference-8">5</a>.</p>
</dd>
</dl>
-<div class="section" id="citations">
+<section id="citations">
<h1>Citations</h1>
<dl class="citation">
<dt class="label" id="cit2002"><span class="brackets">CIT2002</span><span class="fn-backref">(<a href="#citation-reference-1">1</a>,<a href="#citation-reference-3">2</a>)</span></dt>
@@ -60,7 +60,7 @@
<dd><p>this footnote is missing in the standard example document.</p>
</dd>
</dl>
+</section>
</div>
-</div>
</body>
</html>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-01-27 15:14:57 UTC (rev 8471)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2020-01-30 00:44:15 UTC (rev 8472)
@@ -18,11 +18,9 @@
<link rel="stylesheet" href="../input/data/math.css" type="text/css" />
</head>
<body>
-<div class="header">
+<header>
<p>Document header</p>
-
-<hr class="header"/>
-</div>
+</header>
<div class="document" id="restructuredtext-test-document">
<span id="doctitle"></span>
<h1 class="title">reStructuredText Test Document</h1>
@@ -164,32 +162,32 @@
<li><p><a class="reference internal" href="#error-handling" id="toc-entry-52"><span class="sectnum">5</span> Error Handling</a></p></li>
</ul>
</div>
-<div class="section" id="structural-elements">
+<section id="structural-elements">
<h1><a class="toc-backref" href="#toc-entry-1"><span class="sectnum">1</span> Structural Elements</a></h1>
-<div class="section" id="section-title">
+<section id="section-title">
<h2 class="with-subtitle"><a class="toc-backref" href="#toc-entry-2"><span class="sectnum">1.1</span> Section Title</a></h2>
<p class="section-subtitle" id="section-subtitle">Section Subtitle</p>
<p>Lone subsections are converted to a section subtitle by a transform
activated with the <span class="docutils literal"><span class="pre">--section-subtitles</span></span> command line option or the
<span class="docutils literal"><span class="pre">sectsubtitle-xform</span></span> configuration value.</p>
-</div>
-<div class="section" id="empty-section">
+</section>
+<section id="empty-section">
<h2><a class="toc-backref" href="#toc-entry-3"><span class="sectnum">1.2</span> Empty Section</a></h2>
-</div>
-<div class="section" id="transitions">
+</section>
+<section id="transitions">
<h2><a class="toc-backref" href="#toc-entry-4"><span class="sectnum">1.3</span> Transitions</a></h2>
<p>Here's a transition:</p>
<hr class="docutils" />
<p>It divides the section. Transitions may also occur between sections:</p>
-</div>
-</div>
+</section>
+</section>
<hr class="docutils" />
-<div class="section" id="body-elements">
+<section id="body-elements">
<h1><a class="toc-backref" href="#toc-entry-5"><span class="sectnum">2</span> Body Elements</a></h1>
-<div class="section" id="paragraphs">
+<section id="paragraphs">
<h2><a class="toc-backref" href="#toc-entry-6"><span class="sectnum">2.1</span> Paragraphs</a></h2>
<p>A paragraph.</p>
-<div class="section" id="inline-markup">
+<section id="inline-markup">
<h3><a class="toc-backref" href="#toc-entry-7"><span class="sectnum">2.1.1</span> Inline Markup</a></h3>
<p>Paragraphs contain text and may contain inline markup: <em>emphasis</em>,
<strong>strong emphasis</strong>, <span class="docutils literal">inline literals</span>, standalone hyperlinks
@@ -216,9 +214,9 @@
<span class="docutils literal">This is an example of <span class="pre">--inline-literal</span> <span class="pre">--text,</span> <span class="pre">--including</span> <span class="pre">some--</span> <span class="pre">strangely--hyphenated-words.</span> <span class="pre">Adjust-the-width-of-your-browser-window</span> to see how the text is wrapped. <span class="pre">--</span> <span class="pre">----</span> <span class="pre">--------</span> Now note the spacing between the words of this sentence (words should be grouped in pairs).</span></p>
<p>If the <span class="docutils literal"><span class="pre">--pep-references</span></span> option was supplied, there should be a
live link to PEP 258 here.</p>
-</div>
-</div>
-<div class="section" id="bullet-lists">
+</section>
+</section>
+<section id="bullet-lists">
<h2><a class="toc-backref" href="#toc-entry-8"><span class="sectnum">2.2</span> Bullet Lists</a></h2>
<ul>
<li><p>A bullet list</p>
@@ -244,8 +242,8 @@
</ul>
</li>
</ul>
-</div>
-<div class="section" id="enumerated-lists">
+</section>
+<section id="enumerated-lists">
<h2><a class="toc-backref" href="#toc-entry-9"><span class="sectnum">2.3</span> Enumerated Lists</a></h2>
<ol class="arabic">
<li><p>Arabic numerals.</p>
@@ -280,8 +278,8 @@
</ol>
</li>
</ol>
-</div>
-<div class="section" id="definition-lists">
+</section>
+<section id="definition-lists">
<h2><a class="toc-backref" href="#toc-entry-10"><span class="sectnum">2.4</span> Definition Lists</a></h2>
<dl>
<dt>Term</dt>
@@ -298,8 +296,8 @@
<dd><p>Definition</p>
</dd>
</dl>
-</div>
-<div class="section" id="field-lists">
+</section>
+<section id="field-lists">
<h2><a class="toc-backref" href="#toc-entry-11"><span class="sectnum">2.5</span> Field Lists</a></h2>
<dl class="field-list">
<dt>what</dt>
@@ -318,8 +316,8 @@
doesn't get stripped away.)</p>
</dd>
</dl>
-</div>
-<div class="section" id="option-lists">
+</section>
+<section id="option-lists">
<h2><a class="toc-backref" href="#toc-entry-12"><span class="sectnum">2.6</span> Option Lists</a></h2>
<p>For listing command-line options:</p>
<dl class="option-list">
@@ -357,8 +355,8 @@
</dl>
<p>There must be at least two spaces between the option and the
description.</p>
-</div>
-<div class="section" id="literal-blocks">
+</section>
+<section id="literal-blocks">
<h2><a class="toc-backref" href="#toc-entry-13"><span class="sectnum">2.7</span> Literal Blocks</a></h2>
<p>Literal blocks are indicated with a double-colon ("::") at the end of
the preceding paragraph (over there <span class="docutils literal"><span class="pre">--></span></span>). They can be indented:</p>
@@ -370,8 +368,8 @@
<pre class="literal-block">>> Great idea!
>
> Why didn't I think of that?</pre>
-</div>
-<div class="section" id="line-blocks">
+</section>
+<section id="line-blocks">
<h2><a class="toc-backref" href="#toc-entry-14"><span class="sectnum">2.8</span> Line Blocks</a></h2>
<p>This section tests line blocks. Line blocks are body elements which
consist of lines and other line blocks. Nested line blocks cause
@@ -444,8 +442,8 @@
<div class="line">w.</div>
<div class="line"><br /></div>
</div>
-</div>
-<div class="section" id="block-quotes">
+</section>
+<section id="block-quotes">
<h2><a class="toc-backref" href="#toc-entry-15"><span class="sectnum">2.9</span> Block Quotes</a></h2>
<p>Block quotes consist of indented body elements:</p>
<blockquote>
@@ -463,8 +461,8 @@
<p>ReStructuredText est un langage de balisage léger utilisé
notamment dans la documentation du langage Python.</p>
</blockquote>
-</div>
-<div class="section" id="doctest-blocks">
+</section>
+<section id="doctest-blocks">
<h2><a class="toc-backref" href="#toc-entry-16"><span class="sectnum">2.10</span> Doctest Blocks</a></h2>
<pre class="code python doctest">>>> print 'Python-specific usage examples; begun with ">>>"'
Python-specific usage examples; begun with ">>>"
@@ -471,8 +469,8 @@
>>> print '(cut and pasted from interactive Python sessions)'
(cut and pasted from interactive Python sessions)
</pre>
-</div>
-<div class="section" id="footnotes">
+</section>
+<section id="footnotes">
<h2><a class="toc-backref" href="#toc-entry-17"><span class="sectnum">2.11</span> Footnotes</a></h2>
<dl class="footnote brackets">
<dt class="label" id="footnote-1"><span class="brackets">1</span><span class="fn-backref">(<a href="#footnote-reference-1">1</a>,<a href="#footnote-reference-5">2</a>,<a href="#footnote-reference-9">3</a>)</span></dt>
@@ -504,8 +502,8 @@
nonexistent footnote: <a href="#system-message-2"><span class="problematic" id="footnote-reference-8">[5]_</span></a>.</p>
</dd>
</dl>
-</div>
-<div class="section" id="citations">
+</section>
+<section id="citations">
<h2><a class="toc-backref" href="#toc-entry-18"><span class="sectnum">2.12</span> Citations</a></h2>
<dl class="citation">
<dt class="label" id="cit2002"><span class="brackets">CIT2002</span><span class="fn-backref">(<a href="#citation-reference-1">1</a>,<a href="#citation-reference-2">2</a>)</span></dt>
@@ -515,8 +513,8 @@
</dl>
<p>Here's a reference to the above, <a class="citation-reference" href="#cit2002" id="citation-reference-2">[CIT2002]</a>, and a <a href="#system-message-3"><span class="problematic" id="citation-reference-3">[nonexistent]_</span></a>
citation.</p>
-</div>
-<div class="section" id="targets">
+</section>
+<section id="targets">
<span id="another-target"></span><h2><a class="toc-backref" href="#toc-entry-19"><span class="sectnum">2.13</span> Targets</a></h2>
<p id="example">This paragraph is pointed to by the explicit "example" target. A
reference can be found under <a class="reference internal" href="#inline-markup">Inline Markup</a>, above. <a class="reference internal" href="#inline-hyperlink-targets">Inline
@@ -529,20 +527,20 @@
refer to the <a class="reference internal" href="#targets">Targets</a> section.</p>
<p>Here's a <a href="#system-message-4"><span class="problematic" id="problematic-2">`hyperlink reference without a target`_</span></a>, which generates an
error.</p>
-<div class="section" id="duplicate-target-names">
+<section id="duplicate-target-names">
<h3><a class="toc-backref" href="#toc-entry-20"><span class="sectnum">2.13.1</span> Duplicate Target Names</a></h3>
<p>Duplicate names in section headers or other implicit targets will
generate "info" (level-1) system messages. Duplicate names in
explicit targets will generate "warning" (level-2) system messages.</p>
-</div>
-<div class="section" id="duplicate-target-names-1">
+</section>
+<section id="duplicate-target-names-1">
<h3><a class="toc-backref" href="#toc-entry-21"><span class="sectnum">2.13.2</span> Duplicate Target Names</a></h3>
<p>Since there are two "Duplicate Target Names" section headers, we
cannot uniquely refer to either of them by name. If we try to (like
this: <a href="#system-message-5"><span class="problematic" id="problematic-3">`Duplicate Target Names`_</span></a>), an error is generated.</p>
-</div>
-</div>
-<div class="section" id="directives">
+</section>
+</section>
+<section id="directives">
<h2><a class="toc-backref" href="#toc-entry-22"><span class="sectnum">2.14</span> Directives</a></h2>
<div class="contents local topic" id="contents">
<ul class="auto-toc simple">
@@ -560,13 +558,13 @@
<p>These are just a sample of the many reStructuredText Directives. For
others, please see
<a class="reference external" href="http://docutils.sourceforge.net/docs/ref/rst/directives.html">http://docutils.sourceforge.net/docs/ref/rst/directives.html</a>.</p>
-<div class="section" id="document-parts">
+<section id="document-parts">
<h3><a class="toc-backref" href="#toc-entry-53"><span class="sectnum">2.14.1</span> Document Parts</a></h3>
<p>An example of the "contents" directive can be seen above this section
(a local, untitled table of <a class="reference internal" href="#contents">contents</a>) and at the beginning of the
document (a document-wide <a class="reference internal" href="#table-of-contents">table of contents</a>).</p>
-</div>
-<div class="section" id="images-and-figures">
+</section>
+<section id="images-and-figures">
<h3><a class="toc-backref" href="#toc-entry-54"><span class="sectnum">2.14.2</span> Images and Figures</a></h3>
<p>An image directive (also clickable -- a hyperlink reference):</p>
<a class="reference internal image-reference" href="#directives"><img alt="../../../docs/user/rst/images/title.png" class="class1 class2" src="../../../docs/user/rst/images/title.png" /></a>
@@ -747,8 +745,8 @@
</tr>
</tbody>
</table>
-</div>
-<div class="section" id="admonitions">
+</section>
+<section id="admonitions">
<h3><a class="toc-backref" href="#toc-entry-55"><span class="sectnum">2.14.3</span> Admonitions</a></h3>
<div class="admonition attention">
<p class="admonition-title">Attention!</p>
@@ -796,11 +794,11 @@
<p class="admonition-title">And, by the way...</p>
<p>You can make up your own admonition too.</p>
</div>
-</div>
-<div class="section" id="topics-sidebars-and-rubrics">
+</section>
+<section id="topics-sidebars-and-rubrics">
<h3><a class="toc-backref" href="#toc-entry-56"><span class="sectnum">2.14.4</span> Topics, Sidebars, and Rubrics</a></h3>
<p><em>Sidebars</em> are like miniature, parallel documents.</p>
-<div class="sidebar">
+<aside class="sidebar">
<p class="sidebar-title">Sidebar Title</p>
<p class="sidebar-subtitle">Optional Subtitle</p>
<p>This is a sidebar. It is for text outside the flow of the main
@@ -808,7 +806,7 @@
<p class="rubric">This is a rubric inside a sidebar</p>
<p>Sidebars often appear beside the main text with a border and a different
background or font color.</p>
-</div>
+</aside>
<p>A <em>topic</em> is like a block quote with a title, or a self-contained section
with no subsections.</p>
<div class="topic">
@@ -820,8 +818,8 @@
<p class="rubric">This is a rubric</p>
<p>Topics and rubrics can be used at places where a <a class="reference internal" href="#section-title">section title</a> is not
allowed (e.g. inside a directive).</p>
-</div>
-<div class="section" id="target-footnotes">
+</section>
+<section id="target-footnotes">
<h3><a class="toc-backref" href="#toc-entry-57"><span class="sectnum">2.14.5</span> Target Footnotes</a></h3>
<dl class="footnote brackets">
<dt class="label" id="footnote-7"><span class="brackets">7</span><span class="fn-backref">(<a href="#footnote-reference-18">1</a>,<a href="#footnote-reference-19">2</a>,<a href="#footnote-reference-20">3</a>,<a href="#footnote-reference-25">4</a>)</span></dt>
@@ -849,12 +847,12 @@
<dd><p><a class="reference external" href="https://html.spec.whatwg.org/multipage/edits.html">https://html.spec.whatwg.org/multipage/edits.html</a></p>
</dd>
</dl>
-</div>
-<div class="section" id="replacement-text">
+</section>
+<section id="replacement-text">
<h3><a class="toc-backref" href="#toc-entry-58"><span class="sectnum">2.14.6</span> Replacement Text</a></h3>
<p>I recommend you try <a class="reference external" href="http://www.python.org/">Python, <em>the</em> best language around</a> <a class="footnote-reference brackets" href="#footnote-7" id="footnote-reference-20">7</a>.</p>
-</div>
-<div class="section" id="compound-paragraph">
+</section>
+<section id="compound-paragraph">
<h3><a class="toc-backref" href="#toc-entry-59"><span class="sectnum">2.14.7</span> Compound Paragraph</a></h3>
<p>The <em>compound</em> directive is used to create a "compound paragraph", which
is a single logical paragraph containing multiple physical body
@@ -964,8 +962,8 @@
</div>
<p class="compound-last">and the final paragraph of the compound 7.</p>
</div>
-</div>
-<div class="section" id="parsed-literal-blocks">
+</section>
+<section id="parsed-literal-blocks">
<h3><a class="toc-backref" href="#toc-entry-60"><span class="sectnum">2.14.8</span> Parsed Literal Blocks</a></h3>
<pre class="literal-block">This is a parsed literal block.
This line is indented. The next line is blank.
@@ -974,8 +972,8 @@
text</span>, <sub>sub-</sub> and <sup>super</sup>scripts,
inline formulas: <span class="formula"><i>A</i> = 2<i>π</i><i>r</i><sup>2</sup></span>,
footnotes <a class="footnote-reference brackets" href="#footnote-1" id="footnote-reference-9">1</a>, <span class="target" id="hyperlink-targets">hyperlink targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.</pre>
-</div>
-<div class="section" id="code">
+</section>
+<section id="code">
<h3><a class="toc-backref" href="#toc-entry-61"><span class="sectnum">2.14.9</span> Code</a></h3>
<p>Blocks of source code can be set with the <cite>code</cite> directive. If the code
language is specified, the content is parsed and tagged by the <a class="reference external" href="http://pygments.org/">Pygments</a> <a class="footnote-reference brackets" href="#footnote-8" id="footnote-reference-21">8</a>
@@ -999,15 +997,15 @@
as a code block, here the rst file <span class="docutils literal">header_footer.txt</span> with line numbers:</p>
<pre class="code rst literal-block"><code><span class="ln">1 </span>.. header:: Document header
<span class="ln">2 </span>.. footer:: Document footer</code></pre>
-</div>
-</div>
-<div class="section" id="substitution-definitions">
+</section>
+</section>
+<section id="substitution-definitions">
<h2><a class="toc-backref" href="#toc-entry-32"><span class="sectnum">2.15</span> Substitution Definitions</a></h2>
<p>An inline image (<img alt="EXAMPLE" src="../../../docs/user/rst/images/biohazard.png" />) example:</p>
<p>A Unicode example:</p>
<p>(Substitution definitions are not visible in the HTML source.)</p>
-</div>
-<div class="section" id="comments">
+</section>
+<section id="comments">
<h2><a class="toc-backref" href="#toc-entry-33"><span class="sectnum">2.16</span> Comments</a></h2>
<p>Here's one:</p>
<!-- Comments begin with two dots and a space. Anything may
@@ -1018,21 +1016,21 @@
Comments may contain non-ASCII characters: ä ö ü æ ø å -->
<p>(View the HTML source to see the comment.)</p>
-</div>
-<div class="section" id="raw-text">
+</section>
+<section id="raw-text">
<h2><a class="toc-backref" href="#toc-entry-34"><span class="sectnum">2.17</span> Raw text</a></h2>
<p>This does not necessarily look nice, because there may be missing white space.</p>
<p>It's just there to freeze the behavior.</p>
A test.Second test.<div class="myclass">Another test with myclass set.</div><p>This is the <span class="myrawroleclass">fourth test</span> with myrawroleclass set.</p>
-Fifth test in HTML.<br />Line two.</div>
-<div class="section" id="container">
+Fifth test in HTML.<br />Line two.</section>
+<section id="container">
<h2><a class="toc-backref" href="#toc-entry-35"><span class="sectnum">2.18</span> Container</a></h2>
<div class="custom docutils container">
<p>paragraph 1</p>
<p>paragraph 2</p>
</div>
-</div>
-<div class="section" id="colspanning-tables">
+</section>
+<section id="colspanning-tables">
<h2><a class="toc-backref" href="#toc-entry-36"><span class="sectnum">2.19</span> Colspanning tables</a></h2>
<p>This table has a cell spanning two columns:</p>
<table>
@@ -1069,8 +1067,8 @@
</tr>
</tbody>
</table>
-</div>
-<div class="section" id="rowspanning-tables">
+</section>
+<section id="rowspanning-tables">
<h2><a class="toc-backref" href="#toc-entry-37"><span class="sectnum">2.20</span> Rowspanning tables</a></h2>
<p>Here's a table with cells spanning several rows:</p>
<table>
@@ -1102,8 +1100,8 @@
</tr>
</tbody>
</table>
-</div>
-<div class="section" id="complex-tables">
+</section>
+<section id="complex-tables">
<h2><a class="toc-backref" href="#toc-entry-38"><span class="sectnum">2.21</span> Complex tables</a></h2>
<p>Here's a complex table, which should test all features.</p>
<table>
@@ -1151,8 +1149,8 @@
</tr>
</tbody>
</table>
-</div>
-<div class="section" id="list-tables">
+</section>
+<section id="list-tables">
<h2><a class="toc-backref" href="#toc-entry-39"><span class="sectnum">2.22</span> List Tables</a></h2>
<p>Here's a list table exercising all features:</p>
<table class="colwidths-given test" style="width: 40em">
@@ -1198,8 +1196,8 @@
</tr>
</tbody>
</table>
-</div>
-<div class="section" id="custom-roles">
+</section>
+<section id="custom-roles">
<h2><a class="toc-backref" href="#toc-entry-40"><span class="sectnum">2.23</span> Custom Roles</a></h2>
<ul>
<li><p>A role based on an existing role.</p>
@@ -1226,11 +1224,11 @@
<p><span class="green sc" lang="en-gb">British colourful text in small-caps</span>.</p>
</li>
</ul>
-</div>
-</div>
-<div class="section" id="html-specific">
+</section>
+</section>
+<section id="html-specific">
<h1><a class="toc-backref" href="#toc-entry-41"><span class="sectnum">3</span> HTML specific</a></h1>
-<div class="section" id="svg-images">
+<section id="svg-images">
<h2><a class="toc-backref" href="#toc-entry-42"><span class="sectnum">3.1</span> SVG Images</a></h2>
<img alt="../../../docs/user/rst/images/biohazard.svg" class="align-left" src="../../../docs/user/rst/images/biohazard.svg" style="width: 48px; height: 48px;" />
<p>Scalable vector graphics (SVG) images are the only standards-compliable way
@@ -1314,8 +1312,8 @@
<p class="caption"><strong>Figure:</strong> SVG image in a figure.</p>
</div>
</blockquote>
-</div>
-<div class="section" id="swf-images">
+</section>
+<section id="swf-images">
<h2><a class="toc-backref" href="#toc-entry-43"><span class="sectnum">3.2</span> SWF Images</a></h2>
<p>Shockwave Flash is an image/movie format that most modern web browsers
support via a plugin. It is sometimes blocked due to privacy/security
@@ -1326,8 +1324,8 @@
[biohazard.swf]</object>
<p>An SWF image in a 4 cm x 2 em box, left aligned.</p>
<p>An inline SWF image <object data="../../../docs/user/rst/images/biohazard.swf" style="width: 0.8em; height: 0.8em;" type="application/x-shockwave-flash">inline-swf</object> scaled to 0.8 em x 0.8 em.</p>
-</div>
-<div class="section" id="text-level-semantics">
+</section>
+<section id="text-level-semantics">
<h2><a class="toc-backref" href="#toc-entry-44"><span class="sectnum">3.3</span> Text-level semantics</a></h2>
<p><a class="reference external" href="https://html.spec.whatwg.org/#text-level-semantics">HTML 5 tags for representation of text-level semantics</a> <a class="footnote-reference brackets" href="#footnote-13" id="footnote-reference-27">13</a> and their
reStructuredText equivalents.</p>
@@ -1531,8 +1529,8 @@
</blockquote>
</dd>
</dl>
-</div>
-<div class="section" id="indicating-edits">
+</section>
+<section id="indicating-edits">
<h2><a class="toc-backref" href="#toc-entry-45"><span class="sectnum">3.4</span> Indicating Edits</a></h2>
<p><a class="reference external" href="https://html.spec.whatwg.org/multipage/edits.html">HTML tags for representation of edits to the document</a> <a class="footnote-reference brackets" href="#footnote-14" id="footnote-reference-28">14</a> and their
reStructuredText equivalents.</p>
@@ -1566,9 +1564,9 @@
roles to make sense.</p>
</dd>
</dl>
-</div>
-</div>
-<div class="section" id="changes-to-the-html4css1-writer">
+</section>
+</section>
+<section id="changes-to-the-html4css1-writer">
<h1><a class="toc-backref" href="#toc-entry-46"><span class="sectnum">4</span> Changes to the html4css1 writer</a></h1>
<ul class="simple">
<li><p>Use only meta keywords recognized by HTML 5.</p></li>
@@ -1579,7 +1577,7 @@
space.</p></li>
<li><p>Put subtitles in <p> elements.</p></li>
</ul>
-<div class="section" id="field-list-handling">
+<section id="field-list-handling">
<h2><a class="toc-backref" href="#toc-entry-47"><span class="sectnum">4.1</span> Field list handling</a></h2>
<p>The following list demonstrates the problems with the html4css1
approach: the <cite>field-name-limit</cite> setting is given in "number of
@@ -1622,12 +1620,12 @@
<dd><p>must not lead to misalignment of the following content.</p>
</dd>
</dl>
-</div>
-<div class="section" id="styling-with-class-arguments">
+</section>
+<section id="styling-with-class-arguments">
<h2><a class="toc-backref" href="#toc-entry-48"><span class="sectnum">4.2</span> Styling with class arguments</a></h2>
<p>The <span class="docutils literal">plain.css</span> style sheet comes with some pre-defined style variants
that can be choosen via a class argument.</p>
-<div class="section" id="description-lists">
+<section id="description-lists">
<h3><a class="toc-backref" href="#toc-entry-49"><span class="sectnum">4.2.1</span> Description lists</a></h3>
<p>Definition lists with the "description" class argument:</p>
<dl class="description simple">
@@ -1642,8 +1640,8 @@
<dd><p>Starts on the same line and has a hanging indent.</p>
</dd>
</dl>
-</div>
-<div class="section" id="field-list-variants">
+</section>
+<section id="field-list-variants">
<h3><a class="toc-backref" href="#toc-entry-50"><span class="sectnum">4.2.2</span> Field list variants</a></h3>
<p>For field lists, the "compact/open", "narrow" and "run-in" styles are defined
in the style sheet <span class="docutils literal">plain.css</span>.</p>
@@ -1709,8 +1707,8 @@
</dl>
</dd>
</dl>
-</div>
-<div class="section" id="table-variants">
+</section>
+<section id="table-variants">
<h3><a class="toc-backref" href="#toc-entry-51"><span class="sectnum">4.2.3</span> Table variants</a></h3>
<p>The following styles can be applied to individual tables via a class
argument or as document wide setting with the <a class="reference external" href="http://docutils.sourceforge.net/docs/user/config.html#table-style">table-style</a> <a class="footnote-reference brackets" href="#footnote-10" id="footnote-reference-23">10</a> configuration
@@ -1789,17 +1787,17 @@
</tbody>
</table>
</blockquote>
-</div>
-</div>
-</div>
-<div class="section" id="error-handling">
+</section>
+</section>
+</section>
+<section id="error-handling">
<h1><a class="toc-backref" href="#toc-entry-52"><span class="sectnum">5</span> Error Handling</a></h1>
<p>Any errors caught during processing will generate system messages.</p>
<p>There should be five messages in the following, auto-generated
section, "Docutils System Messages":</p>
<!-- section should be added by Docutils automatically -->
-</div>
-<div class="system-messages section">
+</section>
+<section class="system-messages">
<h1>Docutils System Messages</h1>
<div class="system-message" id="system-message-1">
<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">functional/input/data/standard.txt</span>, line 104); <em><a href="#problematic-1">backlink</a></em></p>
@@ -1821,13 +1819,12 @@
<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">functional/input/data/standard.txt</span>, line 441); <em><a href="#problematic-3">backlink</a></em></p>
<p>Duplicate target name, cannot be used as a unique reference: "duplicate target names".</p>
</div>
+</section>
</div>
-</div>
-<div class="footer">
-<hr class="footer" />
+<footer>
<p>Document footer</p>
<p><a class="reference external" href="http://www.w3.org/TR/html5/"><img alt="Conforms to HTML 5" src="http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png" style="width: 88px; height: 31px;" /></a> <a class="reference external" href="http://validator.w3.org/check?uri=referer"><img alt="Check validity!" src="https://www.w3.org/Icons/ValidatorSuite/vs-blue-190.png" style="width: 88px; height: 31px;" /></a> <a class="reference external" href="http://jigsaw.w3.org/css-validator/check/referer"><img alt="Valid CSS 2.1!" src="http://jigsaw.w3.org/css-validator/images/vcss" style="width: 88px; height: 31px;" /></a></p>
-</div>
+</footer>
</body>
</html>
Modified: trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2020-01-27 15:14:57 UTC (rev 8471)
+++ trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2020-01-30 00:44:15 UTC (rev 8472)
@@ -13,7 +13,9 @@
"""
from __future__ import absolute_import
-from . import DocutilsTestSupport
+if __name__ == '__main__':
+ import __init__
+from test_transforms import DocutilsTestSupport # must be imported before docutils
from DocutilsTestSupport import (HtmlWriterPublishPartsTestCase,
HtmlPublishPartsTestSuite)
from docutils import core, __version__
@@ -140,26 +142,26 @@
""",
"""\
{'fragment': '''<p>Some stuff</p>
-<div class="section" id="section">
+<section id="section">
<h1>Section</h1>
<p>Some more stuff</p>
-<div class="section" id="another-section">
+<section id="another-section">
<h2>Another Section</h2>
<p>And even more stuff</p>
-</div>
-</div>\\n''',
+</section>
+</section>\\n''',
'html_body': '''<div class="document" id="title">
<h1 class="title">Title</h1>
<p class="subtitle" id="subtitle">Subtitle</p>
<p>Some stuff</p>
-<div class="section" id="section">
+<section id="section">
<h1>Section</h1>
<p>Some more stuff</p>
-<div class="section" id="another-section">
+<section id="another-section">
<h2>Another Section</h2>
<p>And even more stuff</p>
-</div>
-</div>
+</section>
+</section>
</div>\\n''',
'html_head': '''...<title>Title</title>\\n''',
'html_subtitle': '''<p class="subtitle" id="subtitle">Subtitle</p>\\n''',
@@ -279,37 +281,37 @@
And even more stuff
""",
"""\
-{'fragment': '''<div class="section" id="title">
+{'fragment': '''<section id="title">
<h1>Title</h1>
-<div class="section" id="not-a-subtitle">
+<section id="not-a-subtitle">
<h2>Not A Subtitle</h2>
<p>Some stuff</p>
-<div class="section" id="section">
+<section id="section">
<h3>Section</h3>
<p>Some more stuff</p>
-<div class="section" id="another-section">
+<section id="another-section">
<h4>Another Section</h4>
<p>And even more stuff</p>
-</div>
-</div>
-</div>
-</div>\\n''',
+</section>
+</section>
+</section>
+</section>\\n''',
'html_body': '''<div class="document">
-<div class="section" id="title">
+<section id="title">
<h1>Title</h1>
-<div class="section" id="not-a-subtitle">
+<section id="not-a-subtitle">
<h2>Not A Subtitle</h2>
<p>Some stuff</p>
-<div class="section" id="section">
+<section id="section">
<h3>Section</h3>
<p>Some more stuff</p>
-<div class="section" id="another-section">
+<section id="another-section">
<h4>Another Section</h4>
<p>And even more stuff</p>
-</div>
-</div>
-</div>
-</div>
+</section>
+</section>
+</section>
+</section>
</div>\\n''',
'html_head': '''...<title><string></title>\\n'''}
"""],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|