|
From: <mi...@us...> - 2017-08-08 21:39:23
|
Revision: 8161
http://sourceforge.net/p/docutils/code/8161
Author: milde
Date: 2017-08-08 21:39:19 +0000 (Tue, 08 Aug 2017)
Log Message:
-----------
Fix [ 323 ]: do not add ``\\\\phantomsection`` and whitespace to ``parts["title"].
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/latex2e/default.tex
trunk/docutils/test/functional/expected/cyrillic.tex
trunk/docutils/test/functional/expected/latex_babel.tex
trunk/docutils/test/functional/expected/latex_cornercases.tex
trunk/docutils/test/functional/expected/latex_docinfo.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/functional/expected/xetex-cyrillic.tex
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-08-08 20:26:12 UTC (rev 8160)
+++ trunk/docutils/HISTORY.txt 2017-08-08 21:39:19 UTC (rev 8161)
@@ -16,13 +16,19 @@
Changes Since 0.14
==================
-* infrastructure automatisms
+* General
+ - infrastructure automatisms.
+
+* docutils/writers/latex2e/__init__.py
+
+ - Fix [ 323 ] don't add ``\phantomsection`` and whitespace to
+ ``parts['title'].
+
+
Release 0.14 (2017-08-03)
=========================
-As rc2.
-
* docs/ref/docutils.dtd:
- Enable validation of Docutils XML documents against the DTD:
@@ -117,7 +123,7 @@
documents.
- The heading/title of admonitions now reflects the language
specified by the ``language`` setting.
- - Fixed [ 306 ] only first of multiple "image" directives with the same URL
+ - Fixed [ 306 ] only first of multiple "image" directives with the same URL
shown in output.
- Fixed [ 282 ] python3: AttributeError.
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2017-08-08 20:26:12 UTC (rev 8160)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2017-08-08 21:39:19 UTC (rev 8161)
@@ -217,9 +217,9 @@
config_section_dependencies = ('writers',)
head_parts = ('head_prefix', 'requirements', 'latex_preamble',
- 'stylesheet', 'fallbacks', 'pdfsetup',
- 'title', 'subtitle', 'titledata')
- visitor_attributes = head_parts + ('body_pre_docinfo', 'docinfo',
+ 'stylesheet', 'fallbacks', 'pdfsetup', 'titledata')
+ visitor_attributes = head_parts + ('title', 'subtitle',
+ 'body_pre_docinfo', 'docinfo',
'dedication', 'abstract', 'body')
output = None
@@ -596,8 +596,7 @@
}{}"""
# PreambleCmds.lineblock._depends = 'providelength'
-PreambleCmds.linking = r"""
-%% hyperlinks:
+PreambleCmds.linking = r"""%% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
\usepackage[%s]{hyperref}
\usepackage{bookmark}
@@ -1687,6 +1686,7 @@
self.out.append('}\n')
def visit_author(self, node):
+ self.pdfauthor.append(self.attval(node.astext()))
self.visit_docinfo_item(node, 'author')
def depart_author(self, node):
@@ -1922,8 +1922,6 @@
'\\end{center}\n')
def visit_docinfo_item(self, node, name):
- if name == 'author':
- self.pdfauthor.append(self.attval(node.astext()))
if self.use_latex_docinfo:
if name in ('author', 'organization', 'contact', 'address'):
# We attach these to the last author. If any of them precedes
@@ -1989,12 +1987,10 @@
# 'author', 'organization', 'contact', 'address' and 'date')
if self.title or (
self.use_latex_docinfo and (self.author_stack or self.date)):
- # with the default template, titledata is written to the preamble
- self.titledata.append('%%% Title Data')
# \title (empty \title prevents error with \maketitle)
+ title = [''.join(self.title)]
if self.title:
- self.title.insert(0, '\\phantomsection%\n ')
- title = [''.join(self.title)] + self.title_labels
+ title += self.title_labels
if self.subtitle:
title += [r'\\ % subtitle',
r'\DUdocumentsubtitle{%s}' % ''.join(self.subtitle)
Modified: trunk/docutils/docutils/writers/latex2e/default.tex
===================================================================
--- trunk/docutils/docutils/writers/latex2e/default.tex 2017-08-08 20:26:12 UTC (rev 8160)
+++ trunk/docutils/docutils/writers/latex2e/default.tex 2017-08-08 21:39:19 UTC (rev 8161)
@@ -6,9 +6,9 @@
%%% User specified packages and stylesheets
$stylesheet
%%% Fallback definitions for Docutils-specific commands
-$fallbacks$pdfsetup
-$titledata
+$fallbacks
+$pdfsetup
%%% Body
\begin{document}
-$body_pre_docinfo$docinfo$dedication$abstract$body
+$titledata$body_pre_docinfo$docinfo$dedication$abstract$body
\end{document}
Modified: trunk/docutils/test/functional/expected/cyrillic.tex
===================================================================
--- trunk/docutils/test/functional/expected/cyrillic.tex 2017-08-08 20:26:12 UTC (rev 8160)
+++ trunk/docutils/test/functional/expected/cyrillic.tex 2017-08-08 21:39:19 UTC (rev 8161)
@@ -28,7 +28,6 @@
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
-
%%% Body
\begin{document}
Modified: trunk/docutils/test/functional/expected/latex_babel.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_babel.tex 2017-08-08 20:26:12 UTC (rev 8160)
+++ trunk/docutils/test/functional/expected/latex_babel.tex 2017-08-08 21:39:19 UTC (rev 8161)
@@ -31,7 +31,6 @@
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
}{}
-
%%% Body
\begin{document}
Modified: trunk/docutils/test/functional/expected/latex_cornercases.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_cornercases.tex 2017-08-08 20:26:12 UTC (rev 8160)
+++ trunk/docutils/test/functional/expected/latex_cornercases.tex 2017-08-08 21:39:19 UTC (rev 8161)
@@ -37,15 +37,12 @@
pdftitle={Some Tests for the LaTeX Writer},
}
-%%% Title Data
-\title{\phantomsection%
- Some Tests for the LaTeX Writer%
+%%% Body
+\begin{document}
+\title{Some Tests for the LaTeX Writer%
\label{some-tests-for-the-latex-writer}}
\author{}
\date{}
-
-%%% Body
-\begin{document}
\maketitle
These tests contain unusual combinations of syntax elements which may cause
Modified: trunk/docutils/test/functional/expected/latex_docinfo.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_docinfo.tex 2017-08-08 20:26:12 UTC (rev 8160)
+++ trunk/docutils/test/functional/expected/latex_docinfo.tex 2017-08-08 21:39:19 UTC (rev 8161)
@@ -25,7 +25,8 @@
pdfauthor={Foo Fred;Bar Barney}
}
-%%% Title Data
+%%% Body
+\begin{document}
\title{}
\author{Foo Fred\\
Food Foomatics \& Friends\\
@@ -38,9 +39,6 @@
Barbara St 16\\
South Barwell}
\date{}
-
-%%% Body
-\begin{document}
\maketitle
\end{document}
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2017-08-08 20:26:12 UTC (rev 8160)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2017-08-08 21:39:19 UTC (rev 8161)
@@ -196,9 +196,9 @@
pdfauthor={David Goodger;Me;Myself;I}
}
-%%% Title Data
-\title{\phantomsection%
- reStructuredText Test Document%
+%%% Body
+\begin{document}
+\title{reStructuredText Test Document%
\label{restructuredtext-test-document}%
\label{doctitle}%
\\ % subtitle%
@@ -207,9 +207,6 @@
\label{subtitle}}
\author{}
\date{}
-
-%%% Body
-\begin{document}
\maketitle
% Docinfo
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2017-08-08 20:26:12 UTC (rev 8160)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2017-08-08 21:39:19 UTC (rev 8161)
@@ -186,7 +186,6 @@
\hspace*{\fill}\hrulefill\hspace*{\fill}
\vskip 0.5\baselineskip
}
-
% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
@@ -198,9 +197,7 @@
pdfauthor={David Goodger;Me;Myself;I}
}
-%%% Title Data
-\title{\phantomsection%
- reStructuredText Test Document%
+\title{reStructuredText Test Document%
\label{restructuredtext-test-document}%
\label{doctitle}%
\\ % subtitle%
Modified: trunk/docutils/test/functional/expected/xetex-cyrillic.tex
===================================================================
--- trunk/docutils/test/functional/expected/xetex-cyrillic.tex 2017-08-08 20:26:12 UTC (rev 8160)
+++ trunk/docutils/test/functional/expected/xetex-cyrillic.tex 2017-08-08 21:39:19 UTC (rev 8161)
@@ -26,7 +26,6 @@
% titlereference role
\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
-
% hyperlinks:
\ifthenelse{\isundefined{\hypersetup}}{
\usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue,unicode=false]{hyperref}
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2017-08-08 20:26:12 UTC (rev 8160)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2017-08-08 21:39:19 UTC (rev 8161)
@@ -45,10 +45,9 @@
$stylesheet
%%% Fallback definitions for Docutils-specific commands
$fallbacks$pdfsetup
-$titledata
%%% Body
\begin{document}
-""")
+$titledata""")
parts = dict(
head_prefix = r"""\documentclass[a4paper]{article}
@@ -899,9 +898,7 @@
pdfsetup=parts['pdfsetup'] + r"""\hypersetup{
pdftitle={This is the Title},
}
-""", titledata=r"""%%% Title Data
-\title{\phantomsection%
- This is the \emph{Title}%
+""", titledata=r"""\title{This is the \emph{Title}%
\label{this-is-the-title}%
\\ % subtitle%
\DUdocumentsubtitle{This is the \emph{Subtitle}}%
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-08-10 17:51:04
|
Revision: 8162
http://sourceforge.net/p/docutils/code/8162
Author: milde
Date: 2017-08-10 17:51:01 +0000 (Thu, 10 Aug 2017)
Log Message:
-----------
Documentation update: Dropped support for Python 2.4, 2.5, 3.1, and 3.2.
No change to the code yet, but from now on constructs requiring 2.6 or later
can be checked in.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/README.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/dev/distributing.txt
trunk/docutils/docs/dev/release.txt
trunk/docutils/docs/dev/testing.txt
trunk/docutils/docs/dev/todo.txt
trunk/docutils/docs/user/odt.txt
trunk/docutils/docutils/io.py
trunk/docutils/setup.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-08-08 21:39:19 UTC (rev 8161)
+++ trunk/docutils/HISTORY.txt 2017-08-10 17:51:01 UTC (rev 8162)
@@ -18,6 +18,7 @@
* General
+ - Dropped support for Python 2.4, 2.5, 3.1, and 3.2.
- infrastructure automatisms.
* docutils/writers/latex2e/__init__.py
Modified: trunk/docutils/README.txt
===================================================================
--- trunk/docutils/README.txt 2017-08-08 21:39:19 UTC (rev 8161)
+++ trunk/docutils/README.txt 2017-08-10 17:51:01 UTC (rev 8162)
@@ -16,7 +16,7 @@
This is for those who want to get up & running quickly.
-1. Docutils requires Python (version 2.4 or later), available from
+1. Docutils requires Python (version 2.6 or later), available from
http://www.python.org/
@@ -103,8 +103,8 @@
============
To run the code, Python_ must be installed.
-Docutils is compatible with Python versions from 2.4 up to 2.7 and
-versions 3.1 to 3.5 (cf. `Python 3 compatibility`_).
+Docutils is compatible with Python versions 2.6, 2.7, and
+versions 3.3 to 3.5 (cf. `Python 3 compatibility`_).
Docutils uses the following packages for enhanced functionality, if they are
installed:
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2017-08-08 21:39:19 UTC (rev 8161)
+++ trunk/docutils/RELEASE-NOTES.txt 2017-08-10 17:51:01 UTC (rev 8162)
@@ -22,9 +22,6 @@
Future changes
==============
-* Drop support for Python 2.4, 2.5, 3.1, and 3.2 immediately after the 0.14
- release.
-
* Remove the `handle_io_errors` option from io.FileInput/Output.
Used by Sphinx up to version 1.3.1, fixed in 1.3.2 (Nov 29, 2015).
@@ -41,6 +38,18 @@
.. _rst2html.py: docs/user/tools.html#rst2html-py
+Release 0.15b.dev
+=================
+
+.. Note::
+
+ Docutils 0.14.x is the last version supporting Python 2.4, 2.5,
+ 3.1, and 3.2.
+
+ Docutils 0.15.x is compatible with Python versions 2.6, 2.7 and 3.3 to 3.5
+ (cf. `Python 3 compatibility`_).
+
+
Release 0.14 (2017-08-03)
=========================
Modified: trunk/docutils/docs/dev/distributing.txt
===================================================================
--- trunk/docutils/docs/dev/distributing.txt 2017-08-08 21:39:19 UTC (rev 8161)
+++ trunk/docutils/docs/dev/distributing.txt 2017-08-10 17:51:01 UTC (rev 8162)
@@ -28,7 +28,7 @@
Docutils has the following dependencies:
-* Python 2.4 or later is required. Use ">= Python 2.4" in the
+* Python 2.6 or later is required. Use ">= Python 2.6" in the
dependencies.
* Docutils may optionally make use of the PIL (`Python Imaging
Modified: trunk/docutils/docs/dev/release.txt
===================================================================
--- trunk/docutils/docs/dev/release.txt 2017-08-08 21:39:19 UTC (rev 8161)
+++ trunk/docutils/docs/dev/release.txt 2017-08-10 17:51:01 UTC (rev 8162)
@@ -13,7 +13,7 @@
Assumptions and their failure
-----------------------------
-On the test machine python2.4, 2.5, 2.6, 2.7 and 3.2, 3.3, and 3.4
+On the test machine python 2.6, 2.7 and 3.2, 3.3, and 3.4
are installed.
Some in /usr/ some under /usr/local.
Modified: trunk/docutils/docs/dev/testing.txt
===================================================================
--- trunk/docutils/docs/dev/testing.txt 2017-08-08 21:39:19 UTC (rev 8161)
+++ trunk/docutils/docs/dev/testing.txt 2017-08-10 17:51:01 UTC (rev 8162)
@@ -38,21 +38,19 @@
Python Versions
===============
-A docutils release has a commitment to support a minimum version and
+A docutils release has a commitment to support a minimum version and
beyond. Before a release is cut, tests must pass in all supported python
versions.
-The Docutils 0.10 release supports Python 2.4 or later.
-Versions after 0.12 will drop python 2.4, supporting **2.5** and later.
+The Docutils 0.15 release supports Python 2.6 or later.
-Therefore, you should install python 2.5, as well as the latest Python
-(3.4 at the time of this writing) installed and always run the tests on
-all of them. In a pinch, the edge cases (2.5, and 3.4) should cover most
-of it.
+Therefore, you should install python 2.6, 2.7 as well as 3.3 up to the
+latest Python (3.5 at the time of this writing) installed and always run the
+tests on all of them. In a pinch, the edge cases (2.6, and 3.5) should cover
+most of it.
Good resources covering the differences between Python versions:
-* `What's New in Python 2.5`__
* `What's New in Python 2.6`__
* `What's New in Python 2.7`__
* `What's New in Python 3.3`__
@@ -59,7 +57,6 @@
* `What's New in Python 3.4`__
* `PEP 290 - Code Migration and Modernization`__
-__ http://www.python.org/doc/2.5.2/whatsnew/whatsnew25.html
__ http://docs.python.org/whatsnew/2.6.html
__ http://docs.python.org/whatsnew/2.7.html
__ https://docs.python.org/3/whatsnew/3.3.html
@@ -75,7 +72,7 @@
Testing across multiple python versions
---------------------------------------
-`pyenv`_ can be installed and configured (see `installing pyenv`_) to
+`pyenv`_ can be installed and configured (see `installing pyenv`_) to
test multiple python versions::
# assuming your system runs 2.7.x
@@ -82,7 +79,7 @@
pyenv install 2.6.9
pyenv install 3.3.6
pyenv install 3.4.3
- pyenv global system 2.5.6 2.6.9 3.3.6 3.4.3
+ pyenv global system 2.6.9 3.3.6 3.4.3
# reset your shims
rm -rf ~/.pyenv/shims && pyenv rehash
@@ -90,7 +87,7 @@
This will give you ``python2.6``, ``python2.7``, ``python3.3`` and
``python3.4``. Along with that, ``pip2.6``, ``pip2.7`` and so on.
-To save time, you can use `tox`_ to test docutils on versions 2.6+. To
+To save time, you can use `tox`_. To
install tox, you can use ``easy_install tox`` or ``pip install tox``.
From shell::
@@ -97,8 +94,6 @@
cd docutils
tox
-Note: tox and virtualenv only supports python 2.6 and onward.
-
.. _tox: https://tox.readthedocs.org/en/latest/
.. _pyenv: https://github.com/yyuu/pyenv
.. _installing pyenv: https://github.com/yyuu/pyenv#installation
Modified: trunk/docutils/docs/dev/todo.txt
===================================================================
--- trunk/docutils/docs/dev/todo.txt 2017-08-08 21:39:19 UTC (rev 8161)
+++ trunk/docutils/docs/dev/todo.txt 2017-08-10 17:51:01 UTC (rev 8162)
@@ -75,8 +75,6 @@
(Cf. `Porting Python 2 Code to Python 3`_ and
`clean single-source support for Python 2/3`_.)
- - Gradually phase out support for Python 2.4 and 2.5 first.
-
.. _Porting Python 2 Code to Python 3:
https://docs.python.org/3/howto/pyporting.html
.. _clean single-source support for Python 2/3:
@@ -1307,7 +1305,10 @@
.. _mathweb wiki: http://www.mathweb.org/wiki/MathML
.. _ConTeXT MathML page: http://wiki.contextgarden.net/MathML
+ A MathML to LaTeX XSLT sheet:
+ https://github.com/davidcarlisle/web-xslt/tree/master/pmml2tex
+
ASCIIMath_
Simple, ASCII based math input language (see also `ASCIIMath tutorial`_).
@@ -1317,9 +1318,19 @@
A more comprehensive implementation is ASCIIMathPython_ by
Paul Trembley (also used in his sandbox projects).
- * For conversion to LaTeX, there is a JavaScript script at
- http://dlippman.imathas.com/asciimathtex/ASCIIMath2TeX.js
+ * For conversion to LaTeX, there is
+ - a JavaScript script at
+ http://dlippman.imathas.com/asciimathtex/ASCIIMath2TeX.js
+
+ - The javascript `asciimath-to-latex` AsciiMath to LaTex converter at
+ the node package manager
+ https://www.npmjs.com/package/asciimath-to-latex
+ and at GitHub https://github.com/tylerlong/asciimath-to-latex
+
+ - a javascript and a PHP converter script at GitHub
+ https://github.com/asciimath/asciimathml/tree/master/asciimath-based
+
.. _ASCIIMath: http://www1.chapman.edu/~jipsen/mathml/asciimath.html
.. _ASCIIMath tutorial:
http://www.wjagray.co.uk/maths/ASCIIMathTutorial.html
Modified: trunk/docutils/docs/user/odt.txt
===================================================================
--- trunk/docutils/docs/user/odt.txt 2017-08-08 21:39:19 UTC (rev 8161)
+++ trunk/docutils/docs/user/odt.txt 2017-08-10 17:51:01 UTC (rev 8162)
@@ -41,9 +41,6 @@
In addition to the Docutils standard requirements, ``odtwriter``
requires:
-- ElementTree -- Python (version 2.5 or later) now includes
- ElementTree (``xml.etree.ElementTree``).
-
- Optional -- `Pygments`_ is required if you want syntax
highlighting of code in literal blocks. See section `Syntax
highlighting`_.
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2017-08-08 21:39:19 UTC (rev 8161)
+++ trunk/docutils/docutils/io.py 2017-08-10 17:51:01 UTC (rev 8162)
@@ -226,7 +226,7 @@
if key == 'handle_io_errors':
sys.stderr.write('deprecation warning: '
'io.FileInput() argument `handle_io_errors` '
- 'is ignored since "Docutils 0.10 (2012-12-16)" '
+ 'is ignored since Docutils 0.10 (2012-12-16) '
'and will soon be removed.')
else:
raise TypeError('__init__() got an unexpected keyword '
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2017-08-08 21:39:19 UTC (rev 8161)
+++ trunk/docutils/setup.py 2017-08-10 17:51:01 UTC (rev 8162)
@@ -138,11 +138,9 @@
'docutils.writers',
'docutils.writers.html4css1',
'docutils.writers.html5_polyglot',
- # 'docutils.writers.xhtml11', # moved to the sandbox
'docutils.writers.pep_html',
'docutils.writers.s5_html',
'docutils.writers.latex2e',
- # 'docutils.writers.newlatex2e', # in the sandbox since 0.8
'docutils.writers.xetex',
'docutils.writers.odf_odt',
],
@@ -196,8 +194,6 @@
'License :: OSI Approved :: BSD License',
'License :: OSI Approved :: GNU General Public License (GPL)',
'Operating System :: OS Independent',
- 'Programming Language :: Python :: 2.4',
- 'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-08-11 14:05:33
|
Revision: 8163
http://sourceforge.net/p/docutils/code/8163
Author: milde
Date: 2017-08-11 14:05:30 +0000 (Fri, 11 Aug 2017)
Log Message:
-----------
Drop compatibility code for Python 2.4 and 2.5.
Modified Paths:
--------------
trunk/docutils/docutils/_compat.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/statemachine.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/code_analyzer.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/test/DocutilsTestSupport.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_io.py
trunk/docutils/test/test_parsers/test_rst/test_character_level_inline_markup.py
trunk/docutils/test/test_parsers/test_rst/test_inline_markup.py
trunk/docutils/test/test_publisher.py
Modified: trunk/docutils/docutils/_compat.py
===================================================================
--- trunk/docutils/docutils/_compat.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/docutils/_compat.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -18,7 +18,7 @@
import sys
if sys.version_info < (3,0):
- b = bytes = str
+ b = str
u_prefix = 'u'
from StringIO import StringIO as BytesIO
else:
@@ -35,14 +35,3 @@
# using this hack since 2to3 "fixes" the relative import
# when using ``from io import BytesIO``
BytesIO = __import__('io').BytesIO
-
-if sys.version_info < (2,5):
- import __builtin__
-
- def __import__(name, globals={}, locals={}, fromlist=[], level=-1):
- """Compatibility definition for Python 2.4.
-
- Silently ignore the `level` argument missing in Python < 2.5.
- """
- # we need the level arg because the default changed in Python 3.3
- return __builtin__.__import__(name, globals, locals, fromlist)
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/docutils/io.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -125,7 +125,7 @@
coding_slug = re.compile(b(r"coding[:=]\s*([-\w.]+)"))
"""Encoding declaration pattern."""
- byte_order_marks = ((codecs.BOM_UTF8, 'utf-8'), # 'utf-8-sig' new in v2.5
+ byte_order_marks = ((codecs.BOM_UTF8, 'utf-8'),
(codecs.BOM_UTF16_BE, 'utf-16-be'),
(codecs.BOM_UTF16_LE, 'utf-16-le'),)
"""Sequence of (start_bytes, encoding) tuples for encoding detection.
@@ -263,25 +263,24 @@
"""
Read and decode a single file and return the data (Unicode string).
"""
- try: # In Python < 2.5, try...except has to be nested in try...finally.
- try:
- if self.source is sys.stdin and sys.version_info >= (3,0):
- # read as binary data to circumvent auto-decoding
- data = self.source.buffer.read()
- # normalize newlines
- data = b('\n').join(data.splitlines()) + b('\n')
- else:
- data = self.source.read()
- except (UnicodeError, LookupError), err: # (in Py3k read() decodes)
- if not self.encoding and self.source_path:
- # re-read in binary mode and decode with heuristics
- b_source = open(self.source_path, 'rb')
- data = b_source.read()
- b_source.close()
- # normalize newlines
- data = b('\n').join(data.splitlines()) + b('\n')
- else:
- raise
+ try:
+ if self.source is sys.stdin and sys.version_info >= (3,0):
+ # read as binary data to circumvent auto-decoding
+ data = self.source.buffer.read()
+ # normalize newlines
+ data = b('\n').join(data.splitlines()) + b('\n')
+ else:
+ data = self.source.read()
+ except (UnicodeError, LookupError), err: # (in Py3k read() decodes)
+ if not self.encoding and self.source_path:
+ # re-read in binary mode and decode with heuristics
+ b_source = open(self.source_path, 'rb')
+ data = b_source.read()
+ b_source.close()
+ # normalize newlines
+ data = b('\n').join(data.splitlines()) + b('\n')
+ else:
+ raise
finally:
if self.autoclose:
self.close()
@@ -382,26 +381,25 @@
if sys.version_info >= (3,0) and os.linesep != '\n':
data = data.replace(b('\n'), b(os.linesep)) # fix endings
- try: # In Python < 2.5, try...except has to be nested in try...finally.
- try:
- self.destination.write(data)
- except TypeError, e:
- if sys.version_info >= (3,0) and isinstance(data, bytes):
- try:
- self.destination.buffer.write(data)
- except AttributeError:
- if check_encoding(self.destination,
- self.encoding) is False:
- raise ValueError('Encoding of %s (%s) differs \n'
- ' from specified encoding (%s)' %
- (self.destination_path or 'destination',
- self.destination.encoding, self.encoding))
- else:
- raise e
- except (UnicodeError, LookupError), err:
- raise UnicodeError(
- 'Unable to encode output data. output-encoding is: '
- '%s.\n(%s)' % (self.encoding, ErrorString(err)))
+ try:
+ self.destination.write(data)
+ except TypeError, e:
+ if sys.version_info >= (3,0) and isinstance(data, bytes):
+ try:
+ self.destination.buffer.write(data)
+ except AttributeError:
+ if check_encoding(self.destination,
+ self.encoding) is False:
+ raise ValueError('Encoding of %s (%s) differs \n'
+ ' from specified encoding (%s)' %
+ (self.destination_path or 'destination',
+ self.destination.encoding, self.encoding))
+ else:
+ raise e
+ except (UnicodeError, LookupError), err:
+ raise UnicodeError(
+ 'Unable to encode output data. output-encoding is: '
+ '%s.\n(%s)' % (self.encoding, ErrorString(err)))
finally:
if self.autoclose:
self.close()
Modified: trunk/docutils/docutils/statemachine.py
===================================================================
--- trunk/docutils/docutils/statemachine.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/docutils/statemachine.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -1452,10 +1452,7 @@
Pad all double-width characters in self by appending `pad_char` to each.
For East Asian language support.
"""
- if hasattr(unicodedata, 'east_asian_width'):
- east_asian_width = unicodedata.east_asian_width
- else:
- return # new in Python 2.4
+ east_asian_width = unicodedata.east_asian_width
for i in range(len(self.data)):
line = self.data[i]
if isinstance(line, unicode):
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/docutils/utils/__init__.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -647,11 +647,8 @@
"""
if isinstance(text, str) and sys.version_info < (3,0):
return len(text)
- try:
- width = sum([east_asian_widths[unicodedata.east_asian_width(c)]
- for c in text])
- except AttributeError: # east_asian_width() New in version 2.4.
- width = len(text)
+ width = sum([east_asian_widths[unicodedata.east_asian_width(c)]
+ for c in text])
# correction for combining chars:
width -= len(find_combining_chars(text))
return width
@@ -690,11 +687,12 @@
# split (except singletons, which mark the following tag as non-standard):
tag = re.sub(r'_([a-zA-Z0-9])_', r'_\1-', tag)
subtags = [subtag for subtag in tag.split('_')]
- base_tag = [subtags.pop(0)]
+ base_tag = (subtags.pop(0),)
# find all combinations of subtags
taglist = []
for n in range(len(subtags), 0, -1):
- for tags in unique_combinations(subtags, n):
+ # for tags in unique_combinations(subtags, n):
+ for tags in itertools.combinations(subtags, n):
taglist.append('-'.join(base_tag+tags))
taglist += base_tag
return taglist
Modified: trunk/docutils/docutils/utils/code_analyzer.py
===================================================================
--- trunk/docutils/docutils/utils/code_analyzer.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/docutils/utils/code_analyzer.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -22,7 +22,7 @@
''] # short name for Token and Text
# (Add, e.g., Token.Punctuation with ``unstyled_tokens += 'punctuation'``.)
-class LexerError(ApplicationError):
+class LexerError(ApplicationError):
pass
class Lexer(object):
@@ -64,11 +64,14 @@
except pygments.util.ClassNotFound:
raise LexerError('Cannot analyze code. '
'No Pygments lexer found for "%s".' % language)
+ # self.lexer.add_filter('tokenmerge')
+ # Since version 1.2. (released Jan 01, 2010) Pygments has a
+ # TokenMergeFilter. # ``self.merge(tokens)`` in __iter__ could
+ # be replaced by ``self.lexer.add_filter('tokenmerge')`` in __init__.
+ # However, `merge` below also strips a final newline added by pygments.
+ #
+ # self.lexer.add_filter('tokenmerge')
- # Since version 1.2. (released Jan 01, 2010) Pygments has a
- # TokenMergeFilter. However, this requires Python >= 2.4. When Docutils
- # requires same minimal version, ``self.merge(tokens)`` in __iter__ can
- # be replaced by ``self.lexer.add_filter('tokenmerge')`` in __init__.
def merge(self, tokens):
"""Merge subsequent tokens of same token-type.
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/docutils/writers/_html_base.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -997,9 +997,8 @@
self.body.append('</a>')
self.body.append('</span>')
if self.settings.footnote_backlinks and len(backrefs) > 1:
- # Python 2.4 fails with enumerate(backrefs, 1)
- backlinks = ['<a href="#%s">%s</a>' % (ref, i+1)
- for (i, ref) in enumerate(backrefs)]
+ backlinks = ['<a href="#%s">%s</a>' % (ref, i)
+ for (i, ref) in enumerate(backrefs, 1)]
self.body.append('<span class="fn-backref">(%s)</span>'
% ','.join(backlinks))
self.body.append('</dt>\n<dd>')
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -484,10 +484,9 @@
self.context.append('<a class="fn-backref" href="#%s">'
% backrefs[0])
else:
- # Python 2.4 fails with enumerate(backrefs, 1)
- for (i, backref) in enumerate(backrefs):
+ for (i, backref) in enumerate(backrefs, 1):
backlinks.append('<a class="fn-backref" href="#%s">%s</a>'
- % (backref, i+1))
+ % (backref, i))
self.context.append('<em>(%s)</em> ' % ', '.join(backlinks))
self.context += ['', '']
else:
Modified: trunk/docutils/test/DocutilsTestSupport.py
===================================================================
--- trunk/docutils/test/DocutilsTestSupport.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/test/DocutilsTestSupport.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -72,7 +72,6 @@
from docutils.parsers.rst import states, tableparser, roles, languages
from docutils.readers import standalone, pep
from docutils.statemachine import StringList, string2lines
- from docutils._compat import bytes
except ImportError:
# The importing module (usually __init__.py in one of the
# subdirectories) may catch ImportErrors in order to detect the
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/test/test_error_reporting.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -37,7 +37,7 @@
import DocutilsTestSupport # must be imported before docutils
from docutils import core, parsers, frontend, utils
from docutils.utils.error_reporting import SafeString, ErrorString, ErrorOutput
-from docutils._compat import b, bytes
+from docutils._compat import b
oldlocale = None
if sys.version_info < (3,0): # problems solved in py3k
@@ -158,7 +158,7 @@
# -----------------
# Stub: Buffer with 'strict' auto-conversion of input to byte string:
-class BBuf(BytesIO, object): # super class object required by Python <= 2.5
+class BBuf(BytesIO):
def write(self, data):
if isinstance(data, unicode):
data.encode('ascii', 'strict')
@@ -165,7 +165,7 @@
super(BBuf, self).write(data)
# Stub: Buffer expecting unicode string:
-class UBuf(StringIO, object): # super class object required by Python <= 2.5
+class UBuf(StringIO):
def write(self, data):
# emulate Python 3 handling of stdout, stderr
if isinstance(data, bytes):
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/test/test_io.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -11,7 +11,7 @@
import unittest, sys
import DocutilsTestSupport # must be imported before docutils
from docutils import io
-from docutils._compat import b, bytes
+from docutils._compat import b
from docutils.utils.error_reporting import locale_encoding
from test_error_reporting import BBuf, UBuf
Modified: trunk/docutils/test/test_parsers/test_rst/test_character_level_inline_markup.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_character_level_inline_markup.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/test/test_parsers/test_rst/test_character_level_inline_markup.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -480,7 +480,6 @@
\xa0.
"""],
# Whitespace characters:
-# \u180e*MONGOLIAN VOWEL SEPARATOR*\u180e, fails in Python 2.4
[u"""\
inline markup surrounded by various whitespace characters:
*newline*
@@ -487,6 +486,7 @@
or *space* or one of
\xa0*NO-BREAK SPACE*\xa0,
\u1680*OGHAM SPACE MARK*\u1680,
+\u180e*MONGOLIAN VOWEL SEPARATOR*\u180e,
\u2000*EN QUAD*\u2000,
\u2001*EM QUAD*\u2001,
\u2002*EN SPACE*\u2002,
@@ -522,6 +522,10 @@
<emphasis>
OGHAM SPACE MARK
\u1680,
+ \u180e
+ <emphasis>
+ MONGOLIAN VOWEL SEPARATOR
+ \u180e,
\u2000
<emphasis>
EN QUAD
Modified: trunk/docutils/test/test_parsers/test_rst/test_inline_markup.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_inline_markup.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/test/test_parsers/test_rst/test_inline_markup.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -1689,7 +1689,7 @@
\u00a0.
"""],
# Whitespace characters:
-# \u180e*MONGOLIAN VOWEL SEPARATOR*\u180e, fails in Python 2.4
+# \u180e*MONGOLIAN VOWEL SEPARATOR*\u180e, fails in Python 2.6
[u"""\
text separated by
*newline*
Modified: trunk/docutils/test/test_publisher.py
===================================================================
--- trunk/docutils/test/test_publisher.py 2017-08-10 17:51:01 UTC (rev 8162)
+++ trunk/docutils/test/test_publisher.py 2017-08-11 14:05:30 UTC (rev 8163)
@@ -12,7 +12,7 @@
import DocutilsTestSupport # must be imported before docutils
import docutils
from docutils import core, nodes, io
-from docutils._compat import b, bytes, u_prefix
+from docutils._compat import b, u_prefix
test_document = """\
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-08-14 11:28:51
|
Revision: 8164
http://sourceforge.net/p/docutils/code/8164
Author: milde
Date: 2017-08-14 11:28:48 +0000 (Mon, 14 Aug 2017)
Log Message:
-----------
Drop 2.4 and 2.5 compatibility code, part 2.
Modified Paths:
--------------
trunk/docutils/docutils/__init__.py
trunk/docutils/docutils/_compat.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/writers/s5_html/__init__.py
trunk/docutils/test/test_error_reporting.py
trunk/docutils/test/test_io.py
trunk/docutils/test/test_nodes.py
trunk/docutils/test/test_parsers/test_parser.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_raw.py
trunk/docutils/test/test_parsers/test_rst/test_east_asian_text.py
trunk/docutils/test/test_publisher.py
trunk/docutils/test/test_writers/test_html4css1_misc.py
trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
trunk/docutils/test/test_writers/test_manpage.py
Modified: trunk/docutils/docutils/__init__.py
===================================================================
--- trunk/docutils/docutils/__init__.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/docutils/__init__.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -74,11 +74,6 @@
rather than parsing the text of `__version__`.
"""
-# workaround for Python < 2.6:
-__version_info__ = (0, 15, 0, 'beta', 0, False)
-# NOTE: (0, 15, 0, 'beta', 0, False) means 0.15b.dev
-# To add in Docutils 0.15, replacing the line above:
-"""
from collections import namedtuple
VersionInfo = namedtuple(
'VersionInfo', 'major minor micro releaselevel serial release')
@@ -86,14 +81,13 @@
major=0,
minor=15,
micro=0,
- releaselevel='alpha', # `development status`__:
+ releaselevel='beta', # `development status`__:
# one of 'alpha', 'beta', 'candidate', 'final'
# __ https://en.wikipedia.org/wiki/Software_release_life_cycle
- serial=0, # pre-release number (0 for final releases)
+ serial=0, # pre-release serial number (0 for final releases)
release=False # True for official releases and pre-releases
)
-
-Comprehensive version information tuple. Can be used to test for a
+"""Comprehensive version information tuple. Can be used to test for a
minimally required version, e.g. ::
if __version_info__ >= (0, 13, 0, 'candidate', 2, True)
@@ -111,16 +105,7 @@
"""
-class ApplicationError(StandardError):
- # Workaround:
- # In Python < 2.6, unicode(<exception instance>) calls `str` on the
- # arg and therefore, e.g., unicode(StandardError(u'\u234')) fails
- # with UnicodeDecodeError.
- if sys.version_info < (2,6):
- def __unicode__(self):
- return u', '.join(self.args)
-
-
+class ApplicationError(StandardError): pass
class DataError(ApplicationError): pass
Modified: trunk/docutils/docutils/_compat.py
===================================================================
--- trunk/docutils/docutils/_compat.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/docutils/_compat.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -7,9 +7,6 @@
This module currently provides the following helper symbols:
-* bytes (name of byte string type; str in 2.x, bytes in 3.x)
-* b (function converting a string literal to an ASCII byte string;
- can be also used to convert a Unicode string into a byte string)
* u_prefix (unicode repr prefix: 'u' in 2.x, '' in 3.x)
(Required in docutils/test/test_publisher.py)
* BytesIO (a StringIO class that works with bytestrings)
@@ -18,20 +15,10 @@
import sys
if sys.version_info < (3,0):
- b = str
u_prefix = 'u'
from StringIO import StringIO as BytesIO
else:
- import builtins
- bytes = builtins.bytes
- u_prefix = ''
- def b(s):
- if isinstance(s, str):
- return s.encode('latin1')
- elif isinstance(s, bytes):
- return s
- else:
- raise TypeError("Invalid argument %r for b()" % (s,))
+ u_prefix = b''
# using this hack since 2to3 "fixes" the relative import
# when using ``from io import BytesIO``
BytesIO = __import__('io').BytesIO
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/docutils/io.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -14,7 +14,6 @@
import re
import codecs
from docutils import TransformSpec
-from docutils._compat import b
from docutils.utils.error_reporting import locale_encoding, ErrorString, ErrorOutput
@@ -122,7 +121,7 @@
'%s.\n(%s)' % (', '.join([repr(enc) for enc in encodings]),
ErrorString(error)))
- coding_slug = re.compile(b(r"coding[:=]\s*([-\w.]+)"))
+ coding_slug = re.compile(br"coding[:=]\s*([-\w.]+)")
"""Encoding declaration pattern."""
byte_order_marks = ((codecs.BOM_UTF8, 'utf-8'),
@@ -268,7 +267,7 @@
# read as binary data to circumvent auto-decoding
data = self.source.buffer.read()
# normalize newlines
- data = b('\n').join(data.splitlines()) + b('\n')
+ data = b'\n'.join(data.splitlines()) + b'\n'
else:
data = self.source.read()
except (UnicodeError, LookupError), err: # (in Py3k read() decodes)
@@ -278,7 +277,7 @@
data = b_source.read()
b_source.close()
# normalize newlines
- data = b('\n').join(data.splitlines()) + b('\n')
+ data = b'\n'.join(data.splitlines()) + b'\n'
else:
raise
finally:
@@ -379,7 +378,7 @@
):
data = self.encode(data)
if sys.version_info >= (3,0) and os.linesep != '\n':
- data = data.replace(b('\n'), b(os.linesep)) # fix endings
+ data = data.replace(b'\n', bytes(os.linesep)) # fix endings
try:
self.destination.write(data)
Modified: trunk/docutils/docutils/writers/s5_html/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/s5_html/__init__.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/docutils/writers/s5_html/__init__.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -17,7 +17,6 @@
from docutils import frontend, nodes, utils
from docutils.writers import html4css1
from docutils.parsers.rst import directives
-from docutils._compat import b
themes_dir_path = utils.relative_path(
os.path.join(os.getcwd(), 'dummy'),
@@ -268,8 +267,7 @@
src_file.close()
dest_file = open(dest, 'wb')
dest_dir = dest_dir.replace(os.sep, '/')
- dest_file.write(src_data.replace(
- b('ui/default'),
+ dest_file.write(src_data.replace(b'ui/default',
dest_dir[dest_dir.rfind('ui/'):].encode(
sys.getfilesystemencoding())))
dest_file.close()
Modified: trunk/docutils/test/test_error_reporting.py
===================================================================
--- trunk/docutils/test/test_error_reporting.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/test/test_error_reporting.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -37,7 +37,6 @@
import DocutilsTestSupport # must be imported before docutils
from docutils import core, parsers, frontend, utils
from docutils.utils.error_reporting import SafeString, ErrorString, ErrorOutput
-from docutils._compat import b
oldlocale = None
if sys.version_info < (3,0): # problems solved in py3k
@@ -82,7 +81,7 @@
# -> see the test in test_error_reporting.py
# test data:
- bs = b('\xfc') # unicode(bs) fails, str(bs) in Python 3 return repr()
+ bs = b'\xfc' # unicode(bs) fails, str(bs) in Python 3 return repr()
us = u'\xfc' # bytes(us) fails; str(us) fails in Python 2
be = Exception(bs) # unicode(be) fails
ue = Exception(us) # bytes(ue) fails, str(ue) fails in Python 2;
@@ -97,7 +96,7 @@
def test_7bit(self):
# wrapping (not required with 7-bit chars) must not change the
# result of conversions:
- bs7 = b('foo')
+ bs7 = b'foo'
us7 = u'foo'
be7 = Exception(bs7)
ue7 = Exception(us7)
@@ -134,8 +133,8 @@
class ErrorStringTests(unittest.TestCase):
- bs = b('\xfc') # unicode(bs) fails, str(bs) in Python 3 return repr()
- us = u'\xfc' # bytes(us) fails; str(us) fails in Python 2
+ bs = b'\xfc' # unicode(bs) fails, str(bs) in Python 3 return repr()
+ us = u'\xfc' # bytes(us) fails; str(us) fails in Python 2
def test_str(self):
self.assertEqual('Exception: spam',
@@ -181,25 +180,25 @@
buf = BBuf() # buffer storing byte string
e = ErrorOutput(buf, encoding='ascii')
# write byte-string as-is
- e.write(b('b\xfc'))
- self.assertEqual(buf.getvalue(), b('b\xfc'))
+ e.write(b'b\xfc')
+ self.assertEqual(buf.getvalue(), b'b\xfc')
# encode unicode data with backslashescape fallback replacement:
e.write(u' u\xfc')
- self.assertEqual(buf.getvalue(), b('b\xfc u\\xfc'))
+ self.assertEqual(buf.getvalue(), b'b\xfc u\\xfc')
# handle Exceptions with Unicode string args
# unicode(Exception(u'e\xfc')) # fails in Python < 2.6
e.write(AttributeError(u' e\xfc'))
- self.assertEqual(buf.getvalue(), b('b\xfc u\\xfc e\\xfc'))
+ self.assertEqual(buf.getvalue(), b'b\xfc u\\xfc e\\xfc')
# encode with `encoding` attribute
e.encoding = 'utf8'
e.write(u' u\xfc')
- self.assertEqual(buf.getvalue(), b('b\xfc u\\xfc e\\xfc u\xc3\xbc'))
+ self.assertEqual(buf.getvalue(), b'b\xfc u\\xfc e\\xfc u\xc3\xbc')
def test_ubuf(self):
buf = UBuf() # buffer only accepting unicode string
# decode of binary strings
e = ErrorOutput(buf, encoding='ascii')
- e.write(b('b\xfc'))
+ e.write(b'b\xfc')
self.assertEqual(buf.getvalue(), u'b\ufffd') # use REPLACEMENT CHARACTER
# write Unicode string and Exceptions with Unicode args
e.write(u' u\xfc')
@@ -208,7 +207,7 @@
self.assertEqual(buf.getvalue(), u'b\ufffd u\xfc e\xfc')
# decode with `encoding` attribute
e.encoding = 'latin1'
- e.write(b(' b\xfc'))
+ e.write(b' b\xfc')
self.assertEqual(buf.getvalue(), u'b\ufffd u\xfc e\xfc b\xfc')
@@ -223,10 +222,10 @@
if testlocale:
locale.setlocale(locale.LC_ALL, testlocale)
# test data:
- bs = b('\xfc')
+ bs = b'\xfc'
us = u'\xfc'
try:
- open(b('\xfc'))
+ open(b'\xfc')
except IOError, e: # in Python 3 the name for the exception instance
bioe = e # is local to the except clause
try:
@@ -239,7 +238,7 @@
except IOError, e:
uioe = e
try:
- os.chdir(b('\xfc'))
+ os.chdir(b'\xfc')
except OSError, e:
bose = e
try:
Modified: trunk/docutils/test/test_io.py
===================================================================
--- trunk/docutils/test/test_io.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/test/test_io.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -11,7 +11,6 @@
import unittest, sys
import DocutilsTestSupport # must be imported before docutils
from docutils import io
-from docutils._compat import b
from docutils.utils.error_reporting import locale_encoding
from test_error_reporting import BBuf, UBuf
@@ -50,7 +49,7 @@
class InputTests(unittest.TestCase):
def test_bom(self):
- input = io.StringInput(source=b('\xef\xbb\xbf foo \xef\xbb\xbf bar'),
+ input = io.StringInput(source=b'\xef\xbb\xbf foo \xef\xbb\xbf bar',
encoding='utf8')
# Assert BOMs are gone.
self.assertEqual(input.read(), u' foo bar')
@@ -60,26 +59,26 @@
self.assertEqual(input.read(), u'\ufeff foo \ufeff bar')
def test_coding_slug(self):
- input = io.StringInput(source=b("""\
+ input = io.StringInput(source=b"""\
.. -*- coding: ascii -*-
data
blah
-"""))
+""")
data = input.read()
self.assertEqual(input.successful_encoding, 'ascii')
- input = io.StringInput(source=b("""\
+ input = io.StringInput(source=b"""\
#! python
# -*- coding: ascii -*-
print "hello world"
-"""))
+""")
data = input.read()
self.assertEqual(input.successful_encoding, 'ascii')
- input = io.StringInput(source=b("""\
+ input = io.StringInput(source=b"""\
#! python
# extraneous comment; prevents coding slug from being read
# -*- coding: ascii -*-
print "hello world"
-"""))
+""")
data = input.read()
self.assertNotEqual(input.successful_encoding, 'ascii')
@@ -132,12 +131,12 @@
# keep unicode instances as-is
self.assertEqual(uniinput.decode(u'ja'), u'ja')
# raise AssertionError if data is not an unicode string
- self.assertRaises(AssertionError, uniinput.decode, b('ja'))
+ self.assertRaises(AssertionError, uniinput.decode, b'ja')
class OutputTests(unittest.TestCase):
- bdata = b('\xfc')
+ bdata = b'\xfc'
udata = u'\xfc'
def setUp(self):
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/test/test_nodes.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -14,7 +14,6 @@
import types
import DocutilsTestSupport # must be imported before docutils
from DocutilsTestSupport import nodes, utils
-from docutils._compat import b
debug = False
@@ -58,10 +57,10 @@
def test_asciirestriction(self):
if sys.version_info < (3,):
self.assertRaises(UnicodeDecodeError, nodes.Text,
- b('hol%s' % chr(224)))
+ b'hol%s' % chr(224))
else:
# no bytes at all allowed
- self.assertRaises(TypeError, nodes.Text, b('hol'))
+ self.assertRaises(TypeError, nodes.Text, b'hol')
def test_longrepr(self):
self.assertEqual(repr(self.longtext), r"<#text: 'Mary had a "
Modified: trunk/docutils/test/test_parsers/test_parser.py
===================================================================
--- trunk/docutils/test/test_parsers/test_parser.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/test/test_parsers/test_parser.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -13,7 +13,6 @@
import DocutilsTestSupport # must be imported before docutils
import docutils
from docutils import parsers, utils, frontend
-from docutils._compat import b
class RstParserTests(unittest.TestCase):
@@ -27,10 +26,10 @@
if sys.version_info < (3,):
# supplying string input is supported, but only if ascii-decodable
self.assertRaises(UnicodeDecodeError,
- parser.parse, b('hol%s' % chr(224)), document)
+ parser.parse, b'hol%s' % chr(224), document)
else:
# input must be unicode at all times
- self.assertRaises(TypeError, parser.parse, b('hol'), document)
+ self.assertRaises(TypeError, parser.parse, b'hol', document)
if __name__ == '__main__':
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_include.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -12,7 +12,6 @@
import sys
from __init__ import DocutilsTestSupport
from docutils.parsers.rst import states
-from docutils._compat import b
from docutils.utils.code_analyzer import with_pygments
def suite():
@@ -423,7 +422,7 @@
.. include:: %s
:encoding: utf-16
""" % reldir(utf_16_file),
-b("""\
+b"""\
<document source="test data">
<paragraph>
Encoding:
@@ -433,7 +432,7 @@
"Crunchy Frog", 1.49, "If we took the b\xf6nes out, it wouldn\\u2019t be
crunchy, now would it?"
"Gannet Ripple", 1.99, "\xbfOn a \\u03c3\\u03c4\\u03b9\\u03ba?"
-""").decode('raw_unicode_escape')],
+""".decode('raw_unicode_escape')],
["""\
Include file is UTF-16-encoded, and is not valid ASCII.
@@ -719,7 +718,7 @@
.. include:: <isogrk4.txt>
""",
-b("""\
+b"""\
<document source="test data">
<paragraph>
Standard include data file:
@@ -734,7 +733,7 @@
\\u03dc
<substitution_definition names="b.gammad">
\\u03dd
-""").decode('raw_unicode_escape')],
+""".decode('raw_unicode_escape')],
["""\
Nonexistent standard include data file:
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_raw.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_raw.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_raw.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -11,7 +11,6 @@
import os.path
import sys
from __init__ import DocutilsTestSupport
-from docutils._compat import b
def suite():
s = DocutilsTestSupport.ParserTestSuite()
@@ -98,7 +97,7 @@
:file: %s
:encoding: utf-16
""" % utf_16_file_rel,
-b("""\
+b"""\
<document source="test data">
<raw format="html" source="%s" xml:space="preserve">
"Treat", "Quantity", "Description"
@@ -106,7 +105,7 @@
"Crunchy Frog", 1.49, "If we took the b\xf6nes out, it wouldn\\u2019t be
crunchy, now would it?"
"Gannet Ripple", 1.99, "\xbfOn a \\u03c3\\u03c4\\u03b9\\u03ba?"
-""" % utf_16_file_rel).decode('raw_unicode_escape')],
+""".decode('raw_unicode_escape') % utf_16_file_rel],
["""\
Raw input file is UTF-16-encoded, and is not valid ASCII.
Modified: trunk/docutils/test/test_parsers/test_rst/test_east_asian_text.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_east_asian_text.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/test/test_parsers/test_rst/test_east_asian_text.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -17,8 +17,6 @@
except AttributeError:
east_asian_width = None
-from docutils._compat import b
-
def suite():
s = DocutilsTestSupport.ParserTestSuite()
s.generateTests(totest)
@@ -177,7 +175,7 @@
⇔ left-right double arrow
= ===================================
""",
-b("""\
+b"""\
<document source="test data">
<paragraph>
Some ambiguous-width characters:
@@ -305,7 +303,7 @@
<entry>
<paragraph>
left-right double arrow
-""").decode('raw_unicode_escape')],
+""".decode('raw_unicode_escape')],
]
'''
[u"""\
Modified: trunk/docutils/test/test_publisher.py
===================================================================
--- trunk/docutils/test/test_publisher.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/test/test_publisher.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -12,7 +12,7 @@
import DocutilsTestSupport # must be imported before docutils
import docutils
from docutils import core, nodes, io
-from docutils._compat import b, u_prefix
+from docutils._compat import u_prefix
test_document = """\
@@ -21,7 +21,7 @@
This is a test document with a broken reference: nonexistent_
"""
-pseudoxml_output = b("""\
+pseudoxml_output = b"""\
<document ids="test-document" names="test\ document" source="<string>" title="Test Document">
<title>
Test Document
@@ -35,9 +35,11 @@
<system_message backrefs="id2" ids="id1" level="3" line="4" source="<string>" type="ERROR">
<paragraph>
Unknown target name: "nonexistent".
-""")
-exposed_pseudoxml_output = b("""\
-<document ids="test-document" internal:refnames="{%s\'nonexistent\': [<reference: <#text: \'nonexistent\'>>]}" names="test\ document" source="<string>" title="Test Document">
+"""
+exposed_pseudoxml_output = (b"""\
+<document ids="test-document" internal:refnames="{"""
++ u_prefix
++ b"""\'nonexistent\': [<reference: <#text: \'nonexistent\'>>]}" names="test\ document" source="<string>" title="Test Document">
<title>
Test Document
<paragraph>
@@ -50,7 +52,7 @@
<system_message backrefs="id2" ids="id1" level="3" line="4" source="<string>" type="ERROR">
<paragraph>
Unknown target name: "nonexistent".
-""" % u_prefix)
+""") # % u_prefix # %-expansion not supported in bytes in 3.3 and 3.4
class PublisherTests(DocutilsTestSupport.StandardTestCase):
Modified: trunk/docutils/test/test_writers/test_html4css1_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1_misc.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/test/test_writers/test_html4css1_misc.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -12,7 +12,6 @@
from __init__ import DocutilsTestSupport
from docutils import core
-from docutils._compat import b
import os
class EncodingTestCase(DocutilsTestSupport.StandardTestCase):
@@ -29,7 +28,7 @@
settings_overrides=settings_overrides)
# Encoding a euro sign with latin1 doesn't work, so the
# xmlcharrefreplace handler is used.
- self.assertIn(b('EUR = €'), result)
+ self.assertIn(b'EUR = €', result)
class MovingArgsTestCase(DocutilsTestSupport.StandardTestCase):
@@ -52,7 +51,7 @@
"""
result = core.publish_string(data, writer_name='html4css1',
settings_overrides=self.settings_overrides)
- self.assertIn(b('<dt class="for the second item">second term:</dt>'),
+ self.assertIn(b'<dt class="for the second item">second term:</dt>',
result)
def test_definition_list_item_name(self):
@@ -69,7 +68,7 @@
"""
result = core.publish_string(data, writer_name='html4css1',
settings_overrides=self.settings_overrides)
- self.assertIn(b('<dt id="second-item">second term:</dt>'),
+ self.assertIn(b'<dt id="second-item">second term:</dt>',
result)
Modified: trunk/docutils/test/test_writers/test_html5_polyglot_misc.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/test/test_writers/test_html5_polyglot_misc.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -12,7 +12,6 @@
from __init__ import DocutilsTestSupport
from docutils import core
-from docutils._compat import b
import os
class EncodingTestCase(DocutilsTestSupport.StandardTestCase):
@@ -29,7 +28,7 @@
settings_overrides=settings_overrides)
# Encoding a euro sign with latin1 doesn't work, so the
# xmlcharrefreplace handler is used.
- self.assertIn(b('EUR = €'), result)
+ self.assertIn(b'EUR = €', result)
class MovingArgsTestCase(DocutilsTestSupport.StandardTestCase):
@@ -52,7 +51,7 @@
"""
result = core.publish_string(data, writer_name='html5_polyglot',
settings_overrides=self.settings_overrides)
- self.assertIn(b('<dt class="for the second item">second term:</dt>'),
+ self.assertIn(b'<dt class="for the second item">second term:</dt>',
result)
def test_definition_list_item_name(self):
@@ -69,7 +68,7 @@
"""
result = core.publish_string(data, writer_name='html5_polyglot',
settings_overrides=self.settings_overrides)
- self.assertIn(b('<dt id="second-item">second term:</dt>'),
+ self.assertIn(b'<dt id="second-item">second term:</dt>',
result)
Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py 2017-08-11 14:05:30 UTC (rev 8163)
+++ trunk/docutils/test/test_writers/test_manpage.py 2017-08-14 11:28:48 UTC (rev 8164)
@@ -10,8 +10,6 @@
from __init__ import DocutilsTestSupport
-from docutils._compat import b
-
def suite():
settings = {}
s = DocutilsTestSupport.PublishTestSuite('manpage', suite_settings=settings)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <go...@us...> - 2017-08-14 22:23:33
|
Revision: 8165
http://sourceforge.net/p/docutils/code/8165
Author: goodger
Date: 2017-08-14 22:23:30 +0000 (Mon, 14 Aug 2017)
Log Message:
-----------
* Consolidated version numbering documentation in docs/dev/policies.txt (moved text from docs/dev/release.txt).
* Updated docutils.utils.version_identifier for Python 2.6 (docutils.VersionInfo).
* Moved code from tests/test/test_utils.py::HelperFunctionsTests.test_version_identifier to tests/test__init__.py::VersionInfoTests.test_version_identifier; uncommented lines in tests/test__init__.py::VersionInfoTests.test_version_info.
* Added new tests/test/test_utils.py::HelperFunctionsTests.test_version_identifier.
Modified Paths:
--------------
trunk/docutils/docs/dev/policies.txt
trunk/docutils/docs/dev/release.txt
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/test/test__init__.py
trunk/docutils/test/test_utils.py
Modified: trunk/docutils/docs/dev/policies.txt
===================================================================
--- trunk/docutils/docs/dev/policies.txt 2017-08-14 11:28:48 UTC (rev 8164)
+++ trunk/docutils/docs/dev/policies.txt 2017-08-14 22:23:30 UTC (rev 8165)
@@ -287,7 +287,7 @@
If we need to cut a bugfix release, we'll create a **maintenance branch**
based on the latest feature release. For example, when Docutils 0.5 is
-released, this would be ``branches/docutils-0.5``, any existing 0.4.x
+released, this would be ``branches/docutils-0.5``, and any existing 0.4.x
maintenance branches may be retired. Maintenance branches will receive bug
fixes only; no new features will be allowed here.
@@ -406,32 +406,117 @@
Version Numbering
=================
-Docutils version numbering uses a ``major.minor.micro`` scheme (x.y.z;
-for example, 0.4.1).
+The version identifier ``docutils.__version__`` indicates the state of
+development of the current Docutils codebase.
+``docutils.__version__``, a text string, is a concise, `PEP
+440`_-conforming representation of the namedtuple
+``docutils.__version_info__``.
-**Major releases** (x.0, e.g. 1.0) will be rare, and will represent major
-changes in API, functionality, or commitment. When Docutils reaches version
-1.0, the major APIs will be considered frozen and backward compatibility
-will become of paramount importance.
+.. _PEP 440: https://www.python.org/dev/peps/pep-0440/
-Releases that change the minor number (x.y, e.g. 0.5) will be
-**feature releases**; new features from the `Docutils core`_ will be
-included.
+* The *release segment* ("``<major>.<minor>[.<micro>]``",
+ e.g. "0.4.1") is incremented after each official release.
-Releases that change the micro number (x.y.z, e.g. 0.4.1) will be
-**bug-fix releases**. No new features will be introduced in these
-releases; only bug fixes will be included.
+ **Major releases** (x.0, e.g. 1.0) will be rare, and will represent
+ major changes in API, functionality, or commitment. When Docutils
+ reaches version 1.0, the major APIs will be considered frozen and
+ backward compatibility will become of paramount importance. The
+ Docutils major release number is found in
+ ``docutils.__version_info__.major``.
-This policy was adopted in October 2005, and will take effect with
-Docutils version 0.4. Prior to version 0.4, Docutils didn't have an
-official version numbering policy, and micro releases contained both
-bug fixes and new features.
+ Releases that change the minor number (x.y, e.g. 0.5) will be
+ **feature releases**; new features from the `Docutils core`_ will be
+ included. The Docutils minor release number is found in
+ ``docutils.__version_info__.minor``.
-See also the `Docutils Release Procedure`_, `docutils.__version__` and
-`docutils.__version_info__`.
+ Releases that change the micro number (x.y.z, e.g. 0.4.1) will be
+ **bug-fix releases**. No new features will be introduced in these
+ releases; only bug fixes will be included. The Docutils micro
+ release number is found in ``docutils.__version_info__.micro``.
+* The *pre-release segment* ("``[{a|b|rc}[N]]``") corresponds to the
+ `development status`_ of the repository or release. The alphabetic
+ label indicates the release level, found in
+ ``docutils.__version_info__.releaselevel``:
+
+ ======= ============= ============================================
+ Label Release Level Comment
+ ======= ============= ============================================
+ ``a`` alpha To be used only after major experimental
+ changes, to indicate an unstable codebase.
+
+ ``b`` beta Stable but between releases. This is the
+ default state of the repository, with serial==0.
+
+ ``rcN`` candidate Release candidate: ready to release unless
+ significant bugs emerge.
+
+ .. final (No label.) There is no pre-release segment
+ for final releases.
+ ======= ============= ============================================
+
+ .. _development status:
+ https://en.wikipedia.org/wiki/Software_release_life_cycle
+
+ ``N`` in the *pre-release segment* is a non-negative integer serial
+ number; found in ``docutils.__version_info__.serial``. The serial
+ number is incremented whenever a new pre-release is begun. When the
+ serial number N is 0, it is omitted from the pre-release segment. 0
+ is used between releases (with the "beta" release level).
+
+* The *development release segment* (``.dev``) is in place during
+ development, and omitted for official releases and pre-releases.
+ "``.dev``" is present in ``docutils.__version__`` when
+ ``docutils.__version_info__.release`` is False, and absent from
+ ``docutils.__version__`` when ``docutils.__version_info__.release``
+ is True.
+
+Examples of ``docutils.__version__`` version identifiers, over the
+course of normal development (without branches), in chronological
+order:
+
+====================== ============================
+Release Level Version Identifier
+====================== ============================
+final (release) 0.14
+beta (development) 0.15b.dev
+beta (release) 0.15b¹
+candidate 1 (dev.) 0.15rc1.dev
+candidate 1 (release) 0.15rc1
+candidate 2 (dev.) 0.15rc2.dev¹
+candidate 2 (release) 0.15rc2¹
+... candidate N 0.15rcN.dev¹, 0.15rcN¹
+final (dev.) 0.15.dev¹
+final (release) 0.15
+beta (dev.) 0.16b.dev
+====================== ============================
+
+¹may be skipped
+
+Policy history:
+
+* Prior to version 0.4, Docutils didn't have an official version
+ numbering policy, and micro releases contained both bug fixes and
+ new features.
+
+* An earlier version of this policy was adopted in October 2005, and
+ took effect with Docutils version 0.4.
+
+* This policy was updated in June 2017 for Docutils version 0.14. See
+ `Feature Request #50`_ and the `discussion on docutils-devel`__ from
+ May 28 to June 20 2017.
+
+ .. _Feature Request #50:
+ https://sourceforge.net/p/docutils/feature-requests/50/
+ __ https://sourceforge.net/p/docutils/mailman/message/35903816/
+
+See also the `Docutils Release Procedure`_, and
+``docutils.__version__`` & ``docutils.__version_info__`` in
+docuitls/__init__.py.
+
.. _Docutils Release Procedure: release.html#version-numbers
+
Snapshots
=========
Modified: trunk/docutils/docs/dev/release.txt
===================================================================
--- trunk/docutils/docs/dev/release.txt 2017-08-14 11:28:48 UTC (rev 8164)
+++ trunk/docutils/docs/dev/release.txt 2017-08-14 22:23:30 UTC (rev 8165)
@@ -42,61 +42,15 @@
Version identifier
~~~~~~~~~~~~~~~~~~
-The version identifier ``docutils.__version__`` is a concise,
-`PEP 440`_-conforming representation of the namedtuple
-``docutils.__version_info__``.
+For details, see `Version Numbering in Docutils Project Policies`__.
-* The `release segment` (``<major>.<minor>[.<micro>]``)
- is set according to the `Docutils Project Policies`_.
+__ policies.html#version-numbering
-* The `pre-release segment` (``[{a|b|rc}N]``) corresponds to the
- `development status`_ of the repository or release.
- It matches ``__version_info__.releaselevel``:
- ======= ============ ==========================================
- .. releaselevel comment
- ======= ============ ==========================================
- ``a`` alpha only after major experimental changes
- ``b`` beta default state of the repository
- ``rcN`` candidate ready to release unless significant bugs
- emerge (N is ``__version_info__.serial``)
- .. final no pre-release segment
- ======= ============ ==========================================
-
-* The `development release segment` (``.dev``) is omitted for official
- releases and pre-releases, i.e. if ``__version_info__.release`` is True.
-
-See also `Feature Request #50`_ and the `discussion on
-docutils-devel`__ from May 28 to June 20 2017.
-
-Examples:
-
- ============ ============== =============
- releaselevel repository release
- ============ ============== =============
- final … 0.14
- beta 0.15b.dev 0.15b¹
- candidate 0.15rc1.dev 0.15rc1
- candidate 0.15rc2.dev¹ 0.15rc2¹
- final 0.15.dev 0.15
- beta 0.16b.dev …
- ============ ============== =============
-
- ¹may be skipped
-
-
-.. _Docutils Project Policies: policies.html#version-numbers
-.. _Feature Request #50:
- https://sourceforge.net/p/docutils/feature-requests/50/
-.. _PEP 440: https://www.python.org/dev/peps/pep-0440/
-.. _development status:
- https://en.wikipedia.org/wiki/Software_release_life_cycle
-__ https://sourceforge.net/p/docutils/mailman/message/35903816/
-
How to change the version identifier
""""""""""""""""""""""""""""""""""""
-The `version identifier` ``docutils.__version__`` is defined in
+The *version identifier* ``docutils.__version__`` is defined in
``docutils/docutils/__init__.py`` and used in in the following files::
docutils/setup.py
@@ -104,11 +58,11 @@
docutils/README.txt
web/index.txt
-You can use the script ``set_release.sh``:
+You can use the script ``set_release.sh`` to change the version
+identifier:
#. ``cd`` to the "docutils" subdirectory in the repository checkout,
-
#. call ::
../sandbox/infrastructure/set_release.sh <new_version>
@@ -116,9 +70,12 @@
where ``<new_version>`` is major.minor[.micro][<pre>][.dev].
Finally change ``__version_info__`` in ``docutils/docutils/__init__.py``
-"by hand" to ensure it matches the `version identifier`_.
+**by hand** to ensure it matches the `version identifier`_.
+Run the test suite after changing the codebase version to ensure
+accuracy and consistency.
+
Release steps
~~~~~~~~~~~~~
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2017-08-14 11:28:48 UTC (rev 8164)
+++ trunk/docutils/docutils/utils/__init__.py 2017-08-14 22:23:30 UTC (rev 8165)
@@ -773,31 +773,33 @@
'final': '',}
def version_identifier(version_info=None):
- # to add in Docutils 0.15:
- # version_info is a namedtuple, an instance of Docutils.VersionInfo.
"""
- Given a `version_info` tuple (default is docutils.__version_info__),
- build & return a version identifier string.
+ Return a version identifier string built from `version_info`, a
+ `docutils.VersionInfo` namedtuple instance or compatible tuple. If
+ `version_info` is not provided, by default return a version identifier
+ string based on `docutils.__version_info__` (i.e. the current Docutils
+ version).
"""
if version_info is None:
version_info = __version_info__
- if version_info[2]: # version_info.micro
- micro = '.%s' % version_info[2]
+ if version_info.micro:
+ micro = '.%s' % version_info.micro
else:
+ # 0 is omitted:
micro = ''
- releaselevel = release_level_abbreviations[
- version_info[3]] # version_info.releaselevel
- if version_info[4]: # version_info.serial
- serial = version_info[4]
+ releaselevel = release_level_abbreviations[version_info.releaselevel]
+ if version_info.serial:
+ serial = version_info.serial
else:
+ # 0 is omitted:
serial = ''
- if version_info[5]: # version_info.release
+ if version_info.release:
dev = ''
else:
dev = '.dev'
version = '%s.%s%s%s%s%s' % (
- version_info[0], # version_info.major
- version_info[1], # version_info.minor
+ version_info.major,
+ version_info.minor,
micro,
releaselevel,
serial,
Modified: trunk/docutils/test/test__init__.py
===================================================================
--- trunk/docutils/test/test__init__.py 2017-08-14 11:28:48 UTC (rev 8164)
+++ trunk/docutils/test/test__init__.py 2017-08-14 22:23:30 UTC (rev 8165)
@@ -1,7 +1,8 @@
#! /usr/bin/env python
-# .. coding: utf-8
+# -*- coding: utf-8 -*-
# $Id$
-# Author: Günter Milde <mi...@us...>
+# Authors: Günter Milde <mi...@us...>,
+# David Goodger <go...@py...>
# Copyright: This module has been placed in the public domain.
"""
@@ -12,7 +13,9 @@
import sys
import DocutilsTestSupport # must be imported before docutils
import docutils
+import docutils.utils
+
class ApplicationErrorTests(unittest.TestCase):
def test_message(self):
@@ -23,16 +26,27 @@
err = docutils.ApplicationError(u'\u0169')
self.assertEqual(unicode(err), u'\u0169')
+
class VersionInfoTests(unittest.TestCase):
def test_version_info(self):
self.assertEqual(len(docutils.__version_info__), 6)
- # self.assertEqual(type(docutils.__version_info__.major), int)
- # self.assertEqual(type(docutils.__version_info__.minor), int)
- # self.assertEqual(type(docutils.__version_info__.micro), int)
- # self.assertEqual(type(docutils.__version_info__.releaselevel), str)
- # self.assertEqual(type(docutils.__version_info__.serial), int)
- # self.assertEqual(type(docutils.__version_info__.release), bool)
+ self.assertEqual(type(docutils.__version_info__.major), int)
+ self.assertEqual(type(docutils.__version_info__.minor), int)
+ self.assertEqual(type(docutils.__version_info__.micro), int)
+ self.assertEqual(type(docutils.__version_info__.releaselevel), str)
+ self.assertEqual(type(docutils.__version_info__.serial), int)
+ self.assertEqual(type(docutils.__version_info__.release), bool)
+ def test_version_identifier(self):
+ """
+ docutils.utils.version_identifier() implicitly depends on
+ docutils.__version_info__, so this tests that
+ docutils.__version__ is equivalent to docutils.__version_info__.
+ """
+ self.assertEqual(
+ docutils.utils.version_identifier(), docutils.__version__)
+
+
if __name__ == '__main__':
unittest.main()
Modified: trunk/docutils/test/test_utils.py
===================================================================
--- trunk/docutils/test/test_utils.py 2017-08-14 11:28:48 UTC (rev 8164)
+++ trunk/docutils/test/test_utils.py 2017-08-14 22:23:30 UTC (rev 8165)
@@ -1,5 +1,5 @@
+#! /usr/bin/env python
# -*- coding: utf-8 -*-
-#! /usr/bin/env python
# $Id$
# Author: David Goodger <go...@py...>
@@ -238,12 +238,18 @@
class HelperFunctionsTests(unittest.TestCase):
def test_version_identifier(self):
- """
- docutils.utils.version_identifier() depends on
- docutils.__version_info__, so this also tests that
- docutils.__version__ is equivalent to docutils.__version_info__.
- """
- self.assertEqual(utils.version_identifier(), docutils.__version__)
+ release_0_14_final = docutils.VersionInfo(
+ major=0, minor=14, micro=0,
+ releaselevel='final', serial=0, release=True)
+ self.assertEqual(utils.version_identifier(release_0_14_final), '0.14')
+ dev_0_15_beta = docutils.VersionInfo(
+ major=0, minor=15, micro=0,
+ releaselevel='beta', serial=0, release=False)
+ self.assertEqual(utils.version_identifier(dev_0_15_beta), '0.15b.dev')
+ release_0_14_rc1 = docutils.VersionInfo(
+ major=0, minor=14, micro=0,
+ releaselevel='candidate', serial=1, release=True)
+ self.assertEqual(utils.version_identifier(release_0_14_rc1), '0.14rc1')
def test_normalize_language_tag(self):
self.assertEqual(utils.normalize_language_tag('de'), ['de'])
@@ -263,7 +269,6 @@
self.assertEqual(utils.column_width(u'dâ'), 2) # pre-composed
self.assertEqual(utils.column_width(u'dâ'), 2) # combining
-
def test_relative_path(self):
# Build and return a path to `target`, relative to `source`:
# Use '/' as path sep in result.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <go...@us...> - 2017-08-15 21:20:39
|
Revision: 8167
http://sourceforge.net/p/docutils/code/8167
Author: goodger
Date: 2017-08-15 21:20:36 +0000 (Tue, 15 Aug 2017)
Log Message:
-----------
* Consolidated version identifier documentation, moving text from docutils/__init__.py to docs/dev/policies.txt.
* Cleaned up version-related code in docutils/__init__.py.
* Reworked the Version Numbering section in docs/dev/policies.txt.
* Added test/test_utils.HelperFunctionTests.test_implicit_version_identifier to test the implicit use of docutils.utils.version_identifier().
Modified Paths:
--------------
trunk/docutils/docs/dev/policies.txt
trunk/docutils/docutils/__init__.py
trunk/docutils/test/test_utils.py
Modified: trunk/docutils/docs/dev/policies.txt
===================================================================
--- trunk/docutils/docs/dev/policies.txt 2017-08-15 07:24:42 UTC (rev 8166)
+++ trunk/docutils/docs/dev/policies.txt 2017-08-15 21:20:36 UTC (rev 8167)
@@ -406,95 +406,157 @@
Version Numbering
=================
-The version identifier ``docutils.__version__`` indicates the state of
-development of the current Docutils codebase.
-``docutils.__version__``, a text string, is a concise, `PEP
-440`_-conforming representation of the namedtuple
-``docutils.__version_info__``.
+The state of development of the current Docutils codebase is stored in
+two forms: a ``docutils.__version_info__`` namedtuple, and a
+``docutils.__version__`` text string.
-.. _PEP 440: https://www.python.org/dev/peps/pep-0440/
+See also the `Docutils Release Procedure`_, and
+``docutils.__version__`` & ``docutils.__version_info__`` in
+docutils/__init__.py.
-* The *release segment* ("``<major>.<minor>[.<micro>]``",
- e.g. "0.4.1") is incremented after each official release.
+.. _Docutils Release Procedure: release.html#version-numbers
- **Major releases** (x.0, e.g. 1.0) will be rare, and will represent
- major changes in API, functionality, or commitment. When Docutils
- reaches version 1.0, the major APIs will be considered frozen and
- backward compatibility will become of paramount importance. The
- Docutils major release number is found in
- ``docutils.__version_info__.major``.
- Releases that change the minor number (x.y, e.g. 0.5) will be
- **feature releases**; new features from the `Docutils core`_ will be
- included. The Docutils minor release number is found in
- ``docutils.__version_info__.minor``.
+``docutils.__version_info__``
+-----------------------------
- Releases that change the micro number (x.y.z, e.g. 0.4.1) will be
- **bug-fix releases**. No new features will be introduced in these
- releases; only bug fixes will be included. The Docutils micro
- release number is found in ``docutils.__version_info__.micro``.
+Detailed version information is available in the namedtuple
+``docutils.__version_info__``, which has the following attributes:
-* The *pre-release segment* ("``[{a|b|rc}[N]]``") corresponds to the
- `development status`_ of the repository or release. The alphabetic
- label indicates the release level, found in
- ``docutils.__version_info__.releaselevel``:
+major : non-negative integer
+ **Major releases** (x.0, e.g. 1.0) will be rare, and will
+ represent major changes in API, functionality, or commitment. The
+ major number will be bumped to 1 when the project is
+ feature-complete, and may be incremented later if there is a major
+ change in the design or API. When Docutils reaches version 1.0,
+ the major APIs will be considered frozen and backward
+ compatibility will become of paramount importance.
- ======= ============= ============================================
- Label Release Level Comment
- ======= ============= ============================================
- ``a`` alpha To be used only after major experimental
- changes, to indicate an unstable codebase.
+minor : non-negative integer
+ Releases that change the minor number (x.y, e.g. 0.5) will be
+ **feature releases**; new features from the `Docutils core`_ will
+ be included.
- ``b`` beta Stable but between releases. This is the
- default state of the repository, with serial==0.
+micro : non-negative integer
+ Releases that change the micro number (x.y.z, e.g. 0.4.1) will be
+ **bug-fix releases**. No new features will be introduced in these
+ releases; only bug fixes will be included. The micro number is
+ omitted from ``docutils.__version__`` when micro=0.
- ``rcN`` candidate Release candidate: ready to release unless
- significant bugs emerge.
+releaselevel : text string
+ The release level indicates the `development status`_ (or phase)
+ of the project's codebase:
- .. final (No label.) There is no pre-release segment
- for final releases.
- ======= ============= ============================================
+ ============= ======= ============================================
+ Release Level Label Description
+ ============= ======= ============================================
+ alpha ``a`` Reserved for use after major experimental
+ changes, to indicate an unstable codebase.
- .. _development status:
- https://en.wikipedia.org/wiki/Software_release_life_cycle
+ beta ``b`` Indicates active development, between releases.
+ Used with serial = 0.
- ``N`` in the *pre-release segment* is a non-negative integer serial
- number; found in ``docutils.__version_info__.serial``. The serial
- number is incremented whenever a new pre-release is begun. When the
- serial number N is 0, it is omitted from the pre-release segment. 0
- is used between releases (with the "beta" release level).
+ candidate ``rcN`` Release candidate: indicates that the
+ codebase is ready to release unless
+ significant bugs emerge.
+ Serial N starts at 1.
-* The *development release segment* (``.dev``) is in place during
- development, and omitted for official releases and pre-releases.
- "``.dev``" is present in ``docutils.__version__`` when
- ``docutils.__version_info__.release`` is False, and absent from
- ``docutils.__version__`` when ``docutils.__version_info__.release``
- is True.
+ final Indicates an official project release.
+ There is no pre-release segment for final
+ releases (no label).
+ ============= ======= ============================================
-Examples of ``docutils.__version__`` version identifiers, over the
-course of normal development (without branches), in chronological
-order:
+ The abbreviations in the "Label" column are used in the
+ `docutils.__version__`_ identifier text.
+ .. _development status:
+ https://en.wikipedia.org/wiki/Software_release_life_cycle
+
+serial : non-negative integer
+ The serial number is incremented whenever a new pre-release is
+ begun.
+
+release : boolean
+ True for official releases and pre-releases, False during
+ development.
+
+One of *{major, minor, micro}* is incremented after each official
+release, and the lower-order numbers are reset to 0.
+
+The default state of the repository during active development and
+between releases is: release level "beta", serial = 0, release =
+False.
+
+``docutils.__version_info__`` can be used to test for a minimally
+required version, e.g.::
+
+ if docutils.__version_info__ >= (0, 13, 0, 'candidate', 2, True)
+
+or in a self-documenting way::
+
+ comparison_version = docutils.VersionInfo(
+ major=0, minor=13, micro=0,
+ releaselevel='candidate', serial=2, release=True)
+ if docutils.__version_info__ >= comparison_version:
+ ...
+
+
+``docutils.__version__``
+------------------------
+
+``docutils.__version__`` contains the version identifier as a text
+string: a concise, `PEP 440`_-conforming representation of
+``docutils.__version_info__``.
+
+For version comparison operations, use `docutils.__version_info__`_.
+Do not parse the text of ``docutils.__version__``.
+
+``docutils.__version__`` takes the following form::
+
+ <major>.<minor>[.<micro>][<releaselevel>[<serial>]][.dev]
+ <--- release segment ---><-- pre-release segment -><- development ->
+
+.. _PEP 440: https://www.python.org/dev/peps/pep-0440/
+
+* The abbreviated forms of each release level, found in the "Label"
+ column in the table above ("a" or "b" or "rc"), are used in the
+ pre-release segment.
+
+* When the serial number is 0, it is omitted from the pre-release
+ segment.
+
+* The development segment is present during active development (as
+ "``.dev``", when ``docutils.__version_info__.release`` is False),
+ and absent for official releases and pre-releases (when
+ ``docutils.__version_info__.release`` is True).
+
+Examples of ``docutils.__version__`` identifiers, over the course of
+normal development (without branches), in chronological order:
+
====================== ============================
Release Level Version Identifier
====================== ============================
final (release) 0.14
-beta (development) 0.15b.dev
-beta (release) 0.15b¹
+beta (development) 0.15b.dev [2]_
+beta (release) 0.15b [1]_
candidate 1 (dev.) 0.15rc1.dev
candidate 1 (release) 0.15rc1
-candidate 2 (dev.) 0.15rc2.dev¹
-candidate 2 (release) 0.15rc2¹
-... candidate N 0.15rcN.dev¹, 0.15rcN¹
-final (dev.) 0.15.dev¹
+candidate 2 (dev.) 0.15rc2.dev [1]_
+candidate 2 (release) 0.15rc2 [1]_
+... candidate N 0.15rcN.dev [1]_, 0.15rcN [1]_
+final (dev.) 0.15.dev [1]_
final (release) 0.15
-beta (dev.) 0.16b.dev
+beta (dev.) 0.16b.dev [2]_
====================== ============================
-¹may be skipped
+.. [1] These steps may be skipped.
-Policy history:
+.. [2] Default active development state between releases.
+
+Policy History
+--------------
+
* Prior to version 0.4, Docutils didn't have an official version
numbering policy, and micro releases contained both bug fixes and
new features.
@@ -510,13 +572,7 @@
https://sourceforge.net/p/docutils/feature-requests/50/
__ https://sourceforge.net/p/docutils/mailman/message/35903816/
-See also the `Docutils Release Procedure`_, and
-``docutils.__version__`` & ``docutils.__version_info__`` in
-docuitls/__init__.py.
-.. _Docutils Release Procedure: release.html#version-numbers
-
-
Snapshots
=========
Modified: trunk/docutils/docutils/__init__.py
===================================================================
--- trunk/docutils/docutils/__init__.py 2017-08-15 07:24:42 UTC (rev 8166)
+++ trunk/docutils/docutils/__init__.py 2017-08-15 21:20:36 UTC (rev 8167)
@@ -51,6 +51,7 @@
"""
import sys
+from collections import namedtuple
__docformat__ = 'reStructuredText'
@@ -60,45 +61,29 @@
major.minor[.micro][releaselevel[serial]][.dev]
-* The major number will be bumped when the project is feature-complete, and
- later if there is a major change in the design or API.
-* The minor number is bumped whenever there are new features.
-* The micro number is bumped for bug-fix releases. Omitted if micro=0.
-* The releaselevel identifier is used for pre-releases, one of 'a' (alpha),
- 'b' (beta), or 'rc' (release candidate). Omitted for final releases.
-* The serial release number identifies prereleases; omitted if 0.
-* The '.dev' suffix indicates active development, not a release, before the
- version indicated.
+For version comparison operations, use `__version_info__` (which see, below)
+rather than parsing the text of `__version__`.
-For version comparison operations, use `__version_info__`
-rather than parsing the text of `__version__`.
+See 'Version Numbering' in docs/dev/policies.txt.
"""
-from collections import namedtuple
VersionInfo = namedtuple(
'VersionInfo', 'major minor micro releaselevel serial release')
+
__version_info__ = VersionInfo(
major=0,
minor=15,
micro=0,
- releaselevel='beta', # `development status`__:
- # one of 'alpha', 'beta', 'candidate', 'final'
- # __ https://en.wikipedia.org/wiki/Software_release_life_cycle
- serial=0, # pre-release serial number (0 for final releases)
- release=False # True for official releases and pre-releases
+ # one of 'alpha', 'beta', 'candidate', 'final':
+ releaselevel='beta',
+ # pre-release serial number (0 for final releases and active development):
+ serial=0,
+ # True for official releases and pre-releases, False during development:
+ release=False
)
-"""Comprehensive version information tuple. Can be used to test for a
-minimally required version, e.g. ::
+"""Comprehensive version information tuple. See 'Version Numbering' in
+docs/dev/policies.txt."""
- if __version_info__ >= (0, 13, 0, 'candidate', 2, True)
-
-or in a self-documenting way like ::
-
- if __version_info__ >= docutils.VersionInfo(
- major=0, minor=13, micro=0,
- releaselevel='candidate', serial=2, release=True)
-"""
-
__version_details__ = ''
"""Optional extra version details (e.g. 'snapshot 2005-05-29, r3410').
(For development and release status see `__version_info__`.)
Modified: trunk/docutils/test/test_utils.py
===================================================================
--- trunk/docutils/test/test_utils.py 2017-08-15 07:24:42 UTC (rev 8166)
+++ trunk/docutils/test/test_utils.py 2017-08-15 21:20:36 UTC (rev 8167)
@@ -235,7 +235,7 @@
field_list, self.optionspec)
-class HelperFunctionsTests(unittest.TestCase):
+class HelperFunctionTests(unittest.TestCase):
def test_version_identifier(self):
release_0_14_final = docutils.VersionInfo(
@@ -251,6 +251,11 @@
releaselevel='candidate', serial=1, release=True)
self.assertEqual(utils.version_identifier(release_0_14_rc1), '0.14rc1')
+ def test_implicit_version_identifier(self):
+ self.assertEqual(
+ utils.version_identifier(docutils.__version_info__),
+ utils.version_identifier())
+
def test_normalize_language_tag(self):
self.assertEqual(utils.normalize_language_tag('de'), ['de'])
self.assertEqual(utils.normalize_language_tag('de-AT'),
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <go...@us...> - 2017-08-16 21:40:27
|
Revision: 8169
http://sourceforge.net/p/docutils/code/8169
Author: goodger
Date: 2017-08-16 21:40:24 +0000 (Wed, 16 Aug 2017)
Log Message:
-----------
* docutils/parsers/rst/states.py: Allow embedded colons in field list field names (also updated docs/ref/rst/restructuredtext.txt).
* docutils/parsers/rst/directives/html.py: [Fix for bug 281:] Allow backslash-escaped colons in meta directive field list field names (also updated docs/dev/todo.txt).
* Added tests for the above.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/ref/rst/restructuredtext.txt
trunk/docutils/docutils/parsers/rst/directives/html.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
trunk/docutils/test/test_parsers/test_rst/test_field_lists.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-08-16 21:30:43 UTC (rev 8168)
+++ trunk/docutils/HISTORY.txt 2017-08-16 21:40:24 UTC (rev 8169)
@@ -19,8 +19,18 @@
* General
- Dropped support for Python 2.4, 2.5, 3.1, and 3.2.
- - infrastructure automatisms.
+ - Infrastructure automation.
+* docutils/parsers/rst/states.py:
+
+ - Allow embedded colons in field list field names (also updated
+ docs/ref/rst/restructuredtext.txt).
+
+* docutils/parsers/rst/directives/html.py:
+
+ - [Fix for bug 281:] Allow backslash-escaped colons in meta directive
+ field list field names (also updated docs/dev/todo.txt).
+
* docutils/writers/latex2e/__init__.py
- Fix [ 323 ] don't add ``\phantomsection`` and whitespace to
Modified: trunk/docutils/docs/ref/rst/restructuredtext.txt
===================================================================
--- trunk/docutils/docs/ref/rst/restructuredtext.txt 2017-08-16 21:30:43 UTC (rev 8168)
+++ trunk/docutils/docs/ref/rst/restructuredtext.txt 2017-08-16 21:40:24 UTC (rev 8169)
@@ -830,7 +830,8 @@
Field lists are mappings from *field names* to *field bodies*, modeled on
RFC822_ headers. A field name may consist of any characters, but
-colons (":") inside of field names must be escaped with a backslash.
+colons (":") inside of field names must be backslash-escaped
+when followed by whitespace.
Inline markup is parsed in field names. Field names are
case-insensitive when further processed or transformed. The field
name, along with a single colon prefix and suffix, together form the
Modified: trunk/docutils/docutils/parsers/rst/directives/html.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/html.py 2017-08-16 21:30:43 UTC (rev 8168)
+++ trunk/docutils/docutils/parsers/rst/directives/html.py 2017-08-16 21:40:24 UTC (rev 8169)
@@ -29,6 +29,7 @@
def parsemeta(self, match):
name = self.parse_field_marker(match)
+ name = utils.unescape(utils.escape2null(name))
indented, indent, line_offset, blank_finish = \
self.state_machine.get_first_known_indented(match.end())
node = self.meta()
@@ -36,7 +37,7 @@
{'component': 'writer',
'format': 'html',
'nodes': [node]})
- node['content'] = ' '.join(indented)
+ node['content'] = utils.unescape(utils.escape2null(' '.join(indented)))
if not indented:
line = self.state_machine.line
msg = self.reporter.info(
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2017-08-16 21:30:43 UTC (rev 8168)
+++ trunk/docutils/docutils/parsers/rst/states.py 2017-08-16 21:40:24 UTC (rev 8169)
@@ -1119,7 +1119,7 @@
patterns = {
'bullet': u'[-+*\u2022\u2023\u2043]( +|$)',
'enumerator': r'(%(parens)s|%(rparen)s|%(period)s)( +|$)' % pats,
- 'field_marker': r':(?![: ])([^:\\]|\\.)*(?<! ):( +|$)',
+ 'field_marker': r':(?![: ])([^:\\]|\\.|:(?!([ `]|$)))*(?<! ):( +|$)',
'option_marker': r'%(option)s(, %(option)s)*( +| ?$)' % pats,
'doctest': r'>>>( +|$)',
'line_block': r'\|( +|$)',
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py 2017-08-16 21:30:43 UTC (rev 8168)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_meta.py 2017-08-16 21:40:24 UTC (rev 8169)
@@ -222,6 +222,22 @@
<literal_block xml:space="preserve">
:name notattval: content
"""],
+[r"""
+.. meta::
+ :name\:with\:colons: escaped line\
+ break
+""",
+"""\
+<document source="test data">
+ <pending>
+ .. internal attributes:
+ .transform: docutils.transforms.components.Filter
+ .details:
+ component: 'writer'
+ format: 'html'
+ nodes:
+ <meta content="escaped linebreak" name="name:with:colons">
+"""],
]
Modified: trunk/docutils/test/test_parsers/test_rst/test_field_lists.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_field_lists.py 2017-08-16 21:30:43 UTC (rev 8168)
+++ trunk/docutils/test/test_parsers/test_rst/test_field_lists.py 2017-08-16 21:40:24 UTC (rev 8169)
@@ -542,6 +542,52 @@
<paragraph>
A definition list, not a field list.
"""],
+[r"""
+:first: field
+:field:name:with:embedded:colons: unambiguous, no need for escapes
+
+..
+
+:embedded:colons: in first field name
+:field:\`:name: not interpreted text
+:field:\`name: not interpreted text
+""",
+"""\
+<document source="test data">
+ <field_list>
+ <field>
+ <field_name>
+ first
+ <field_body>
+ <paragraph>
+ field
+ <field>
+ <field_name>
+ field:name:with:embedded:colons
+ <field_body>
+ <paragraph>
+ unambiguous, no need for escapes
+ <comment xml:space="preserve">
+ <field_list>
+ <field>
+ <field_name>
+ embedded:colons
+ <field_body>
+ <paragraph>
+ in first field name
+ <field>
+ <field_name>
+ field:`:name
+ <field_body>
+ <paragraph>
+ not interpreted text
+ <field>
+ <field_name>
+ field:`name
+ <field_body>
+ <paragraph>
+ not interpreted text
+"""],
]
if __name__ == '__main__':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-08-17 15:58:26
|
Revision: 8171
http://sourceforge.net/p/docutils/code/8171
Author: milde
Date: 2017-08-17 15:58:23 +0000 (Thu, 17 Aug 2017)
Log Message:
-----------
Small cleanup and formatting edits.
* Use `True` instead of 1 in boolean arguments.
* Deprecate `unique_combinations` (obsoleted by `itertools.combinations`).
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/parsers/rst/directives/html.py
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/utils/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-08-16 21:50:06 UTC (rev 8170)
+++ trunk/docutils/HISTORY.txt 2017-08-17 15:58:23 UTC (rev 8171)
@@ -28,8 +28,7 @@
* docutils/parsers/rst/directives/html.py:
- - [Fix for bug 281:] Allow backslash-escaped colons in meta directive
- field list field names (also updated docs/dev/todo.txt).
+ - Fix [ 281 ] Remove escaping backslashes in meta directive content.
* docutils/writers/latex2e/__init__.py
@@ -36,7 +35,11 @@
- Fix [ 323 ] don't add ``\phantomsection`` and whitespace to
``parts['title'].
+* docutils/utils/__init__.py:
+ - Deprecate `unique_combinations` (obsoleted by `itertools.combinations`).
+
+
Release 0.14 (2017-08-03)
=========================
Modified: trunk/docutils/docutils/parsers/rst/directives/html.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/html.py 2017-08-16 21:50:06 UTC (rev 8170)
+++ trunk/docutils/docutils/parsers/rst/directives/html.py 2017-08-17 15:58:23 UTC (rev 8171)
@@ -37,7 +37,8 @@
{'component': 'writer',
'format': 'html',
'nodes': [node]})
- node['content'] = utils.unescape(utils.escape2null(' '.join(indented)))
+ node['content'] = utils.unescape(utils.escape2null(
+ ' '.join(indented)))
if not indented:
line = self.state_machine.line
msg = self.reporter.info(
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2017-08-16 21:50:06 UTC (rev 8170)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2017-08-17 15:58:23 UTC (rev 8171)
@@ -308,7 +308,7 @@
prb = inliner.problematic(rawtext, rawtext, msg)
return [prb], [msg]
set_classes(options)
- node = nodes.raw(rawtext, utils.unescape(text, 1), **options)
+ node = nodes.raw(rawtext, utils.unescape(text, True), **options)
node.source, node.line = inliner.reporter.get_source_and_line(lineno)
return [node], []
@@ -325,7 +325,7 @@
if language and language not in classes:
classes.append(language)
try:
- tokens = Lexer(utils.unescape(text, 1), language,
+ tokens = Lexer(utils.unescape(text, True), language,
inliner.document.settings.syntax_highlight)
except LexerError, error:
msg = inliner.reporter.warning(error)
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2017-08-16 21:50:06 UTC (rev 8170)
+++ trunk/docutils/docutils/parsers/rst/states.py 2017-08-17 15:58:23 UTC (rev 8171)
@@ -714,14 +714,14 @@
text = unescape(endmatch.string[:endmatch.start(1)],
restore_backslashes)
textend = matchend + endmatch.end(1)
- rawsource = unescape(string[matchstart:textend], 1)
+ rawsource = unescape(string[matchstart:textend], True)
return (string[:matchstart], [nodeclass(rawsource, text)],
string[textend:], [], endmatch.group(1))
msg = self.reporter.warning(
'Inline %s start-string without end-string.'
% nodeclass.__name__, line=lineno)
- text = unescape(string[matchstart:matchend], 1)
- rawsource = unescape(string[matchstart:matchend], 1)
+ text = unescape(string[matchstart:matchend], True)
+ rawsource = unescape(string[matchstart:matchend], True)
prb = self.problematic(text, rawsource, msg)
return string[:matchstart], [prb], string[matchend:], [msg], ''
@@ -764,25 +764,25 @@
'Multiple roles in interpreted text (both '
'prefix and suffix present; only one allowed).',
line=lineno)
- text = unescape(string[rolestart:textend], 1)
+ text = unescape(string[rolestart:textend], True)
prb = self.problematic(text, text, msg)
return string[:rolestart], [prb], string[textend:], [msg]
role = endmatch.group('suffix')[1:-1]
position = 'suffix'
escaped = endmatch.string[:endmatch.start(1)]
- rawsource = unescape(string[matchstart:textend], 1)
+ rawsource = unescape(string[matchstart:textend], True)
if rawsource[-1:] == '_':
if role:
msg = self.reporter.warning(
'Mismatch: both interpreted text role %s and '
'reference suffix.' % position, line=lineno)
- text = unescape(string[rolestart:textend], 1)
+ text = unescape(string[rolestart:textend], True)
prb = self.problematic(text, text, msg)
return string[:rolestart], [prb], string[textend:], [msg]
return self.phrase_ref(string[:matchstart], string[textend:],
rawsource, escaped, unescape(escaped))
else:
- rawsource = unescape(string[rolestart:textend], 1)
+ rawsource = unescape(string[rolestart:textend], True)
nodelist, messages = self.interpreted(rawsource, escaped, role,
lineno)
return (string[:rolestart], nodelist,
@@ -790,7 +790,7 @@
msg = self.reporter.warning(
'Inline interpreted text or phrase reference start-string '
'without end-string.', line=lineno)
- text = unescape(string[matchstart:matchend], 1)
+ text = unescape(string[matchstart:matchend], True)
prb = self.problematic(text, text, msg)
return string[:matchstart], [prb], string[matchend:], [msg]
@@ -977,8 +977,8 @@
else:
addscheme = ''
text = match.group('whole')
- unescaped = unescape(text, 0)
- return [nodes.reference(unescape(text, 1), unescaped,
+ unescaped = unescape(text)
+ return [nodes.reference(unescape(text, True), unescaped,
refuri=addscheme + unescaped)]
else: # not a valid scheme
raise MarkupMismatch
@@ -993,8 +993,8 @@
raise MarkupMismatch
ref = (self.document.settings.pep_base_url
+ self.document.settings.pep_file_url_template % pepnum)
- unescaped = unescape(text, 0)
- return [nodes.reference(unescape(text, 1), unescaped, refuri=ref)]
+ unescaped = unescape(text)
+ return [nodes.reference(unescape(text, True), unescaped, refuri=ref)]
rfc_url = 'rfc%d.html'
@@ -1005,8 +1005,8 @@
ref = self.document.settings.rfc_base_url + self.rfc_url % rfcnum
else:
raise MarkupMismatch
- unescaped = unescape(text, 0)
- return [nodes.reference(unescape(text, 1), unescaped, refuri=ref)]
+ unescaped = unescape(text)
+ return [nodes.reference(unescape(text, True), unescaped, refuri=ref)]
def implicit_inline(self, text, lineno):
"""
@@ -1028,7 +1028,7 @@
self.implicit_inline(text[match.end():], lineno))
except MarkupMismatch:
pass
- return [nodes.Text(unescape(text), rawsource=unescape(text, 1))]
+ return [nodes.Text(unescape(text), rawsource=unescape(text, True))]
dispatch = {'*': emphasis,
'**': strong,
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2017-08-16 21:50:06 UTC (rev 8170)
+++ trunk/docutils/docutils/utils/__init__.py 2017-08-17 15:58:23 UTC (rev 8171)
@@ -660,15 +660,12 @@
r.append(item)
return r
-# by Li Daobing http://code.activestate.com/recipes/190465/
-# since Python 2.6 there is also itertools.combinations()
def unique_combinations(items, n):
- """Return n-length tuples, in sorted order, no repeated elements"""
- if n==0: yield []
- else:
- for i in xrange(len(items)-n+1):
- for cc in unique_combinations(items[i+1:],n-1):
- yield [items[i]]+cc
+ """Return `itertools.combinations`."""
+ warnings.warn('docutils.utils.unique_combinations is deprecated; '
+ 'use itertools.combinations directly.',
+ DeprecationWarning, stacklevel=2)
+ return itertools.combinations(items, n)
def normalize_language_tag(tag):
"""Return a list of normalized combinations for a `BCP 47` language tag.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <go...@us...> - 2017-08-17 22:28:44
|
Revision: 8172
http://sourceforge.net/p/docutils/code/8172
Author: goodger
Date: 2017-08-17 22:28:42 +0000 (Thu, 17 Aug 2017)
Log Message:
-----------
Added a test case and updated docs/ref/rst/restructuredtext.txt for interpreted text in field list field names.
Modified Paths:
--------------
trunk/docutils/docs/ref/rst/restructuredtext.txt
trunk/docutils/test/test_parsers/test_rst/test_field_lists.py
Modified: trunk/docutils/docs/ref/rst/restructuredtext.txt
===================================================================
--- trunk/docutils/docs/ref/rst/restructuredtext.txt 2017-08-17 15:58:23 UTC (rev 8171)
+++ trunk/docutils/docs/ref/rst/restructuredtext.txt 2017-08-17 22:28:42 UTC (rev 8172)
@@ -832,7 +832,9 @@
RFC822_ headers. A field name may consist of any characters, but
colons (":") inside of field names must be backslash-escaped
when followed by whitespace.
-Inline markup is parsed in field names. Field names are
+Inline markup is parsed in field names, but care must be taken when
+using `interpreted text`_ with explicit roles in field names: the role
+must be a suffix to the interpreted text. Field names are
case-insensitive when further processed or transformed. The field
name, along with a single colon prefix and suffix, together form the
field marker. The field marker is followed by whitespace and the
@@ -2651,7 +2653,29 @@
custom interpreted text roles. In addition, applications may support
specialized roles.
+In `field lists`_, care must be taken when using interpreted text with
+explicit roles in field names: the role must be a suffix to the
+interpreted text. The following are recognized as field list items::
+ :`field name`:code:: interpreted text with explicit role as suffix
+
+ :a `complex`:code:\ field name: a backslash-escaped space
+ is necessary
+
+The following are **not** recognized as field list items::
+
+ ::code:`not a field name`: paragraph with interpreted text
+
+ :code:`not a field name`: paragraph with interpreted text
+
+Edge cases::
+
+ :field\:`name`: interpreted text (standard role) requires
+ escaping the leading colon in a field name
+
+ :field:\`name`: not interpreted text
+
+
Inline Literals
---------------
Modified: trunk/docutils/test/test_parsers/test_rst/test_field_lists.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_field_lists.py 2017-08-17 15:58:23 UTC (rev 8171)
+++ trunk/docutils/test/test_parsers/test_rst/test_field_lists.py 2017-08-17 22:28:42 UTC (rev 8172)
@@ -588,6 +588,94 @@
<paragraph>
not interpreted text
"""],
+[r"""
+Edge cases involving embedded colons and interpreted text.
+
+Recognized as field list items:
+
+:field\:`name`: interpreted text (standard role) requires
+ escaping a leading colon in a field name
+
+:field:name: unambiguous, no need for escapes
+
+:field::name: double colons are OK, too
+
+:field:\`name`: not interpreted text
+
+:`field name`:code:: interpreted text with role in the field name
+ works only when the role follows the text
+
+:a `complex`:code:\ field name: field body
+
+Not recognized as field list items:
+
+::code:`not a field name`: paragraph with interpreted text
+
+:code:`not a field name`: paragraph with interpreted text
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Edge cases involving embedded colons and interpreted text.
+ <paragraph>
+ Recognized as field list items:
+ <field_list>
+ <field>
+ <field_name>
+ field:
+ <title_reference>
+ name
+ <field_body>
+ <paragraph>
+ interpreted text (standard role) requires
+ escaping a leading colon in a field name
+ <field>
+ <field_name>
+ field:name
+ <field_body>
+ <paragraph>
+ unambiguous, no need for escapes
+ <field>
+ <field_name>
+ field::name
+ <field_body>
+ <paragraph>
+ double colons are OK, too
+ <field>
+ <field_name>
+ field:`name`
+ <field_body>
+ <paragraph>
+ not interpreted text
+ <field>
+ <field_name>
+ <literal classes="code">
+ field name
+ <field_body>
+ <paragraph>
+ interpreted text with role in the field name
+ works only when the role follows the text
+ <field>
+ <field_name>
+ a
+ <literal classes="code">
+ complex
+ field name
+ <field_body>
+ <paragraph>
+ field body
+ <paragraph>
+ Not recognized as field list items:
+ <paragraph>
+ :
+ <literal classes="code">
+ not a field name
+ : paragraph with interpreted text
+ <paragraph>
+ <literal classes="code">
+ not a field name
+ : paragraph with interpreted text
+"""],
]
if __name__ == '__main__':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-08-18 16:44:30
|
Revision: 8173
http://sourceforge.net/p/docutils/code/8173
Author: milde
Date: 2017-08-18 16:44:27 +0000 (Fri, 18 Aug 2017)
Log Message:
-----------
0.15.dev must not be used after 0.15b or 0.15rc.
According to PEP 440, <major>.<minor>.dev must be sorted before
<major>.<minor><pre>.dev.
As we agreed on default releaselevel "beta" for development,
the ".dev" suffix should not be used without a pre-release segment
for Docutils versions.
Modified Paths:
--------------
trunk/docutils/docs/dev/policies.txt
trunk/docutils/test/test__init__.py
Modified: trunk/docutils/docs/dev/policies.txt
===================================================================
--- trunk/docutils/docs/dev/policies.txt 2017-08-17 22:28:42 UTC (rev 8172)
+++ trunk/docutils/docs/dev/policies.txt 2017-08-18 16:44:27 UTC (rev 8173)
@@ -403,12 +403,14 @@
.. _HISTORY.txt: ../../HISTORY.txt
-Version Numbering
-=================
+.. _`Version Numbering`:
+Version Identification
+======================
+
The state of development of the current Docutils codebase is stored in
-two forms: a ``docutils.__version_info__`` namedtuple, and a
-``docutils.__version__`` text string.
+two forms: a `docutils.__version_info__`_ namedtuple, and a
+`docutils.__version__`_ text string.
See also the `Docutils Release Procedure`_, and
``docutils.__version__`` & ``docutils.__version_info__`` in
@@ -420,8 +422,10 @@
``docutils.__version_info__``
-----------------------------
-Detailed version information is available in the namedtuple
-``docutils.__version_info__``, which has the following attributes:
+Detailed version information is available in
+``docutils.__version_info__``, an instance of the namedtuple_
+``docutils.VersionInfo``. It is modelled on `sys.version_info`_ and
+has the following attributes:
major : non-negative integer
**Major releases** (x.0, e.g. 1.0) will be rare, and will
@@ -490,10 +494,6 @@
``docutils.__version_info__`` can be used to test for a minimally
required version, e.g.::
- if docutils.__version_info__ >= (0, 13, 0, 'candidate', 2, True)
-
-or in a self-documenting way::
-
comparison_version = docutils.VersionInfo(
major=0, minor=13, micro=0,
releaselevel='candidate', serial=2, release=True)
@@ -500,7 +500,24 @@
if docutils.__version_info__ >= comparison_version:
...
+For practical purposes it may suffice to test against a truncated tuple,
+e.g.::
+ if docutils.__version_info__ >= (0, 13)
+
+is True for all versions "larger" than ``"0.13"``.
+
+Mind, however, that a test like ::
+
+ if docutils.__version_info__ > (0, 14)
+
+is True also for development versions and pre-releases of the 0.14 series
+although, according to PEP 440, these must be sorted before 0.14.
+
+.. _namedtuple: https://docs.python.org/3/library/collections.html#collections.namedtuple
+.. _sys.version_info: https://docs.python.org/3/library/sys.html#version-info
+
+
``docutils.__version__``
------------------------
@@ -531,7 +548,7 @@
``docutils.__version_info__.release`` is True).
Examples of ``docutils.__version__`` identifiers, over the course of
-normal development (without branches), in chronological order:
+normal development (without branches), in ascending order:
====================== ============================
Release Level Version Identifier
@@ -544,7 +561,6 @@
candidate 2 (dev.) 0.15rc2.dev [1]_
candidate 2 (release) 0.15rc2 [1]_
... candidate N 0.15rcN.dev [1]_, 0.15rcN [1]_
-final (dev.) 0.15.dev [1]_
final (release) 0.15
beta (dev.) 0.16b.dev [2]_
====================== ============================
Modified: trunk/docutils/test/test__init__.py
===================================================================
--- trunk/docutils/test/test__init__.py 2017-08-17 22:28:42 UTC (rev 8172)
+++ trunk/docutils/test/test__init__.py 2017-08-18 16:44:27 UTC (rev 8173)
@@ -37,10 +37,25 @@
self.assertEqual(type(docutils.__version_info__.releaselevel), str)
self.assertEqual(type(docutils.__version_info__.serial), int)
self.assertEqual(type(docutils.__version_info__.release), bool)
+
releaselevels = ('alpha', 'beta', 'candidate', 'final')
self.assertTrue(
docutils.__version_info__.releaselevel in releaselevels)
+ if (docutils.__version_info__.releaselevel == 'final'):
+ # releaselevel 'final' must not be used with development versions
+ # (leads to wrong version ordering of the related __version__):
+ #
+ # Within a numeric release (1.0, 2.7.3), the following suffixes
+ # are permitted and MUST be ordered as shown:
+ #
+ # .devN, aN, bN, rcN, <no suffix>, .postN
+ #
+ # https://www.python.org/dev/peps/pep-0440/#summary-of-permitted-suffixes-and-relative-ordering
+ self.assertTrue(docutils.__version_info__.release)
+ # pre-release serial number must be 0 for final releases:
+ self.assertEqual(type(docutils.__version_info__.serial), 0)
+
def test__version__(self):
"""Test that __version__ is equivalent to __version_info__."""
self.assertEqual(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-09-07 07:39:21
|
Revision: 8174
http://sourceforge.net/p/docutils/code/8174
Author: milde
Date: 2017-09-07 07:39:18 +0000 (Thu, 07 Sep 2017)
Log Message:
-----------
Fix [ 324 ] Invalid LaTeX for table with empty multicolumn cell.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-08-18 16:44:27 UTC (rev 8173)
+++ trunk/docutils/HISTORY.txt 2017-09-07 07:39:18 UTC (rev 8174)
@@ -32,8 +32,9 @@
* docutils/writers/latex2e/__init__.py
- - Fix [ 323 ] don't add ``\phantomsection`` and whitespace to
+ - Fix [ 323 ] spurious ``\phantomsection`` and whitespace in
``parts['title'].
+ - Fix [ 324 ] Invalid LaTeX for table with empty multicolumn cell.
* docutils/utils/__init__.py:
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2017-08-18 16:44:27 UTC (rev 8173)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2017-09-07 07:39:18 UTC (rev 8174)
@@ -2098,7 +2098,9 @@
self.context.append('')
# if line ends with '{', mask line break to prevent spurious whitespace
- if not self.active_table.colwidths_auto and self.out[-1].endswith("{"):
+ if (not self.active_table.colwidths_auto
+ and self.out[-1].endswith("{")
+ and node.astext()):
self.out.append("%")
self.active_table.visit_entry() # increment cell count
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2017-08-18 16:44:27 UTC (rev 8173)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2017-09-07 07:39:18 UTC (rev 8174)
@@ -770,8 +770,7 @@
"""],
]
-totest['table_empty_thead_entry'] = [
-# input
+totest['table_empty_cells'] = [
["""\
===== ======
Title
@@ -807,6 +806,29 @@
\end{document}
"""],
+["""\
++----+----+
+| c3 | c4 |
++----+----+
+| |
++---------+
+""",
+head_table + r"""
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.063\DUtablewidth}|}
+\hline
+
+c3
+ &
+c4
+ \\
+\hline
+\multicolumn{2}{|p{0.13\DUtablewidth}|}{} \\
+\hline
+\end{longtable*}
+
+\end{document}
+"""],
]
# The "[" needs to be protected (otherwise it will be seen as an
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-09-07 19:35:01
|
Revision: 8175
http://sourceforge.net/p/docutils/code/8175
Author: milde
Date: 2017-09-07 19:34:59 +0000 (Thu, 07 Sep 2017)
Log Message:
-----------
Document rST syntax change.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-09-07 07:39:18 UTC (rev 8174)
+++ trunk/docutils/HISTORY.txt 2017-09-07 19:34:59 UTC (rev 8175)
@@ -21,10 +21,14 @@
- Dropped support for Python 2.4, 2.5, 3.1, and 3.2.
- Infrastructure automation.
+* docs/ref/rst/restructuredtext.txt:
+
+ - Document rST syntax change: Tokens like ``:this:example:`` are now valid
+ field list names (instead of ordinary text).
+
* docutils/parsers/rst/states.py:
- - Allow embedded colons in field list field names (also updated
- docs/ref/rst/restructuredtext.txt).
+ - Allow embedded colons in field list field names.
* docutils/parsers/rst/directives/html.py:
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2017-09-07 07:39:18 UTC (rev 8174)
+++ trunk/docutils/RELEASE-NOTES.txt 2017-09-07 19:34:59 UTC (rev 8175)
@@ -43,18 +43,21 @@
.. Note::
- Docutils 0.14.x is the last version supporting Python 2.4, 2.5,
+ Docutils 0.14.x is the last version supporting Python 2.4, 2.5,
3.1, and 3.2.
Docutils 0.15.x is compatible with Python versions 2.6, 2.7 and 3.3 to 3.5
(cf. `Python 3 compatibility`_).
+* reStructuredText:
+ - Allow embedded colons in field list field names (before, tokens like
+ ``:this:example:`` were considered ordinary text).
+
+
Release 0.14 (2017-08-03)
=========================
-As rc2.
-
* docutils/docs/ref/docutils.dtd:
- Enable validation of Docutils XML documents against the DTD:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-09-14 13:47:18
|
Revision: 8179
http://sourceforge.net/p/docutils/code/8179
Author: milde
Date: 2017-09-14 13:47:15 +0000 (Thu, 14 Sep 2017)
Log Message:
-----------
HTML5-compatible meta tags for docinfo items authors, date, and copyright.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_html5.html
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-09-14 13:41:15 UTC (rev 8178)
+++ trunk/docutils/HISTORY.txt 2017-09-14 13:47:15 UTC (rev 8179)
@@ -34,6 +34,11 @@
- Fix [ 281 ] Remove escaping backslashes in meta directive content.
+* docutils/writers/html5_polyglot/
+
+ - automatically add HTML5-compatible meta tags for docinfo items
+ "authors", "date", and "copyright".
+
* docutils/writers/latex2e/__init__.py
- Fix [ 323 ] spurious ``\phantomsection`` and whitespace in
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2017-09-14 13:41:15 UTC (rev 8178)
+++ trunk/docutils/docutils/writers/_html_base.py 2017-09-14 13:47:15 UTC (rev 8179)
@@ -720,6 +720,9 @@
self.html_prolog.append(self.doctype)
self.meta.insert(0, self.content_type % self.settings.output_encoding)
self.head.insert(0, self.content_type % self.settings.output_encoding)
+ if 'name="dcterms.' in ''.join(self.meta):
+ self.head.append(
+ '<link rel="schema.dcterms" href="http://purl.org/dc/terms/">')
if self.math_header:
if self.math_output == 'mathjax':
self.head.extend(self.math_header)
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2017-09-14 13:41:15 UTC (rev 8178)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2017-09-14 13:47:15 UTC (rev 8179)
@@ -162,21 +162,30 @@
def depart_acronym(self, node):
self.body.append('</abbr>')
- # no meta tag in HTML5
+ # no standard meta tag name in HTML5, use separate "author" meta tags
+ # https://www.w3.org/TR/html5/document-metadata.html#standard-metadata-names
def visit_authors(self, node):
self.visit_docinfo_item(node, 'authors', meta=False)
+ for subnode in node:
+ self.add_meta('<meta name="author" content="%s" />\n' %
+ self.attval(subnode.astext()))
def depart_authors(self, node):
self.depart_docinfo_item()
- # no meta tag in HTML5
+ # no standard meta tag name in HTML5, use dcterms.rights
+ # see https://wiki.whatwg.org/wiki/MetaExtensions
def visit_copyright(self, node):
self.visit_docinfo_item(node, 'copyright', meta=False)
+ self.add_meta('<meta name="dcterms.rights" content="%s" />\n'
+ % self.attval(node.astext()))
def depart_copyright(self, node):
self.depart_docinfo_item()
- # no meta tag in HTML5
+ # no standard meta tag name in HTML5, use dcterms.date
def visit_date(self, node):
self.visit_docinfo_item(node, 'date', meta=False)
+ self.add_meta('<meta name="dcterms.date" content="%s" />\n'
+ % self.attval(node.astext()))
def depart_date(self, node):
self.depart_docinfo_item()
@@ -199,7 +208,7 @@
def depart_meta(self, node):
pass
- # no meta tag in HTML5
+ # no standard meta tag name in HTML5
def visit_organization(self, node):
self.visit_docinfo_item(node, 'organization', meta=False)
def depart_organization(self, node):
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2017-09-14 13:41:15 UTC (rev 8178)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2017-09-14 13:47:15 UTC (rev 8179)
@@ -5,8 +5,14 @@
<meta name="generator" content="Docutils 0.15b.dev: http://docutils.sourceforge.net/" />
<title>reStructuredText Test Document</title>
<meta name="author" content="David Goodger" />
+<meta name="author" content="Me" />
+<meta name="author" content="Myself" />
+<meta name="author" content="I" />
+<meta name="dcterms.date" content="Now, or yesterday. Or maybe even before yesterday." />
+<meta name="dcterms.rights" content="This document has been placed in the public domain. You may do with it as you wish. You may copy, modify, redistribute, reattribute, sell, buy, rent, lease, destroy, or improve it, quote it at length, excerpt, incorporate, collate, fold, staple, or mutilate it, or do anything else to it that your or anyone else's heart desires." />
<meta content="reStructuredText, test, parser" name="keywords" />
<meta content="A test document, containing at least one example of each reStructuredText construct." lang="en" name="description" xml:lang="en" />
+<link rel="schema.dcterms" href="http://purl.org/dc/terms/">
<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" />
<link rel="stylesheet" href="../input/data/plain.css" type="text/css" />
<link rel="stylesheet" href="../input/data/math.css" type="text/css" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-09-22 10:29:07
|
Revision: 8180
http://sourceforge.net/p/docutils/code/8180
Author: milde
Date: 2017-09-22 10:29:04 +0000 (Fri, 22 Sep 2017)
Log Message:
-----------
Fixes and test for literal block handling in LaTeX.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/ref/rst/restructuredtext.txt
trunk/docutils/docs/user/latex.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
Added Paths:
-----------
trunk/docutils/test/functional/expected/latex_literal_block.tex
trunk/docutils/test/functional/expected/latex_literal_block_Verbatim.tex
trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
trunk/docutils/test/functional/input/latex_literal_block.txt
trunk/docutils/test/functional/tests/latex_literal_block.py
trunk/docutils/test/functional/tests/latex_literal_block_Verbatim.py
trunk/docutils/test/functional/tests/latex_literal_block_listings.py
trunk/docutils/test/functional/tests/latex_literal_block_verbatim.py
trunk/docutils/test/functional/tests/latex_literal_block_verbatimtab.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-09-14 13:47:15 UTC (rev 8179)
+++ trunk/docutils/HISTORY.txt 2017-09-22 10:29:04 UTC (rev 8180)
@@ -44,6 +44,7 @@
- Fix [ 323 ] spurious ``\phantomsection`` and whitespace in
``parts['title'].
- Fix [ 324 ] Invalid LaTeX for table with empty multicolumn cell.
+ - Fixes to literal block handling.
* docutils/utils/__init__.py:
Modified: trunk/docutils/docs/ref/rst/restructuredtext.txt
===================================================================
--- trunk/docutils/docs/ref/rst/restructuredtext.txt 2017-09-14 13:47:15 UTC (rev 8179)
+++ trunk/docutils/docs/ref/rst/restructuredtext.txt 2017-09-22 10:29:04 UTC (rev 8180)
@@ -2998,7 +2998,7 @@
Punctuation at the end of a URI is not considered part of the URI,
unless the URI is terminated by a closing angle bracket (">").
Backslashes may be used in URIs to escape markup characters,
-specifically asterisks ("*") and underscores ("_") which are vaid URI
+specifically asterisks ("*") and underscores ("_") which are valid URI
characters (see `Escaping Mechanism`_ above).
.. [#URI] Uniform Resource Identifier. URIs are a general form of
Modified: trunk/docutils/docs/user/latex.txt
===================================================================
--- trunk/docutils/docs/user/latex.txt 2017-09-14 13:47:15 UTC (rev 8179)
+++ trunk/docutils/docs/user/latex.txt 2017-09-22 10:29:04 UTC (rev 8180)
@@ -1260,7 +1260,8 @@
``--literal-block-env=lstlisting``
The ``lstlisting`` environment is highly configurable (as documented in
- listings.pdf_), for instance ::
+ listings.pdf_) and provides syntax highlight for many programming languages,
+ for instance ::
\renewcommand{\ttdefault}{txtt}
\lstset{language=Python, morekeywords=[1]{yield}}
@@ -1275,7 +1276,11 @@
\lstset{columns=fullflexible,
basewidth={0.5em,0.4em}}
+ and to get LaTeX syntax highlight for a code block with "listings"::
+ \lstloadlanguages{[LaTeX]TeX} % comma separated list of languages
+ \newcommand{\DUCLASSlatex}{\lstset{language=[LaTeX]TeX}}
+
The indentation of literal blocks can be reset with ::
\lstset{resetmargins=true}
@@ -2002,9 +2007,15 @@
umlauts) might fail. See font_ and `font encoding`_ (as well as
`Searching PDF files`_ for background information).
+It may help to load the `cmap` package (via `style sheets`_ or the custom
+`LaTeX preamble`_ (see also `Proper use of cmap and mmmap`_).
+
.. _Searching PDF files:
http://www.tex.ac.uk/cgi-bin/texfaq2html?label=srchpdf
+.. _Proper use of cmap and mmmap:
+ https://tex.stackexchange.com/questions/64409/proper-use-of-cmap-and-mmap
+
Unicode box drawing and block characters
````````````````````````````````````````
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2017-09-14 13:47:15 UTC (rev 8179)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2017-09-22 10:29:04 UTC (rev 8180)
@@ -1204,9 +1204,9 @@
self.section_enumerator_separator = (
settings.section_enumerator_separator.replace('_', r'\_'))
# literal blocks:
- self.literal_block_env = 'alltt'
+ self.literal_block_env = ''
self.literal_block_options = ''
- if settings.literal_block_env != '':
+ if settings.literal_block_env:
(none,
self.literal_block_env,
self.literal_block_options,
@@ -1492,7 +1492,7 @@
if not self.alltt:
table.update(CharMaps.special)
# keep the underscore in citation references
- if self.inside_citation_reference_label:
+ if self.inside_citation_reference_label and not self.alltt:
del(table[ord('_')])
# Workarounds for OT1 font-encoding
if self.font_encoding in ['OT1', ''] and not self.is_xetex:
@@ -1526,7 +1526,7 @@
self.requirements['textcomp'] = PreambleCmds.textcomp
elif cp in CharMaps.pifont:
self.requirements['pifont'] = '\\usepackage{pifont}'
- # preamble-definitions for unsupported Unicode characters
+ # preamble-definitions for unsupported Unicode characters
elif (self.latex_encoding == 'utf8'
and cp in CharMaps.unsupported_unicode):
self.requirements['_inputenc'+str(cp)] = (
@@ -2513,49 +2513,77 @@
return (len(node) == 1) and isinstance(node[0], nodes.Text)
def visit_literal_block(self, node):
- """Render a literal block."""
- # environments and packages to typeset literal blocks
- packages = {'alltt': r'\usepackage{alltt}',
+ """Render a literal block.
+
+ Corresponding rST elements: literal block, parsed-literal, code.
+ """
+ packages = {'lstlisting': r'\usepackage{listings}' '\n'
+ r'\lstset{xleftmargin=\leftmargin}',
'listing': r'\usepackage{moreverb}',
- 'lstlisting': r'\usepackage{listings}',
'Verbatim': r'\usepackage{fancyvrb}',
- # 'verbatim': '',
'verbatimtab': r'\usepackage{moreverb}'}
+ environment = self.literal_block_env
+ _in_table = self.active_table.is_open()
+ # TODO: fails if normal text precedes the literal block.
+ # Check parent node instead?
+ _autowidth_table = _in_table and self.active_table.colwidths_auto
+ _plaintext = self.is_plaintext(node)
+ _listings = (environment == 'lstlisting') and _plaintext
+
+ # Labels and classes:
if node.get('ids'):
self.out += ['\n'] + self.ids_to_labels(node)
+ self.duclass_open(node)
+ if (not _plaintext and 'code' in node['classes']
+ and self.settings.syntax_highlight != 'none'):
+ self.requirements['color'] = PreambleCmds.color
+ self.fallbacks['code'] = PreambleCmds.highlight_rules
- self.duclass_open(node)
- if not self.active_table.is_open():
- # no quote inside tables, to avoid vertical space between
- # table border and literal block.
- # TODO: fails if normal text precedes the literal block.
- # check parent node instead?
+ # Wrapper?
+ if _in_table and _plaintext and not _autowidth_table:
+ # minipage prevents extra vertical space with alltt
+ # and verbatim-like environments
+ self.fallbacks['ttem'] = '\n'.join(['',
+ r'% character width in monospaced font',
+ r'\newlength{\ttemwidth}',
+ r'\settowidth{\ttemwidth}{\ttfamily M}'])
+ self.out.append('\\begin{minipage}{%d\\ttemwidth}\n' %
+ (max(len(line) for line in node.astext().split('\n'))))
+ self.context.append('\n\\end{minipage}\n')
+ elif not _in_table and not _listings:
+ # wrap in quote to set off vertically and indent
self.out.append('\\begin{quote}\n')
self.context.append('\n\\end{quote}\n')
else:
self.context.append('\n')
- if self.is_plaintext(node):
- environment = self.literal_block_env
- self.requirements['literal_block'] = packages.get(environment, '')
- if environment == 'alltt':
- self.alltt = True
- else:
- self.verbatim = True
+ # Use verbatim-like environment, if defined and possible
+ if environment and _plaintext and (not _autowidth_table or _listings):
+ try:
+ self.requirements['literal_block'] = packages[environment]
+ except KeyError:
+ pass
+ self.verbatim = True
+ if _in_table and _listings:
+ self.out.append('\lstset{xleftmargin=0pt}\n')
self.out.append('\\begin{%s}%s\n' %
(environment, self.literal_block_options))
self.context.append('\n\\end{%s}' % environment)
+ elif _plaintext and not _autowidth_table:
+ self.alltt = True
+ self.requirements['alltt'] = r'\usepackage{alltt}'
+ self.out.append('\\begin{alltt}\n')
+ self.context.append('\n\\end{alltt}')
else:
self.literal = True
self.insert_newline = True
self.insert_non_breaking_blanks = True
- if 'code' in node['classes'] and (
- self.settings.syntax_highlight != 'none'):
- self.requirements['color'] = PreambleCmds.color
- self.fallbacks['code'] = PreambleCmds.highlight_rules
- self.out.append('{\\ttfamily \\raggedright \\noindent\n')
- self.context.append('\n}')
+ # \raggedright ensures leading blanks are respected but
+ # leads to additional leading vspace if the first line
+ # of the block is overfull :-(
+ self.out.append('\\ttfamily\\raggedright\n')
+ self.context.append('')
def depart_literal_block(self, node):
self.insert_non_breaking_blanks = False
Added: trunk/docutils/test/functional/expected/latex_literal_block.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block.tex (rev 0)
+++ trunk/docutils/test/functional/expected/latex_literal_block.tex 2017-09-22 10:29:04 UTC (rev 8180)
@@ -0,0 +1,172 @@
+\documentclass[a4paper]{article}
+% generated by Docutils <http://docutils.sourceforge.net/>
+\usepackage{cmap} % fix search and cut-and-paste in Acrobat
+\usepackage{ifthen}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{alltt}
+\usepackage{amsmath}
+\usepackage{graphicx}
+\usepackage{longtable,ltcaption,array}
+\setlength{\extrarowheight}{2pt}
+\newlength{\DUtablewidth} % internal use in tables
+
+%%% Custom LaTeX preamble
+% PDF Standard Fonts
+\usepackage{mathptmx} % Times
+\usepackage[scaled=.90]{helvet}
+\usepackage{courier}
+
+%%% User specified packages and stylesheets
+
+%%% Fallback definitions for Docutils-specific commands
+
+% class handling for environments (block-level elements)
+% \begin{DUclass}{spam} tries \DUCLASSspam and
+% \end{DUclass}{spam} tries \endDUCLASSspam
+\ifx\DUclass\undefined % poor man's "provideenvironment"
+ \newenvironment{DUclass}[1]%
+ {\def\DocutilsClassFunctionName{DUCLASS#1}% arg cannot be used in end-part of environment.
+ \csname \DocutilsClassFunctionName \endcsname}%
+ {\csname end\DocutilsClassFunctionName \endcsname}%
+\fi
+% numeric or symbol footnotes with hyperlinks
+\providecommand*{\DUfootnotemark}[3]{%
+ \raisebox{1em}{\hypertarget{#1}{}}%
+ \hyperlink{#2}{\textsuperscript{#3}}%
+}
+\providecommand{\DUfootnotetext}[4]{%
+ \begingroup%
+ \renewcommand{\thefootnote}{%
+ \protect\raisebox{1em}{\protect\hypertarget{#1}{}}%
+ \protect\hyperlink{#2}{#3}}%
+ \footnotetext{#4}%
+ \endgroup%
+}
+
+% inline markup (custom roles)
+% \DUrole{#1}{#2} tries \DUrole#1{#2}
+\providecommand*{\DUrole}[2]{%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else
+ \csname DUrole#1\endcsname{#2}%
+ \fi%
+}
+
+% text mode subscript
+\ifx\textsubscript\undefined
+ \usepackage{fixltx2e} % since 2015 loaded by default
+\fi
+
+% titlereference role
+\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
+
+% character width in monospaced font
+\newlength{\ttemwidth}
+\settowidth{\ttemwidth}{\ttfamily M}
+
+% hyperlinks:
+\ifthenelse{\isundefined{\hypersetup}}{
+ \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+ \usepackage{bookmark}
+ \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
+}{}
+
+%%% Body
+\begin{document}
+
+In LaTeX, literal blocks can be customized with the \textquotedbl{}literal-block-env\textquotedbl{}
+setting. This test file exists to check the latex writer output compiles and
+looks as expected. Start with a plain literal block:
+
+\begin{quote}
+\begin{alltt}
+$\textbackslash{}sin^2(x)$ and $\textbackslash{}cos^2(x)$ equals one:
+
+\textbackslash{}[
+ \textbackslash{}sin^2(x) + \textbackslash{}cos^2(x) = 1 % for all x
+\textbackslash{}]
+\end{alltt}
+\end{quote}
+
+A latex \textquotedbl{}code-block\textquotedbl{} (set with \textquotedbl{}literal-block-env\textquotedbl{}, if syntax
+highlight is \textquotedbl{}none\textquotedbl{}):
+
+\begin{DUclass}{code}
+\begin{DUclass}{latex}
+\begin{quote}
+\begin{alltt}
+$\textbackslash{}sin^2(x)$ and $\textbackslash{}cos^2(x)$ equals one:
+
+\textbackslash{}[
+ \textbackslash{}sin^2(x) + \textbackslash{}cos^2(x) = 1 % for all x
+\textbackslash{}]
+\end{alltt}
+\end{quote}
+\end{DUclass}
+\end{DUclass}
+
+A literal block in a table:
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
+\hline
+
+test
+ &
+\begin{minipage}{8\ttemwidth}
+\begin{alltt}
+\textbackslash{}sin^2 x
+\end{alltt}
+\end{minipage}
+ &
+test
+ \\
+\hline
+\end{longtable*}
+
+A literal block in a table with auto-width columns:
+
+\begin{longtable*}[c]{|l|l|l|}
+\hline
+test &
+\ttfamily\raggedright
+\textbackslash{}sin\textasciicircum{}2~x
+ & test \\
+\hline
+\end{longtable*}
+
+Parsed literal block with inline markup and leading whitespace:
+
+\begin{quote}
+\ttfamily\raggedright
+~~~\emph{emphasis},~\textbf{strong~emphasis},~\texttt{inline~literals},\\
+standalone~hyperlinks~(\url{http://www.python.org}),\\
+\hyperref[internal]{internal}~and~\href{http://www.python.org/}{external}~hyperlinks,\\
+%
+\phantomsection\label{internal}internal~hyperlink~targets,\\
+images~via~substitution~references~(\includegraphics{../../../docs/user/rst/images/biohazard.png}),\\
+footnote~references\DUfootnotemark{id1}{id3}{*},\\
+citation~references~(\hyperlink{cit2002}{[CIT2002]}),~and~more.\\
+~\\
+~~~Here~are~some~explicit~interpreted~text~roles:\\
+a~PEP~reference~(\href{http://www.python.org/dev/peps/pep-0287}{PEP~287}),\\
+an~RFC~reference~(\href{http://tools.ietf.org/html/rfc2822.html}{RFC~2822}),\\
+an~abbreviation~(\DUrole{abbreviation}{abb.}),~an~acronym~(\DUrole{acronym}{reST}),\\
+code~(\texttt{\DUrole{code}{print~\textquotedbl{}hello~world\textquotedbl{}}}),\\
+maths~$\sin^2(x)$,\\
+\textsubscript{subscript}~and~\textsuperscript{superscript},\\
+\DUrole{custom}{custom}~\DUrole{custom-role}{roles},~and~explicit~roles~for\\
+\DUroletitlereference{Docutils}'~\emph{standard}~\textbf{inline}~\texttt{markup}.
+\end{quote}
+%
+\DUfootnotetext{id3}{id1}{*}{%
+This footnote is referenced in a \DUroletitlereference{parsed literal} block.
+}
+\begin{figure}[b]\raisebox{1em}{\hypertarget{cit2002}{}}[CIT2002]
+Sample Citation, 2017.
+\end{figure}
+
+\end{document}
Property changes on: trunk/docutils/test/functional/expected/latex_literal_block.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/functional/expected/latex_literal_block_Verbatim.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_Verbatim.tex (rev 0)
+++ trunk/docutils/test/functional/expected/latex_literal_block_Verbatim.tex 2017-09-22 10:29:04 UTC (rev 8180)
@@ -0,0 +1,172 @@
+\documentclass[a4paper]{article}
+% generated by Docutils <http://docutils.sourceforge.net/>
+\usepackage{cmap} % fix search and cut-and-paste in Acrobat
+\usepackage{ifthen}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{amsmath}
+\usepackage{graphicx}
+\usepackage{fancyvrb}
+\usepackage{longtable,ltcaption,array}
+\setlength{\extrarowheight}{2pt}
+\newlength{\DUtablewidth} % internal use in tables
+
+%%% Custom LaTeX preamble
+% PDF Standard Fonts
+\usepackage{mathptmx} % Times
+\usepackage[scaled=.90]{helvet}
+\usepackage{courier}
+
+%%% User specified packages and stylesheets
+
+%%% Fallback definitions for Docutils-specific commands
+
+% class handling for environments (block-level elements)
+% \begin{DUclass}{spam} tries \DUCLASSspam and
+% \end{DUclass}{spam} tries \endDUCLASSspam
+\ifx\DUclass\undefined % poor man's "provideenvironment"
+ \newenvironment{DUclass}[1]%
+ {\def\DocutilsClassFunctionName{DUCLASS#1}% arg cannot be used in end-part of environment.
+ \csname \DocutilsClassFunctionName \endcsname}%
+ {\csname end\DocutilsClassFunctionName \endcsname}%
+\fi
+% numeric or symbol footnotes with hyperlinks
+\providecommand*{\DUfootnotemark}[3]{%
+ \raisebox{1em}{\hypertarget{#1}{}}%
+ \hyperlink{#2}{\textsuperscript{#3}}%
+}
+\providecommand{\DUfootnotetext}[4]{%
+ \begingroup%
+ \renewcommand{\thefootnote}{%
+ \protect\raisebox{1em}{\protect\hypertarget{#1}{}}%
+ \protect\hyperlink{#2}{#3}}%
+ \footnotetext{#4}%
+ \endgroup%
+}
+
+% inline markup (custom roles)
+% \DUrole{#1}{#2} tries \DUrole#1{#2}
+\providecommand*{\DUrole}[2]{%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else
+ \csname DUrole#1\endcsname{#2}%
+ \fi%
+}
+
+% text mode subscript
+\ifx\textsubscript\undefined
+ \usepackage{fixltx2e} % since 2015 loaded by default
+\fi
+
+% titlereference role
+\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
+
+% character width in monospaced font
+\newlength{\ttemwidth}
+\settowidth{\ttemwidth}{\ttfamily M}
+
+% hyperlinks:
+\ifthenelse{\isundefined{\hypersetup}}{
+ \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+ \usepackage{bookmark}
+ \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
+}{}
+
+%%% Body
+\begin{document}
+
+In LaTeX, literal blocks can be customized with the \textquotedbl{}literal-block-env\textquotedbl{}
+setting. This test file exists to check the latex writer output compiles and
+looks as expected. Start with a plain literal block:
+
+\begin{quote}
+\begin{Verbatim}
+$\sin^2(x)$ and $\cos^2(x)$ equals one:
+
+\[
+ \sin^2(x) + \cos^2(x) = 1 % for all x
+\]
+\end{Verbatim}
+\end{quote}
+
+A latex \textquotedbl{}code-block\textquotedbl{} (set with \textquotedbl{}literal-block-env\textquotedbl{}, if syntax
+highlight is \textquotedbl{}none\textquotedbl{}):
+
+\begin{DUclass}{code}
+\begin{DUclass}{latex}
+\begin{quote}
+\begin{Verbatim}
+$\sin^2(x)$ and $\cos^2(x)$ equals one:
+
+\[
+ \sin^2(x) + \cos^2(x) = 1 % for all x
+\]
+\end{Verbatim}
+\end{quote}
+\end{DUclass}
+\end{DUclass}
+
+A literal block in a table:
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
+\hline
+
+test
+ &
+\begin{minipage}{8\ttemwidth}
+\begin{Verbatim}
+\sin^2 x
+\end{Verbatim}
+\end{minipage}
+ &
+test
+ \\
+\hline
+\end{longtable*}
+
+A literal block in a table with auto-width columns:
+
+\begin{longtable*}[c]{|l|l|l|}
+\hline
+test &
+\ttfamily\raggedright
+\textbackslash{}sin\textasciicircum{}2~x
+ & test \\
+\hline
+\end{longtable*}
+
+Parsed literal block with inline markup and leading whitespace:
+
+\begin{quote}
+\ttfamily\raggedright
+~~~\emph{emphasis},~\textbf{strong~emphasis},~\texttt{inline~literals},\\
+standalone~hyperlinks~(\url{http://www.python.org}),\\
+\hyperref[internal]{internal}~and~\href{http://www.python.org/}{external}~hyperlinks,\\
+%
+\phantomsection\label{internal}internal~hyperlink~targets,\\
+images~via~substitution~references~(\includegraphics{../../../docs/user/rst/images/biohazard.png}),\\
+footnote~references\DUfootnotemark{id1}{id3}{*},\\
+citation~references~(\hyperlink{cit2002}{[CIT2002]}),~and~more.\\
+~\\
+~~~Here~are~some~explicit~interpreted~text~roles:\\
+a~PEP~reference~(\href{http://www.python.org/dev/peps/pep-0287}{PEP~287}),\\
+an~RFC~reference~(\href{http://tools.ietf.org/html/rfc2822.html}{RFC~2822}),\\
+an~abbreviation~(\DUrole{abbreviation}{abb.}),~an~acronym~(\DUrole{acronym}{reST}),\\
+code~(\texttt{\DUrole{code}{print~\textquotedbl{}hello~world\textquotedbl{}}}),\\
+maths~$\sin^2(x)$,\\
+\textsubscript{subscript}~and~\textsuperscript{superscript},\\
+\DUrole{custom}{custom}~\DUrole{custom-role}{roles},~and~explicit~roles~for\\
+\DUroletitlereference{Docutils}'~\emph{standard}~\textbf{inline}~\texttt{markup}.
+\end{quote}
+%
+\DUfootnotetext{id3}{id1}{*}{%
+This footnote is referenced in a \DUroletitlereference{parsed literal} block.
+}
+\begin{figure}[b]\raisebox{1em}{\hypertarget{cit2002}{}}[CIT2002]
+Sample Citation, 2017.
+\end{figure}
+
+\end{document}
Property changes on: trunk/docutils/test/functional/expected/latex_literal_block_Verbatim.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_listings.tex (rev 0)
+++ trunk/docutils/test/functional/expected/latex_literal_block_listings.tex 2017-09-22 10:29:04 UTC (rev 8180)
@@ -0,0 +1,177 @@
+\documentclass[a4paper]{article}
+% generated by Docutils <http://docutils.sourceforge.net/>
+\usepackage{cmap} % fix search and cut-and-paste in Acrobat
+\usepackage{ifthen}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{amsmath}
+\usepackage{graphicx}
+\usepackage{listings}
+\lstset{xleftmargin=\leftmargin}
+\usepackage{longtable,ltcaption,array}
+\setlength{\extrarowheight}{2pt}
+\newlength{\DUtablewidth} % internal use in tables
+
+%%% Custom LaTeX preamble
+
+% PDF Standard Fonts
+\usepackage{mathptmx} % Times
+\usepackage[scaled=.90]{helvet}
+\usepackage{courier}
+% LaTeX syntax highlight with "listings":
+\lstloadlanguages{[LaTeX]TeX} % comma separated list of languages
+\newcommand{\DUCLASSlatex}{\lstset{language=[LaTeX]TeX}}
+
+
+%%% User specified packages and stylesheets
+
+%%% Fallback definitions for Docutils-specific commands
+
+% class handling for environments (block-level elements)
+% \begin{DUclass}{spam} tries \DUCLASSspam and
+% \end{DUclass}{spam} tries \endDUCLASSspam
+\ifx\DUclass\undefined % poor man's "provideenvironment"
+ \newenvironment{DUclass}[1]%
+ {\def\DocutilsClassFunctionName{DUCLASS#1}% arg cannot be used in end-part of environment.
+ \csname \DocutilsClassFunctionName \endcsname}%
+ {\csname end\DocutilsClassFunctionName \endcsname}%
+\fi
+% numeric or symbol footnotes with hyperlinks
+\providecommand*{\DUfootnotemark}[3]{%
+ \raisebox{1em}{\hypertarget{#1}{}}%
+ \hyperlink{#2}{\textsuperscript{#3}}%
+}
+\providecommand{\DUfootnotetext}[4]{%
+ \begingroup%
+ \renewcommand{\thefootnote}{%
+ \protect\raisebox{1em}{\protect\hypertarget{#1}{}}%
+ \protect\hyperlink{#2}{#3}}%
+ \footnotetext{#4}%
+ \endgroup%
+}
+
+% inline markup (custom roles)
+% \DUrole{#1}{#2} tries \DUrole#1{#2}
+\providecommand*{\DUrole}[2]{%
+ % backwards compatibility: try \docutilsrole#1{#2}
+ \ifcsname docutilsrole#1\endcsname%
+ \csname docutilsrole#1\endcsname{#2}%
+ \else
+ \csname DUrole#1\endcsname{#2}%
+ \fi%
+}
+
+% text mode subscript
+\ifx\textsubscript\undefined
+ \usepackage{fixltx2e} % since 2015 loaded by default
+\fi
+
+% titlereference role
+\providecommand*{\DUroletitlereference}[1]{\textsl{#1}}
+
+% character width in monospaced font
+\newlength{\ttemwidth}
+\settowidth{\ttemwidth}{\ttfamily M}
+
+% hyperlinks:
+\ifthenelse{\isundefined{\hypersetup}}{
+ \usepackage[colorlinks=true,linkcolor=blue,urlcolor=blue]{hyperref}
+ \usepackage{bookmark}
+ \urlstyle{same} % normal text font (alternatives: tt, rm, sf)
+}{}
+
+%%% Body
+\begin{document}
+
+In LaTeX, literal blocks can be customized with the \textquotedbl{}literal-block-env\textquotedbl{}
+setting. This test file exists to check the latex writer output compiles and
+looks as expected. Start with a plain literal block:
+
+\begin{lstlisting}
+$\sin^2(x)$ and $\cos^2(x)$ equals one:
+
+\[
+ \sin^2(x) + \cos^2(x) = 1 % for all x
+\]
+\end{lstlisting}
+
+A latex \textquotedbl{}code-block\textquotedbl{} (set with \textquotedbl{}literal-block-env\textquotedbl{}, if syntax
+highlight is \textquotedbl{}none\textquotedbl{}):
+
+\begin{DUclass}{code}
+\begin{DUclass}{latex}
+\begin{lstlisting}
+$\sin^2(x)$ and $\cos^2(x)$ equals one:
+
+\[
+ \sin^2(x) + \cos^2(x) = 1 % for all x
+\]
+\end{lstlisting}
+\end{DUclass}
+\end{DUclass}
+
+A literal block in a table:
+
+\setlength{\DUtablewidth}{\linewidth}
+\begin{longtable*}[c]{|p{0.063\DUtablewidth}|p{0.145\DUtablewidth}|p{0.063\DUtablewidth}|}
+\hline
+
+test
+ &
+\begin{minipage}{8\ttemwidth}
+\lstset{xleftmargin=0pt}
+\begin{lstlisting}
+\sin^2 x
+\end{lstlisting}
+\end{minipage}
+ &
+test
+ \\
+\hline
+\end{longtable*}
+
+A literal block in a table with auto-width columns:
+
+\begin{longtable*}[c]{|l|l|l|}
+\hline
+test &
+\lstset{xleftmargin=0pt}
+\begin{lstlisting}
+\sin^2 x
+\end{lstlisting}
+ & test \\
+\hline
+\end{longtable*}
+
+Parsed literal block with inline markup and leading whitespace:
+
+\begin{quote}
+\ttfamily\raggedright
+~~~\emph{emphasis},~\textbf{strong~emphasis},~\texttt{inline~literals},\\
+standalone~hyperlinks~(\url{http://www.python.org}),\\
+\hyperref[internal]{internal}~and~\href{http://www.python.org/}{external}~hyperlinks,\\
+%
+\phantomsection\label{internal}internal~hyperlink~targets,\\
+images~via~substitution~references~(\includegraphics{../../../docs/user/rst/images/biohazard.png}),\\
+footnote~references\DUfootnotemark{id1}{id3}{*},\\
+citation~references~(\hyperlink{cit2002}{[CIT2002]}),~and~more.\\
+~\\
+~~~Here~are~some~explicit~interpreted~text~roles:\\
+a~PEP~reference~(\href{http://www.python.org/dev/peps/pep-0287}{PEP~287}),\\
+an~RFC~reference~(\href{http://tools.ietf.org/html/rfc2822.html}{RFC~2822}),\\
+an~abbreviation~(\DUrole{abbreviation}{abb.}),~an~acronym~(\DUrole{acronym}{reST}),\\
+code~(\texttt{\DUrole{code}{print~\textquotedbl{}hello~world\textquotedbl{}}}),\\
+maths~$\sin^2(x)$,\\
+\textsubscript{subscript}~and~\textsuperscript{superscript},\\
+\DUrole{custom}{custom}~\DUrole{custom-role}{roles},~and~explicit~roles~for\\
+\DUroletitlereference{Docutils}'~\emph{standard}~\textbf{inline}~\texttt{markup}.
+\end{quote}
+%
+\DUfootnotetext{id3}{id1}{*}{%
+This footnote is referenced in a \DUroletitlereference{parsed literal} block.
+}
+\begin{figure}[b]\raisebox{1em}{\hypertarget{cit2002}{}}[CIT2002]
+Sample Citation, 2017.
+\end{figure}
+
+\end{document}
Property changes on: trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+Author Date Id Revision
\ No newline at end of property
Added: trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex (rev 0)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex 2017-09-22 10:29:04 UTC (rev 8180)
@@ -0,0 +1,171 @@
+\documentclass[a4paper]{article}
+% generated by Docutils <http://docutils.sourceforge.net/>
+\usepackage{cmap} % fix search and cut-and-paste in Acrobat
+\usepackage{ifthen}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{amsmath}
+\usepackage{graphicx}
+\usepackage{longtable,ltcaption,array}
+\setlength{\extrarowheight}{2pt}
+\newlength{\DUtablewidth} % internal use in tables
+
+%%% Custom LaTeX preamble
+% PDF Standard Fonts
+\usepackage{mathptmx} % Times
+\usepackage[scaled=.90]{helvet}
+\usepackage{courier}
+
+%%% User specified packages and stylesheets
+
+%%% Fallback definitions for Docutils-specific commands
+
+% class handling for environments (block-level elements)
+% \begin{DUclass}{spam} tries \DUCLASSspam and
+% \end{DUclass}{spam} tries \endDUCLASSspam
+\ifx\DUclass\undefined % poor man's "provideenvironment"
+ \newenvironment{DUclass}[1]%
+ {\def\DocutilsClassFunctionName{DUCLASS#1}% arg cannot be used in end-part of environment.
+ \csname \DocutilsClassFunctionName \endcsname}%
+ {\csname end\DocutilsClassFunctionName \endcsname}...
[truncated message content] |
|
From: <mi...@us...> - 2017-10-06 09:00:03
|
Revision: 8183
http://sourceforge.net/p/docutils/code/8183
Author: milde
Date: 2017-10-06 09:00:00 +0000 (Fri, 06 Oct 2017)
Log Message:
-----------
Add field name as class argument to generic docinfo fields unconditionally.
Also add the field name, if the DocInfo tranform fails to
converts a bibliographic field list into a docinfo element.
This allows styling of, e.g., a "copyright" element that also contains
a license as separate paragraph when suppressing the warning (cf. Bug [325]).
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/test/test_transforms/test_docinfo.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-10-03 10:00:47 UTC (rev 8182)
+++ trunk/docutils/HISTORY.txt 2017-10-06 09:00:00 UTC (rev 8183)
@@ -34,6 +34,10 @@
- Fix [ 281 ] Remove escaping backslashes in meta directive content.
+* docutils/transforms/frontmatter.py
+
+ - Add field name as class argument to generic docinfo fields unconditionally.
+
* docutils/writers/html5_polyglot/
- automatically add HTML5-compatible meta tags for docinfo items
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2017-10-03 10:00:47 UTC (rev 8182)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2017-10-06 09:00:00 UTC (rev 8183)
@@ -433,10 +433,10 @@
and isinstance(field[-1][0], nodes.paragraph):
utils.clean_rcs_keywords(
field[-1][0], self.rcs_keyword_substitutions)
- if normedname not in bibliofields:
- classvalue = nodes.make_id(normedname)
- if classvalue:
- field['classes'].append(classvalue)
+ # if normedname not in bibliofields:
+ classvalue = nodes.make_id(normedname)
+ if classvalue:
+ field['classes'].append(classvalue)
docinfo.append(field)
nodelist = []
if len(docinfo) != 0:
Modified: trunk/docutils/test/test_transforms/test_docinfo.py
===================================================================
--- trunk/docutils/test/test_transforms/test_docinfo.py 2017-10-03 10:00:47 UTC (rev 8182)
+++ trunk/docutils/test/test_transforms/test_docinfo.py 2017-10-06 09:00:00 UTC (rev 8183)
@@ -95,7 +95,7 @@
me...@my...
<version>
1
- <field>
+ <field classes="abstract">
<field_name>
Abstract
<field_body>
@@ -133,7 +133,7 @@
"""\
<document source="test data">
<docinfo>
- <field>
+ <field classes="author">
<field_name>
Author
<field_body>
@@ -149,7 +149,7 @@
<emphasis>
simple
paragraph
- <field>
+ <field classes="date">
<field_name>
Date
<field_body>
@@ -160,7 +160,7 @@
<system_message level="2" line="3" source="test data" type="WARNING">
<paragraph>
Cannot extract compound bibliographic field "Date".
- <field>
+ <field classes="version">
<field_name>
Version
<field_body>
@@ -253,7 +253,7 @@
"""\
<document source="test data">
<docinfo>
- <field>
+ <field classes="authors">
<field_name>
Authors
<field_body>
@@ -260,7 +260,7 @@
<system_message level="2" line="1" source="test data" type="WARNING">
<paragraph>
Cannot extract empty bibliographic field "Authors".
- <field>
+ <field classes="authors">
<field_name>
Authors
<field_body>
@@ -274,7 +274,7 @@
<system_message level="2" line="3" source="test data" type="WARNING">
<paragraph>
Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
- <field>
+ <field classes="authors">
<field_name>
Authors
<field_body>
@@ -284,7 +284,7 @@
<system_message level="2" line="6" source="test data" type="WARNING">
<paragraph>
Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
- <field>
+ <field classes="authors">
<field_name>
Authors
<field_body>
@@ -297,7 +297,7 @@
<system_message level="2" line="10" source="test data" type="WARNING">
<paragraph>
Bibliographic field "Authors" incompatible with extraction: it must contain either a single paragraph (with authors separated by one of ";,"), multiple paragraphs (one per author), or a bullet list with one paragraph (one author) per item.
- <field>
+ <field classes="authors">
<field_name>
Authors
<field_body>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-10-06 14:41:09
|
Revision: 8184
http://sourceforge.net/p/docutils/code/8184
Author: milde
Date: 2017-10-06 14:41:07 +0000 (Fri, 06 Oct 2017)
Log Message:
-----------
Apply [ 121 ] Add a :width: option for the table directives.
Thanks to Brecht Machiels for the patch.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/ref/rst/directives.txt
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-10-06 09:00:00 UTC (rev 8183)
+++ trunk/docutils/HISTORY.txt 2017-10-06 14:41:07 UTC (rev 8184)
@@ -34,6 +34,10 @@
- Fix [ 281 ] Remove escaping backslashes in meta directive content.
+* docutils/parsers/rst/directives/tables.py:
+
+ - Apply [ 121 ] Add a :width: option for the table directives.
+
* docutils/transforms/frontmatter.py
- Add field name as class argument to generic docinfo fields unconditionally.
Modified: trunk/docutils/docs/ref/rst/directives.txt
===================================================================
--- trunk/docutils/docs/ref/rst/directives.txt 2017-10-06 09:00:00 UTC (rev 8183)
+++ trunk/docutils/docs/ref/rst/directives.txt 2017-10-06 14:41:07 UTC (rev 8184)
@@ -221,9 +221,6 @@
Used to reserve space or scale the image horizontally. As with "height"
above, when the "scale" option is also specified, they are combined.
- .. _length: restructuredtext.html#length-units
- .. _percentage: restructuredtext.html#percentage-units
-
``scale`` : integer percentage (the "%" symbol is optional)
The uniform scaling factor of the image. The default is "100 %", i.e.
no scaling.
@@ -795,6 +792,11 @@
(LaTeX, the HTML browser, ...).
See also the `table_style`_ configuration option.
+``width`` : `length`_ or `percentage`_ of the current line width
+ Forces the width of the table to the specified length or percentage
+ of the line width. If omitted, the renderer determines the width
+ of the table based on its contents.
+
and the common options `:class:`_ and `:name:`_.
.. _table_style: ../../user/config.html#table-style-html4css1-writer
@@ -866,6 +868,11 @@
whether to delegate the determination of column widths to the backend
(LaTeX, the HTML browser, ...).
+``width`` : `length`_ or `percentage`_ of the current line width
+ Forces the width of the table to the specified length or percentage
+ of the line width. If omitted, the renderer determines the width
+ of the table based on its contents.
+
``header-rows`` : integer
The number of rows of CSV data to use in the table header.
Defaults to 0.
@@ -971,6 +978,11 @@
whether to delegate the determination of column widths to the backend
(LaTeX, the HTML browser, ...).
+``width`` : `length`_ or `percentage`_ of the current line width
+ Forces the width of the table to the specified length or percentage
+ of the line width. If omitted, the renderer determines the width
+ of the table based on its contents.
+
``header-rows`` : integer
The number of rows of list data to use in the table header.
Defaults to 0.
@@ -1956,9 +1968,11 @@
.. _inline elements: ../doctree.html#inline-elements
.. _literal_block: ../doctree.html#literal-block
.. _legend: ../doctree.html#legend
+.. _length: restructuredtext.html#length-units
.. _line_block: ../doctree.html#line-block
.. _math_block: ../doctree.html#math-block
.. _pending: ../doctree.html#pending
+.. _percentage: restructuredtext.html#percentage-units
.. _raw: ../doctree.html#raw
.. _rubric: ../doctree.html#rubric
.. _sidebar: ../doctree.html#sidebar
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2017-10-06 09:00:00 UTC (rev 8183)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2017-10-06 14:41:07 UTC (rev 8184)
@@ -35,6 +35,7 @@
option_spec = {'class': directives.class_option,
'name': directives.unchanged,
'align': align,
+ 'width': directives.length_or_percentage_or_unitless,
'widths': directives.value_or(('auto', 'grid'),
directives.positive_int_list)}
has_content = True
@@ -94,6 +95,10 @@
self.block_text, self.block_text), line=self.lineno)
raise SystemMessagePropagation(error)
+ def set_table_width(self, table_node):
+ if 'width' in self.options:
+ table_node['width'] = self.options.get('width')
+
@property
def widths(self):
return self.options.get('widths', '')
@@ -143,6 +148,7 @@
return [error]
table_node = node[0]
table_node['classes'] += self.options.get('class', [])
+ self.set_table_width(table_node)
if 'align' in self.options:
table_node['align'] = self.options.get('align')
tgroup = table_node[0]
@@ -169,6 +175,7 @@
option_spec = {'header-rows': directives.nonnegative_int,
'stub-columns': directives.nonnegative_int,
'header': directives.unchanged,
+ 'width': directives.length_or_percentage_or_unitless,
'widths': directives.value_or(('auto', ),
directives.positive_int_list),
'file': directives.path,
@@ -392,6 +399,7 @@
option_spec = {'header-rows': directives.nonnegative_int,
'stub-columns': directives.nonnegative_int,
+ 'width': directives.length_or_percentage_or_unitless,
'widths': directives.value_or(('auto', ),
directives.positive_int_list),
'class': directives.class_option,
@@ -422,6 +430,7 @@
if 'align' in self.options:
table_node['align'] = self.options.get('align')
table_node['classes'] += self.options.get('class', [])
+ self.set_table_width(table_node)
self.add_name(table_node)
if title:
table_node.insert(0, title)
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2017-10-06 09:00:00 UTC (rev 8183)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2017-10-06 14:41:07 UTC (rev 8184)
@@ -192,6 +192,75 @@
"""],
["""\
.. table::
+ :width: 100 %
+
+ ============ ==============
+ col 1 col 2
+ ============ ==============
+""",
+"""\
+<document source="test data">
+ <table width="100%">
+ <tgroup cols="2">
+ <colspec colwidth="12">
+ <colspec colwidth="14">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ col 1
+ <entry>
+ <paragraph>
+ col 2
+"""],
+["""\
+.. table::
+ :width: 100px
+
+ ============ ==============
+ col 1 col 2
+ ============ ==============
+""",
+"""\
+<document source="test data">
+ <table width="100px">
+ <tgroup cols="2">
+ <colspec colwidth="12">
+ <colspec colwidth="14">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ col 1
+ <entry>
+ <paragraph>
+ col 2
+"""],
+["""\
+.. table::
+ :width: 321
+
+ ============ ==============
+ col 1 col 2
+ ============ ==============
+""",
+"""\
+<document source="test data">
+ <table width="321">
+ <tgroup cols="2">
+ <colspec colwidth="12">
+ <colspec colwidth="14">
+ <tbody>
+ <row>
+ <entry>
+ <paragraph>
+ col 1
+ <entry>
+ <paragraph>
+ col 2
+"""],
+["""\
+.. table::
:widths: 15, 25
============ ==============
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-10-19 16:21:30
|
Revision: 8187
http://sourceforge.net/p/docutils/code/8187
Author: milde
Date: 2017-10-19 16:21:27 +0000 (Thu, 19 Oct 2017)
Log Message:
-----------
Fix :width: option for the table directives.
* add table width argument in docutils.dtd
* support table width argument in html and latex writers
* fix support in "csv-table" directive
* add test cases.
Modified Paths:
--------------
trunk/docutils/docs/ref/docutils.dtd
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/functional/input/data/list_table.txt
trunk/docutils/test/functional/input/standalone_rst_latex.txt
trunk/docutils/test/functional/input/standalone_rst_xetex.txt
trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
Modified: trunk/docutils/docs/ref/docutils.dtd
===================================================================
--- trunk/docutils/docs/ref/docutils.dtd 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/docs/ref/docutils.dtd 2017-10-19 16:21:27 UTC (rev 8187)
@@ -197,7 +197,8 @@
" %basic.atts;
morecols %number; #IMPLIED ">
<!ATTLIST table
- %align-h.att;>
+ %align-h.att;
+ width %measure; #IMPLIED>
<!--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2017-10-19 16:21:27 UTC (rev 8187)
@@ -276,6 +276,7 @@
table_node['classes'] += self.options.get('class', [])
if 'align' in self.options:
table_node['align'] = self.options.get('align')
+ self.set_table_width(table_node)
self.add_name(table_node)
if title:
table_node.insert(0, title)
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/docutils/writers/_html_base.py 2017-10-19 16:21:27 UTC (rev 8187)
@@ -1452,16 +1452,15 @@
def depart_system_message(self, node):
self.body.append('</div>\n')
- # tables
- # ------
- # no hard-coded border setting in the table head::
-
def visit_table(self, node):
+ atts = {}
classes = [cls.strip(u' \t\n')
for cls in self.settings.table_style.split(',')]
if 'align' in node:
classes.append('align-%s' % node['align'])
- tag = self.starttag(node, 'table', CLASS=' '.join(classes))
+ if 'width' in node:
+ atts['style'] = 'width: %s' % node['width']
+ tag = self.starttag(node, 'table', CLASS=' '.join(classes), **atts)
self.body.append(tag)
def depart_table(self, node):
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2017-10-19 16:21:27 UTC (rev 8187)
@@ -757,11 +757,14 @@
def visit_table(self, node):
self.context.append(self.compact_p)
self.compact_p = True
+ atts = {'border': 1}
classes = ['docutils', self.settings.table_style]
if 'align' in node:
classes.append('align-%s' % node['align'])
+ if 'width' in node:
+ atts['style'] = 'width: %s' % node['width']
self.body.append(
- self.starttag(node, 'table', CLASS=' '.join(classes), border="1"))
+ self.starttag(node, 'table', CLASS=' '.join(classes), **atts))
def depart_table(self, node):
self.compact_p = self.context.pop()
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2017-10-19 16:21:27 UTC (rev 8187)
@@ -965,7 +965,7 @@
return ''
# horizontal lines are drawn below a row,
- def get_opening(self):
+ def get_opening(self, width=r'\linewidth'):
align_map = {'left': 'l',
'center': 'c',
'right': 'r'}
@@ -972,7 +972,7 @@
align = align_map.get(self.get('align') or 'center')
opening = [r'\begin{%s}[%s]' % (self.get_latex_type(), align)]
if not self.colwidths_auto:
- opening.insert(0, r'\setlength{\DUtablewidth}{\linewidth}')
+ opening.insert(0, r'\setlength{\DUtablewidth}{%s}'%width)
return '\n'.join(opening)
def get_closing(self):
@@ -2954,7 +2954,11 @@
# wrap content in the right environment:
content = self.out
self.pop_output_collector()
- self.out.append('\n' + self.active_table.get_opening())
+ try:
+ width = self.to_latex_length(node.attributes['width'])
+ except KeyError:
+ width = r'\linewidth'
+ self.out.append('\n' + self.active_table.get_opening(width))
self.out += content
self.out.append(self.active_table.get_closing() + '\n')
self.active_table.close()
Modified: trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2017-10-19 16:21:27 UTC (rev 8187)
@@ -1605,7 +1605,7 @@
<section ids="list-tables" names="list\ tables">
<title auto="1" refid="id72"><generated classes="sectnum">2.22 </generated>List Tables</title>
<paragraph>Here's a list table exercising all features:</paragraph>
- <table classes="colwidths-given test">
+ <table classes="colwidths-given test" width="40em">
<title>list table with integral header</title>
<tgroup cols="3">
<colspec colwidth="10" stub="1"></colspec>
@@ -1662,7 +1662,7 @@
</tbody>
</tgroup>
</table>
- <table align="center">
+ <table align="center" classes="colwidths-auto">
<title>center aligned list table</title>
<tgroup cols="2">
<colspec colwidth="50"></colspec>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2017-10-19 16:21:27 UTC (rev 8187)
@@ -1169,7 +1169,7 @@
<div class="section" id="list-tables">
<h2><a class="toc-backref" href="#id72">2.22 List Tables</a></h2>
<p>Here's a list table exercising all features:</p>
-<table border="1" class="colwidths-given test docutils">
+<table border="1" class="colwidths-given test docutils" style="width: 40em">
<caption>list table with integral header</caption>
<colgroup>
<col width="17%" />
@@ -1198,12 +1198,8 @@
</tr>
</tbody>
</table>
-<table border="1" class="docutils align-center">
+<table border="1" class="colwidths-auto docutils align-center">
<caption>center aligned list table</caption>
-<colgroup>
-<col width="50%" />
-<col width="50%" />
-</colgroup>
<tbody valign="top">
<tr><td>Albatross</td>
<td>2.99</td>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2017-10-19 16:21:27 UTC (rev 8187)
@@ -1139,7 +1139,7 @@
<div class="section" id="list-tables">
<h2><a class="toc-backref" href="#id76"><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">
+<table class="colwidths-given test" style="width: 40em">
<caption>list table with integral header</caption>
<colgroup>
<col style="width: 17%" />
@@ -1168,12 +1168,8 @@
</tr>
</tbody>
</table>
-<table class="align-center">
+<table class="colwidths-auto align-center">
<caption>center aligned list table</caption>
-<colgroup>
-<col style="width: 50%" />
-<col style="width: 50%" />
-</colgroup>
<tbody>
<tr><td><p>Albatross</p></td>
<td><p>2.99</p></td>
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2017-10-19 16:21:27 UTC (rev 8187)
@@ -1671,7 +1671,79 @@
\end{longtable*}
-\subsection{2.21 Custom Roles%
+\subsection{2.21 List Tables%
+ \label{list-tables}%
+}
+
+Here’s a list table exercising all features:
+
+\setlength{\DUtablewidth}{40em}
+\begin{longtable}[c]{|p{0.133\DUtablewidth}|p{0.249\DUtablewidth}|p{0.365\DUtablewidth}|}
+\caption{list table with integral header}\\
+\hline
+\textbf{%
+Treat
+} & \textbf{%
+Quantity
+} & \textbf{%
+Description
+} \\
+\hline
+\endfirsthead
+\caption[]{list table with integral header (... continued)}\\
+\hline
+\textbf{%
+Treat
+} & \textbf{%
+Quantity
+} & \textbf{%
+Description
+} \\
+\hline
+\endhead
+\multicolumn{3}{c}{\hfill ... continued on next page} \\
+\endfoot
+\endlastfoot
+\textbf{%
+Albatross
+} &
+2.99
+ &
+On a stick!
+ \\
+\hline
+\textbf{%
+Crunchy Frog
+} &
+1.49
+ &
+If we took the bones out, it wouldn’t be
+crunchy, now would it?
+ \\
+\hline
+\textbf{%
+Gannet Ripple
+} &
+1.99
+ &
+On a stick!
+ \\
+\hline
+\end{longtable}
+
+\begin{longtable}[c]{|l|l|}
+\caption{center aligned list table}\\
+\hline
+Albatross & 2.99 \\
+\hline
+Crunchy Frog & 1.49 \\
+\hline
+Gannet Ripple & 1.99 \\
+\hline
+\end{longtable}
+
+
+\subsection{2.22 Custom Roles%
\label{custom-roles}%
}
@@ -1715,7 +1787,7 @@
\end{itemize}
-\subsection{2.22 Mathematics%
+\subsection{2.23 Mathematics%
\label{mathematics}%
}
Modified: trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2017-10-19 16:21:27 UTC (rev 8187)
@@ -2211,7 +2211,7 @@
List Tables
<paragraph>
Here's a list table exercising all features:
- <table classes="colwidths-given test">
+ <table classes="colwidths-given test" width="40em">
<title>
list table with integral header
<tgroup cols="3">
@@ -2261,7 +2261,7 @@
<entry>
<paragraph>
On a stick!
- <table align="center">
+ <table align="center" classes="colwidths-auto">
<title>
center aligned list table
<tgroup cols="2">
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2017-10-19 16:21:27 UTC (rev 8187)
@@ -1677,7 +1677,79 @@
\end{longtable*}
-\subsection{2.21 Custom Roles%
+\subsection{2.21 List Tables%
+ \label{list-tables}%
+}
+
+Here’s a list table exercising all features:
+
+\setlength{\DUtablewidth}{40em}
+\begin{longtable}[c]{|p{0.133\DUtablewidth}|p{0.249\DUtablewidth}|p{0.365\DUtablewidth}|}
+\caption{list table with integral header}\\
+\hline
+\textbf{%
+Treat
+} & \textbf{%
+Quantity
+} & \textbf{%
+Description
+} \\
+\hline
+\endfirsthead
+\caption[]{list table with integral header (... continued)}\\
+\hline
+\textbf{%
+Treat
+} & \textbf{%
+Quantity
+} & \textbf{%
+Description
+} \\
+\hline
+\endhead
+\multicolumn{3}{c}{\hfill ... continued on next page} \\
+\endfoot
+\endlastfoot
+\textbf{%
+Albatross
+} &
+2.99
+ &
+On a stick!
+ \\
+\hline
+\textbf{%
+Crunchy Frog
+} &
+1.49
+ &
+If we took the bones out, it wouldn’t be
+crunchy, now would it?
+ \\
+\hline
+\textbf{%
+Gannet Ripple
+} &
+1.99
+ &
+On a stick!
+ \\
+\hline
+\end{longtable}
+
+\begin{longtable}[c]{|l|l|}
+\caption{center aligned list table}\\
+\hline
+Albatross & 2.99 \\
+\hline
+Crunchy Frog & 1.49 \\
+\hline
+Gannet Ripple & 1.99 \\
+\hline
+\end{longtable}
+
+
+\subsection{2.22 Custom Roles%
\label{custom-roles}%
}
@@ -1721,7 +1793,7 @@
\end{itemize}
-\subsection{2.22 Mathematics%
+\subsection{2.23 Mathematics%
\label{mathematics}%
}
Modified: trunk/docutils/test/functional/input/data/list_table.txt
===================================================================
--- trunk/docutils/test/functional/input/data/list_table.txt 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/test/functional/input/data/list_table.txt 2017-10-19 16:21:27 UTC (rev 8187)
@@ -5,6 +5,7 @@
.. list-table:: list table with integral header
:class: test
+ :width: 40em
:widths: 10 20 30
:header-rows: 1
:stub-columns: 1
@@ -25,6 +26,7 @@
.. list-table:: center aligned list table
:align: center
+ :widths: auto
* - Albatross
- 2.99
Modified: trunk/docutils/test/functional/input/standalone_rst_latex.txt
===================================================================
--- trunk/docutils/test/functional/input/standalone_rst_latex.txt 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/test/functional/input/standalone_rst_latex.txt 2017-10-19 16:21:27 UTC (rev 8187)
@@ -3,6 +3,7 @@
.. include:: data/header_footer.txt
.. include:: data/table_colspan.txt
.. include:: data/table_rowspan.txt
+.. include:: data/list_table.txt
.. include:: data/custom_roles.txt
.. include:: data/math.txt
Modified: trunk/docutils/test/functional/input/standalone_rst_xetex.txt
===================================================================
--- trunk/docutils/test/functional/input/standalone_rst_xetex.txt 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/test/functional/input/standalone_rst_xetex.txt 2017-10-19 16:21:27 UTC (rev 8187)
@@ -3,6 +3,7 @@
.. include:: data/header_footer.txt
.. include:: data/table_colspan.txt
.. include:: data/table_rowspan.txt
+.. include:: data/list_table.txt
.. include:: data/custom_roles.txt
.. include:: data/math.txt
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2017-10-17 13:32:24 UTC (rev 8186)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_tables.py 2017-10-19 16:21:27 UTC (rev 8187)
@@ -379,6 +379,7 @@
totest['csv-table'] = [
["""\
.. csv-table:: inline with integral header
+ :width: 80%
:widths: 10, 20, 30
:header-rows: 1
:stub-columns: 1
@@ -391,7 +392,7 @@
""",
"""\
<document source="test data">
- <table classes="colwidths-given">
+ <table classes="colwidths-given" width="80%">
<title>
inline with integral header
<tgroup cols="3">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <go...@us...> - 2017-10-20 20:53:50
|
Revision: 8188
http://sourceforge.net/p/docutils/code/8188
Author: goodger
Date: 2017-10-20 20:53:47 +0000 (Fri, 20 Oct 2017)
Log Message:
-----------
Fix bug #331: fixed the "trim" options of the "unicode" directive.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/transforms/references.py
trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/functional/input/data/standard.txt
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-10-19 16:21:27 UTC (rev 8187)
+++ trunk/docutils/HISTORY.txt 2017-10-20 20:53:47 UTC (rev 8188)
@@ -42,6 +42,10 @@
- Add field name as class argument to generic docinfo fields unconditionally.
+* docutils/transforms/references.py
+
+ - Fix bug #331: fixed the "trim" options of the "unicode" directive.
+
* docutils/writers/html5_polyglot/
- automatically add HTML5-compatible meta tags for docinfo items
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2017-10-19 16:21:27 UTC (rev 8187)
+++ trunk/docutils/RELEASE-NOTES.txt 2017-10-20 20:53:47 UTC (rev 8188)
@@ -54,7 +54,9 @@
- Allow embedded colons in field list field names (before, tokens like
``:this:example:`` were considered ordinary text).
+ - Fixed a bug with the "trim" options of the "unicode" directive.
+
Release 0.14 (2017-08-03)
=========================
Modified: trunk/docutils/docutils/transforms/references.py
===================================================================
--- trunk/docutils/docutils/transforms/references.py 2017-10-19 16:21:27 UTC (rev 8187)
+++ trunk/docutils/docutils/transforms/references.py 2017-10-20 20:53:47 UTC (rev 8188)
@@ -692,14 +692,12 @@
or 'trim' in subdef.attributes):
if index > 0 and isinstance(parent[index - 1],
nodes.Text):
- parent.replace(parent[index - 1],
- parent[index - 1].rstrip())
+ parent[index - 1] = parent[index - 1].rstrip()
if ('rtrim' in subdef.attributes
or 'trim' in subdef.attributes):
if (len(parent) > index + 1
and isinstance(parent[index + 1], nodes.Text)):
- parent.replace(parent[index + 1],
- parent[index + 1].lstrip())
+ parent[index + 1] = parent[index + 1].lstrip()
subdef_copy = subdef.deepcopy()
try:
# Take care of nested substitution references:
Modified: trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2017-10-19 16:21:27 UTC (rev 8187)
+++ trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2017-10-20 20:53:47 UTC (rev 8188)
@@ -236,7 +236,8 @@
references</reference> <footnote_reference auto="1" ids="id31" refid="id25">5</footnote_reference> (<reference anonymous="1" name="a second reference" refuri="http://docutils.sourceforge.net/">a second reference</reference> <footnote_reference auto="1" ids="id33" refid="id32">7</footnote_reference>), footnote references (manually
numbered <footnote_reference ids="id1" refid="id8">1</footnote_reference>, anonymous auto-numbered <footnote_reference auto="1" ids="id2" refid="id12">3</footnote_reference>, labeled auto-numbered
<footnote_reference auto="1" ids="id3" refid="label">2</footnote_reference>, or symbolic <footnote_reference auto="*" ids="id4" refid="id13">*</footnote_reference>), citation references (<citation_reference ids="id5" refid="cit2002">CIT2002</citation_reference>),
- substitution references (<image alt="EXAMPLE" uri="../../../docs/user/rst/images/biohazard.png"></image>), and <target ids="inline-hyperlink-targets" names="inline\ hyperlink\ targets">inline hyperlink targets</target>
+ substitution references (<image alt="EXAMPLE" uri="../../../docs/user/rst/images/biohazard.png"></image> &
+ a <emphasis>trimmed heart</emphasis> <literal>(U+2665):</literal>♥), and <target ids="inline-hyperlink-targets" names="inline\ hyperlink\ targets">inline hyperlink targets</target>
(see <reference name="Targets" refid="targets">Targets</reference> below for a reference back to here). Character-level
inline markup is also possible (although exceedingly ugly!) in <emphasis>re</emphasis><literal>Structured</literal><emphasis>Text</emphasis>. Problems are indicated by <problematic ids="id24" refid="id23">|problematic|</problematic> text
(generated by processing errors; this one is intentional). Here is a
@@ -738,7 +739,7 @@
</section>
<section dupnames="duplicate\ target\ names" ids="id21">
<title auto="1" refid="id54"><generated classes="sectnum">2.13.2 </generated>Duplicate Target Names</title>
- <system_message backrefs="id21" level="1" line="438" source="functional/input/data/standard.txt" type="INFO">
+ <system_message backrefs="id21" level="1" line="439" source="functional/input/data/standard.txt" type="INFO">
<paragraph>Duplicate implicit target name: "duplicate target names".</paragraph>
</system_message>
<paragraph>Since there are two "Duplicate Target Names" section headers, we
@@ -1343,6 +1344,8 @@
<title auto="1" refid="id65"><generated classes="sectnum">2.15 </generated>Substitution Definitions</title>
<paragraph>An inline image (<image alt="EXAMPLE" uri="../../../docs/user/rst/images/biohazard.png"></image>) example:</paragraph>
<substitution_definition names="EXAMPLE"><image alt="EXAMPLE" uri="../../../docs/user/rst/images/biohazard.png"></image></substitution_definition>
+ <paragraph>A Unicode example:</paragraph>
+ <substitution_definition ltrim="1" names="heart" rtrim="1">♥</substitution_definition>
<paragraph>(Substitution definitions are not visible in the HTML source.)</paragraph>
</section>
<section ids="comments" names="comments">
@@ -1709,43 +1712,43 @@
<system_message backrefs="id24" ids="id23" level="3" line="104" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>Undefined substitution referenced: "problematic".</paragraph>
</system_message>
- <system_message backrefs="id17" ids="id83" level="3" line="391" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id17" ids="id83" level="3" line="392" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>Unknown target name: "5".</paragraph>
</system_message>
- <system_message backrefs="id19" ids="id84" level="3" line="400" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id19" ids="id84" level="3" line="401" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>Unknown target name: "nonexistent".</paragraph>
</system_message>
- <system_message backrefs="id86" ids="id85" level="3" line="427" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id86" ids="id85" level="3" line="428" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>Unknown target name: "hyperlink reference without a target".</paragraph>
</system_message>
- <system_message backrefs="id88" ids="id87" level="3" line="440" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id88" ids="id87" level="3" line="441" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>Duplicate target name, cannot be used as a unique reference: "duplicate target names".</paragraph>
</system_message>
- <system_message level="1" line="163" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="164" source="functional/input/data/standard.txt" type="INFO">
<paragraph>Hyperlink target "target" is not referenced.</paragraph>
</system_message>
- <system_message level="1" line="405" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="406" source="functional/input/data/standard.txt" type="INFO">
<paragraph>Hyperlink target "another-target" is not referenced.</paragraph>
</system_message>
- <system_message level="1" line="473" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="474" source="functional/input/data/standard.txt" type="INFO">
<paragraph>Hyperlink target "image-target-1" is not referenced.</paragraph>
</system_message>
- <system_message level="1" line="474" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="475" source="functional/input/data/standard.txt" type="INFO">
<paragraph>Hyperlink target "image-target-2" is not referenced.</paragraph>
</system_message>
- <system_message level="1" line="475" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="476" source="functional/input/data/standard.txt" type="INFO">
<paragraph>Hyperlink target "image-target-3" is not referenced.</paragraph>
</system_message>
- <system_message level="1" line="639" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="640" source="functional/input/data/standard.txt" type="INFO">
<paragraph>Hyperlink target "target1" is not referenced.</paragraph>
</system_message>
- <system_message level="1" line="640" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="641" source="functional/input/data/standard.txt" type="INFO">
<paragraph>Hyperlink target "target2" is not referenced.</paragraph>
</system_message>
- <system_message level="1" line="685" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="686" source="functional/input/data/standard.txt" type="INFO">
<paragraph>Hyperlink target "docutils" is not referenced.</paragraph>
</system_message>
- <system_message level="1" line="851" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="852" source="functional/input/data/standard.txt" type="INFO">
<paragraph>Hyperlink target "hyperlink targets" is not referenced.</paragraph>
</system_message>
</section>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2017-10-19 16:21:27 UTC (rev 8187)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2017-10-20 20:53:47 UTC (rev 8188)
@@ -176,7 +176,8 @@
references</a> <a class="footnote-reference" href="#id25" id="id31">[5]</a> (<a class="reference external" href="http://docutils.sourceforge.net/">a second reference</a> <a class="footnote-reference" href="#id32" id="id33">[7]</a>), footnote references (manually
numbered <a class="footnote-reference" href="#id8" id="id1">[1]</a>, anonymous auto-numbered <a class="footnote-reference" href="#id12" id="id2">[3]</a>, labeled auto-numbered
<a class="footnote-reference" href="#label" id="id3">[2]</a>, or symbolic <a class="footnote-reference" href="#id13" id="id4">[*]</a>), citation references (<a class="citation-reference" href="#cit2002" id="id5">[CIT2002]</a>),
-substitution references (<img alt="EXAMPLE" src="../../../docs/user/rst/images/biohazard.png" />), and <span class="target" id="inline-hyperlink-targets">inline hyperlink targets</span>
+substitution references (<img alt="EXAMPLE" src="../../../docs/user/rst/images/biohazard.png" /> &
+a <em>trimmed heart</em> <tt class="docutils literal">(U+2665):</tt>♥), and <span class="target" id="inline-hyperlink-targets">inline hyperlink targets</span>
(see <a class="reference internal" href="#targets">Targets</a> below for a reference back to here). Character-level
inline markup is also possible (although exceedingly ugly!) in <em>re</em><tt class="docutils literal">Structured</tt><em>Text</em>. Problems are indicated by <a href="#id23"><span class="problematic" id="id24">|problematic|</span></a> text
(generated by processing errors; this one is intentional). Here is a
@@ -1019,6 +1020,7 @@
<div class="section" id="substitution-definitions">
<h2><a class="toc-backref" href="#id65">2.15 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">
@@ -1365,16 +1367,16 @@
<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 104); <em><a href="#id24">backlink</a></em></p>
Undefined substitution referenced: "problematic".</div>
<div class="system-message" id="id86">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 391); <em><a href="#id17">backlink</a></em></p>
+<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 392); <em><a href="#id17">backlink</a></em></p>
Unknown target name: "5".</div>
<div class="system-message" id="id87">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 400); <em><a href="#id19">backlink</a></em></p>
+<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 401); <em><a href="#id19">backlink</a></em></p>
Unknown target name: "nonexistent".</div>
<div class="system-message" id="id88">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 427); <em><a href="#id89">backlink</a></em></p>
+<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 428); <em><a href="#id89">backlink</a></em></p>
Unknown target name: "hyperlink reference without a target".</div>
<div class="system-message" id="id90">
-<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 440); <em><a href="#id91">backlink</a></em></p>
+<p class="system-message-title">System Message: ERROR/3 (<tt class="docutils">functional/input/data/standard.txt</tt>, line 441); <em><a href="#id91">backlink</a></em></p>
Duplicate target name, cannot be used as a unique reference: "duplicate target names".</div>
</div>
</div>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2017-10-19 16:21:27 UTC (rev 8187)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2017-10-20 20:53:47 UTC (rev 8188)
@@ -194,7 +194,8 @@
references</a> <a class="footnote-reference brackets" href="#id25" id="id35">5</a> (<a class="reference external" href="http://docutils.sourceforge.net/">a second reference</a> <a class="footnote-reference brackets" href="#id36" id="id37">9</a>), footnote references (manually
numbered <a class="footnote-reference brackets" href="#id8" id="id1">1</a>, anonymous auto-numbered <a class="footnote-reference brackets" href="#id12" id="id2">3</a>, labeled auto-numbered
<a class="footnote-reference brackets" href="#label" id="id3">2</a>, or symbolic <a class="footnote-reference brackets" href="#id13" id="id4">*</a>), citation references (<a class="citation-reference" href="#cit2002" id="id5">[CIT2002]</a>),
-substitution references (<img alt="EXAMPLE" src="../../../docs/user/rst/images/biohazard.png" />), and <span class="target" id="inline-hyperlink-targets">inline hyperlink targets</span>
+substitution references (<img alt="EXAMPLE" src="../../../docs/user/rst/images/biohazard.png" /> &
+a <em>trimmed heart</em> <span class="docutils literal">(U+2665):</span>♥), and <span class="target" id="inline-hyperlink-targets">inline hyperlink targets</span>
(see <a class="reference internal" href="#targets">Targets</a> below for a reference back to here). Character-level
inline markup is also possible (although exceedingly ugly!) in <em>re</em><span class="docutils literal">Structured</span><em>Text</em>. Problems are indicated by <a href="#id23"><span class="problematic" id="id24">|problematic|</span></a> text
(generated by processing errors; this one is intentional). Here is a
@@ -989,6 +990,7 @@
<div class="section" id="substitution-definitions">
<h2><a class="toc-backref" href="#id69"><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">
@@ -1546,19 +1548,19 @@
<p>Undefined substitution referenced: "problematic".</p>
</div>
<div class="system-message" id="id96">
-<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">functional/input/data/standard.txt</span>, line 391); <em><a href="#id17">backlink</a></em></p>
+<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">functional/input/data/standard.txt</span>, line 392); <em><a href="#id17">backlink</a></em></p>
<p>Unknown target name: "5".</p>
</div>
<div class="system-message" id="id97">
-<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">functional/input/data/standard.txt</span>, line 400); <em><a href="#id19">backlink</a></em></p>
+<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">functional/input/data/standard.txt</span>, line 401); <em><a href="#id19">backlink</a></em></p>
<p>Unknown target name: "nonexistent".</p>
</div>
<div class="system-message" id="id98">
-<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">functional/input/data/standard.txt</span>, line 427); <em><a href="#id99">backlink</a></em></p>
+<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">functional/input/data/standard.txt</span>, line 428); <em><a href="#id99">backlink</a></em></p>
<p>Unknown target name: "hyperlink reference without a target".</p>
</div>
<div class="system-message" id="id100">
-<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">functional/input/data/standard.txt</span>, line 440); <em><a href="#id101">backlink</a></em></p>
+<p class="system-message-title">System Message: ERROR/3 (<span class="docutils literal">functional/input/data/standard.txt</span>, line 441); <em><a href="#id101">backlink</a></em></p>
<p>Duplicate target name, cannot be used as a unique reference: "duplicate target names".</p>
</div>
</div>
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2017-10-19 16:21:27 UTC (rev 8187)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2017-10-20 20:53:47 UTC (rev 8188)
@@ -347,7 +347,8 @@
(\href{http://www.python.org}{Python web site}), \href{http://www.python.org/}{anonymous hyperlink
references}\DUfootnotemark{id38}{id29}{5} (\href{http://docutils.sourceforge.net/}{a second reference}\DUfootnotemark{id40}{id39}{8}), footnote references (manually
numbered\DUfootnotemark{id1}{id8}{1}, anonymous auto-numbered\DUfootnotemark{id2}{id12}{3}, labeled auto-numbered\DUfootnotemark{id3}{label}{2}, or symbolic\DUfootnotemark{id4}{id13}{*}), citation references (\hyperlink{cit2002}{[CIT2002]}),
-substitution references (\includegraphics{../../../docs/user/rst/images/biohazard.png}), and %
+substitution references (\includegraphics{../../../docs/user/rst/images/biohazard.png} \&
+a \emph{trimmed heart} \texttt{(U+2665):}\ding{170}), and %
\phantomsection\label{inline-hyperlink-targets}inline hyperlink targets
(see \hyperref[targets]{Targets} below for a reference back to here). Character-level
inline markup is also possible (although exceedingly ugly!) in \emph{re}\texttt{Structured}\emph{Text}. Problems are indicated by %
@@ -1480,6 +1481,8 @@
An inline image (\includegraphics{../../../docs/user/rst/images/biohazard.png}) example:
+A Unicode example:
+
(Substitution definitions are not visible in the HTML source.)
@@ -2876,7 +2879,7 @@
\DUtitle[system-message]{system-message}
\raisebox{1em}{\hypertarget{id45}{}}
-{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~391
+{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~392
\hyperlink{id17}{
Unknown target name: \textquotedbl{}5\textquotedbl{}.
@@ -2886,7 +2889,7 @@
\DUtitle[system-message]{system-message}
\raisebox{1em}{\hypertarget{id46}{}}
-{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~400
+{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~401
\hyperlink{id19}{
Unknown target name: \textquotedbl{}nonexistent\textquotedbl{}.
@@ -2896,7 +2899,7 @@
\DUtitle[system-message]{system-message}
\raisebox{1em}{\hypertarget{id47}{}}
-{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~427
+{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~428
\hyperlink{id48}{
Unknown target name: \textquotedbl{}hyperlink reference without a target\textquotedbl{}.
@@ -2906,7 +2909,7 @@
\DUtitle[system-message]{system-message}
\raisebox{1em}{\hypertarget{id49}{}}
-{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~440
+{\color{red}ERROR/3} in \texttt{functional/input/data/standard.txt}, line~441
\hyperlink{id50}{
Duplicate target name, cannot be used as a unique reference: \textquotedbl{}duplicate target names\textquotedbl{}.
Modified: trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2017-10-19 16:21:27 UTC (rev 8187)
+++ trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2017-10-20 20:53:47 UTC (rev 8188)
@@ -450,6 +450,14 @@
),
substitution references (
<image alt="EXAMPLE" uri="../../../docs/user/rst/images/biohazard.png">
+ &
+ a
+ <emphasis>
+ trimmed heart
+
+ <literal>
+ (U+2665):
+ ♥
), and
<target ids="inline-hyperlink-targets" names="inline\ hyperlink\ targets">
inline hyperlink targets
@@ -1132,7 +1140,7 @@
<generated classes="sectnum">
2.13.2
Duplicate Target Names
- <system_message backrefs="id21" level="1" line="438" source="functional/input/data/standard.txt" type="INFO">
+ <system_message backrefs="id21" level="1" line="439" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Duplicate implicit target name: "duplicate target names".
<paragraph>
@@ -1944,6 +1952,10 @@
<substitution_definition names="EXAMPLE">
<image alt="EXAMPLE" uri="../../../docs/user/rst/images/biohazard.png">
<paragraph>
+ A Unicode example:
+ <substitution_definition ltrim="1" names="heart" rtrim="1">
+ ♥
+ <paragraph>
(Substitution definitions are not visible in the HTML source.)
<section ids="comments" names="comments">
<title auto="1" refid="id66">
@@ -2307,42 +2319,42 @@
<system_message backrefs="id24" ids="id23" level="3" line="104" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>
Undefined substitution referenced: "problematic".
- <system_message backrefs="id17" ids="id83" level="3" line="391" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id17" ids="id83" level="3" line="392" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>
Unknown target name: "5".
- <system_message backrefs="id19" ids="id84" level="3" line="400" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id19" ids="id84" level="3" line="401" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>
Unknown target name: "nonexistent".
- <system_message backrefs="id86" ids="id85" level="3" line="427" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id86" ids="id85" level="3" line="428" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>
Unknown target name: "hyperlink reference without a target".
- <system_message backrefs="id88" ids="id87" level="3" line="440" source="functional/input/data/standard.txt" type="ERROR">
+ <system_message backrefs="id88" ids="id87" level="3" line="441" source="functional/input/data/standard.txt" type="ERROR">
<paragraph>
Duplicate target name, cannot be used as a unique reference: "duplicate target names".
- <system_message level="1" line="163" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="164" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "target" is not referenced.
- <system_message level="1" line="405" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="406" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "another-target" is not referenced.
- <system_message level="1" line="473" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="474" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "image-target-1" is not referenced.
- <system_message level="1" line="474" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="475" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "image-target-2" is not referenced.
- <system_message level="1" line="475" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="476" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "image-target-3" is not referenced.
- <system_message level="1" line="639" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="640" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "target1" is not referenced.
- <system_message level="1" line="640" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="641" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "target2" is not referenced.
- <system_message level="1" line="685" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="686" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "docutils" is not referenced.
- <system_message level="1" line="851" source="functional/input/data/standard.txt" type="INFO">
+ <system_message level="1" line="852" source="functional/input/data/standard.txt" type="INFO">
<paragraph>
Hyperlink target "hyperlink targets" is not referenced.
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 20...
[truncated message content] |
|
From: <mi...@us...> - 2017-10-25 13:57:30
|
Revision: 8190
http://sourceforge.net/p/docutils/code/8190
Author: milde
Date: 2017-10-25 13:57:27 +0000 (Wed, 25 Oct 2017)
Log Message:
-----------
smartquotes: Fix bug #332.
Use open quote after whitespace, ZWSP, and ZWNJ.
Code cleanup.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/utils/smartquotes.py
trunk/docutils/test/test_transforms/test_smartquotes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-10-20 22:00:02 UTC (rev 8189)
+++ trunk/docutils/HISTORY.txt 2017-10-25 13:57:27 UTC (rev 8190)
@@ -32,30 +32,34 @@
* docutils/parsers/rst/directives/html.py:
- - Fix [ 281 ] Remove escaping backslashes in meta directive content.
+ - Fix bug #281: Remove escaping backslashes in meta directive content.
* docutils/parsers/rst/directives/tables.py:
- - Apply [ 121 ] Add a :width: option for the table directives.
+ - Apply patch #121: Add "width" option for the table directives.
-* docutils/transforms/frontmatter.py
+* docutils/transforms/frontmatter.py:
- Add field name as class argument to generic docinfo fields unconditionally.
-* docutils/transforms/references.py
+* docutils/transforms/references.py:
- Fix bug #331: fixed the "trim" options of the "unicode" directive.
+* docutils/utils/smartquotes.py:
+
+ - Fix bug #332: use open quote after whitespace, ZWSP, and ZWNJ.
+
* docutils/writers/html5_polyglot/
- automatically add HTML5-compatible meta tags for docinfo items
"authors", "date", and "copyright".
-* docutils/writers/latex2e/__init__.py
+* docutils/writers/latex2e/__init__.py:
- - Fix [ 323 ] spurious ``\phantomsection`` and whitespace in
- ``parts['title'].
- - Fix [ 324 ] Invalid LaTeX for table with empty multicolumn cell.
+ - Fix bug #323: spurious ``\phantomsection`` and whitespace in
+ ``parts['title']``.
+ - Fix bug #324: Invalid LaTeX for table with empty multicolumn cell.
- Fixes to literal block handling.
* docutils/utils/__init__.py:
@@ -98,15 +102,15 @@
- Rework patch [ 120 ] (revert change to ``Table.get_column_widths()``
that led to problems in an application with a custom table directive).
-* docutils/transforms/frontmatter.py
+* docutils/transforms/frontmatter.py:
- Fix [ 320 ] Russian docinfo fields not recognized.
-* docutils/transforms/references.py
+* docutils/transforms/references.py:
- Don't add a second ID to problematic references.
-* docutils/transforms/universal.py
+* docutils/transforms/universal.py:
Fix SmartQuotes: warn only once if language is unsupported,
keep "rawsource" when "educating" quotes.
@@ -116,7 +120,7 @@
- Added ``split_escaped_whitespace`` function, support for escaped
whitespace in URI contexts.
-* docutils/utils/error_reporting.py
+* docutils/utils/error_reporting.py:
- Fix [ 321 ] Import block might cause name error.
@@ -129,7 +133,7 @@
- Fix [ 317 ] Extra space inserted with French smartquotes.
- Add command line interface for stand-alone use (requires 2.7).
-* docutils/writers/_html_base.py
+* docutils/writers/_html_base.py:
- Provide default title in metadata (required by HTML5).
- Fix [ 312 ] HTML writer generates invalid HTML if the table has two tags.
@@ -137,17 +141,17 @@
reasons, we don't use a third party public installation as default but
warn if math-output_ is set to MathJax without specifying a URL.
-* docutils/writers/html4css1/__init__.py
+* docutils/writers/html4css1/__init__.py:
- Apply [ 125 ] HTML writer: respect automatic table column sizing.
-* docutils/writers/latex2e/__init__.py
+* docutils/writers/latex2e/__init__.py:
- Handle class arguments for block-level elements by wrapping them
in a "DUclass" environment. This replaces the special handling for
"epigraph" and "topic" elements.
-* docutils/writers/manpage.py
+* docutils/writers/manpage.py:
- Apply [ 141 ] Handling inline in manpage writer.
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2017-10-20 22:00:02 UTC (rev 8189)
+++ trunk/docutils/RELEASE-NOTES.txt 2017-10-25 13:57:27 UTC (rev 8190)
@@ -25,6 +25,8 @@
* Remove the `handle_io_errors` option from io.FileInput/Output.
Used by Sphinx up to version 1.3.1, fixed in 1.3.2 (Nov 29, 2015).
+* Remove `utils.unique_combinations` (obsoleted by `itertools.combinations`).
+
* The default HTML writer "html" with frontend ``rst2html.py`` may change
from "html4css1" to "html5".
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2017-10-20 22:00:02 UTC (rev 8189)
+++ trunk/docutils/docutils/utils/smartquotes.py 2017-10-25 13:57:27 UTC (rev 8190)
@@ -261,6 +261,10 @@
Version History
===============
+1.8.1 2017-10-25
+ - Use open quote after Unicode whitespace, ZWSP, and ZWNJ.
+ - Code cleanup.
+
1.8: 2017-04-24
- Command line front-end.
@@ -635,8 +639,10 @@
smart = smartchars(language)
- # oldtext = text
punct_class = r"""[!"#\$\%'()*+,-.\/:;<=>?\@\[\\\]\^_`{|}~]"""
+ close_class = r"""[^\ \t\r\n\[\{\(\-]"""
+ open_class = u'[\u200B\u200C]' # ZWSP, ZWNJ
+ dec_dashes = r"""–|—"""
# Special case if the very first character is a quote
# followed by punctuation at a non-word-break.
@@ -653,22 +659,21 @@
if language.startswith('en'): # TODO similar cases in other languages?
text = re.sub(r"""'(?=\d{2}s)""", smart.apostrophe, text, re.UNICODE)
- close_class = r"""[^\ \t\r\n\[\{\(\-]"""
- dec_dashes = r"""–|—"""
-
# Get most opening single quotes:
- opening_single_quotes_regex = re.compile(r"""
- (
+ opening_single_quotes_regex = re.compile(ur"""
+ (# ?<= # look behind fails: requires fixed-width pattern
\s | # a whitespace char, or
+ %s | # another separating char, or
| # a non-breaking space entity, or
- -- | # dashes, or
- &[mn]dash; | # named dash entities
- %s | # or decimal entities
- &\#x201[34]; # or hex
+ [–—] | # literal dashes, or
+ -- | # dumb dashes, or
+ &[mn]dash; | # dash entities (named or
+ %s | # decimal or
+ &\#x201[34]; # hex)
)
' # the quote
(?=\w) # followed by a word character
- """ % (dec_dashes,), re.VERBOSE | re.UNICODE)
+ """ % (open_class,dec_dashes), re.VERBOSE | re.UNICODE)
text = opening_single_quotes_regex.sub(r'\1'+smart.osquote, text)
# In many locales, single closing quotes are different from apostrophe:
@@ -679,54 +684,40 @@
# "Ich fass' es nicht."
closing_single_quotes_regex = re.compile(r"""
- (%s)
+ (?<=%s)
'
- (?!\s | # whitespace
- s\b |
- \d # digits ('80s)
- )
- """ % (close_class,), re.VERBOSE | re.UNICODE)
- text = closing_single_quotes_regex.sub(r'\1'+smart.csquote, text)
+ """ % close_class, re.VERBOSE)
+ text = closing_single_quotes_regex.sub(smart.csquote, text)
- closing_single_quotes_regex = re.compile(r"""
- (%s)
- '
- (\s | s\b)
- """ % (close_class,), re.VERBOSE | re.UNICODE)
- text = closing_single_quotes_regex.sub(r'\1%s\2' % smart.csquote, text)
-
# Any remaining single quotes should be opening ones:
text = re.sub(r"""'""", smart.osquote, text)
# Get most opening double quotes:
- opening_double_quotes_regex = re.compile(r"""
+ opening_double_quotes_regex = re.compile(ur"""
(
\s | # a whitespace char, or
+ %s | # another separating char, or
| # a non-breaking space entity, or
- -- | # dashes, or
- &[mn]dash; | # named dash entities
- %s | # or decimal entities
- &\#x201[34]; # or hex
+ [–—] | # literal dashes, or
+ -- | # dumb dashes, or
+ &[mn]dash; | # dash entities (named or
+ %s | # decimal or
+ &\#x201[34]; # hex)
)
" # the quote
(?=\w) # followed by a word character
- """ % (dec_dashes,), re.VERBOSE)
+ """ % (open_class,dec_dashes), re.VERBOSE | re.UNICODE)
text = opening_double_quotes_regex.sub(r'\1'+smart.opquote, text)
# Double closing quotes:
closing_double_quotes_regex = re.compile(r"""
- #(%s)? # character that indicates the quote should be closing
- "
- (?=\s)
- """ % (close_class,), re.VERBOSE)
+ (
+ (?<=%s)" | # char indicating the quote should be closing
+ "(?=\s) # whitespace behind
+ )
+ """ % (close_class,), re.VERBOSE | re.UNICODE)
text = closing_double_quotes_regex.sub(smart.cpquote, text)
- closing_double_quotes_regex = re.compile(r"""
- (%s) # character that indicates the quote should be closing
- "
- """ % (close_class,), re.VERBOSE)
- text = closing_double_quotes_regex.sub(r'\1'+smart.cpquote, text)
-
# Any remaining quotes should be opening ones.
text = re.sub(r'"', smart.opquote, text)
Modified: trunk/docutils/test/test_transforms/test_smartquotes.py
===================================================================
--- trunk/docutils/test/test_transforms/test_smartquotes.py 2017-10-20 22:00:02 UTC (rev 8189)
+++ trunk/docutils/test/test_transforms/test_smartquotes.py 2017-10-25 13:57:27 UTC (rev 8190)
@@ -56,16 +56,12 @@
“‘nested’ smart” quotes
– and —also long— dashes.
"""],
-[r"""Escaped \\"smart quotes\\", \\'secondary smart quotes\\',
-\\"\\'nested\\' smart\\" quotes
-\\-- and -\\--also long-\\-- dashes.
+[r"""Escaped \\"ASCII quotes\\" and \\'secondary ASCII quotes\\'.
""",
u"""\
<document source="test data">
<paragraph>
- Escaped "smart quotes", 'secondary smart quotes',
- "'nested' smart" quotes
- -- and ---also long--- dashes.
+ Escaped "ASCII quotes" and 'secondary ASCII quotes'.
"""],
["""\
Do not "educate" quotes ``inside "literal" text`` and ::
@@ -106,6 +102,40 @@
<math_block xml:space="preserve">
f'(x) = df(x)/dx
"""],
+[u"""\
+Quotes preceded by
+a word"a" and'a',
+punctuation:"a",'a',
+
+normal space "a" 'a',
+thin space "a" 'a',
+em space "a" 'a',
+NBSP "a" 'a',
+ZWSP\u200B"a" and\u200B'a',
+ZWNJ\u200C"a" and\u200C'a',
+
+—"a",—'a'
+en dash–"a"–'a',
+em dash—"a"—'a'.
+""",
+u"""\
+<document source="test data">
+ <paragraph>
+ Quotes preceded by
+ a word”a” and’a’,
+ punctuation:”a”,’a’,
+ <paragraph>
+ normal space “a” ‘a’,
+ thin space “a” ‘a’,
+ em space “a” ‘a’,
+ NBSP “a” ‘a’,
+ ZWSP\u200B“a” and\u200B‘a’,
+ ZWNJ\u200C“a” and\u200C‘a’,
+ <paragraph>
+ —“a”,—‘a’
+ en dash–“a”–‘a’,
+ em dash—“a”—‘a’.
+"""],
["""\
Quotes and inline-elements:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-11-04 09:40:29
|
Revision: 8194
http://sourceforge.net/p/docutils/code/8194
Author: milde
Date: 2017-11-04 09:40:27 +0000 (Sat, 04 Nov 2017)
Log Message:
-----------
`Text.rstrip` and `Text.lstrip` now handle `rawsource` attribute.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/nodes.py
trunk/docutils/test/test_nodes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-11-04 09:27:41 UTC (rev 8193)
+++ trunk/docutils/HISTORY.txt 2017-11-04 09:40:27 UTC (rev 8194)
@@ -26,6 +26,10 @@
- Document rST syntax change: Tokens like ``:this:example:`` are now valid
field list names (instead of ordinary text).
+* docutils/nodes.py
+
+ - `Text.rstrip` and `Text.lstrip` now handle `rawsource` attribute.
+
* docutils/parsers/rst/states.py:
- Allow embedded colons in field list field names.
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2017-11-04 09:27:41 UTC (rev 8193)
+++ trunk/docutils/docutils/nodes.py 2017-11-04 09:40:27 UTC (rev 8194)
@@ -304,8 +304,6 @@
def __repr__(self):
return unicode.__repr__(self)[1:]
-
-
else:
reprunicode = unicode
@@ -344,7 +342,6 @@
return reprunicode.__new__(cls, data)
def __init__(self, data, rawsource=''):
-
self.rawsource = rawsource
"""The raw text from which this element was constructed."""
@@ -387,13 +384,17 @@
# rstrip and lstrip are used by substitution definitions where
# they are expected to return a Text instance, this was formerly
- # taken care of by UserString. Note that then and now the
- # rawsource member is lost.
+ # taken care of by UserString.
def rstrip(self, chars=None):
- return self.__class__(reprunicode.rstrip(self, chars))
+ node = self.__class__(reprunicode.rstrip(self, chars))
+ node.rawsource = self.rawsource.rstrip((chars or ' \n\t\r')+'\\')
+ return node
def lstrip(self, chars=None):
- return self.__class__(reprunicode.lstrip(self, chars))
+ node = self.__class__(reprunicode.lstrip(self, chars))
+ node.rawsource = re.sub(ur'^(\\?[%s])+'%(chars or ' \n\t\r'), u'',
+ self.rawsource)
+ return node
class Element(Node):
@@ -447,7 +448,7 @@
"""List attributes, automatically initialized to empty lists for
all nodes."""
- known_attributes = list_attributes + ('source',)
+ known_attributes = list_attributes + ('source', 'rawsource')
"""List attributes that are known to the Element base class."""
tagname = None
@@ -459,8 +460,11 @@
def __init__(self, rawsource='', *children, **attributes):
self.rawsource = rawsource
- """The raw text from which this element was constructed."""
+ """The raw text from which this element was constructed.
+ NOTE: some elements do not set this value (default '').
+ """
+
self.children = []
"""List of child nodes (elements and/or `Text`)."""
Modified: trunk/docutils/test/test_nodes.py
===================================================================
--- trunk/docutils/test/test_nodes.py 2017-11-04 09:27:41 UTC (rev 8193)
+++ trunk/docutils/test/test_nodes.py 2017-11-04 09:40:27 UTC (rev 8194)
@@ -54,6 +54,15 @@
self.assertTrue(isinstance(self.text.pformat(), unicode))
self.assertEqual(self.text.pformat(), u'Line 1.\nLine 2.\n')
+ def test_strip(self):
+ text = nodes.Text(' was noch ', ' \was\ noch \\ ')
+ stripped = text.lstrip().rstrip()
+ stripped2 = text.lstrip(' wahn').rstrip(' wahn')
+ self.assertEqual(stripped, u'was noch')
+ self.assertEqual(stripped.rawsource, u'\was\\ noch')
+ self.assertEqual(stripped2, u's noc')
+ self.assertEqual(stripped2.rawsource, u's\\ noc')
+
def test_asciirestriction(self):
if sys.version_info < (3,):
self.assertRaises(UnicodeDecodeError, nodes.Text,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-11-04 10:06:48
|
Revision: 8195
http://sourceforge.net/p/docutils/code/8195
Author: milde
Date: 2017-11-04 10:06:45 +0000 (Sat, 04 Nov 2017)
Log Message:
-----------
New function `utils.unescape_rawsource`.
Removes backslashes and backslash-escaped whitespace from
`rawsource` arguments.
Required for fixes in definition list terms, author docinfo extraction,
and smartquote escaping.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/test/test_utils.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-11-04 09:40:27 UTC (rev 8194)
+++ trunk/docutils/HISTORY.txt 2017-11-04 10:06:45 UTC (rev 8195)
@@ -69,6 +69,7 @@
* docutils/utils/__init__.py:
- Deprecate `unique_combinations` (obsoleted by `itertools.combinations`).
+ - New function `unescape_rawsource`.
Release 0.14 (2017-08-03)
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2017-11-04 09:40:27 UTC (rev 8194)
+++ trunk/docutils/docutils/utils/__init__.py 2017-11-04 10:06:45 UTC (rev 8195)
@@ -588,6 +588,13 @@
text = ''.join(text.split(sep))
return text
+def unescape_rawsource(text):
+ """Remove escape-backslashes and escaped whitespace."""
+ # remove escaped whitespace or backslash at end of text
+ text = re.sub(r'(?<!\\)\\([ \n]|$)', r'', text)
+ # remove backslash-escapes
+ return re.sub(r'\\(.)', r'\1', text)
+
def split_escaped_whitespace(text):
"""
Split `text` on escaped whitespace (null+space or null+newline).
Modified: trunk/docutils/test/test_utils.py
===================================================================
--- trunk/docutils/test/test_utils.py 2017-11-04 09:40:27 UTC (rev 8194)
+++ trunk/docutils/test/test_utils.py 2017-11-04 10:06:45 UTC (rev 8195)
@@ -321,6 +321,22 @@
self.assertEqual(utils.find_file_in_dirs('gibts/nicht.txt', dirs),
'gibts/nicht.txt')
+ # samples for the (un)escaping tests:
+ raw = r'spa\m\ and \\ham' + '\\'
+ nulled = 'spa\x00m\x00 and \x00\ham\x00'
+ unescaped = 'spamand \\ham'
+ def test_escape2null(self):
+ self.assertEqual(utils.escape2null(self.raw), self.nulled)
+
+ def test_unescape(self):
+ self.assertEqual(utils.unescape(self.nulled), self.unescaped)
+ self.assertEqual(utils.unescape(self.nulled, restore_backslashes=True),
+ self.raw)
+
+ def test_unescape_rawsource(self):
+ self.assertEqual(utils.unescape_rawsource(self.raw), self.unescaped)
+
+
if __name__ == '__main__':
unittest.main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-11-04 10:31:04
|
Revision: 8197
http://sourceforge.net/p/docutils/code/8197
Author: milde
Date: 2017-11-04 10:31:01 +0000 (Sat, 04 Nov 2017)
Log Message:
-----------
"rawsource" attribute for text of inline elements and definition list terms.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/docutils/transforms/references.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-11-04 10:21:10 UTC (rev 8196)
+++ trunk/docutils/HISTORY.txt 2017-11-04 10:31:01 UTC (rev 8197)
@@ -33,6 +33,8 @@
* docutils/parsers/rst/states.py:
- Allow embedded colons in field list field names.
+ - Add "rawsource" attribute for text of inline elements and definition
+ list terms.
* docutils/parsers/rst/directives/html.py:
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2017-11-04 10:21:10 UTC (rev 8196)
+++ trunk/docutils/docutils/parsers/rst/states.py 2017-11-04 10:31:01 UTC (rev 8197)
@@ -424,7 +424,9 @@
"""
Return 2 lists: nodes (text and inline elements), and system_messages.
"""
- return self.inliner.parse(text, lineno, self.memo, self.parent)
+ nodes, messages = self.inliner.parse(text, lineno,
+ self.memo, self.parent)
+ return nodes, messages
def unindent_warning(self, node_name):
# the actual problem is one line below the current line
@@ -711,11 +713,13 @@
return (string[:matchend], [], string[matchend:], [], '')
endmatch = end_pattern.search(string[matchend:])
if endmatch and endmatch.start(1): # 1 or more chars
- text = unescape(endmatch.string[:endmatch.start(1)],
- restore_backslashes)
+ _text = endmatch.string[:endmatch.start(1)]
+ text = unescape(_text, restore_backslashes)
textend = matchend + endmatch.end(1)
rawsource = unescape(string[matchstart:textend], True)
- return (string[:matchstart], [nodeclass(rawsource, text)],
+ node = nodeclass(rawsource, text)
+ node[0].rawsource = unescape(_text, True)
+ return (string[:matchstart], [node],
string[textend:], [], endmatch.group(1))
msg = self.reporter.warning(
'Inline %s start-string without end-string.'
@@ -798,6 +802,7 @@
match = self.patterns.embedded_link.search(escaped)
if match: # embedded <URI> or <alias_>
text = unescape(escaped[:match.start(0)])
+ rawtext = unescape(escaped[:match.start(0)], True)
aliastext = match.group(2)
underscore_escaped = aliastext.endswith('\x00_')
aliastext = unescape(aliastext)
@@ -824,10 +829,13 @@
text = alias
else:
target = None
+ rawtext = unescape(escaped, True)
refname = normalize_name(text)
reference = nodes.reference(rawsource, text,
name=whitespace_normalize_name(text))
+ reference[0].rawsource = rawtext
+
node_list = [reference]
if rawsource[-2:] == '__':
@@ -869,6 +877,10 @@
self.reporter)
if role_fn:
nodes, messages2 = role_fn(role, rawsource, text, lineno, self)
+ try:
+ nodes[0][0].rawsource = unescape(text, True)
+ except IndexError:
+ pass
return nodes, messages + messages2
else:
msg = self.reporter.error(
@@ -956,6 +968,7 @@
referencenode = nodes.reference(
referencename + match.group('refend'), referencename,
name=whitespace_normalize_name(referencename))
+ referencenode[0].rawsource = referencename
if anonymous:
referencenode['anonymous'] = 1
else:
@@ -978,8 +991,11 @@
addscheme = ''
text = match.group('whole')
unescaped = unescape(text)
- return [nodes.reference(unescape(text, True), unescaped,
- refuri=addscheme + unescaped)]
+ rawsource = unescape(text, True)
+ reference = nodes.reference(rawsource, unescaped,
+ refuri=addscheme + unescaped)
+ reference[0].rawsource = rawsource
+ return [reference]
else: # not a valid scheme
raise MarkupMismatch
@@ -2829,10 +2845,9 @@
"""Return a definition_list's term and optional classifiers."""
assert len(lines) == 1
text_nodes, messages = self.inline_text(lines[0], lineno)
- term_node = nodes.term()
+ term_node = nodes.term(lines[0])
(term_node.source,
term_node.line) = self.state_machine.get_source_and_line(lineno)
- term_node.rawsource = unescape(lines[0])
node_list = [term_node]
for i in range(len(text_nodes)):
node = text_nodes[i]
@@ -2841,10 +2856,14 @@
if len(parts) == 1:
node_list[-1] += node
else:
-
- node_list[-1] += nodes.Text(parts[0].rstrip())
+ rawtext = parts[0].rstrip()
+ textnode = nodes.Text(utils.unescape_rawsource(rawtext))
+ textnode.rawsource = rawtext
+ node_list[-1] += textnode
for part in parts[1:]:
- classifier_node = nodes.classifier('', part)
+ classifier_node = nodes.classifier(part,
+ utils.unescape_rawsource(part))
+ classifier_node[0].rawsource = part
node_list.append(classifier_node)
else:
node_list[-1] += node
Modified: trunk/docutils/docutils/transforms/references.py
===================================================================
--- trunk/docutils/docutils/transforms/references.py 2017-11-04 10:21:10 UTC (rev 8196)
+++ trunk/docutils/docutils/transforms/references.py 2017-11-04 10:31:01 UTC (rev 8197)
@@ -866,7 +866,7 @@
class DanglingReferencesVisitor(nodes.SparseNodeVisitor):
-
+
def __init__(self, document, unknown_reference_resolvers):
nodes.SparseNodeVisitor.__init__(self, document)
self.document = document
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-11-04 21:14:40
|
Revision: 8198
http://sourceforge.net/p/docutils/code/8198
Author: milde
Date: 2017-11-04 21:14:37 +0000 (Sat, 04 Nov 2017)
Log Message:
-----------
Ignore backslash-escaped separators when extracting authors from a paragraph.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/test/test_transforms/test_docinfo.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2017-11-04 10:31:01 UTC (rev 8197)
+++ trunk/docutils/HISTORY.txt 2017-11-04 21:14:37 UTC (rev 8198)
@@ -47,6 +47,8 @@
* docutils/transforms/frontmatter.py:
- Add field name as class argument to generic docinfo fields unconditionally.
+ - Ignore backslash-escaped separators when extracting authors from a
+ paragraph.
* docutils/transforms/references.py:
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2017-11-04 10:31:01 UTC (rev 8197)
+++ trunk/docutils/RELEASE-NOTES.txt 2017-11-04 21:14:37 UTC (rev 8198)
@@ -58,7 +58,11 @@
- Fixed a bug with the "trim" options of the "unicode" directive.
+ - Allow escaping of author-separators in `bibliographic fields`__.
+
+ __ docs/ref/rst/restructuredtext.html#bibliographic-fields
+
Release 0.14 (2017-08-03)
=========================
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2017-11-04 10:31:01 UTC (rev 8197)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2017-11-04 21:14:37 UTC (rev 8198)
@@ -424,6 +424,7 @@
base_node=field)
raise TransformError
title = nodes.title(name, labels[canonical])
+ title[0].rawsource = labels[canonical]
topics[canonical] = biblioclass(
'', title, classes=[canonical], *field[1].children)
else:
@@ -503,20 +504,30 @@
raise
def authors_from_one_paragraph(self, field):
- text = field[1][0].astext().strip()
+ """Return list of Text nodes for ";"- or ","-separated authornames."""
+ # @@ keep original formatting? (e.g. ``:authors: A. Test, *et-al*``)
+ rawnames = (node.rawsource or node.astext
+ for node in field[1].traverse(nodes.Text))
+ text = ''.join(rawnames)
if not text:
raise TransformError
for authorsep in self.language.author_separators:
- authornames = text.split(authorsep)
+ # don't split at escaped `authorsep`:
+ pattern = r'(?<=\\\\)%s|(?<!\\)%s' % (authorsep, authorsep)
+ authornames = re.split(pattern, text)
if len(authornames) > 1:
break
- authornames = [author.strip() for author in authornames]
- authors = [[nodes.Text(author)] for author in authornames if author]
+ authornames = ((utils.unescape_rawsource(rawname).strip(),
+ rawname.strip()) for rawname in authornames)
+ authors = [[nodes.Text(author, rawname)]
+ for (author, rawname) in authornames if author]
return authors
def authors_from_bullet_list(self, field):
authors = []
for item in field[1][0]:
+ if isinstance(item, nodes.comment):
+ continue
if len(item) != 1 or not isinstance(item[0], nodes.paragraph):
raise TransformError
authors.append(item[0].children)
@@ -526,7 +537,8 @@
def authors_from_paragraphs(self, field):
for item in field[1]:
- if not isinstance(item, nodes.paragraph):
+ if not isinstance(item, (nodes.paragraph, nodes.comment)):
raise TransformError
- authors = [item.children for item in field[1]]
+ authors = [item.children for item in field[1]
+ if not isinstance(item, nodes.comment)]
return authors
Modified: trunk/docutils/test/test_transforms/test_docinfo.py
===================================================================
--- trunk/docutils/test/test_transforms/test_docinfo.py 2017-11-04 10:31:01 UTC (rev 8197)
+++ trunk/docutils/test/test_transforms/test_docinfo.py 2017-11-04 21:14:37 UTC (rev 8198)
@@ -230,6 +230,49 @@
<author>
One, Only
"""],
+[r""":Authors: Me\, Myself; **I**
+:Authors: Pac\;Man\\; Ms. Pac\Man; Pac\ Man, Jr.
+:Authors:
+ Here
+
+ The\re
+
+ *Every\ where*
+:Authors: - First\\
+ - Se\ cond
+ - Thir\d
+""",
+"""\
+<document source="test data">
+ <docinfo>
+ <authors>
+ <author>
+ Me, Myself
+ <author>
+ I
+ <authors>
+ <author>
+ Pac;Man\\
+ <author>
+ Ms. PacMan
+ <author>
+ PacMan, Jr.
+ <authors>
+ <author>
+ Here
+ <author>
+ There
+ <author>
+ <emphasis>
+ Everywhere
+ <authors>
+ <author>
+ First\\
+ <author>
+ Second
+ <author>
+ Third
+"""],
["""\
:Authors:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-11-08 11:25:13
|
Revision: 8202
http://sourceforge.net/p/docutils/code/8202
Author: milde
Date: 2017-11-08 11:25:10 +0000 (Wed, 08 Nov 2017)
Log Message:
-----------
Minor documentation update: smartquotes is still experimental.
Modified Paths:
--------------
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/utils/smartquotes.py
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2017-11-08 11:24:23 UTC (rev 8201)
+++ trunk/docutils/docs/user/config.txt 2017-11-08 11:25:10 UTC (rev 8202)
@@ -678,7 +678,7 @@
smart_quotes
~~~~~~~~~~~~
-Activate the SmartQuotes_ transform to
+Activate the experimental SmartQuotes_ transform to
change straight quotation marks to typographic form. `Quote characters`_
are selected according to the language of the current block element (see
language_code_, smartquotes_locales_, and the `pre-defined quote sets`__).
Modified: trunk/docutils/docutils/utils/smartquotes.py
===================================================================
--- trunk/docutils/docutils/utils/smartquotes.py 2017-11-08 11:24:23 UTC (rev 8201)
+++ trunk/docutils/docutils/utils/smartquotes.py 2017-11-08 11:25:10 UTC (rev 8202)
@@ -404,11 +404,7 @@
# [9] Typografisk håndbok. Oslo: Spartacus. 2000. s. 67. ISBN 8243001530.
# [10] http://www.typografi.org/sitat/sitatart.html
#
- # TODO: configuration option, e.g.::
- #
- # smartquote-locales: nl: „“’’, # apostrophe for ``'s Gravenhage``
- # nr: se, # alias
- # fr: « : »:‹ : ›, # :-separated list with NBSPs
+ # See also configuration option "smartquote-locales".
quotes = {'af': u'“”‘’',
'af-x-altquot': u'„”‚’',
'bg': u'„“‚‘', # Bulgarian, https://bg.wikipedia.org/wiki/Кавички
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2017-12-18 14:25:10
|
Revision: 8206
http://sourceforge.net/p/docutils/code/8206
Author: milde
Date: 2017-12-18 14:25:07 +0000 (Mon, 18 Dec 2017)
Log Message:
-----------
Add tagname to "illegal element" substitution definition error message.
Be a bit more verbose when detecting nodes that are disallowed inside
substitution definitions.
Modified Paths:
--------------
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace.py
trunk/docutils/test/test_parsers/test_rst/test_substitutions.py
trunk/docutils/test/test_transforms/test_hyperlinks.py
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2017-11-27 11:07:28 UTC (rev 8205)
+++ trunk/docutils/docutils/parsers/rst/states.py 2017-12-18 14:25:07 UTC (rev 8206)
@@ -2065,7 +2065,8 @@
if self.disallowed_inside_substitution_definitions(node):
pformat = nodes.literal_block('', node.pformat().rstrip())
msg = self.reporter.error(
- 'Substitution definition contains illegal element:',
+ 'Substitution definition contains illegal element <%s>:'
+ % node.tagname,
pformat, nodes.literal_block(blocktext, blocktext),
source=src, line=srcline)
return [msg], blank_finish
@@ -2083,9 +2084,9 @@
if (node['ids'] or
isinstance(node, nodes.reference) and node.get('anonymous') or
isinstance(node, nodes.footnote_reference) and node.get('auto')):
- return 1
+ return True
else:
- return 0
+ return False
def directive(self, match, **option_presets):
"""Returns a 2-tuple: list of nodes, and a "blank finish" boolean."""
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace.py 2017-11-27 11:07:28 UTC (rev 8205)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace.py 2017-12-18 14:25:07 UTC (rev 8206)
@@ -109,7 +109,7 @@
Inline literal start-string without end-string.
<system_message level="3" line="1" source="test data" type="ERROR">
<paragraph>
- Substitution definition contains illegal element:
+ Substitution definition contains illegal element <problematic>:
<literal_block xml:space="preserve">
<problematic ids="id2" refid="id1">
*
Modified: trunk/docutils/test/test_parsers/test_rst/test_substitutions.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_substitutions.py 2017-11-27 11:07:28 UTC (rev 8205)
+++ trunk/docutils/test/test_parsers/test_rst/test_substitutions.py 2017-12-18 14:25:07 UTC (rev 8206)
@@ -266,7 +266,7 @@
Elements that are prohibited inside of substitution definitions:
<system_message level="3" line="3" source="test data" type="ERROR">
<paragraph>
- Substitution definition contains illegal element:
+ Substitution definition contains illegal element <target>:
<literal_block xml:space="preserve">
<target ids="target" names="target">
target
@@ -274,7 +274,7 @@
.. |target| replace:: _`target`
<system_message level="3" line="4" source="test data" type="ERROR">
<paragraph>
- Substitution definition contains illegal element:
+ Substitution definition contains illegal element <reference>:
<literal_block xml:space="preserve">
<reference anonymous="1" name="anonymous">
anonymous
@@ -282,7 +282,7 @@
.. |reference| replace:: anonymous__
<system_message level="3" line="5" source="test data" type="ERROR">
<paragraph>
- Substitution definition contains illegal element:
+ Substitution definition contains illegal element <footnote_reference>:
<literal_block xml:space="preserve">
<footnote_reference auto="1" ids="id1">
<literal_block xml:space="preserve">
Modified: trunk/docutils/test/test_transforms/test_hyperlinks.py
===================================================================
--- trunk/docutils/test/test_transforms/test_hyperlinks.py 2017-11-27 11:07:28 UTC (rev 8205)
+++ trunk/docutils/test/test_transforms/test_hyperlinks.py 2017-12-18 14:25:07 UTC (rev 8206)
@@ -297,7 +297,7 @@
match in this snippet.
<system_message level="3" line="5" source="test data" type="ERROR">
<paragraph>
- Substitution definition contains illegal element:
+ Substitution definition contains illegal element <reference>:
<literal_block xml:space="preserve">
<reference anonymous="1" name="anonymous">
anonymous
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|