|
From: <mi...@us...> - 2015-03-11 15:56:32
|
Revision: 7820
http://sourceforge.net/p/docutils/code/7820
Author: milde
Date: 2015-03-11 15:55:43 +0000 (Wed, 11 Mar 2015)
Log Message:
-----------
Announce the new HTML writers. Small fixes to get valid HTML.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/writers/html_base/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_html_base.html
trunk/docutils/test/functional/expected/standalone_rst_xhtml11.xhtml
trunk/docutils/test/functional/input/standalone_rst_html_base.txt
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2015-03-11 15:47:51 UTC (rev 7819)
+++ trunk/docutils/HISTORY.txt 2015-03-11 15:55:43 UTC (rev 7820)
@@ -33,7 +33,16 @@
- Add ``\colon`` macro, fix spacing around colons. Fixes [ 246 ].
- New upstream version (additional macros, piecewise integrals and sums).
-
+
+* docutils/writers/html_base/
+
+ - New HTML writer generating basic HTML (`polyglot markup`_ conforming to
+ both, `HTML 5`_ and `XHTML 1.0`_ (transitional)).
+
+ New stylesheet ``html-base.css`` for default layout using CSS 2.1 rules.
+
+ Also base for the `xhtml11` writer.
+
* docutils/writers/html4css1/__init__.py
- Add "docutils" to class values for "container" object to address [ 267 ].
@@ -43,11 +52,9 @@
* docutils/writers/xhtml11/
- - New HTML writer generating `XHTML1.1`_ styled with CSS2.1
+ - New HTML writer generating `XHTML 1.1`_ styled with CSS2.1
Moved to the docutils core from sandbox/html4strict.
- .. _XHTML1.1: http://www.w3.org/TR/xhtml11/
-
* docutils/writers/latex2e/__init__.py
- use absolute path for ``default_template_path``.
@@ -61,6 +68,17 @@
- Fix [ 262 ] Use ``\linewidth`` instead of ``\textwidth`` for figures,
admonitions and docinfo.
+* tools/
+
+ - New front-ends ``rst2xhtml.py`` and ``rst2html5.py`` for the
+ corresponding writers.
+
+.. _polyglot markup: http://www.w3.org/TR/html-polyglot/
+.. _HTML 5: http://www.w3.org/TR/html5/
+.. _XHTML 1.0: http://www.w3.org/TR/xhtml1/
+.. _XHTML 1.1: http://www.w3.org/TR/xhtml11/
+
+
Release 0.12 (2014-07-06)
=========================
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2015-03-11 15:47:51 UTC (rev 7819)
+++ trunk/docutils/RELEASE-NOTES.txt 2015-03-11 15:55:43 UTC (rev 7820)
@@ -38,7 +38,7 @@
See `Porting Python 2 Code to Python 3`_ and
`future: clean single-source support for Python 2/3`_
- - Drop support for python 2.4 after 0.12 release.
+ - Drop support for python 2.4 after release 0.12.
.. _Porting Python 2 Code to Python 3: https://docs.python.org/3/howto/pyporting.html
.. _future\: clean single-source support for Python 2/3: http://python-future.org
@@ -46,7 +46,21 @@
Changes Since 0.12
==================
+* docutils/writers/
+ - New HTML writers generating `HTML 5`_ and `XHTML 1.1`_.
+
+ New stylesheet ``html-base.css`` for default layout using CSS 2.1.
+
+* tools/
+
+ - New front-ends ``rst2xhtml.py`` and ``rst2html5.py`` for the
+ corresponding writers.
+
+.. _HTML 5: http://www.w3.org/TR/html5/
+.. _XHTML 1.1: http://www.w3.org/TR/xhtml11/
+
+
Release 0.12 (2014-07-06)
=========================
Modified: trunk/docutils/docutils/writers/html_base/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html_base/__init__.py 2015-03-11 15:47:51 UTC (rev 7819)
+++ trunk/docutils/docutils/writers/html_base/__init__.py 2015-03-11 15:55:43 UTC (rev 7820)
@@ -19,7 +19,7 @@
"""
Basic HyperText Markup Language document tree Writer.
-The output conforms to the `HTML 5` specification as well as
+The output conforms to the `HTML 5` specification as well as
to `XHTML 1.0 transitional`.
The cascading style sheet "html-base.css" is required for proper viewing.
@@ -298,7 +298,8 @@
def encode(self, text):
"""Encode special characters in `text` & return."""
- # @@@ A codec to do these and all other HTML entities would be nice.
+ # Use only named entities known in both XML and HTML
+ # other characters are automatically encoded "by number" if required.
text = unicode(text)
return text.translate({
ord('&'): u'&',
@@ -432,10 +433,6 @@
return
child['classes'].append(class_)
- def set_first_last(self, node):
- pass
- # TODO: remove calls to this function
-
def visit_Text(self, node):
text = node.astext()
encoded = self.encode(text)
@@ -471,12 +468,11 @@
def visit_admonition(self, node):
node['classes'].insert(0, 'admonition')
self.body.append(self.starttag(node, 'div'))
- self.set_first_last(node)
def depart_admonition(self, node=None):
self.body.append('</div>\n')
- attribution_formats = {'dash': ('—', ''),
+ attribution_formats = {'dash': (u'\u2014', ''),
'parentheses': ('(', ')'),
'parens': ('(', ')'),
'none': ('', '')}
@@ -486,9 +482,10 @@
self.context.append(suffix)
self.body.append(
self.starttag(node, 'p', prefix, CLASS='attribution'))
+ self.body.append(self.starttag(node, 'cite', ''))
def depart_attribution(self, node):
- self.body.append(self.context.pop() + '</p>\n')
+ self.body.append('</cite>' + self.context.pop() + '</p>\n')
# author, authors
# ---------------
@@ -699,7 +696,6 @@
def visit_definition(self, node):
self.body.append('</dt>\n')
self.body.append(self.starttag(node, 'dd', ''))
- self.set_first_last(node)
def depart_definition(self, node):
self.body.append('</dd>\n')
@@ -744,7 +740,7 @@
def depart_docinfo(self, node):
self.body.append('</dl>\n')
-
+
def visit_docinfo_item(self, node, name, meta=True):
if meta:
meta_tag = '<meta name="%s" content="%s" />\n' \
@@ -818,9 +814,9 @@
node.parent.column += node['morecols']
self.body.append(self.starttag(node, tagname, '', **atts))
self.context.append('</%s>\n' % tagname.lower())
- if len(node) == 0: # empty cell
- self.body.append(' ')
- self.set_first_last(node)
+ # TODO: why did the html4css1 writer insert an NBSP into empty cells?
+ # if len(node) == 0: # empty cell
+ # self.body.append(' ') # no-break space
def depart_entry(self, node):
self.body.append(self.context.pop())
@@ -905,6 +901,7 @@
# ---------
# use definition list instead of table for footnote text
+ # TODO: use the new HTML5 element <aside>? (Also for footnote text)
def visit_footnote(self, node):
if not self.in_footnote_list:
self.body.append('<dl class="footnote">\n')
@@ -1134,9 +1131,13 @@
def visit_literal_block(self, node):
self.body.append(self.starttag(node, 'pre', '', CLASS='literal-block'))
+ if 'code' in node.get('classes', []):
+ self.body.append('<code>')
def depart_literal_block(self, node):
- self.body.append('\n</pre>\n')
+ if 'code' in node.get('classes', []):
+ self.body.append('</code>')
+ self.body.append('</pre>\n')
def visit_math(self, node, math_env=''):
# If the method is called from visit_math_block(), math_env != ''.
@@ -1401,7 +1402,6 @@
def visit_sidebar(self, node):
self.body.append(
self.starttag(node, 'div', CLASS='sidebar'))
- self.set_first_last(node)
self.in_sidebar = True
def depart_sidebar(self, node):
@@ -1612,6 +1612,7 @@
def depart_title_reference(self, node):
self.body.append('</cite>')
+ # TODO: use the new HTML5 element <aside>? (Also for footnote text)
def visit_topic(self, node):
self.body.append(self.starttag(node, 'div', CLASS='topic'))
self.topic_classes = node['classes']
@@ -1647,10 +1648,10 @@
Here "simple" means a list item containing nothing other than a single
paragraph, a simple list, or a paragraph followed by a simple list.
-
+
This version also checks for simple field lists and docinfo.
"""
-
+
def default_visit(self, node):
raise nodes.NodeFound
Modified: trunk/docutils/test/functional/expected/standalone_rst_html_base.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html_base.html 2015-03-11 15:47:51 UTC (rev 7819)
+++ trunk/docutils/test/functional/expected/standalone_rst_html_base.html 2015-03-11 15:55:43 UTC (rev 7820)
@@ -352,13 +352,11 @@
<pre class="literal-block">if literal_block:
text = 'is left as-is'
spaces_and_linebreaks = 'are preserved'
- markup_processing = None
-</pre>
+ markup_processing = None</pre>
<p>Or they can be quoted without indentation:</p>
<pre class="literal-block">>> Great idea!
>
-> Why didn't I think of that?
-</pre>
+> Why didn't I think of that?</pre>
</div>
<div class="section" id="line-blocks">
<h2><a class="toc-backref" href="#id51"><span class="sectnum">2.8</span> Line Blocks</a></h2>
@@ -443,7 +441,7 @@
end, much much thicker in the middle and then thin again at the
far end. That is my theory, it is mine, and belongs to me and I
own it, and what it is too.</p>
-<p class="attribution">—Anne Elk (Miss)</p>
+<p class="attribution">—<cite>Anne Elk (Miss)</cite></p>
</blockquote>
<p>The language of a quote (like any other object) can be specified by
a class attribute:</p>
@@ -756,8 +754,7 @@
<p>Another compound statement:</p>
<div class="compound">
<p class="compound-first">Compound 2, a literal block:</p>
-<pre class="compound-middle literal-block">Compound 2, literal.
-</pre>
+<pre class="compound-middle literal-block">Compound 2, literal.</pre>
<p class="compound-last">Compound 2, this is a test.</p>
</div>
<div class="compound">
@@ -765,8 +762,7 @@
</div>
<div class="compound">
<pre class="compound-first literal-block">Compound 4.
-This one starts with a literal block.
-</pre>
+This one starts with a literal block.</pre>
<p class="compound-last">Compound 4, a paragraph.</p>
</div>
<p>Now something <em>really</em> perverted -- a nested compound block. This is
@@ -815,8 +811,7 @@
This line is indented. The next line is blank.
Inline markup is supported, e.g. <em>emphasis</em>, <strong>strong</strong>, <span class="docutils literal">literal
-text</span>, footnotes <a class="footnote-reference" href="#id8" id="id22">[1]</a>, <span class="target" id="hyperlink-targets">hyperlink targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.
-</pre>
+text</span>, footnotes <a class="footnote-reference" href="#id8" id="id22">[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">
<h3><a class="toc-backref" href="#id95"><span class="sectnum">2.14.9</span> Code</a></h3>
@@ -826,14 +821,12 @@
is turned off using the <span class="docutils literal"><span class="pre">syntax-highlight</span></span> config setting in the test
conversions in order to get identical results with/without installed
Pygments highlighter.)</p>
-<pre class="code python literal-block">print 'This is Python code.'
-</pre>
+<pre class="code python literal-block"><code>print 'This is Python code.'</code></pre>
<p>The <span class="docutils literal"><span class="pre">:number-lines:</span></span> option (with optional start value) generates line
numbers:</p>
-<pre class="code python literal-block"><span class="ln"> 8 </span># print integers from 0 to 9:
+<pre class="code python literal-block"><code><span class="ln"> 8 </span># print integers from 0 to 9:
<span class="ln"> 9 </span>for i in range(10):
-<span class="ln">10 </span> print i
-</pre>
+<span class="ln">10 </span> print i</code></pre>
<p>For inline code snippets, there is the <cite>code</cite> role, which can be used
directly (the code will not be parsed/tagged, as the language is not known)
or as base for special code roles, e.g. the LaTeX code in the next
@@ -842,9 +835,8 @@
<code class="tex">\alpha = f(x)</code> prints <span class="formula"><i>α</i> = <i>f</i>(<i>x</i>)</span>.</p>
<p>The <span class="docutils literal">:code:</span> option of the <cite>include</cite> directive sets the included content
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"><span class="ln">1 </span>.. header:: Document header
-<span class="ln">2 </span>.. footer:: Document footer
-</pre>
+<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">
@@ -992,7 +984,7 @@
<tr><td><p>body row 5</p></td>
<td colspan="2"><p>Cells may also be
empty: <span class="docutils literal"><span class="pre">--></span></span></p></td>
-<td> </td>
+<td></td>
</tr>
</tbody>
</table>
@@ -1053,8 +1045,7 @@
<style type="text/css"><!--
.green {color: green;}
.sc {font-variant: small-caps;}
- --></style>
-</pre>
+ --></style></pre>
<p><span class="green sc" lang="en-gb">British colourful text in small-caps</span>.</p>
</li>
</ul>
@@ -1180,8 +1171,7 @@
<dd><p>of the field name width is possible with CSS instead
of the <cite>field-name-limit</cite> configuration setting, for
example:</p>
-<pre class="literal-block">dl.field-list > dd { margin-left: 6em; }
-</pre>
+<pre class="literal-block">dl.field-list > dd { margin-left: 6em; }</pre>
</dd>
</dl>
<div class="section" id="styling-with-class-arguments">
@@ -1436,7 +1426,7 @@
<div class="footer">
<hr class="footer" />
<p>Document footer</p>
-<p><a class="reference external" href="http://validator.w3.org/check?uri=referer"><img alt="Conforms to HTML 5!" src="https://validator-suite.w3.org/icons/vs-blue-256.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>
+<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://validator-suite.w3.org/icons/vs-blue-256.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>
</body>
Modified: trunk/docutils/test/functional/expected/standalone_rst_xhtml11.xhtml
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xhtml11.xhtml 2015-03-11 15:47:51 UTC (rev 7819)
+++ trunk/docutils/test/functional/expected/standalone_rst_xhtml11.xhtml 2015-03-11 15:55:43 UTC (rev 7820)
@@ -354,13 +354,11 @@
<pre class="literal-block">if literal_block:
text = 'is left as-is'
spaces_and_linebreaks = 'are preserved'
- markup_processing = None
-</pre>
+ markup_processing = None</pre>
<p>Or they can be quoted without indentation:</p>
<pre class="literal-block">>> Great idea!
>
-> Why didn't I think of that?
-</pre>
+> Why didn't I think of that?</pre>
</div>
<div class="section" id="line-blocks">
<h2><a class="toc-backref" href="#id51"><span class="sectnum">2.8</span> Line Blocks</a></h2>
@@ -445,7 +443,7 @@
end, much much thicker in the middle and then thin again at the
far end. That is my theory, it is mine, and belongs to me and I
own it, and what it is too.</p>
-<p class="attribution">—Anne Elk (Miss)</p>
+<p class="attribution">—<cite>Anne Elk (Miss)</cite></p>
</blockquote>
<p>The language of a quote (like any other object) can be specified by
a class attribute:</p>
@@ -758,8 +756,7 @@
<p>Another compound statement:</p>
<div class="compound">
<p class="compound-first">Compound 2, a literal block:</p>
-<pre class="compound-middle literal-block">Compound 2, literal.
-</pre>
+<pre class="compound-middle literal-block">Compound 2, literal.</pre>
<p class="compound-last">Compound 2, this is a test.</p>
</div>
<div class="compound">
@@ -767,8 +764,7 @@
</div>
<div class="compound">
<pre class="compound-first literal-block">Compound 4.
-This one starts with a literal block.
-</pre>
+This one starts with a literal block.</pre>
<p class="compound-last">Compound 4, a paragraph.</p>
</div>
<p>Now something <em>really</em> perverted -- a nested compound block. This is
@@ -817,8 +813,7 @@
This line is indented. The next line is blank.
Inline markup is supported, e.g. <em>emphasis</em>, <strong>strong</strong>, <span class="docutils literal">literal
-text</span>, footnotes <a class="footnote-reference" href="#id8" id="id22">[1]</a>, <span class="target" id="hyperlink-targets">hyperlink targets</span>, and <a class="reference external" href="http://www.python.org/">references</a>.
-</pre>
+text</span>, footnotes <a class="footnote-reference" href="#id8" id="id22">[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">
<h3><a class="toc-backref" href="#id96"><span class="sectnum">2.14.9</span> Code</a></h3>
@@ -828,14 +823,12 @@
is turned off using the <span class="docutils literal"><span class="pre">syntax-highlight</span></span> config setting in the test
conversions in order to get identical results with/without installed
Pygments highlighter.)</p>
-<pre class="code python literal-block">print 'This is Python code.'
-</pre>
+<pre class="code python literal-block"><code>print 'This is Python code.'</code></pre>
<p>The <span class="docutils literal"><span class="pre">:number-lines:</span></span> option (with optional start value) generates line
numbers:</p>
-<pre class="code python literal-block"><span class="ln"> 8 </span># print integers from 0 to 9:
+<pre class="code python literal-block"><code><span class="ln"> 8 </span># print integers from 0 to 9:
<span class="ln"> 9 </span>for i in range(10):
-<span class="ln">10 </span> print i
-</pre>
+<span class="ln">10 </span> print i</code></pre>
<p>For inline code snippets, there is the <cite>code</cite> role, which can be used
directly (the code will not be parsed/tagged, as the language is not known)
or as base for special code roles, e.g. the LaTeX code in the next
@@ -845,9 +838,8 @@
<mrow><mi>α</mi><mo>=</mo><mi>f</mi><mo>(</mo><mi>x</mi><mo>)</mo></mrow></math>.</p>
<p>The <span class="docutils literal">:code:</span> option of the <cite>include</cite> directive sets the included content
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"><span class="ln">1 </span>.. header:: Document header
-<span class="ln">2 </span>.. footer:: Document footer
-</pre>
+<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">
@@ -995,7 +987,7 @@
<tr><td><p>body row 5</p></td>
<td colspan="2"><p>Cells may also be
empty: <span class="docutils literal"><span class="pre">--></span></span></p></td>
-<td> </td>
+<td></td>
</tr>
</tbody>
</table>
@@ -1056,8 +1048,7 @@
<style type="text/css"><!--
.green {color: green;}
.sc {font-variant: small-caps;}
- --></style>
-</pre>
+ --></style></pre>
<p><span class="green sc" xml:lang="en-gb">British colourful text in small-caps</span>.</p>
</li>
</ul>
@@ -1202,8 +1193,7 @@
<dd><p>of the field name width is possible with CSS instead
of the <cite>field-name-limit</cite> configuration setting, for
example:</p>
-<pre class="literal-block">dl.field-list > dd { margin-left: 6em; }
-</pre>
+<pre class="literal-block">dl.field-list > dd { margin-left: 6em; }</pre>
</dd>
</dl>
<div class="section" id="styling-with-class-arguments">
Modified: trunk/docutils/test/functional/input/standalone_rst_html_base.txt
===================================================================
--- trunk/docutils/test/functional/input/standalone_rst_html_base.txt 2015-03-11 15:47:51 UTC (rev 7819)
+++ trunk/docutils/test/functional/input/standalone_rst_html_base.txt 2015-03-11 15:55:43 UTC (rev 7820)
@@ -202,7 +202,7 @@
Maths
-----
-For maximal compatibility, the ``html-output`` setting defaults to »HTML«.
+For maximal compatibility, the ``html-output`` setting defaults to »HTML«.
(HTML 5 accepts also MathML and SVG as nested languages.)
The linear mapping :math:`f: \mathbb{C}^{N}\longmapsto\mathbb{C}^{N}`
@@ -219,12 +219,18 @@
.. include:: data/errors.txt
-.. footer:: |validator| |valid-CSS2|
+.. footer:: |HTML 5| |validator| |valid-CSS2|
+.. |HTML 5| image:: http://www.w3.org/html/logo/badge/html5-badge-h-css3-semantics.png
+ :height: 31
+ :width: 88
+ :alt: Conforms to HTML 5
+ :target: http://www.w3.org/TR/html5/
+
.. |validator| image:: https://validator-suite.w3.org/icons/vs-blue-256.png
:height: 31
:width: 88
- :alt: Conforms to HTML 5!
+ :alt: Check validity!
:target: http://validator.w3.org/check?uri=referer
.. |valid-CSS2| image:: http://jigsaw.w3.org/css-validator/images/vcss
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|