|
From: <aa-...@us...> - 2022-11-03 16:11:44
|
Revision: 9208
http://sourceforge.net/p/docutils/code/9208
Author: aa-turner
Date: 2022-11-03 16:11:41 +0000 (Thu, 03 Nov 2022)
Log Message:
-----------
Use the built-in ``open`` instead of ``FileInput``
This simplifies logic to use the standard ``open`` function, and
simultaneously refactors usages to the context manager protocol
for more explicit resource management
Modified Paths:
--------------
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/test_dependencies.py
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-11-03 11:15:40 UTC (rev 9207)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-11-03 16:11:41 UTC (rev 9208)
@@ -70,17 +70,21 @@
tab_width = self.options.get(
'tab-width', self.state.document.settings.tab_width)
try:
- include_file = io.FileInput(source_path=path,
- encoding=encoding,
- error_handler=e_handler)
+ with open(path,
+ encoding=encoding,
+ errors=e_handler) as include_file:
+ rawtext = include_file.read()
except UnicodeEncodeError:
- raise self.severe('Problems with "%s" directive path:\n'
- 'Cannot encode input file path "%s" '
- '(wrong locale?).' %
- (self.name, path))
+ raise self.severe(f'Problems with "{self.name}" directive path:\n'
+ f'Cannot encode input file path "{path}" '
+ f'(wrong locale?).')
except OSError as error:
- raise self.severe('Problems with "%s" directive path:\n%s.' %
- (self.name, io.error_string(error)))
+ error = io.InputError(error.errno, error.strerror, path)
+ raise self.severe(f'Problems with "{self.name}" directive '
+ f'path:\n{io.error_string(error)}.')
+ except UnicodeError as error:
+ raise self.severe(f'Problem with "{self.name}" directive:\n'
+ + io.error_string(error))
else:
self.state.document.settings.record_dependencies.add(path)
@@ -87,15 +91,9 @@
# Get to-be-included content
startline = self.options.get('start-line', None)
endline = self.options.get('end-line', None)
- try:
- if startline or (endline is not None):
- lines = include_file.readlines()
- rawtext = ''.join(lines[startline:endline])
- else:
- rawtext = include_file.read()
- except UnicodeError as error:
- raise self.severe('Problem with "%s" directive:\n%s' %
- (self.name, io.error_string(error)))
+ if startline or (endline is not None):
+ lines = rawtext.splitlines(keepends=True)
+ rawtext = ''.join(lines[startline:endline])
# start-after/end-before: no restrictions on newlines in match-text,
# and no restrictions on matching inside lines vs. line boundaries
after_text = self.options.get('start-after', None)
@@ -250,21 +248,21 @@
self.options['file']))
path = utils.relative_path(None, path)
try:
- raw_file = io.FileInput(source_path=path,
- encoding=encoding,
- error_handler=e_handler)
+ with open(path,
+ encoding=encoding,
+ errors=e_handler) as raw_file:
+ text = raw_file.read()
except OSError as error:
- raise self.severe('Problems with "%s" directive path:\n%s.'
- % (self.name, io.error_string(error)))
+ error = io.InputError(error.errno, error.strerror, path)
+ raise self.severe(f'Problems with "{self.name}" directive '
+ f'path:\n{io.error_string(error)}.')
+ except UnicodeError as error:
+ raise self.severe(f'Problem with "{self.name}" directive:\n'
+ + io.error_string(error))
else:
# TODO: currently, raw input files are recorded as
# dependencies even if not used for the chosen output format.
self.state.document.settings.record_dependencies.add(path)
- try:
- text = raw_file.read()
- except UnicodeError as error:
- raise self.severe('Problem with "%s" directive:\n%s'
- % (self.name, io.error_string(error)))
attributes['source'] = path
elif 'url' in self.options:
source = self.options['url']
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2022-11-03 11:15:40 UTC (rev 9207)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2022-11-03 16:11:41 UTC (rev 9208)
@@ -316,10 +316,10 @@
self.options['file']))
source = utils.relative_path(None, source)
try:
- csv_file = io.FileInput(source_path=source,
- encoding=encoding,
- error_handler=error_handler)
- csv_data = csv_file.read().splitlines()
+ with open(source,
+ encoding=encoding,
+ errors=error_handler) as csv_file:
+ csv_data = csv_file.read().splitlines()
except OSError as error:
severe = self.reporter.severe(
'Problems with "%s" directive path:\n%s.'
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-11-03 11:15:40 UTC (rev 9207)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-11-03 16:11:41 UTC (rev 9208)
@@ -393,8 +393,8 @@
adjust_path = bool(self.settings.stylesheet_path)
if self.settings.embed_stylesheet:
try:
- content = docutils.io.FileInput(source_path=path,
- encoding='utf-8').read()
+ with open(path, encoding='utf-8') as f:
+ content = f.read()
except OSError as err:
msg = f'Cannot embed stylesheet: {err}'
self.document.reporter.error(msg)
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-11-03 11:15:40 UTC (rev 9207)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-11-03 16:11:41 UTC (rev 9208)
@@ -23,7 +23,6 @@
except ImportError:
import docutils.utils.roman as roman
-import docutils
from docutils import frontend, nodes, languages, writers, utils
from docutils.transforms import writer_aux
from docutils.utils.math import pick_math_environment, unichar2tex
@@ -1404,8 +1403,8 @@
if is_package:
path = base + '.sty' # ensure extension
try:
- content = docutils.io.FileInput(source_path=path,
- encoding='utf-8').read()
+ with open(path, encoding='utf-8') as f:
+ content = f.read()
except OSError as err:
msg = f'Cannot embed stylesheet:\n {err}'
self.document.reporter.error(msg)
Modified: trunk/docutils/test/test_dependencies.py
===================================================================
--- trunk/docutils/test/test_dependencies.py 2022-11-03 11:15:40 UTC (rev 9207)
+++ trunk/docutils/test/test_dependencies.py 2022-11-03 16:11:41 UTC (rev 9208)
@@ -46,9 +46,8 @@
**settings)
recorder.close()
# Read the record file:
- record = docutils.io.FileInput(source_path=recordfile,
- encoding='utf-8')
- return record.read().splitlines()
+ with open(recordfile, encoding='utf-8') as record:
+ return record.read().splitlines()
def test_dependencies_xml(self):
# Note: currently, raw input files are read (and hence recorded) while
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-04 10:54:54
|
Revision: 9212
http://sourceforge.net/p/docutils/code/9212
Author: milde
Date: 2022-11-04 10:54:51 +0000 (Fri, 04 Nov 2022)
Log Message:
-----------
Update HISTORY, format COPYING.
Modified Paths:
--------------
trunk/docutils/COPYING.txt
trunk/docutils/HISTORY.txt
Modified: trunk/docutils/COPYING.txt
===================================================================
--- trunk/docutils/COPYING.txt 2022-11-03 16:54:05 UTC (rev 9211)
+++ trunk/docutils/COPYING.txt 2022-11-04 10:54:51 UTC (rev 9212)
@@ -11,7 +11,7 @@
Most of the files included in this project have been placed in the
public domain, and therefore have no license requirements and no
restrictions on copying or usage; see the `Public Domain Dedication`_
-below. There are a few exceptions_, listed below.
+below. There are exceptions_, listed below.
Files in the Sandbox_ are not distributed with Docutils releases and
may have different license terms.
@@ -87,8 +87,8 @@
Released under the terms of the `BSD 2-Clause License`_
(`local copy <licenses/BSD-2-Clause.txt>`__).
-* docutils/utils/math/math2html.py,
- docutils/writers/html5_polyglot/math.css
+* | docutils/utils/math/math2html.py,
+ | docutils/writers/html5_polyglot/math.css
Copyright © 2009,2010 Alex Fernández; 2021 Günter Milde
@@ -99,28 +99,28 @@
.. _eLyXer: https://github.com/alexfernandez/elyxer
-* docutils/__main__.py,
- docutils/parsers/commonmark_wrapper.py,
- docutils/parsers/recommonmark_wrapper.py,
- docutils/utils/error_reporting.py,
- docutils/utils/math/__init__.py,
- docutils/utils/math/latex2mathml.py,
- docutils/utils/math/tex2mathml_extern.py,
- docutils/utils/punctuation_chars.py,
- docutils/utils/smartquotes.py,
- docutils/writers/html5_polyglot/__init__.py,
- docutils/writers/html5_polyglot/*.css,
- docutils/writers/latex2e/docutils.sty,
- docutils/writers/xetex/__init__.py,
- test/test_parsers/test_recommonmark/\*.py,
- test/test_parsers/test_rst/test_directives/test__init__.py,
- test/test_parsers/test_rst/test_directives/test_code_parsing.py,
- test/test_parsers/test_rst/test_line_length_limit_default.py,
- test/test_parsers/test_rst/test_line_length_limit.py,
- test/test_writers/test_latex2e_misc.py,
- test/transforms/test_smartquotes.py,
- tools/docutils-cli.py,
- tools/rst2html5.py
+* | docutils/__main__.py,
+ | docutils/parsers/commonmark_wrapper.py,
+ | docutils/parsers/recommonmark_wrapper.py,
+ | docutils/utils/error_reporting.py,
+ | docutils/utils/math/__init__.py,
+ | docutils/utils/math/latex2mathml.py,
+ | docutils/utils/math/tex2mathml_extern.py,
+ | docutils/utils/punctuation_chars.py,
+ | docutils/utils/smartquotes.py,
+ | docutils/writers/html5_polyglot/__init__.py,
+ | docutils/writers/html5_polyglot/\*.css,
+ | docutils/writers/latex2e/docutils.sty,
+ | docutils/writers/xetex/__init__.py,
+ | test/test_parsers/test_recommonmark/\*.py,
+ | test/test_parsers/test_rst/test_directives/test__init__.py,
+ | test/test_parsers/test_rst/test_directives/test_code_parsing.py,
+ | test/test_parsers/test_rst/test_line_length_limit_default.py,
+ | test/test_parsers/test_rst/test_line_length_limit.py,
+ | test/test_writers/test_latex2e_misc.py,
+ | test/transforms/test_smartquotes.py,
+ | tools/docutils-cli.py,
+ | tools/rst2html5.py
Copyright © Günter Milde.
Released under the terms of the `BSD 2-Clause License`_
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-03 16:54:05 UTC (rev 9211)
+++ trunk/docutils/HISTORY.txt 2022-11-04 10:54:51 UTC (rev 9212)
@@ -47,12 +47,21 @@
- Support Ukrainian. Patch by Dmytro Kazanzhy.
-* Removed test/coverage.sh, use the coverage.py_ project instead,
+* docutils/nodes.py
+
+ - Fix previous_sibling() method that led to invalid HTML in some cases
+ (cf. patch #195).
+
+
+* test/coverage.sh
+
+ Removed. Use the coverage.py_ project instead,
``coverage run test/alltests.py`` and ``coverage report``.
Patch by Adam Turner.
-.. _coverage.py: https://pypi.org/project/coverage/
+ .. _coverage.py: https://pypi.org/project/coverage/
+
Release 0.19 (2022-07-05)
=========================
@@ -79,7 +88,7 @@
- New function `error_string()`
obsoletes `utils.error_reporting.ErrorString`.
- Class `ErrorOutput` moved here from `utils/error_reporting`.
- - Use "utf-8-sig" instead of Python's default encoding if the
+ - Use "utf-8-sig" instead of Python's default encoding if the
"input_encoding" setting is None.
- Fix error when reading of UTF-16 encoded source without trailing newline.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-04 10:55:08
|
Revision: 9213
http://sourceforge.net/p/docutils/code/9213
Author: milde
Date: 2022-11-04 10:55:05 +0000 (Fri, 04 Nov 2022)
Log Message:
-----------
MathML: support "mod" notation for modulo operation/arithmetic.
TeX to HTML/css support still missing, cf. [feature-requests:#93].
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/ref/rst/mathematics.txt
trunk/docutils/docutils/utils/math/latex2mathml.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-04 10:54:51 UTC (rev 9212)
+++ trunk/docutils/HISTORY.txt 2022-11-04 10:55:05 UTC (rev 9213)
@@ -52,7 +52,10 @@
- Fix previous_sibling() method that led to invalid HTML in some cases
(cf. patch #195).
+* docutils/utils/math/latex2mathml.py
+ - Support "mod" notation for modulo operation/modulus arithmetic.
+
* test/coverage.sh
Removed. Use the coverage.py_ project instead,
Modified: trunk/docutils/docs/ref/rst/mathematics.txt
===================================================================
--- trunk/docutils/docs/ref/rst/mathematics.txt 2022-11-04 10:54:51 UTC (rev 9212)
+++ trunk/docutils/docs/ref/rst/mathematics.txt 2022-11-04 10:55:05 UTC (rev 9213)
@@ -10,7 +10,7 @@
:abstract: Docutils supports mathematical content with a `"math"
directive`__ and `role`__. The input format is *LaTeX math
- syntax*\ [#math-syntax]_ with support for Unicode symbols.
+ syntax*\ [#math-syntax]_ with support for literal Unicode symbols.
.. sectnum::
.. contents::
@@ -313,6 +313,7 @@
`\mho` ``\mho`` `\eth` ``\eth`` `\Bbbk` ``\Bbbk``
============= =============== ========== ============ ========== ============ =========== =============
+
Mathematical Alphabets
----------------------
@@ -414,6 +415,7 @@
.. [#] Punctuation (not ratio):
Compare spacing in `a\colon b\to c` to `a:b = c`.
+
Relation symbols
----------------
@@ -534,6 +536,7 @@
and ``\varsupsetneqq`` are not supported by LateX2MathML, as there is no
corresponding Unicode character.
+
Variable-sized operators
------------------------
.. class:: colwidths-auto
@@ -552,6 +555,7 @@
\int_0^1f(x)\,dx \qquad
\prod_{i=1}^{10} b_i \ldots
+
Notations
=========
@@ -560,6 +564,7 @@
See `Accents and embellishments`_.
+
Extensible arrows
-----------------
@@ -574,6 +579,7 @@
.. math:: A \xleftarrow{n+\mu-1} B \xrightarrow[T]{n\pm i-1} C
+
Affixing symbols to other symbols
---------------------------------
@@ -620,6 +626,7 @@
\phantom{-}1 & x>0
\end{cases}
+
Spacing commands
----------------
@@ -659,6 +666,31 @@
width or height of the argument. They are not supported with `math_output`_
MathML.
+
+Modular arithmetic and modulo operation
+---------------------------------------
+
+The commands ``\bmod``, ``\pmod``, ``\mod``, and ``\pod`` deal with the
+special spacing conventions of the “mod” notation. [#]_
+
+.. class:: colwidths-auto
+
+ ========= =========================== =========================
+ command example result
+ ========= =========================== =========================
+ ``\bmod`` ``\gcd(n,m \bmod n)`` `\gcd(n,m \bmod n)`
+ ``\pmod`` ``x\equiv y \pmod b`` `x\equiv y \pmod b`
+ ``\mod`` ``x\equiv y \mod c`` `x\equiv y \mod c`
+ ``\pod`` ``x\equiv y \pod d`` `x\equiv y \pod d`
+ .. ``\operatorname{mod}(m,n)`` `\operatorname{mod}(m,n)`
+ ========= =========================== =========================
+
+.. [#] Currently `not supported`__ by the "HTML" math_output_ option
+ of the HTML writer.
+
+__ https://sourceforge.net/p/docutils/feature-requests/93/
+
+
Roots
-----
@@ -672,6 +704,7 @@
.. ``\sqrt\frac{1}{2}`` `\sqrt\frac{1}{2}`
========= ==================== ==================
+
Boxed formulas
--------------
@@ -680,7 +713,6 @@
.. math:: \boxed{\eta \leq C(\delta(\eta) +\Lambda_M(0,\delta))}
-
Fractions and related constructions
===================================
@@ -782,6 +814,7 @@
`\left(\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}\right)`
vs. `\Bigl(\begin{smallmatrix} a & b \\ c & d \end{smallmatrix}\Bigr)`.
+
Text
====
@@ -803,25 +836,7 @@
.. TODO ignore {}, handle text-mode commands
-
-``\mod`` and its relatives
---------------------------
-Commands ``\mod``, ``\bmod``, ``\pmod``, ``\pod`` deal with the special
-spacing conventions of “mod” notation.
-``\mod`` and ``\pod`` are variants of ``\pmod`` preferred by some
-authors; ``\mod`` omits the parentheses, whereas ``\pod`` omits the
-“mod” and retains the parentheses.
-
-TODO:
- Currently not supported by the "HTML" and "MathML" math_output_
- options of the HTML writer (cf. `feature-request #93
- <https://sourceforge.net/p/docutils/feature-requests/93/>`__).
-
-.. \gcd(n,m\bmod n) ;\quad x\equiv y\pmod b
- ;\quad x\equiv y\mod c ;\quad x\equiv y\pod d
-
-
Integrals and sums
==================
@@ -834,6 +849,7 @@
move to index positions: `\lim_{n\to\infty} \sum_1^n \frac{1}{n}`.
+
Altering the placement of limits
--------------------------------
@@ -903,7 +919,6 @@
Tests
-----
-
Font changes
~~~~~~~~~~~~
@@ -959,6 +974,7 @@
.. math:: \text{das ist ein {toller} text (unescaped \{ and \} is
ignored by LaTeX)}
+
Big delimiters and symbols
~~~~~~~~~~~~~~~~~~~~~~~~~~
Compare automatic sizing with fixed sizes:
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2022-11-04 10:54:51 UTC (rev 9212)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2022-11-04 10:55:05 UTC (rev 9213)
@@ -73,7 +73,16 @@
# Function with limits: 'lim', 'sup', 'inf', 'max', 'min':
# use <mo> to allow "movablelimits" attribute (see below).
+# modulo operator/arithmetic
+modulo_functions = {
+ # cmdname: (binary, named, parentheses, padding)
+ 'bmod': (True, True, False, '0.278em'), # a mod n
+ 'pmod': (False, True, True, '0.444em'), # a (mod n)
+ 'mod': (False, True, False, '0.667em'), # a mod n
+ 'pod': (False, False, True, '0.444em'), # a (n)
+ }
+
# math font selection -> <mi mathvariant=...> or <mstyle mathvariant=...>
math_alphabets = {
# 'cmdname': 'mathvariant value' # package
@@ -433,6 +442,16 @@
xml.extend(['\n', ' ' * level])
return xml
+ def is_block(self):
+ """Return true, if `self` or a parent has ``display='block'``."""
+ try:
+ return self['display'] == 'block'
+ except KeyError:
+ try:
+ return self.parent.is_block()
+ except AttributeError:
+ return False
+
# >>> n2 = math(mn(2))
# >>> n2
# math(mn(2))
@@ -442,13 +461,23 @@
# 1
# >>> eq3 = math(id='eq3', display='block')
# >>> eq3
-# math(display='block', id='eq3')
+# math(id='eq3', display='block')
# >>> eq3.toprettyxml()
-# '<math display="block" id="eq3">\n</math>'
+# '<math id="eq3" display="block">\n</math>'
# >>> len(eq3)
# 0
# >>> math(CLASS='bold').xml_starttag()
# '<math class="bold">'
+# >>> n2.is_block()
+# False
+# >>> node = n2.append(mrow())
+# >>> node.is_block()
+# False
+# >>> eq3.is_block()
+# True
+# >>> node = eq3.append(mrow())
+# >>> node.is_block()
+# True
class mtable(math): pass
@@ -945,6 +974,26 @@
node = node.append(mo('\u2061')) # ⁡
return node, string
+ if name in modulo_functions:
+ (binary, named, parentheses, padding) = modulo_functions[name]
+ if binary:
+ node = node.append(mo('mod', lspace=padding, rspace=padding))
+ return node, string
+ # left padding
+ if node.is_block():
+ padding = '1em'
+ node = node.append(mspace(width=padding))
+ if parentheses:
+ node = node.append(mo('(', stretchy=False))
+ if named:
+ node = node.append(mi('mod'))
+ node = node.append(mspace(width='0.333em'))
+ arg, string = tex_token_or_group(string)
+ node = parse_latex_math(node, arg)
+ if parentheses:
+ node = node.append(mo(')', stretchy=False))
+ return node, string
+
if name in math_alphabets:
if name == 'boldsymbol':
attributes = {'class': 'boldsymbol'}
@@ -1212,7 +1261,7 @@
# >>> handle_cmd('mathrm', math(), '{out} = 3')
# (math(mi('out', mathvariant='normal')), ' = 3')
# >>> handle_cmd('overline', math(), '{981}')
-# (mover(mo('¯', accent=True), switch=True, accent=False), '{981}')
+# (mover(mo('_', accent=True), switch=True, accent=False), '{981}')
# >>> handle_cmd('bar', math(), '{x}')
# (mover(mo('ˉ', stretchy=False), switch=True), '{x}')
# >>> handle_cmd('xleftarrow', math(), r'[\alpha]{10}')
@@ -1366,7 +1415,7 @@
# </math>
# >>> print(tex2mathml(r'a & b \\ c & d', inline=False))
# <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
-# <mtable class="align" columnalign="right left" columnspacing="0" displaystyle="true">
+# <mtable class="align" displaystyle="true" columnalign="right left" columnspacing="0">
# <mtr>
# <mtd>
# <mi>a</mi>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-04 11:16:40
|
Revision: 9216
http://sourceforge.net/p/docutils/code/9216
Author: milde
Date: 2022-11-04 11:16:36 +0000 (Fri, 04 Nov 2022)
Log Message:
-----------
Support `pandoc` as an external LaTeX to MathML converter.
Patch by Ximin Luo [patches:#197].
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/utils/math/tex2mathml_extern.py
trunk/docutils/docutils/writers/_html_base.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-04 10:55:26 UTC (rev 9215)
+++ trunk/docutils/HISTORY.txt 2022-11-04 11:16:36 UTC (rev 9216)
@@ -56,6 +56,10 @@
- Support "mod" notation for modulo operation/modulus arithmetic.
+* docutils/docutils/utils/math/tex2mathml_extern.py
+
+ - Support `pandoc` as LaTeX to MathML converter. Patch by Ximin Luo.
+
* test/coverage.sh
Removed. Use the coverage.py_ project instead,
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2022-11-04 10:55:26 UTC (rev 9215)
+++ trunk/docutils/docs/user/config.txt 2022-11-04 11:16:36 UTC (rev 9216)
@@ -1147,6 +1147,9 @@
TtM_
No "matrix", "align" and "cases" environments. Support may be removed.
+ Pandoc_
+ Comprehensive macro support, fast, but a large install size. (Haskell)
+
:LaTeX:
Include literal LaTeX code.
@@ -1163,6 +1166,7 @@
.. _blahtexml: http://gva.noekeon.org/blahtexml/
.. _LaTeXML: http://dlmf.nist.gov/LaTeXML/
.. _TtM: http://hutchinson.belmont.ma.us/tth/mml/
+.. _Pandoc: https://pandoc.org/
.. _stylesheet [html writers]:
Modified: trunk/docutils/docutils/utils/math/tex2mathml_extern.py
===================================================================
--- trunk/docutils/docutils/utils/math/tex2mathml_extern.py 2022-11-04 10:55:26 UTC (rev 9215)
+++ trunk/docutils/docutils/utils/math/tex2mathml_extern.py 2022-11-04 11:16:36 UTC (rev 9216)
@@ -19,6 +19,7 @@
import subprocess
document_template = r"""\documentclass{article}
+\usepackage{amsmath}
\begin{document}
%s
\end{document}
@@ -89,7 +90,7 @@
close_fds=True)
p.stdin.write((document_template % math_code).encode('utf-8'))
p.stdin.close()
- result = p.stdout.read().decode('utf-8')
+ result = p.stdout.read()
err = p.stderr.read().decode('utf-8')
if err.find('**** Unknown') >= 0:
msg = '\n'.join(line for line in err.splitlines()
@@ -117,7 +118,7 @@
if inline:
mathmode_arg = ''
else:
- mathmode_arg = 'mode="display"'
+ mathmode_arg = ' display="block"'
options.append('--displaymath')
p = subprocess.Popen(['blahtexml']+options,
@@ -142,6 +143,38 @@
return result
+def pandoc(math_code, reporter=None):
+ """Convert LaTeX math code to MathML with pandoc_
+
+ .. _pandoc: https://pandoc.org/
+ """
+ p = subprocess.Popen(['pandoc',
+ '--mathml',
+ '--from=latex',
+ ],
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ close_fds=True)
+ p.stdin.write(math_code.encode('utf-8'))
+ p.stdin.close()
+ result = p.stdout.read().decode('utf-8')
+ err = p.stderr.read().decode('utf-8').strip()
+ x = p.wait()
+
+ if err:
+ if reporter:
+ reporter.error(err)
+ raise SyntaxError('\nError message from external converter pandoc:\n%s'
+ % err)
+ if x != 0:
+ raise SyntaxError('\nError code from external converter pandoc:\n%s'
+ % x)
+
+ start, end = result.find('<math'), result.find('</math>')+7
+ return result[start:end]
+
+
# self-test
if __name__ == "__main__":
@@ -150,3 +183,4 @@
# print(latexml('$'+example+'$'))
# print(ttm('$'+example.replace('\\mathbb{R}', '')+'$'))
print(blahtexml(example))
+ # print(pandoc('$'+example+'$'))
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-11-04 10:55:26 UTC (rev 9215)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-11-04 11:16:36 UTC (rev 9216)
@@ -1259,6 +1259,10 @@
math_code,
inline=(not math_env),
reporter=self.document.reporter)
+ elif converter == 'pandoc':
+ math_code = tex2mathml_extern.pandoc(
+ math_code,
+ reporter=self.document.reporter)
elif not converter:
math_code = latex2mathml.tex2mathml(
math_code, inline=(not math_env))
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-06 21:24:17
|
Revision: 9219
http://sourceforge.net/p/docutils/code/9219
Author: milde
Date: 2022-11-06 21:24:14 +0000 (Sun, 06 Nov 2022)
Log Message:
-----------
Simplify/fix LaTeX character encoding handling.
Do not call "inputenc" if the "output-encoding" setting is 'utf-8'.
(UTF-8 is the default encoding for LaTeX2e since 2018.)
Do not call "inputenc" if the "output-encoding" setting is 'unicode':
Docutils returns a `str` instance and does not know which encoding will
be used when the output is written to a file or passed to LaTeX.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
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/latex_leavevmode.tex
trunk/docutils/test/functional/expected/latex_literal_block.tex
trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.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/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/HISTORY.txt 2022-11-06 21:24:14 UTC (rev 9219)
@@ -14,10 +14,6 @@
Changes Since 0.19
==================
-* docutils/writers/manpage.py
-
- - Do not output empty "manual" in ``.TH``
-
* Declared support for Python 3.11 in setup.py and tox.ini.
Patch by Hugo van Kemenade.
@@ -52,11 +48,20 @@
- Fix previous_sibling() method that led to invalid HTML in some cases
(cf. patch #195).
+* docutils/writers/latex2e/__init__.py
+
+ - Do not insert ``\usepackage[utf8]{inputenc}`` into UTF-8 encoded
+ LaTeX sources. UTF-8 is the default encoding for LaTeX2e since 2018.
+
+* docutils/writers/manpage.py
+
+ - Do not output empty "manual" in ``.TH``
+
* docutils/utils/math/latex2mathml.py
- Support "mod" notation for modulo operation/modulus arithmetic.
-* docutils/docutils/utils/math/tex2mathml_extern.py
+* docutils/utils/math/tex2mathml_extern.py
- Support `pandoc` as LaTeX to MathML converter. Patch by Ximin Luo.
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/RELEASE-NOTES.txt 2022-11-06 21:24:14 UTC (rev 9219)
@@ -93,9 +93,6 @@
- Remove ``use_verbatim_when_possible`` setting
(use literal_block_env_: verbatim) in Docutils 2.0.
- - Do not insert ``\usepackage[utf8]{inputenc}`` into UTF-8 encoded
- LaTeX sources. UTF-8 is the default encoding for LaTeX2e since 2018.
-
* `xetex` writer:
- Settings in the [latex2e writer] `configuration file section`__
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-11-06 21:24:14 UTC (rev 9219)
@@ -1304,7 +1304,7 @@
# ~~~~~~~~~~~~~~~~
# Encodings:
# Docutils' output-encoding => TeX input encoding
- if self.latex_encoding != 'ascii':
+ if self.latex_encoding not in ('ascii', 'unicode', 'utf8'):
self.requirements['_inputenc'] = (r'\usepackage[%s]{inputenc}'
% self.latex_encoding)
# TeX font encoding
@@ -1459,15 +1459,13 @@
# 'iso-8859-7': '' # greek
# 'iso-8859-8': '' # hebrew
# 'iso-8859-10': '' # latin6, more complete iso-8859-4
- 'unicode': 'utf8', # TEMPORARY, remove in Docutils 0.21
}
- encoding = docutils_encoding.lower()
+ encoding = docutils_encoding.lower() # normalize case
+ encoding = encoding.split(':')[0] # strip the error handler
if encoding in tr:
return tr[encoding]
- # drop hyphen or low-line from "latin_1", "utf-8" and similar
- encoding = encoding.replace('_', '').replace('-', '')
- # strip the error handler
- return encoding.split(':')[0]
+ # drop HYPHEN or LOW LINE from "latin_1", "utf-8" and similar
+ return encoding.replace('_', '').replace('-', '')
def language_label(self, docutil_label):
return self.language_module.labels[docutil_label]
Modified: trunk/docutils/test/functional/expected/cyrillic.tex
===================================================================
--- trunk/docutils/test/functional/expected/cyrillic.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/cyrillic.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1,T2A]{fontenc}
-\usepackage[utf8]{inputenc}
\usepackage[english,russian]{babel}
\setcounter{secnumdepth}{0}
Modified: trunk/docutils/test/functional/expected/latex_babel.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_babel.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/latex_babel.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
\usepackage[basque,esperanto,estonian,galician,ngerman,english]{babel}
\AtBeginDocument{\shorthandoff{.<>}}
\deactivatetilden % restore ~ in Galician
Modified: trunk/docutils/test/functional/expected/latex_cornercases.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_cornercases.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/latex_cornercases.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{21D4}{\ensuremath{\Leftrightarrow}}
\DeclareUnicodeCharacter{2660}{\ensuremath{\spadesuit}}
\DeclareUnicodeCharacter{2663}{\ensuremath{\clubsuit}}
Modified: trunk/docutils/test/functional/expected/latex_docinfo.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_docinfo.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/latex_docinfo.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
%%% Custom LaTeX preamble
% PDF Standard Fonts
Modified: trunk/docutils/test/functional/expected/latex_leavevmode.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_leavevmode.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/latex_leavevmode.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
\usepackage{alltt}
\usepackage{amsmath}
\usepackage{float} % extended float configuration
Modified: trunk/docutils/test/functional/expected/latex_literal_block.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/latex_literal_block.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
\usepackage{alltt}
\usepackage{amsmath}
\usepackage{color}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/latex_literal_block_fancyvrb.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{color}
\usepackage{graphicx}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_listings.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_listings.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/latex_literal_block_listings.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{color}
\usepackage{graphicx}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatim.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{color}
\usepackage{graphicx}
Modified: trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/latex_literal_block_verbatimtab.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{color}
\usepackage{graphicx}
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
\usepackage{alltt}
\usepackage{amsmath}
\usepackage[british,french,ngerman,english]{babel}
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2022-11-06 21:24:14 UTC (rev 9219)
@@ -3,7 +3,6 @@
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
\usepackage{alltt}
\usepackage{amsmath}
\usepackage[british,french,ngerman,english]{babel}
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2022-11-06 21:23:35 UTC (rev 9218)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2022-11-06 21:24:14 UTC (rev 9219)
@@ -62,7 +62,6 @@
""",
requirements=r"""\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
""",
latex_preamble=r"""% PDF Standard Fonts
\usepackage{mathptmx} % Times
@@ -152,7 +151,6 @@
head_template.substitute(dict(parts,
requirements=r"""\usepackage{ifthen}
\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
\usepackage[spanish,english]{babel}
\AtBeginDocument{\shorthandoff{.<>}}
""")) + r"""
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-07 17:40:25
|
Revision: 9221
http://sourceforge.net/p/docutils/code/9221
Author: milde
Date: 2022-11-07 17:40:24 +0000 (Mon, 07 Nov 2022)
Log Message:
-----------
Update/clarify documentation/docstrings.
After dropping support for Python2, we can use the datatype named `bytes` and
`str` for encoded strings and Unicode strings respectively.
Use the "summary line + optional explanations" style
mandated in the "Docstring Conventions" (PEP 257).
Modified Paths:
--------------
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/core.py
trunk/docutils/docutils/io.py
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2022-11-07 11:00:43 UTC (rev 9220)
+++ trunk/docutils/docs/user/config.txt 2022-11-07 17:40:24 UTC (rev 9221)
@@ -417,6 +417,10 @@
The text encoding for output.
+The "output_encoding" setting may also affect the content of the output
+(e.g. an encoding declaration in HTML or XML or the representation of
+characters as LaTeX macro vs. literal character).
+
Default: "utf-8". Options: ``--output-encoding, -o``.
output_encoding_error_handler
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2022-11-07 11:00:43 UTC (rev 9220)
+++ trunk/docutils/docutils/core.py 2022-11-07 17:40:24 UTC (rev 9221)
@@ -428,19 +428,19 @@
settings_overrides=None, config_section=None,
enable_exit_status=False):
"""
- Set up & run a `Publisher` for programmatic use with string I/O. Return
- the encoded string or Unicode string output.
+ Set up & run a `Publisher` for programmatic use with string I/O.
- For encoded string output, be sure to set the 'output_encoding' setting to
- the desired encoding. Set it to 'unicode' for unencoded Unicode string
- output. Here's one way::
+ `source` and return value may be `bytes` or `str` objects.
+ For `bytes` output, set the "output_encoding" setting to the
+ desired encoding. For `str` output, set it to 'unicode', e.g.::
+
publish_string(..., settings_overrides={'output_encoding': 'unicode'})
- Similarly for Unicode string input (`source`)::
+ Beware that the "output_encoding" setting may also affect the content
+ of the output (e.g. an encoding declaration in HTML or XML or the
+ representation of characters as LaTeX macro vs. literal character).
- publish_string(..., settings_overrides={'input_encoding': 'unicode'})
-
Parameters: see `publish_programmatically`.
"""
warnings.warn('The return type of publish_string will change to '
@@ -506,15 +506,10 @@
enable_exit_status=False):
"""
Set up & run a `Publisher`, and return a dictionary of document parts.
+
Dictionary keys are the names of parts, and values are Unicode strings;
encoding is up to the client. For programmatic use with string I/O.
- For encoded string input, be sure to set the 'input_encoding' setting to
- the desired encoding. Set it to 'unicode' for unencoded Unicode string
- input. Here's how::
-
- publish_parts(..., settings_overrides={'input_encoding': 'unicode'})
-
Parameters: see `publish_programmatically`.
"""
output, pub = publish_programmatically(
@@ -539,15 +534,8 @@
settings_overrides=None, config_section=None,
enable_exit_status=False):
"""
- Set up & run a `Publisher` for programmatic use with string I/O.
- Return the document tree.
+ Set up & run a `Publisher` for programmatic use. Return a document tree.
- For encoded string input, be sure to set the 'input_encoding' setting to
- the desired encoding. Set it to 'unicode' for unencoded Unicode string
- input. Here's one way::
-
- publish_doctree(..., settings_overrides={'input_encoding': 'unicode'})
-
Parameters: see `publish_programmatically`.
"""
_output, pub = publish_programmatically(
@@ -651,9 +639,10 @@
settings_overrides, config_section,
enable_exit_status):
"""
- Set up & run a `Publisher` for custom programmatic use. Return the
- encoded string output and the Publisher object.
+ Set up & run a `Publisher` for custom programmatic use.
+ Return the output (as `str` or `bytes`) and the Publisher object.
+
Applications should not need to call this function directly. If it does
seem to be necessary to call this function directly, please write to the
Docutils-develop mailing list
@@ -671,10 +660,9 @@
(`source_path` is opened). If neither `source` nor
`source_path` are supplied, `sys.stdin` is used.
- - If `source_class` is `io.StringInput` **required**: The input
- string, either an encoded 8-bit string (set the
- 'input_encoding' setting to the correct encoding) or a Unicode
- string (set the 'input_encoding' setting to 'unicode').
+ - If `source_class` is `io.StringInput` **required**:
+ The input as either a `bytes` object (ensure the 'input_encoding'
+ setting matches its encoding) or a `str` object.
* `source_path`: Type depends on `source_class`:
@@ -681,8 +669,8 @@
- `io.FileInput`: Path to the input file, opened if no `source`
supplied.
- - `io.StringInput`: Optional. Path to the file or object that produced
- `source`. Only used for diagnostic output.
+ - `io.StringInput`: Optional. Path to the file or name of the
+ object that produced `source`. Only used for diagnostic output.
* `destination_class` **required**: The class for dynamically created
destination objects. Typically `io.FileOutput` or `io.StringOutput`.
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2022-11-07 11:00:43 UTC (rev 9220)
+++ trunk/docutils/docutils/io.py 2022-11-07 17:40:24 UTC (rev 9221)
@@ -576,15 +576,15 @@
class StringInput(Input):
+ """Input from a `str` or `bytes` instance."""
- """
- Direct string input.
- """
-
default_source_path = '<string>'
def read(self):
- """Decode and return the source string."""
+ """Return the source as `str` instance.
+
+ Decode, if required (see `Input.decode`).
+ """
return self.decode(self.source)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-10 15:02:21
|
Revision: 9235
http://sourceforge.net/p/docutils/code/9235
Author: milde
Date: 2022-11-10 15:02:17 +0000 (Thu, 10 Nov 2022)
Log Message:
-----------
Fix/complement publisher documentation and tests.
API documentation:
- Spell out ampersand (&) as "and".
- Finish description of part "pepnum".
- Add links to LaTeX templates.
- Remove trailing whitespace.
Docstrings:
- Clarify source and output data type for functions using
"string I/O" (with "string" in the general sense of "`str` or `bytes`").
- Recommend using publish_parts() to get Docutils output as `str`.
- Add "()" to functions so that pydoc HTML rendering generates auto-links.
- Add links to the HTML documentation.
Tests:
- Add test for input/output data types of publish_string().
Modified Paths:
--------------
trunk/docutils/docs/api/publisher.txt
trunk/docutils/docutils/core.py
trunk/docutils/test/test_publisher.py
Modified: trunk/docutils/docs/api/publisher.txt
===================================================================
--- trunk/docutils/docs/api/publisher.txt 2022-11-09 20:51:23 UTC (rev 9234)
+++ trunk/docutils/docs/api/publisher.txt 2022-11-10 15:02:17 UTC (rev 9235)
@@ -97,7 +97,7 @@
Encodings
---------
-The default input encoding is UTF-8.
+The default input encoding is UTF-8.
A different encoding can be specified with the `input_encoding`_ setting
or an `explicit encoding declaration` (BOM or special comment).
The locale encoding may be used as a fallback.
@@ -239,12 +239,12 @@
_`html_subtitle`
``parts['html_subtitle']`` contains the document subtitle,
- including the enclosing ``<h2 class="subtitle">`` & ``</h2>``
+ including the enclosing ``<h2 class="subtitle">`` and ``</h2>``
tags.
_`html_title`
``parts['html_title']`` contains the document title, including the
- enclosing ``<h1 class="title">`` & ``</h1>`` tags.
+ enclosing ``<h1 class="title">`` and ``</h1>`` tags.
_`meta`
``parts['meta']`` contains all ``<meta ... />`` tags.
@@ -255,12 +255,12 @@
_`subtitle`
``parts['subtitle']`` contains the document subtitle text and any
- inline markup. It does not include the enclosing ``<h2>`` &
+ inline markup. It does not include the enclosing ``<h2>`` and
``</h2>`` tags.
_`title`
``parts['title']`` contains the document title text and any inline
- markup. It does not include the enclosing ``<h1>`` & ``</h1>``
+ markup. It does not include the enclosing ``<h1>`` and ``</h1>``
tags.
@@ -271,9 +271,12 @@
plus the following:
_`pepnum`
- ``parts['pepnum']`` contains
+ ``parts['pepnum']`` contains the PEP number
+ (extracted from the `header preamble`__).
+ __ https://peps.python.org/pep-0001/#pep-header-preamble
+
S5/HTML Writer
``````````````
@@ -291,7 +294,8 @@
Parts Provided by the LaTeX2e Writer
------------------------------------
-See the template files for examples how these parts can be combined
+See the template files default.tex_, titlepage.tex_, titlingpage.tex_,
+and xelatex.tex_ for examples how these parts can be combined
into a valid LaTeX document.
abstract
@@ -356,7 +360,16 @@
titledata
``parts['titledata]`` contains the combined title data in
- ``\title``, ``\author``, and ``\data`` macros.
+ ``\title``, ``\author``, and ``\date`` macros.
With ``--use-latex-docinfo``, this includes the 'author',
'organization', 'contact', 'address' and 'date' docinfo items.
+
+.. _default.tex:
+ https://docutils.sourceforge.io/docutils/writers/latex2e/default.tex
+.. _titlepage.tex:
+ https://docutils.sourceforge.io/docutils/writers/latex2e/titlepage.tex
+.. _titlingpage.tex:
+ https://docutils.sourceforge.io/docutils/writers/latex2e/titlingpage.tex
+.. _xelatex.tex:
+ https://docutils.sourceforge.io/docutils/writers/latex2e/xelatex.tex
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2022-11-09 20:51:23 UTC (rev 9234)
+++ trunk/docutils/docutils/core.py 2022-11-10 15:02:17 UTC (rev 9235)
@@ -377,7 +377,7 @@
output file paths taken automatically from the command line). Return the
encoded string output also.
- Parameters: see `publish_programmatically` for the remainder.
+ Parameters: see `publish_programmatically()` for the remainder.
- `argv`: Command-line argument list to use instead of ``sys.argv[1:]``.
- `usage`: Usage string, output if there's a problem parsing the command
@@ -404,7 +404,7 @@
Set up & run a `Publisher` for programmatic use with file-like I/O.
Return the encoded string output also.
- Parameters: see `publish_programmatically`.
+ Parameters: see `publish_programmatically()`.
"""
output, pub = publish_programmatically(
source_class=io.FileInput, source=source, source_path=source_path,
@@ -430,18 +430,27 @@
"""
Set up & run a `Publisher` for programmatic use with string I/O.
- `source` and return value may be `bytes` or `str` objects.
+ Accepts a `bytes` or `str` instance as `source`.
+ The output is encoded according to the "output_encoding" setting;
+ the return value is a `bytes` instance (unless `output_encoding`_
+ is "unicode", see below).
- For `bytes` output, set the "output_encoding" setting to the
- desired encoding. For `str` output, set it to 'unicode', e.g.::
+ To get Docutils output as `str` instance, use `publish_parts()`::
- publish_string(..., settings_overrides={'output_encoding': 'unicode'})
+ output = publish_parts(...)['whole']
- Beware that the "output_encoding" setting may also affect the content
+ or set `output_encoding`_ to the pseudo encoding name "unicode", e.g.::
+
+ publish_string(..., settings_overrides={'output_encoding': 'unicode'})
+
+ Beware that the `output_encoding`_ setting may affect the content
of the output (e.g. an encoding declaration in HTML or XML or the
representation of characters as LaTeX macro vs. literal character).
- Parameters: see `publish_programmatically`.
+ Parameters: see `publish_programmatically()`.
+
+ .. _output_encoding:
+ https://docutils.sourceforge.io/docs/user/config.html#output-encoding
"""
warnings.warn('The return type of publish_string will change to '
'"str" from Docutils 0.21.', FutureWarning, stacklevel=2)
@@ -478,7 +487,7 @@
publish_bytes(..., settings_overrides={'input_encoding': 'latin1'})
- Parameters: see `publish_programmatically`.
+ Parameters: see `publish_programmatically()`.
Provisional.
"""
@@ -505,12 +514,20 @@
settings_overrides=None, config_section=None,
enable_exit_status=False):
"""
- Set up & run a `Publisher`, and return a dictionary of document parts.
+ Set up & run a `Publisher`, and return a dictionary of `document parts`_.
- Dictionary keys are the names of parts, and values are Unicode strings;
- encoding is up to the client. For programmatic use with string I/O.
+ Dictionary keys are the names of parts.
+ Dictionary values are `str` instances; encoding is up to the client,
+ e.g.::
- Parameters: see `publish_programmatically`.
+ parts = publish_parts(...)
+ body = parts['body'].encode(parts['encoding'])
+
+ Parameters: see `publish_programmatically()`.
+
+ .. _document parts:
+ https://docutils.sourceforge.io/docs/api/publisher.html
+ #publish-parts-details
"""
output, pub = publish_programmatically(
source=source, source_path=source_path, source_class=source_class,
@@ -536,7 +553,7 @@
"""
Set up & run a `Publisher` for programmatic use. Return a document tree.
- Parameters: see `publish_programmatically`.
+ Parameters: see `publish_programmatically()`.
"""
_output, pub = publish_programmatically(
source=source, source_path=source_path,
@@ -578,7 +595,7 @@
Parameters: `document` is a `docutils.nodes.document` object, an existing
document tree.
- Other parameters: see `publish_programmatically`.
+ Other parameters: see `publish_programmatically()`.
"""
reader = doctree.Reader(parser_name='null')
pub = Publisher(reader, None, writer,
@@ -613,7 +630,7 @@
This is just like publish_cmdline, except that it uses
io.BinaryFileOutput instead of io.FileOutput.
- Parameters: see `publish_programmatically` for the remainder.
+ Parameters: see `publish_programmatically()` for the remainder.
- `argv`: Command-line argument list to use instead of ``sys.argv[1:]``.
- `usage`: Usage string, output if there's a problem parsing the command
Modified: trunk/docutils/test/test_publisher.py
===================================================================
--- trunk/docutils/test/test_publisher.py 2022-11-09 20:51:23 UTC (rev 9234)
+++ trunk/docutils/test/test_publisher.py 2022-11-10 15:02:17 UTC (rev 9235)
@@ -70,7 +70,29 @@
core.publish_cmdline(argv=['data/include.txt', 'nonexisting/path'],
settings_overrides={'traceback': True})
+ def test_publish_string(self):
+ # Transparently decode `bytes` source (with "input_encoding" setting)
+ # default: auto-detect, fallback utf-8
+ # Output is encoded according to "output_encoding" setting.
+ settings = {'_disable_config': True,
+ 'datestamp': False}
+ source = 'test → me'
+ expected = ('<document source="<string>">\n'
+ ' <paragraph>\n'
+ ' test → me\n')
+ output = core.publish_string(source.encode('utf-16'),
+ settings_overrides=settings)
+ self.assertEqual(output.decode('utf-8'), expected)
+ # encoding declaration in source
+ source = '.. encoding: latin1\n\nGrüße'
+ # don't encode output (return `str`)
+ settings['output_encoding'] = 'unicode'
+ output = core.publish_string(source.encode('utf-16'),
+ settings_overrides=settings)
+ self.assertTrue(output.endswith('Grüße\n'))
+
+
class PublishDoctreeTestCase(unittest.TestCase, docutils.SettingsSpec):
settings_default_overrides = {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aa-...@us...> - 2022-11-10 16:54:47
|
Revision: 9237
http://sourceforge.net/p/docutils/code/9237
Author: aa-turner
Date: 2022-11-10 16:54:38 +0000 (Thu, 10 Nov 2022)
Log Message:
-----------
Add support for ``pytest``
This is the minimal configuration required for the test suite to
pass using the pytest framework. This is part of the test suite
refactoring project.
- Ignore two classes that start with the word "Test"
- Provide the standard test header to pytest
- Update the documentation
Modified Paths:
--------------
trunk/docutils/docs/dev/testing.txt
trunk/docutils/docutils/transforms/universal.py
trunk/docutils/test/test_transforms/test___init__.py
Added Paths:
-----------
trunk/docutils/test/conftest.py
Modified: trunk/docutils/docs/dev/testing.txt
===================================================================
--- trunk/docutils/docs/dev/testing.txt 2022-11-10 16:25:32 UTC (rev 9236)
+++ trunk/docutils/docs/dev/testing.txt 2022-11-10 16:54:38 UTC (rev 9237)
@@ -39,16 +39,16 @@
__ policies.html#check-ins
.. note::
- Due to incompatible customization of the standard unittest_
- framework, the test suite does not work with popular test frameworks
- like pytest_ or nose_.
+ The standard ``alltests.py`` test runner uses the standard library's
+ unittest_ framework.
+ For the pytest_ test framework, from a shell run::
+
+ pytest --quiet ./test
+
.. _unittest: https://docs.python.org/3/library/unittest.html
.. _pytest: https://pypi.org/project/pytest/
- .. _nose: https://pypi.org/project/nose3/
- .. cf. https://sourceforge.net/p/docutils/feature-requests/81/
-
.. [#] When using the `Python launcher for Windows`__, make sure to
specify a Python version, e.g., ``py -3.9 -u alltests.py`` for
Python 3.9.
Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py 2022-11-10 16:25:32 UTC (rev 9236)
+++ trunk/docutils/docutils/transforms/universal.py 2022-11-10 16:54:38 UTC (rev 9237)
@@ -172,6 +172,9 @@
Used for testing purposes.
"""
+ # marker for pytest to ignore this class during test discovery
+ __test__ = False
+
default_priority = 880
def apply(self):
Added: trunk/docutils/test/conftest.py
===================================================================
--- trunk/docutils/test/conftest.py (rev 0)
+++ trunk/docutils/test/conftest.py 2022-11-10 16:54:38 UTC (rev 9237)
@@ -0,0 +1,21 @@
+def pytest_report_header(config):
+ import os
+ import platform
+ import sys
+ import time
+
+ # DocutilsTestSupport must be imported before docutils
+ from . import DocutilsTestSupport # NoQA: F401
+ import docutils
+
+ return '\n'.join((
+ '',
+ f'Testing Docutils {docutils.__version__} '
+ f'with Python {sys.version.split()[0]} '
+ f'on {time.strftime("%Y-%m-%d at %H:%M:%S")}',
+ f'OS: {platform.system()} {platform.release()} {platform.version()} '
+ f'({sys.platform}, {platform.platform()})',
+ f'Working directory: {os.getcwd()}',
+ f'Docutils package: {os.path.dirname(docutils.__file__)}',
+ '',
+ ))
Modified: trunk/docutils/test/test_transforms/test___init__.py
===================================================================
--- trunk/docutils/test/test_transforms/test___init__.py 2022-11-10 16:25:32 UTC (rev 9236)
+++ trunk/docutils/test/test_transforms/test___init__.py 2022-11-10 16:54:38 UTC (rev 9237)
@@ -15,6 +15,9 @@
class TestTransform(transforms.Transform):
+ # marker for pytest to ignore this class during test discovery
+ __test__ = False
+
default_priority = 100
applied = 0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-11 12:27:03
|
Revision: 9238
http://sourceforge.net/p/docutils/code/9238
Author: milde
Date: 2022-11-11 12:27:01 +0000 (Fri, 11 Nov 2022)
Log Message:
-----------
Remove "fixltx2e.sty" package call from "titlepage.tex" LaTeX template.
This package is loaded by default since 2015.
The package call was removed from the other templates in Docutils 0.14.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/latex2e/titlepage.tex
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-10 16:54:38 UTC (rev 9237)
+++ trunk/docutils/HISTORY.txt 2022-11-11 12:27:01 UTC (rev 9238)
@@ -53,6 +53,11 @@
- Do not insert ``\usepackage[utf8]{inputenc}`` into UTF-8 encoded
LaTeX sources. UTF-8 is the default encoding for LaTeX2e since 2018.
+* docutils/writers/latex2e/titlepage.tex
+
+ - Drop "fixltx2e" package call from template. (Obsolete since 2015
+ and dropped from other templates since Docutils 0.14.)
+
* docutils/writers/manpage.py
- Do not output empty "manual" in ``.TH``
Modified: trunk/docutils/docutils/writers/latex2e/titlepage.tex
===================================================================
--- trunk/docutils/docutils/writers/latex2e/titlepage.tex 2022-11-10 16:54:38 UTC (rev 9237)
+++ trunk/docutils/docutils/writers/latex2e/titlepage.tex 2022-11-11 12:27:01 UTC (rev 9238)
@@ -1,6 +1,5 @@
% generated by Docutils <https://docutils.sourceforge.io/>
$head_prefix
-\usepackage{fixltx2e} % LaTeX patches, \textsubscript
\usepackage{cmap} % fix search and cut-and-paste in Acrobat
$requirements
%%% Custom LaTeX preamble
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-13 16:15:01
|
Revision: 9239
http://sourceforge.net/p/docutils/code/9239
Author: milde
Date: 2022-11-13 16:14:59 +0000 (Sun, 13 Nov 2022)
Log Message:
-----------
New function utils.xml_declaration()
Return XML text declaration.
Include an encoding declaration if the intended encoding is known.
Used in XML (and soon also in HTML) writer.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/test/test_utils.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-11 12:27:01 UTC (rev 9238)
+++ trunk/docutils/HISTORY.txt 2022-11-13 16:14:59 UTC (rev 9239)
@@ -48,6 +48,10 @@
- Fix previous_sibling() method that led to invalid HTML in some cases
(cf. patch #195).
+* docutils/docutils/utils/__init__.py
+
+ - New utility function `xml_declaration()`.
+
* docutils/writers/latex2e/__init__.py
- Do not insert ``\usepackage[utf8]{inputenc}`` into UTF-8 encoded
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2022-11-11 12:27:01 UTC (rev 9238)
+++ trunk/docutils/docutils/utils/__init__.py 2022-11-13 16:14:59 UTC (rev 9239)
@@ -711,6 +711,19 @@
return taglist
+def xml_declaration(encoding=None):
+ """Return an XML text declaration.
+
+ Include an encoding declaration, if `encoding`
+ is not 'unicode', '', or None.
+ """
+ if encoding and encoding.lower() != 'unicode':
+ encoding_declaration = f' encoding="{encoding}"'
+ else:
+ encoding_declaration = ''
+ return f'<?xml version="1.0"{encoding_declaration}?>\n'
+
+
class DependencyList:
"""
Modified: trunk/docutils/docutils/writers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/writers/docutils_xml.py 2022-11-11 12:27:01 UTC (rev 9238)
+++ trunk/docutils/docutils/writers/docutils_xml.py 2022-11-13 16:14:59 UTC (rev 9239)
@@ -14,7 +14,7 @@
import xml.sax.saxutils
import docutils
-from docutils import frontend, writers, nodes
+from docutils import frontend, nodes, writers, utils
class RawXmlError(docutils.ApplicationError):
@@ -64,7 +64,6 @@
class XMLTranslator(nodes.GenericNodeVisitor):
- xml_declaration = '<?xml version="1.0" encoding="%s"?>\n'
# TODO: add stylesheet options similar to HTML and LaTeX writers?
# xml_stylesheet = '<?xml-stylesheet type="text/xsl" href="%s"?>\n'
doctype = (
@@ -100,8 +99,7 @@
# Output
self.output = []
if settings.xml_declaration:
- self.output.append(
- self.xml_declaration % _encoding(settings))
+ self.output.append(utils.xml_declaration(settings.output_encoding))
if settings.doctype_declaration:
self.output.append(self.doctype)
self.output.append(self.generator % docutils.__version__)
@@ -186,10 +184,3 @@
def setDocumentLocator(self, locator):
self.locator = locator
-
-
-def _encoding(settings):
- """TEMPORARY, remove in Docutils 0.21"""
- if settings.output_encoding == 'unicode':
- return 'utf-8'
- return settings.output_encoding
Modified: trunk/docutils/test/test_utils.py
===================================================================
--- trunk/docutils/test/test_utils.py 2022-11-11 12:27:01 UTC (rev 9238)
+++ trunk/docutils/test/test_utils.py 2022-11-13 16:14:59 UTC (rev 9239)
@@ -269,6 +269,24 @@
['grc-ibycus-x-altquot', 'grc-ibycus',
'grc-x-altquot', 'grc'])
+ def test_xml_declaration(self):
+ # default is no encoding declaration
+ self.assertEqual(utils.xml_declaration(), '<?xml version="1.0"?>\n')
+ # if an encoding is passed, declare it
+ self.assertEqual(utils.xml_declaration('ISO-8859-2'),
+ '<?xml version="1.0" encoding="ISO-8859-2"?>\n')
+ # ignore pseudo encoding name "unicode" introduced by
+ # `docutils.io.Output.encode()`
+ self.assertEqual(utils.xml_declaration('Unicode'),
+ '<?xml version="1.0"?>\n')
+ # ... non-regarding case
+ self.assertEqual(utils.xml_declaration('UNICODE'),
+ '<?xml version="1.0"?>\n')
+ # allow %s for later interpolation
+ # (used for part 'html_prolog', cf. docs/api/publisher.html)
+ self.assertEqual(utils.xml_declaration('%s'),
+ '<?xml version="1.0" encoding="%s"?>\n')
+
def test_column_width(self):
self.assertEqual(utils.column_width('de'), 2)
self.assertEqual(utils.column_width('dâ'), 2) # pre-composed
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-13 16:15:27
|
Revision: 9240
http://sourceforge.net/p/docutils/code/9240
Author: milde
Date: 2022-11-13 16:15:23 +0000 (Sun, 13 Nov 2022)
Log Message:
-----------
Refactor HTMLTranslator initialization and parts setup.
Use utils.xml_declaration().
Don't write charset (encoding) declaration if the intended output encoding
is not known.
Copy "meta" part content into "head" in `depart_document()`
(i.e. after collecting all items).
Obsoletes auxiliary method `add_meta()`. Remove it.
Changes to the HTML output (no space character before closing tag of XML
declaration, order of metadata elements) don't affect the HTML semantics,
styling, and rendering.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/pep_html/template.txt
trunk/docutils/docutils/writers/s5_html/__init__.py
trunk/docutils/test/functional/expected/compact_lists.html
trunk/docutils/test/functional/expected/dangerous.html
trunk/docutils/test/functional/expected/embed_images_html5.html
trunk/docutils/test/functional/expected/field_name_limit.html
trunk/docutils/test/functional/expected/footnotes_html5.html
trunk/docutils/test/functional/expected/math_output_html.html
trunk/docutils/test/functional/expected/math_output_latex.html
trunk/docutils/test/functional/expected/math_output_mathjax.html
trunk/docutils/test/functional/expected/math_output_mathml.html
trunk/docutils/test/functional/expected/misc_rst_html4css1.html
trunk/docutils/test/functional/expected/misc_rst_html5.html
trunk/docutils/test/functional/expected/pep_html.html
trunk/docutils/test/functional/expected/rst_html5_tuftig.html
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_s5_html_1.html
trunk/docutils/test/functional/expected/standalone_rst_s5_html_2.html
trunk/docutils/test/test_writers/test_html4css1_parts.py
trunk/docutils/test/test_writers/test_html4css1_template.py
trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
trunk/docutils/test/test_writers/test_html5_template.py
trunk/docutils/test/test_writers/test_s5.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/HISTORY.txt 2022-11-13 16:15:23 UTC (rev 9240)
@@ -51,7 +51,16 @@
* docutils/docutils/utils/__init__.py
- New utility function `xml_declaration()`.
+
+* docutils/docutils/writers/_html_base.py
+ - Refactoring of HTMLTranslator initialization and collecting of
+ document "parts". Adapt HTML writers importing `_html_base`.
+
+ Changes to the HTML output (no space character before closing tag of
+ XML declaration, order of metadata elements)
+ don't affect the HTML semantics, styling, and rendering.
+
* docutils/writers/latex2e/__init__.py
- Do not insert ``\usepackage[utf8]{inputenc}`` into UTF-8 encoded
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-11-13 16:15:23 UTC (rev 9240)
@@ -233,7 +233,6 @@
This way, changes in stack use will not bite you.
"""
- xml_declaration = '<?xml version="1.0" encoding="%s" ?>\n'
doctype = '<!DOCTYPE html>\n'
doctype_mathml = doctype
@@ -240,8 +239,9 @@
head_prefix_template = ('<html xmlns="http://www.w3.org/1999/xhtml"'
' xml:lang="%(lang)s" lang="%(lang)s">\n<head>\n')
content_type = '<meta charset="%s" />\n'
- generator = ('<meta name="generator" content="Docutils %s: '
- 'https://docutils.sourceforge.io/" />\n')
+ generator = (
+ f'<meta name="generator" content="Docutils {docutils.__version__}: '
+ 'https://docutils.sourceforge.io/" />\n')
# Template for the MathJax script in the header:
mathjax_script = '<script type="text/javascript" src="%s"></script>\n'
@@ -278,32 +278,12 @@
def __init__(self, document):
nodes.NodeVisitor.__init__(self, document)
+ # process settings
self.settings = settings = document.settings
- lcode = settings.language_code
- self.language = languages.get_language(lcode, document.reporter)
- self.meta = [self.generator % docutils.__version__]
- self.head_prefix = []
- self.html_prolog = []
- if settings.xml_declaration:
- self.head_prefix.append(self.xml_declaration
- % _encoding(settings))
- # self.content_type = ""
- # encoding not interpolated:
- self.html_prolog.append(self.xml_declaration)
- self.head = self.meta[:]
- self.stylesheet = [self.stylesheet_call(path)
- for path in utils.get_stylesheet_list(settings)]
- self.body_prefix = ['</head>\n<body>\n']
- # document title, subtitle display
- self.body_pre_docinfo = []
- # author, date, etc.
- self.docinfo = []
- self.body = []
- self.fragment = []
- self.body_suffix = ['</body>\n</html>\n']
- self.section_level = 0
+ self.language = languages.get_language(
+ settings.language_code, document.reporter)
self.initial_header_level = int(settings.initial_header_level)
- # image_loading only defined for HTML5 writer
+ # image_loading (only defined for HTML5 writer)
self.image_loading = getattr(settings, 'image_loading', None)
# legacy setting embed_images:
if getattr(settings, 'embed_images', None) is True:
@@ -324,12 +304,46 @@
self.math_output_options = self.math_output[1:]
self.math_output = self.math_output[0].lower()
+ # set up "parts" (cf. docs/api/publisher.html#publish-parts-details)
+ #
+ self.body = [] # equivalent to `fragment`, ≠ `html_body`
+ self.body_prefix = ['</head>\n<body>\n'] # + optional header
+ self.body_pre_docinfo = [] # document heading (title and subtitle)
+ self.body_suffix = ['</body>\n</html>\n'] # + optional footer
+ self.docinfo = []
+ self.footer = []
+ self.fragment = [] # main content of the document ("naked" body)
+ self.head = []
+ self.head_prefix = [] # everything up to and including <head>
+ self.header = []
+ self.html_body = []
+ self.html_head = [self.content_type] # charset not interpolated
+ self.html_prolog = []
+ self.html_subtitle = []
+ self.html_title = []
+ self.meta = [self.generator]
+ self.stylesheet = [self.stylesheet_call(path)
+ for path in utils.get_stylesheet_list(settings)]
+ self.title = []
+ self.subtitle = []
+ if settings.xml_declaration:
+ self.head_prefix.append(
+ utils.xml_declaration(settings.output_encoding))
+ self.html_prolog.append(
+ utils.xml_declaration('%s')) # encoding not interpolated
+ if (settings.output_encoding
+ and settings.output_encoding.lower() != 'unicode'):
+ self.meta.insert(0, self.content_type % settings.output_encoding)
+
+ # bookkeeping attributes; reflect state of translator
+ #
self.context = []
"""Heterogeneous stack.
Used by visit_* and depart_* functions in conjunction with the tree
- traversal. Make sure that the pops correspond to the pushes."""
-
+ traversal. Make sure that the pops correspond to the pushes.
+ """
+ self.section_level = 0
self.colspecs = []
self.compact_p = True
self.compact_simple = False
@@ -336,14 +350,6 @@
self.compact_field_list = False
self.in_docinfo = False
self.in_sidebar = False
- self.title = []
- self.subtitle = []
- self.header = []
- self.footer = []
- self.html_head = [self.content_type] # charset not interpolated
- self.html_title = []
- self.html_subtitle = []
- self.html_body = []
self.in_document_title = 0 # len(self.body) or 0
self.in_mailto = False
self.author_in_authors = False # for html4css1
@@ -784,12 +790,10 @@
def visit_docinfo_item(self, node, name, meta=True):
if meta:
- meta_tag = '<meta name="%s" content="%s" />\n' \
- % (name, self.attval(node.astext()))
- self.add_meta(meta_tag)
- self.body.append(
- '<dt class="%s">%s<span class="colon">:</span></dt>\n'
- % (name, self.language.labels[name]))
+ self.meta.append(f'<meta name="{name}" '
+ f'content="{self.attval(node.astext())}" />\n')
+ self.body.append(f'<dt class="{name}">{self.language.labels[name]}'
+ '<span class="colon">:</span></dt>\n')
self.body.append(self.starttag(node, 'dd', '', CLASS=name))
def depart_docinfo_item(self):
@@ -812,11 +816,10 @@
self.head_prefix_template %
{'lang': self.settings.language_code}])
self.html_prolog.append(self.doctype)
- self.meta.insert(0, self.content_type % _encoding(self.settings))
- self.head.insert(0, self.content_type % _encoding(self.settings))
+ self.head = self.meta[:] + self.head
if 'name="dcterms.' in ''.join(self.meta):
self.head.append('<link rel="schema.dcterms"'
- 'href="http://purl.org/dc/terms/"/>')
+ ' href="http://purl.org/dc/terms/"/>')
if self.math_header:
if self.math_output == 'mathjax':
self.head.extend(self.math_header)
@@ -1311,16 +1314,12 @@
# Meta tags: 'lang' attribute replaced by 'xml:lang' in XHTML 1.1
# HTML5/polyglot recommends using both
def visit_meta(self, node):
- meta = self.emptytag(node, 'meta', **node.non_default_attributes())
- self.add_meta(meta)
+ self.meta.append(self.emptytag(node, 'meta',
+ **node.non_default_attributes()))
def depart_meta(self, node):
pass
- def add_meta(self, tag):
- self.meta.append(tag)
- self.head.append(tag)
-
def visit_option(self, node):
self.body.append(self.starttag(node, 'span', '', CLASS='option'))
@@ -1783,10 +1782,3 @@
visit_substitution_definition = ignore_node
visit_target = ignore_node
visit_pending = ignore_node
-
-
-def _encoding(settings):
- """TEMPORARY, remove in Docutils 0.21"""
- if settings.output_encoding == 'unicode':
- return 'utf-8'
- return settings.output_encoding
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2022-11-13 16:15:23 UTC (rev 9240)
@@ -344,7 +344,7 @@
if meta:
meta_tag = '<meta name="%s" content="%s" />\n' \
% (name, self.attval(node.astext()))
- self.add_meta(meta_tag)
+ self.meta.append(meta_tag)
self.body.append(self.starttag(node, 'tr', ''))
self.body.append('<th class="docinfo-name">%s:</th>\n<td>'
% self.language.labels[name])
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-11-13 16:15:23 UTC (rev 9240)
@@ -138,8 +138,8 @@
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()))
+ self.meta.append('<meta name="author" content='
+ f'"{self.attval(subnode.astext())}" />\n')
def depart_authors(self, node):
self.depart_docinfo_item()
@@ -178,8 +178,8 @@
# 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()))
+ self.meta.append('<meta name="dcterms.rights" '
+ f'content="{self.attval(node.astext())}" />\n')
def depart_copyright(self, node):
self.depart_docinfo_item()
@@ -187,8 +187,8 @@
# 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()))
+ self.meta.append('<meta name="dcterms.date" '
+ f'content="{self.attval(node.astext())}" />\n')
def depart_date(self, node):
self.depart_docinfo_item()
@@ -197,6 +197,7 @@
title = (node.get('title', '') or os.path.basename(node['source'])
or 'untitled Docutils document')
self.head.append(f'<title>{self.encode(title)}</title>\n')
+ self.meta.append(self.viewport)
def depart_document(self, node):
self.head_prefix.extend([self.doctype,
@@ -203,10 +204,7 @@
self.head_prefix_template %
{'lang': self.settings.language_code}])
self.html_prolog.append(self.doctype)
- self.meta.insert(0, self.viewport)
- self.head.insert(0, self.viewport)
- self.meta.insert(0, self.content_type % _encoding(self))
- self.head.insert(0, self.content_type % _encoding(self))
+ self.head = self.meta[:] + self.head
if 'name="dcterms.' in ''.join(self.meta):
self.head.append('<link rel="schema.dcterms"'
' href="http://purl.org/dc/terms/"/>')
@@ -384,8 +382,8 @@
def visit_meta(self, node):
if node.hasattr('lang'):
node['xml:lang'] = node['lang']
- meta = self.emptytag(node, 'meta', **node.non_default_attributes())
- self.add_meta(meta)
+ self.meta.append(self.emptytag(node, 'meta',
+ **node.non_default_attributes()))
def depart_meta(self, node):
pass
@@ -452,10 +450,3 @@
f' href="#{ids[0]}"></a>')
close_tag = close_tag.replace('</h', self_link + '</h')
return start_tag, close_tag
-
-
-def _encoding(self):
- """TEMPORARY, remove in Docutils 0.21"""
- if self.settings.output_encoding == 'unicode':
- return 'utf-8'
- return self.settings.output_encoding
Modified: trunk/docutils/docutils/writers/pep_html/template.txt
===================================================================
--- trunk/docutils/docutils/writers/pep_html/template.txt 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/docutils/writers/pep_html/template.txt 2022-11-13 16:15:23 UTC (rev 9240)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="%(encoding)s" ?>
+<?xml version="1.0" encoding="%(encoding)s"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
Modified: trunk/docutils/docutils/writers/s5_html/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/s5_html/__init__.py 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/docutils/writers/s5_html/__init__.py 2022-11-13 16:15:23 UTC (rev 9240)
@@ -164,7 +164,7 @@
'control_visibility': control_visibility})
if not self.document.settings.current_slide:
self.stylesheet.append(self.disable_current_slide)
- self.add_meta('<meta name="version" content="S5 1.1" />\n')
+ self.meta.append('<meta name="version" content="S5 1.1" />\n')
self.s5_footer = []
self.s5_header = []
self.section_count = 0
@@ -282,8 +282,7 @@
self.head_prefix_template %
{'lang': self.settings.language_code}])
self.html_prolog.append(self.doctype)
- self.meta.insert(0, self.content_type % _encoding(self))
- self.head.insert(0, self.content_type % _encoding(self))
+ self.head = self.meta[:] + self.head
if self.math_header:
if self.math_output == 'mathjax':
self.head.extend(self.math_header)
@@ -350,10 +349,3 @@
def visit_title(self, node):
html4css1.HTMLTranslator.visit_title(self, node)
-
-
-def _encoding(self):
- """TEMPORARY, remove in Docutils 0.21"""
- if self.settings.output_encoding == 'unicode':
- return 'utf-8'
- return self.settings.output_encoding
Modified: trunk/docutils/test/functional/expected/compact_lists.html
===================================================================
--- trunk/docutils/test/functional/expected/compact_lists.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/compact_lists.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Modified: trunk/docutils/test/functional/expected/dangerous.html
===================================================================
--- trunk/docutils/test/functional/expected/dangerous.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/dangerous.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Modified: trunk/docutils/test/functional/expected/embed_images_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/embed_images_html5.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/embed_images_html5.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -1,8 +1,8 @@
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
+<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta charset="utf-8"/>
-<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
<title>Embedded Images</title>
<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" />
Modified: trunk/docutils/test/functional/expected/field_name_limit.html
===================================================================
--- trunk/docutils/test/functional/expected/field_name_limit.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/field_name_limit.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Modified: trunk/docutils/test/functional/expected/footnotes_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/footnotes_html5.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/footnotes_html5.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -2,8 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
+<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
-<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
<title>Test footnote and citation rendering</title>
<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" />
<link rel="stylesheet" href="../input/data/responsive.css" type="text/css" />
Modified: trunk/docutils/test/functional/expected/math_output_html.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_html.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/math_output_html.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Modified: trunk/docutils/test/functional/expected/math_output_latex.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_latex.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/math_output_latex.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Modified: trunk/docutils/test/functional/expected/math_output_mathjax.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_mathjax.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/math_output_mathjax.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Modified: trunk/docutils/test/functional/expected/math_output_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_mathml.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/math_output_mathml.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -2,8 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
+<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
-<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
<title>Mathematics</title>
<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" />
<link rel="stylesheet" href="../input/data/plain.css" type="text/css" />
Modified: trunk/docutils/test/functional/expected/misc_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/misc_rst_html4css1.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/misc_rst_html4css1.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
Modified: trunk/docutils/test/functional/expected/misc_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/misc_rst_html5.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/misc_rst_html5.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -2,8 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
+<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
-<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
<title>Additional tests with HTML 5</title>
<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" />
<link rel="stylesheet" href="../input/data/responsive.css" type="text/css" />
Modified: trunk/docutils/test/functional/expected/pep_html.html
===================================================================
--- trunk/docutils/test/functional/expected/pep_html.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/pep_html.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!--
Modified: trunk/docutils/test/functional/expected/rst_html5_tuftig.html
===================================================================
--- trunk/docutils/test/functional/expected/rst_html5_tuftig.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/rst_html5_tuftig.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -2,8 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
+<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
-<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
<title>Special Features of the tuftig.css Stylesheet</title>
<link rel="stylesheet" href="../input/data/minimal.css" type="text/css" />
<link rel="stylesheet" href="../input/data/tuftig.css" type="text/css" />
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -1,10 +1,9 @@
-<?xml version="1.0" encoding="utf-8" ?>
+<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
-<title>reStructuredText Test Document</title>
<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" />
<meta name="author" content="David Goodger" />
@@ -12,6 +11,7 @@
<meta name="organization" content="humankind" />
<meta name="date" content="Now, or yesterday. Or maybe even before yesterday." />
<meta name="copyright" 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." />
+<title>reStructuredText Test Document</title>
<link rel="stylesheet" href="../input/data/html4css1.css" type="text/css" />
<link rel="stylesheet" href="../input/data/math.css" type="text/css" />
</head>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2022-11-13 16:14:59 UTC (rev 9239)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2022-11-13 16:15:23 UTC (rev 9240)
@@ -2,9 +2,8 @@
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta charset="utf-8" />
+<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
-<meta name="generator" content="Docutils 0.19.1b.dev: https://docutils.sourceforge.io/" />
-<title>reStructuredText Test Document</title>
<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" />
<meta name="author" content="David Goodger" />
@@ -13,6 +12,7 @@
...
[truncated message content] |
|
From: <gr...@us...> - 2022-11-14 09:26:31
|
Revision: 9243
http://sourceforge.net/p/docutils/code/9243
Author: grubert
Date: 2022-11-14 09:26:29 +0000 (Mon, 14 Nov 2022)
Log Message:
-----------
Fix: SetuptoolsDeprecationWarning: Installing '' as data is deprecated
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/setup.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-13 16:15:49 UTC (rev 9242)
+++ trunk/docutils/HISTORY.txt 2022-11-14 09:26:29 UTC (rev 9243)
@@ -38,6 +38,12 @@
* Refactored tests in ``test/`` towards using common ``unittest`` idioms.
Patch by Adam Turner.
+* setup.py
+
+ - Fix: SetuptoolsDeprecationWarning: Installing '' as data is deprecated,
+
+ by adding data directories to package_data.packages list.
+
* docutils/languages/
docutils/parsers/rst/languages/
Modified: trunk/docutils/setup.py
===================================================================
--- trunk/docutils/setup.py 2022-11-13 16:15:49 UTC (rev 9242)
+++ trunk/docutils/setup.py 2022-11-14 09:26:29 UTC (rev 9243)
@@ -53,6 +53,7 @@
'docutils.parsers',
'docutils.parsers.rst',
'docutils.parsers.rst.directives',
+ 'docutils.parsers.rst.include',
'docutils.parsers.rst.languages',
'docutils.readers',
'docutils.transforms',
@@ -63,6 +64,8 @@
'docutils.writers.html5_polyglot',
'docutils.writers.pep_html',
'docutils.writers.s5_html',
+ 'docutils.writers.s5_html.themes',
+ 'docutils.writers.s5_html.themes.default',
'docutils.writers.latex2e',
'docutils.writers.xetex',
'docutils.writers.odf_odt',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-16 14:01:46
|
Revision: 9251
http://sourceforge.net/p/docutils/code/9251
Author: milde
Date: 2022-11-16 14:01:43 +0000 (Wed, 16 Nov 2022)
Log Message:
-----------
Update `utils.punctuation_chars` (keeping backwards compatibility).
Update/harmonize the formatting/layout in both, the generated file
and the generating script.
Remaining differences between the current module and a re-generation result
are due to different versions of Python's `unicodedata` module.
Modified Paths:
--------------
trunk/docutils/docutils/utils/punctuation_chars.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
Property Changed:
----------------
trunk/docutils/tools/dev/generate_punctuation_chars.py
Modified: trunk/docutils/docutils/utils/punctuation_chars.py
===================================================================
--- trunk/docutils/docutils/utils/punctuation_chars.py 2022-11-16 14:01:31 UTC (rev 9250)
+++ trunk/docutils/docutils/utils/punctuation_chars.py 2022-11-16 14:01:43 UTC (rev 9251)
@@ -1,4 +1,3 @@
-#!/usr/bin/env python3
# :Id: $Id$
# :Copyright: © 2011, 2017 Günter Milde.
# :License: Released under the terms of the `2-Clause BSD license`_, in short:
@@ -38,55 +37,64 @@
"unicodedata" module of Python 2.7.13 (based on Unicode version 5.2.0).
.. _inline markup recognition rules:
- https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules
+ https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html
+ #inline-markup-recognition-rules
"""
-openers = (u'"\'(<\\[{\u0f3a\u0f3c\u169b\u2045\u207d\u208d\u2329\u2768'
- u'\u276a\u276c\u276e\u2770\u2772\u2774\u27c5\u27e6\u27e8\u27ea'
- u'\u27ec\u27ee\u2983\u2985\u2987\u2989\u298b\u298d\u298f\u2991'
- u'\u2993\u2995\u2997\u29d8\u29da\u29fc\u2e22\u2e24\u2e26\u2e28'
- u'\u3008\u300a\u300c\u300e\u3010\u3014\u3016\u3018\u301a\u301d'
- u'\u301d\ufd3e\ufe17\ufe35\ufe37\ufe39\ufe3b\ufe3d\ufe3f\ufe41'
- u'\ufe43\ufe47\ufe59\ufe5b\ufe5d\uff08\uff3b\uff5b\uff5f\uff62'
- u'\xab\u2018\u201c\u2039\u2e02\u2e04\u2e09\u2e0c\u2e1c\u2e20'
- u'\u201a\u201e\xbb\u2019\u201d\u203a\u2e03\u2e05\u2e0a\u2e0d'
- u'\u2e1d\u2e21\u201b\u201f')
-closers = (u'"\')>\\]}\u0f3b\u0f3d\u169c\u2046\u207e\u208e\u232a\u2769'
- u'\u276b\u276d\u276f\u2771\u2773\u2775\u27c6\u27e7\u27e9\u27eb'
- u'\u27ed\u27ef\u2984\u2986\u2988\u298a\u298c\u298e\u2990\u2992'
- u'\u2994\u2996\u2998\u29d9\u29db\u29fd\u2e23\u2e25\u2e27\u2e29'
- u'\u3009\u300b\u300d\u300f\u3011\u3015\u3017\u3019\u301b\u301e'
- u'\u301f\ufd3f\ufe18\ufe36\ufe38\ufe3a\ufe3c\ufe3e\ufe40\ufe42'
- u'\ufe44\ufe48\ufe5a\ufe5c\ufe5e\uff09\uff3d\uff5d\uff60\uff63'
- u'\xbb\u2019\u201d\u203a\u2e03\u2e05\u2e0a\u2e0d\u2e1d\u2e21'
- u'\u201b\u201f\xab\u2018\u201c\u2039\u2e02\u2e04\u2e09\u2e0c'
- u'\u2e1c\u2e20\u201a\u201e')
-delimiters = (u'\\-/:\u058a\xa1\xb7\xbf\u037e\u0387\u055a-\u055f\u0589'
- u'\u05be\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c'
- u'\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d'
- u'\u07f7-\u07f9\u0830-\u083e\u0964\u0965\u0970\u0df4\u0e4f'
- u'\u0e5a\u0e5b\u0f04-\u0f12\u0f85\u0fd0-\u0fd4\u104a-\u104f'
- u'\u10fb\u1361-\u1368\u1400\u166d\u166e\u16eb-\u16ed\u1735'
- u'\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u180a\u1944\u1945'
- u'\u19de\u19df\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-'
- u'\u1b60\u1c3b-\u1c3f\u1c7e\u1c7f\u1cd3\u2010-\u2017\u2020-'
- u'\u2027\u2030-\u2038\u203b-\u203e\u2041-\u2043\u2047-'
- u'\u2051\u2053\u2055-\u205e\u2cf9-\u2cfc\u2cfe\u2cff\u2e00'
- u'\u2e01\u2e06-\u2e08\u2e0b\u2e0e-\u2e1b\u2e1e\u2e1f\u2e2a-'
- u'\u2e2e\u2e30\u2e31\u3001-\u3003\u301c\u3030\u303d\u30a0'
- u'\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7'
- u'\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f'
- u'\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uabeb'
- u'\ufe10-\ufe16\ufe19\ufe30-\ufe32\ufe45\ufe46\ufe49-\ufe4c'
- u'\ufe50-\ufe52\ufe54-\ufe58\ufe5f-\ufe61\ufe63\ufe68\ufe6a'
- u'\ufe6b\uff01-\uff03\uff05-\uff07\uff0a\uff0c-\uff0f\uff1a'
- u'\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65')
+openers = (
+ '"\'(<\\[{\u0f3a\u0f3c\u169b\u2045\u207d\u208d\u2329\u2768'
+ '\u276a\u276c\u276e\u2770\u2772\u2774\u27c5\u27e6\u27e8\u27ea'
+ '\u27ec\u27ee\u2983\u2985\u2987\u2989\u298b\u298d\u298f\u2991'
+ '\u2993\u2995\u2997\u29d8\u29da\u29fc\u2e22\u2e24\u2e26\u2e28'
+ '\u3008\u300a\u300c\u300e\u3010\u3014\u3016\u3018\u301a\u301d'
+ '\u301d\ufd3e\ufe17\ufe35\ufe37\ufe39\ufe3b\ufe3d\ufe3f\ufe41'
+ '\ufe43\ufe47\ufe59\ufe5b\ufe5d\uff08\uff3b\uff5b\uff5f\uff62'
+ '\xab\u2018\u201c\u2039\u2e02\u2e04\u2e09\u2e0c\u2e1c\u2e20'
+ '\u201a\u201e\xbb\u2019\u201d\u203a\u2e03\u2e05\u2e0a\u2e0d'
+ '\u2e1d\u2e21\u201b\u201f'
+ )
+closers = (
+ '"\')>\\]}\u0f3b\u0f3d\u169c\u2046\u207e\u208e\u232a\u2769'
+ '\u276b\u276d\u276f\u2771\u2773\u2775\u27c6\u27e7\u27e9\u27eb'
+ '\u27ed\u27ef\u2984\u2986\u2988\u298a\u298c\u298e\u2990\u2992'
+ '\u2994\u2996\u2998\u29d9\u29db\u29fd\u2e23\u2e25\u2e27\u2e29'
+ '\u3009\u300b\u300d\u300f\u3011\u3015\u3017\u3019\u301b\u301e'
+ '\u301f\ufd3f\ufe18\ufe36\ufe38\ufe3a\ufe3c\ufe3e\ufe40\ufe42'
+ '\ufe44\ufe48\ufe5a\ufe5c\ufe5e\uff09\uff3d\uff5d\uff60\uff63'
+ '\xbb\u2019\u201d\u203a\u2e03\u2e05\u2e0a\u2e0d\u2e1d\u2e21'
+ '\u201b\u201f\xab\u2018\u201c\u2039\u2e02\u2e04\u2e09\u2e0c'
+ '\u2e1c\u2e20\u201a\u201e'
+ )
+delimiters = (
+ '\\-/:\u058a\xa1\xb7\xbf\u037e\u0387\u055a-\u055f\u0589'
+ '\u05be\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c'
+ '\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d'
+ '\u07f7-\u07f9\u0830-\u083e\u0964\u0965\u0970\u0df4\u0e4f'
+ '\u0e5a\u0e5b\u0f04-\u0f12\u0f85\u0fd0-\u0fd4\u104a-\u104f'
+ '\u10fb\u1361-\u1368\u1400\u166d\u166e\u16eb-\u16ed\u1735'
+ '\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u180a\u1944\u1945'
+ '\u19de\u19df\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-'
+ '\u1b60\u1c3b-\u1c3f\u1c7e\u1c7f\u1cd3\u2010-\u2017\u2020-'
+ '\u2027\u2030-\u2038\u203b-\u203e\u2041-\u2043\u2047-'
+ '\u2051\u2053\u2055-\u205e\u2cf9-\u2cfc\u2cfe\u2cff\u2e00'
+ '\u2e01\u2e06-\u2e08\u2e0b\u2e0e-\u2e1b\u2e1e\u2e1f\u2e2a-'
+ '\u2e2e\u2e30\u2e31\u3001-\u3003\u301c\u3030\u303d\u30a0'
+ '\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7'
+ '\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f'
+ '\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uabeb'
+ '\ufe10-\ufe16\ufe19\ufe30-\ufe32\ufe45\ufe46\ufe49-\ufe4c'
+ '\ufe50-\ufe52\ufe54-\ufe58\ufe5f-\ufe61\ufe63\ufe68\ufe6a'
+ '\ufe6b\uff01-\uff03\uff05-\uff07\uff0a\uff0c-\uff0f\uff1a'
+ '\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65'
+ )
if sys.maxunicode >= 0x10FFFF: # "wide" build
- delimiters += (u'\U00010100\U00010101\U0001039f\U000103d0\U00010857'
- u'\U0001091f\U0001093f\U00010a50-\U00010a58\U00010a7f'
- u'\U00010b39-\U00010b3f\U000110bb\U000110bc\U000110be-'
- u'\U000110c1\U00012470-\U00012473')
-closing_delimiters = u'\\\\.,;!?'
+ delimiters += (
+ '\U00010100\U00010101\U0001039f\U000103d0\U00010857'
+ '\U0001091f\U0001093f\U00010a50-\U00010a58\U00010a7f'
+ '\U00010b39-\U00010b3f\U000110bb\U000110bc\U000110be-'
+ '\U000110c1\U00012470-\U00012473'
+ )
+closing_delimiters = r'\\.,;!?'
# Matching open/close quotes
@@ -93,16 +101,16 @@
# --------------------------
quote_pairs = {
- # open char: matching closing characters # usage example
- u'\xbb': u'\xbb', # » » Swedish
- u'\u2018': u'\u201a', # ‘ ‚ Albanian/Greek/Turkish
- u'\u2019': u'\u2019', # ’ ’ Swedish
- u'\u201a': u'\u2018\u2019', # ‚ ‘ German ‚ ’ Polish
- u'\u201c': u'\u201e', # “ „ Albanian/Greek/Turkish
- u'\u201e': u'\u201c\u201d', # „ “ German „ ” Polish
- u'\u201d': u'\u201d', # ” ” Swedish
- u'\u203a': u'\u203a', # › › Swedish
- }
+ # open char: matching closing characters # usage example
+ '\xbb': '\xbb', # » » Swedish
+ '\u2018': '\u201a', # ‘ ‚ Albanian/Greek/Turkish
+ '\u2019': '\u2019', # ’ ’ Swedish
+ '\u201a': '\u2018\u2019', # ‚ ‘ German, ‚ ’ Polish
+ '\u201c': '\u201e', # “ „ Albanian/Greek/Turkish
+ '\u201e': '\u201c\u201d', # „ “ German, „ ” Polish
+ '\u201d': '\u201d', # ” ” Swedish
+ '\u203a': '\u203a', # › › Swedish
+ }
"""Additional open/close quote pairs."""
@@ -119,4 +127,4 @@
i = openers.index(c1)
except ValueError: # c1 not in openers
return False
- return c2 == closers[i] or c2 in quote_pairs.get(c1, u'')
+ return c2 == closers[i] or c2 in quote_pairs.get(c1, '')
Modified: trunk/docutils/tools/dev/generate_punctuation_chars.py
===================================================================
--- trunk/docutils/tools/dev/generate_punctuation_chars.py 2022-11-16 14:01:31 UTC (rev 9250)
+++ trunk/docutils/tools/dev/generate_punctuation_chars.py 2022-11-16 14:01:43 UTC (rev 9251)
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
-# :Copyright: © 2011, 2017 Günter Milde.
+# :Copyright: © 2011, 2017, 2022 Günter Milde.
# :License: Released under the terms of the `2-Clause BSD license`_, in short:
#
# Copying and distribution of this file, with or without modification,
@@ -13,25 +13,26 @@
#
# ::
-"""(Re)generate the utils.punctuation_chars module."""
+"""(Re)generate the utils.punctuation_chars module.
-# (re)generate the utils.punctuation_chars module
-# ===============================================
-#
-# The category of some characters can change with the development of the
-# Unicode standard. This tool checks the patterns in `utils.punctuation_chars`
-# against a re-calculation based on the "unicodedata" stdlib module
-# which may give different results for different Python versions.
-#
-# Updating the module with changed `unicode_punctuation_categories` (due to
-# a new Python or Unicode standard version is an API change (may render valid
-# rST documents invalid). It should only be done for "feature releases" and
-# requires also updating the specification of `inline markup recognition
-# rules`_ in ../../docs/ref/rst/restructuredtext.txt.
-#
-# .. _inline markup recognition rules:
-# ../../docs/ref/rst/restructuredtext.html#inline-markup
+The category of some characters can change with the development of the
+Unicode standard. This tool checks the patterns in `utils.punctuation_chars`
+against a re-calculation based on the "unicodedata" stdlib module
+which may give different results for different Python versions.
+.. admonition:: API change
+
+ Updating the module with changed `unicode_punctuation_categories`
+ (due to a new Python or Unicode standard version is an API change
+ (may render valid rST documents invalid). It should only be done for
+ "feature releases" and requires also updating the specification of
+ `inline markup recognition rules`_.
+
+ .. _inline markup recognition rules:
+ https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html
+ #inline-markup-recognition-rules
+"""
+
import sys
import unicodedata
@@ -39,9 +40,8 @@
# Template for utils.punctuation_chars
# ------------------------------------
-module_template = r'''#!/usr/bin/env python3
-# :Id: $Id$
-# :Copyright: © 2011, 2017 Günter Milde.
+module_template = r'''# :Id: $Id$
+# :Copyright: © 2011, 2017, 2022 Günter Milde.
# :License: Released under the terms of the `2-Clause BSD license`_, in short:
#
# Copying and distribution of this file, with or without modification,
@@ -79,7 +79,8 @@
"unicodedata" module of Python %(python_version)s (based on Unicode version %(unidata_version)s).
.. _inline markup recognition rules:
- https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html#inline-markup-recognition-rules
+ https://docutils.sourceforge.io/docs/ref/rst/restructuredtext.html
+ #inline-markup-recognition-rules
"""
%(openers)s
@@ -98,12 +99,12 @@
'\xbb': '\xbb', # » » Swedish
'\u2018': '\u201a', # ‘ ‚ Albanian/Greek/Turkish
'\u2019': '\u2019', # ’ ’ Swedish
- '\u201a': '\u2018\u2019', # ‚ ‘ German ‚ ’ Polish
+ '\u201a': '\u2018\u2019', # ‚ ‘ German, ‚ ’ Polish
'\u201c': '\u201e', # “ „ Albanian/Greek/Turkish
- '\u201e': '\u201c\u201d', # „ “ German „ ” Polish
+ '\u201e': '\u201c\u201d', # „ “ German, „ ” Polish
'\u201d': '\u201d', # ” ” Swedish
'\u203a': '\u203a', # › › Swedish
-}
+ }
"""Additional open/close quote pairs."""
@@ -280,7 +281,7 @@
return ''.join(lst2)
-def wrap_string(s, startstring="(", endstring=")", wrap=71):
+def wrap_string(s, startstring="(", endstring=" )", wrap=71):
"""Line-wrap a unicode string literal definition."""
c = len(startstring)
left_indent = ' '*(c - len(startstring.lstrip(' ')))
Property changes on: trunk/docutils/tools/dev/generate_punctuation_chars.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-21 20:51:26
|
Revision: 9259
http://sourceforge.net/p/docutils/code/9259
Author: milde
Date: 2022-11-21 20:51:23 +0000 (Mon, 21 Nov 2022)
Log Message:
-----------
Small documentation fixes.
transforms.txt:
Update "added by" in "Transforms Listed in Priority Order".
io.py:
reword docstrings and assertion messages,
use PEP 257 "Docstring Conventions".
Modified Paths:
--------------
trunk/docutils/docs/api/transforms.txt
trunk/docutils/docutils/io.py
Modified: trunk/docutils/docs/api/transforms.txt
===================================================================
--- trunk/docutils/docs/api/transforms.txt 2022-11-21 14:51:43 UTC (rev 9258)
+++ trunk/docutils/docs/api/transforms.txt 2022-11-21 20:51:23 UTC (rev 9259)
@@ -114,7 +114,7 @@
writer_aux.Compound *not used, to be removed* 910
-writer_aux.Admonitions html4css1 (w), 920
+writer_aux.Admonitions _html_base (w), 920
latex2e (w)
misc.CallBack n/a 990
@@ -202,7 +202,7 @@
writers.latex2e.Writer
writer_aux.Admonitions
-writers.html4css1.Writer:
+writers._html_base.Writer:
writer_aux.Admonitions
writers.odf_odt.Writer:
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2022-11-21 14:51:43 UTC (rev 9258)
+++ trunk/docutils/docutils/io.py 2022-11-21 20:51:23 UTC (rev 9259)
@@ -136,7 +136,7 @@
"""
if self.encoding and self.encoding.lower() == 'unicode':
assert isinstance(data, str), ('input encoding is "unicode" '
- 'but input is not a `str` object')
+ 'but `data` is no `str` instance')
if isinstance(data, str):
# nothing to decode
return data
@@ -255,9 +255,8 @@
If `data` is a `bytes` instance, it is returned unchanged.
"""
if self.encoding and self.encoding.lower() == 'unicode':
- assert isinstance(data, str), (
- 'the encoding given is "unicode" but the output is not '
- 'a Unicode string')
+ assert isinstance(data, str), ('output encoding is "unicode" '
+ 'but `data` is no `str` instance')
return data
if not isinstance(data, str):
# Non-unicode (e.g. bytes) output.
@@ -604,8 +603,8 @@
"""Encode `data`, store it in `self.destination`, and return it.
If `self.encoding` is set to the pseudo encoding name "unicode",
- `data` must be a `str` instance and is returned unchanged.
- (cf. `Output.encode`)
+ `data` must be a `str` instance and is returned unchanged
+ (cf. `Output.encode`).
"""
self.destination = self.encode(data)
return self.destination
@@ -613,22 +612,18 @@
class NullInput(Input):
- """
- Degenerate input: read nothing.
- """
+ """Degenerate input: read nothing."""
default_source_path = 'null input'
def read(self):
- """Return a null string."""
+ """Return an empty string."""
return ''
class NullOutput(Output):
- """
- Degenerate output: write nothing.
- """
+ """Degenerate output: write nothing."""
default_destination_path = 'null output'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-21 20:51:40
|
Revision: 9260
http://sourceforge.net/p/docutils/code/9260
Author: milde
Date: 2022-11-21 20:51:37 +0000 (Mon, 21 Nov 2022)
Log Message:
-----------
Make component's "TransformSpec" interface optional.
`Transformer.populate_from_components()` now ignores components
not inheriting `docutils.TransformSpec`.
This is a prerequisite to allow use of standard I/O classes in the Publisher.
Document the handling of `unknown_reference_resolvers`.
Use PEP 257 "Docstring Conventions".
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/__init__.py
trunk/docutils/docutils/transforms/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-21 20:51:23 UTC (rev 9259)
+++ trunk/docutils/HISTORY.txt 2022-11-21 20:51:37 UTC (rev 9260)
@@ -19,10 +19,6 @@
- Declared support for Python 3.11 in setup.py and tox.ini.
Patch by Hugo van Kemenade.
-* tox.ini
-
- - Extracted flake8 configuration and moved to ``.flake8``.
-
* docutils/core.py
- Added new ``publish_bytes()`` function to explicitly return
@@ -35,12 +31,6 @@
- Deprecated returning ``bytes`` from ``StringOutput.encode()``.
Users should use the new class ``BytesOutput`` instead.
-* setup.py
-
- - Fix: SetuptoolsDeprecationWarning: Installing '' as data is deprecated,
-
- by adding data directories to package_data.packages list.
-
* docutils/languages/
docutils/parsers/rst/languages/
@@ -55,6 +45,11 @@
- Improved mock Sphinx module.
+* docutils/transforms/__init__.py
+
+ - `Transformer.populate_from_components()` now silently ignores
+ components that are not instances of `docutils.TransformSpec`.
+
* docutils/utils/__init__.py
- New utility function ``xml_declaration()``.
@@ -90,6 +85,15 @@
- Do not output empty "manual" in ``.TH``
+* setup.py
+
+ - Fix SetuptoolsDeprecationWarning: "Installing '' as data is deprecated"
+ by adding data directories to package_data.packages list.
+
+* tox.ini
+
+ - Extracted flake8 configuration and moved to ``.flake8``.
+
* test/
- Refactored tests in to use common ``unittest`` idioms.
Modified: trunk/docutils/docutils/__init__.py
===================================================================
--- trunk/docutils/docutils/__init__.py 2022-11-21 20:51:23 UTC (rev 9259)
+++ trunk/docutils/docutils/__init__.py 2022-11-21 20:51:37 UTC (rev 9260)
@@ -217,11 +217,13 @@
class TransformSpec:
-
"""
Runtime transform specification base class.
- TransformSpec subclass objects used by `docutils.transforms.Transformer`.
+ Provides the interface to register "transforms" and helper functions
+ to resolve references with a `docutils.transforms.Transformer`.
+
+ https://docutils.sourceforge.io/docs/ref/transforms.html
"""
def get_transforms(self):
@@ -239,11 +241,13 @@
default_transforms = ()
unknown_reference_resolvers = ()
- """List of functions to try to resolve unknown references. Unknown
- references have a 'refname' attribute which doesn't correspond to any
- target in the document. Called when the transforms in
- `docutils.transforms.references` are unable to find a correct target. The
- list should contain functions which will try to resolve unknown
+ """List of functions to try to resolve unknown references.
+
+ Unknown references have a 'refname' attribute which doesn't correspond
+ to any target in the document. Called when the transforms in
+ `docutils.transforms.references` are unable to find a correct target.
+
+ The list should contain functions which will try to resolve unknown
references, with the following signature::
def reference_resolver(node):
@@ -260,7 +264,10 @@
reference_resolver.priority = 100
- Override in subclasses."""
+ This hook is provided for 3rd party extensions.
+ Example use case: the `MoinMoin - ReStructured Text Parser`
+ in ``sandbox/mmgilbe/rst.py``.
+ """
class Component(SettingsSpec, TransformSpec):
Modified: trunk/docutils/docutils/transforms/__init__.py
===================================================================
--- trunk/docutils/docutils/transforms/__init__.py 2022-11-21 20:51:23 UTC (rev 9259)
+++ trunk/docutils/docutils/transforms/__init__.py 2022-11-21 20:51:37 UTC (rev 9260)
@@ -32,11 +32,8 @@
class Transform:
+ """Docutils transform component abstract base class."""
- """
- Docutils transform component abstract base class.
- """
-
default_priority = None
"""Numerical priority of this transform, 0 through 999 (override)."""
@@ -63,11 +60,17 @@
class Transformer(TransformSpec):
+ """
+ Store "transforms" and apply them to the document tree.
+ Collect lists of `Transform` instances and "unknown_reference_resolvers"
+ from Docutils components (`TransformSpec` instances).
+ Apply collected "transforms" to the document tree.
+
+ Also keeps track of components by component type name.
+
+ https://docutils.sourceforge.io/docs/peps/pep-0258.html#transformer
"""
- Stores transforms (`Transform` classes) and applies them to document
- trees. Also keeps track of components by component type name.
- """
def __init__(self, document):
self.transforms = []
@@ -76,7 +79,7 @@
"""
self.unknown_reference_resolvers = []
- """List of hook functions which assist in resolving references"""
+ """List of hook functions which assist in resolving references."""
self.document = document
"""The `nodes.document` object this Transformer is attached to."""
@@ -84,13 +87,15 @@
self.applied = []
"""Transforms already applied, in order."""
- self.sorted = 0
+ self.sorted = False
"""Boolean: is `self.tranforms` sorted?"""
self.components = {}
- """Mapping of component type name to component object. Set by
- `self.populate_from_components()`."""
+ """Mapping of component type name to component object.
+ Set by `self.populate_from_components()`.
+ """
+
self.serialno = 0
"""Internal serial number to keep track of the add order of
transforms."""
@@ -139,25 +144,29 @@
def populate_from_components(self, components):
"""
- Store each component's default transforms, with default priorities.
+ Store each component's default transforms and reference resolvers
+
+ Transforms are stored with default priorities for later sorting.
+ "Unknown reference resolvers" are sorted and stored.
+ Components that don't inherit from `TransformSpec` are ignored.
+
Also, store components by type name in a mapping for later lookup.
"""
+ resolvers = []
for component in components:
- if component is None:
+ if not isinstance(component, TransformSpec):
continue
self.add_transforms(component.get_transforms())
self.components[component.component_type] = component
- self.sorted = 0
- # Set up all of the reference resolvers for this transformer. Each
- # component of this transformer is able to register its own helper
- # functions to help resolve references.
- unknown_reference_resolvers = []
- for i in components:
- unknown_reference_resolvers.extend(i.unknown_reference_resolvers)
- decorated_list = sorted((f.priority, f)
- for f in unknown_reference_resolvers)
- self.unknown_reference_resolvers.extend(f[1] for f in decorated_list)
+ resolvers.extend(component.unknown_reference_resolvers)
+ self.sorted = False # sort transform list in self.apply_transforms()
+ # Sort and add helper functions to help resolve unknown references.
+ def keyfun(f):
+ return f.priority
+ resolvers.sort(key=keyfun)
+ self.unknown_reference_resolvers += resolvers
+
def apply_transforms(self):
"""Apply all of the stored transforms, in priority order."""
self.document.reporter.attach_observer(
@@ -164,10 +173,10 @@
self.document.note_transform_message)
while self.transforms:
if not self.sorted:
- # Unsorted initially, and whenever a transform is added.
- self.transforms.sort()
- self.transforms.reverse()
- self.sorted = 1
+ # Unsorted initially, and whenever a transform is added
+ # (transforms may add other transforms).
+ self.transforms.sort(reverse=True)
+ self.sorted = True
priority, transform_class, pending, kwargs = self.transforms.pop()
transform = transform_class(self.document, startnode=pending)
transform.apply(**kwargs)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-24 15:08:16
|
Revision: 9263
http://sourceforge.net/p/docutils/code/9263
Author: milde
Date: 2022-11-24 15:08:12 +0000 (Thu, 24 Nov 2022)
Log Message:
-----------
Fix running of individual test (first batch).
After test refactoring, test scripts failed with ImportError
unless started from the "test root" ``docutils/test/``.
Prepend the "docutils root" to the Python library path
so we import the local `docutils` and `test` packages,
ignoring an eventually installed Docutils package.
Set executable bit where this was missing.
Also:
Use "pathlib" instead of "os.path" for self-documenting path manipulations.
Remove duplicate ``import unittest`` statements.
Modified Paths:
--------------
trunk/docutils/docs/dev/testing.txt
trunk/docutils/test/test_CLI.py
trunk/docutils/test/test_dependencies.py
trunk/docutils/test/test_language.py
trunk/docutils/test/test_parsers/test_get_parser_class.py
trunk/docutils/test/test_parsers/test_rst/test_block_quotes.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_parsing.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_math.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace_fr.py
trunk/docutils/test/test_writers/test_html4css1_template.py
Property Changed:
----------------
trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_parsing.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_math.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace_fr.py
Modified: trunk/docutils/docs/dev/testing.txt
===================================================================
--- trunk/docutils/docs/dev/testing.txt 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/docs/dev/testing.txt 2022-11-24 15:08:12 UTC (rev 9263)
@@ -42,9 +42,9 @@
The standard ``alltests.py`` test runner uses the standard library's
unittest_ framework.
- For the pytest_ test framework, from a shell run::
+ For the pytest_ test framework::
- pytest --quiet ./test
+ pytest --quiet .
.. _unittest: https://docs.python.org/3/library/unittest.html
.. _pytest: https://pypi.org/project/pytest/
Modified: trunk/docutils/test/test_CLI.py
===================================================================
--- trunk/docutils/test/test_CLI.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_CLI.py 2022-11-24 15:08:12 UTC (rev 9263)
@@ -19,16 +19,21 @@
import difflib
from io import StringIO
import locale
+from pathlib import Path
import os
import re
import sys
import unittest
-# import docutils
+if __name__ == '__main__':
+ # prepend the "docutils root" to the Python library path
+ # so we import the local `docutils` package.
+ sys.path.insert(0, str(Path(__file__).parents[1]))
+
from docutils import __main__, frontend
# DATA_ROOT is ./test/data/ from the docutils root
-DATA_ROOT = os.path.abspath(os.path.join(__file__, '..', 'data'))
+DATA_ROOT = Path(__file__).parent / 'data'
def print_mismatch(expected, output):
@@ -70,7 +75,7 @@
f'{frontend.OptionParser.default_error_encoding}:backslashreplace',
'utf-8:backslashreplace')
# compare to stored version
- docutils_txt = os.path.join(DATA_ROOT, 'help/docutils.txt')
+ docutils_txt = DATA_ROOT / 'help' / 'docutils.txt'
with open(docutils_txt, encoding='utf-8') as samplefile:
expected = samplefile.read()
if expected != output:
Modified: trunk/docutils/test/test_dependencies.py
===================================================================
--- trunk/docutils/test/test_dependencies.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_dependencies.py 2022-11-24 15:08:12 UTC (rev 9263)
@@ -8,10 +8,17 @@
Test module for the --record-dependencies option.
"""
+from io import StringIO
import os.path
+from pathlib import Path
+import sys
import unittest
-from io import StringIO
+if __name__ == '__main__':
+ # prepend the "docutils root" to the Python library path
+ # so we import the local `docutils` package.
+ sys.path.insert(0, str(Path(__file__).parents[1]))
+
import docutils.core
import docutils.utils
import docutils.io
Modified: trunk/docutils/test/test_language.py
===================================================================
--- trunk/docutils/test/test_language.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_language.py 2022-11-24 15:08:12 UTC (rev 9263)
@@ -12,10 +12,17 @@
that language.
"""
+from pathlib import Path
import os
import re
+import sys
import unittest
+if __name__ == '__main__':
+ # prepend the "docutils root" to the Python library path
+ # so we import the local `docutils` package.
+ sys.path.insert(0, str(Path(__file__).parent))
+
from docutils import frontend, languages, utils
from docutils.parsers.rst import languages as rst_languages
from docutils.parsers.rst.directives import _directive_registry # NoQA
Modified: trunk/docutils/test/test_parsers/test_get_parser_class.py
===================================================================
--- trunk/docutils/test/test_parsers/test_get_parser_class.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_parsers/test_get_parser_class.py 2022-11-24 15:08:12 UTC (rev 9263)
@@ -5,12 +5,19 @@
# Maintainer: doc...@li...
# Copyright: This module has been placed in the public domain.
-"""
-test get_parser_class
-"""
+"""test `docutils.parsers.get_parser_class()`"""
+from pathlib import Path
+import sys
import unittest
+if __name__ == '__main__':
+ # prepend the "docutils root" to the Python library path
+ # so we import the local `docutils` package.
+ sys.path.insert(0, str(Path(__file__).parents[2]))
+ # prepend the "test root", home of the `local_parser`
+ sys.path.insert(0, str(Path(__file__).parents[2]/'test'))
+
from docutils.core import publish_string
from docutils.parsers import get_parser_class
try:
@@ -30,7 +37,7 @@
get_parser_class('nope')
def test_local_parser(self):
- # requires local-parser.py in test directory (testroot)
+ # requires local-parser.py in "test root" directory
get_parser_class('local-parser')
# raises ImportError on failure
Modified: trunk/docutils/test/test_parsers/test_rst/test_block_quotes.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_block_quotes.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_parsers/test_rst/test_block_quotes.py 2022-11-24 15:08:12 UTC (rev 9263)
@@ -8,9 +8,14 @@
Tests for states.py.
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+if __name__ == '__main__':
+ # prepend the "docutils root" to the Python library path
+ # so we import the local `docutils` package.
+ sys.path.insert(0, str(Path(__file__).parents[3]))
from docutils.frontend import get_default_settings
from docutils.parsers.rst import Parser
@@ -396,5 +401,4 @@
if __name__ == '__main__':
- import unittest
unittest.main()
Index: trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py 2022-11-24 15:08:12 UTC (rev 9263)
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_directives/test__init__.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_admonitions.py 2022-11-24 15:08:12 UTC (rev 9263)
@@ -8,9 +8,14 @@
Tests for admonitions.py directives.
"""
+from pathlib import Path
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+if __name__ == '__main__':
+ # prepend the "docutils root" to the Python library path
+ # so we import the local `docutils` package.
+ sys.path.insert(0, str(Path(__file__).parents[4]))
from docutils.frontend import get_default_settings
from docutils.parsers.rst import Parser
Index: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py 2022-11-24 15:08:12 UTC (rev 9263)
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py 2022-11-24 15:08:12 UTC (rev 9263)
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_long.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py 2022-11-24 15:08:12 UTC (rev 9263)
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_none.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_parsing.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_parsing.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_parsing.py 2022-11-24 15:08:12 UTC (rev 9263)
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_directives/test_code_parsing.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/docutils/test/test_parsers/test_rst/test_directives/test_math.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_math.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_math.py 2022-11-24 15:08:12 UTC (rev 9263)
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_directives/test_math.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace_fr.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace_fr.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace_fr.py 2022-11-24 15:08:12 UTC (rev 9263)
Property changes on: trunk/docutils/test/test_parsers/test_rst/test_directives/test_replace_fr.py
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Modified: trunk/docutils/test/test_writers/test_html4css1_template.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1_template.py 2022-11-24 15:07:36 UTC (rev 9262)
+++ trunk/docutils/test/test_writers/test_html4css1_template.py 2022-11-24 15:08:12 UTC (rev 9263)
@@ -8,11 +8,16 @@
Tests for the HTML writer.
"""
+from pathlib import Path
import os
import platform
+import sys
import unittest
-from test import DocutilsTestSupport # NoQA: F401
+if __name__ == '__main__':
+ # prepend the "docutils root" to the Python library path
+ # so we import the local `docutils` package.
+ sys.path.insert(0, str(Path(__file__).parents[2]))
import docutils
from docutils.core import publish_string
@@ -262,5 +267,4 @@
]
if __name__ == '__main__':
- import unittest
unittest.main()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-24 20:28:05
|
Revision: 9270
http://sourceforge.net/p/docutils/code/9270
Author: milde
Date: 2022-11-24 20:28:03 +0000 (Thu, 24 Nov 2022)
Log Message:
-----------
Simplify/update utils.punctuation_chars and generating script.
Since Python 3.3 (PEP 393), all Python builds have support for the full range
of Unicode, and hence there are no longer "wide" and "narrow" builds.
Patch by Adam Turner.
Review/refactoring of ``generate_punctuation_chars.py`` including
fixup for r9253: add quote pair for Old Hungarian.
Modified Paths:
--------------
trunk/docutils/docutils/utils/punctuation_chars.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
Modified: trunk/docutils/docutils/utils/punctuation_chars.py
===================================================================
--- trunk/docutils/docutils/utils/punctuation_chars.py 2022-11-24 15:10:48 UTC (rev 9269)
+++ trunk/docutils/docutils/utils/punctuation_chars.py 2022-11-24 20:28:03 UTC (rev 9270)
@@ -13,8 +13,6 @@
# ``docutils/tools/dev/generate_punctuation_chars.py``.
# ::
-import sys
-
"""Docutils character category patterns.
Patterns for the implementation of the `inline markup recognition rules`_
@@ -86,14 +84,11 @@
'\ufe50-\ufe52\ufe54-\ufe58\ufe5f-\ufe61\ufe63\ufe68\ufe6a'
'\ufe6b\uff01-\uff03\uff05-\uff07\uff0a\uff0c-\uff0f\uff1a'
'\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65'
+ '\U00010100\U00010101\U0001039f\U000103d0\U00010857'
+ '\U0001091f\U0001093f\U00010a50-\U00010a58\U00010a7f'
+ '\U00010b39-\U00010b3f\U000110bb\U000110bc\U000110be-'
+ '\U000110c1\U00012470-\U00012473'
)
-if sys.maxunicode >= 0x10FFFF: # "wide" build
- delimiters += (
- '\U00010100\U00010101\U0001039f\U000103d0\U00010857'
- '\U0001091f\U0001093f\U00010a50-\U00010a58\U00010a7f'
- '\U00010b39-\U00010b3f\U000110bb\U000110bc\U000110be-'
- '\U000110c1\U00012470-\U00012473'
- )
closing_delimiters = r'\\.,;!?'
@@ -100,8 +95,13 @@
# Matching open/close quotes
# --------------------------
+# Matching open/close pairs are at the same position in
+# `punctuation_chars.openers` and `punctuation_chars.closers`.
+# Additional matches (due to different typographic conventions
+# in different languages) are stored in `quote_pairs`.
+
quote_pairs = {
- # open char: matching closing characters # usage example
+ # open char: matching closing characters # use case
'\xbb': '\xbb', # » » Swedish
'\u2018': '\u201a', # ‘ ‚ Albanian/Greek/Turkish
'\u2019': '\u2019', # ’ ’ Swedish
@@ -115,14 +115,7 @@
def match_chars(c1, c2):
- """Test whether `c1` and `c2` are a matching open/close character pair.
-
- Matching open/close pairs are at the same position in
- `punctuation_chars.openers` and `punctuation_chars.closers`.
- The pairing of open/close quotes is ambiguous due to different
- typographic conventions in different languages,
- so we test for additional matches stored in `quote_pairs`.
- """
+ """Test whether `c1` and `c2` are a matching open/close character pair."""
try:
i = openers.index(c1)
except ValueError: # c1 not in openers
Modified: trunk/docutils/tools/dev/generate_punctuation_chars.py
===================================================================
--- trunk/docutils/tools/dev/generate_punctuation_chars.py 2022-11-24 15:10:48 UTC (rev 9269)
+++ trunk/docutils/tools/dev/generate_punctuation_chars.py 2022-11-24 20:28:03 UTC (rev 9270)
@@ -55,8 +55,6 @@
# ``docutils/tools/dev/generate_punctuation_chars.py``.
# ::
-import sys
-
"""Docutils character category patterns.
Patterns for the implementation of the `inline markup recognition rules`_
@@ -86,8 +84,6 @@
%(openers)s
%(closers)s
%(delimiters)s
-if sys.maxunicode >= 0x10FFFF: # "wide" build
-%(delimiters_wide)s
closing_delimiters = r'\\.,;!?'
@@ -94,8 +90,13 @@
# Matching open/close quotes
# --------------------------
+# Matching open/close pairs are at the same position in
+# `punctuation_chars.openers` and `punctuation_chars.closers`.
+# Additional matches (due to different typographic conventions
+# in different languages) are stored in `quote_pairs`.
+
quote_pairs = {
- # open char: matching closing characters # usage example
+ # open char: matching closing characters # use case
'\xbb': '\xbb', # » » Swedish
'\u2018': '\u201a', # ‘ ‚ Albanian/Greek/Turkish
'\u2019': '\u2019', # ’ ’ Swedish
@@ -104,19 +105,14 @@
'\u201e': '\u201c\u201d', # „ “ German, „ ” Polish
'\u201d': '\u201d', # ” ” Swedish
'\u203a': '\u203a', # › › Swedish
+ '\u301d': '\u301f' # 〝 〟 CJK punctuation
+ '\u2e42': '\u201F', # ⹂ ‟ Old Hungarian (right to left)
}
"""Additional open/close quote pairs."""
def match_chars(c1, c2):
- """Test whether `c1` and `c2` are a matching open/close character pair.
-
- Matching open/close pairs are at the same position in
- `punctuation_chars.openers` and `punctuation_chars.closers`.
- The pairing of open/close quotes is ambiguous due to different
- typographic conventions in different languages,
- so we test for additional matches stored in `quote_pairs`.
- """
+ """Test whether `c1` and `c2` are a matching open/close character pair."""
try:
i = openers.index(c1)
except ValueError: # c1 not in openers
@@ -136,13 +132,12 @@
# ::
unicode_punctuation_categories = {
- # 'Pc': 'Connector', # not used in Docutils inline markup recognition
- 'Pd': 'Dash',
- 'Ps': 'Open',
- 'Pe': 'Close',
- 'Pi': 'Initial quote', # may behave like Ps or Pe depending on usage
- 'Pf': 'Final quote', # may behave like Ps or Pe depending on usage
- 'Po': 'Other'
+ 'Pd': 'dash',
+ 'Ps': 'open',
+ 'Pe': 'close',
+ 'Pi': 'initial quote', # may behave like Ps or Pe depending on language
+ 'Pf': 'final quote', # may behave like Ps or Pe depending on language
+ 'Po': 'other'
}
"""Unicode character categories for punctuation"""
@@ -191,30 +186,41 @@
# Rearange the lists to ensure matching characters at the same
# index position.
- # low quotation marks are also used as closers (e.g. in Greek)
- # move them to category Pi:
+ # LOW-9 QUOTATION MARKs are categorized as Ps (open) without matching Pe.
+ # They are used as initial quotes in German and final quotes in Greek.
+ # Remove them to get balanced Ps/Pe pairs.
ucharlists['Ps'].remove('‚') # 201A SINGLE LOW-9 QUOTATION MARK
ucharlists['Ps'].remove('„') # 201E DOUBLE LOW-9 QUOTATION MARK
- ucharlists['Pi'] += ['‚', '„']
+ #
+ # HIGH-REVERSED-9 QUOTATION MARKs are categorized as Pi (initial quote)
+ # without matching Pf (final quote).
+ # Insert the LOW-9 QUOTATION MARKs at the "empty slots" in Pf.
+ ucharlists['Pf'].insert(ucharlists['Pi'].index('‛'), '‚')
+ ucharlists['Pf'].insert(ucharlists['Pi'].index('‟'), '„')
- ucharlists['Pi'].remove('‛') # 201B … HIGH-REVERSED-9 QUOTATION MARK
- ucharlists['Pi'].remove('‟') # 201F … HIGH-REVERSED-9 QUOTATION MARK
- ucharlists['Pf'] += ['‛', '‟']
-
- # 301F LOW DOUBLE PRIME QUOTATION MARK misses the opening pendant:
- ucharlists['Ps'].insert(ucharlists['Pe'].index('\u301f'), '\u301d')
-
- # 2E42 DOUBLE LOW-REVERSED-9 QUOTATION MARK has no pair, and the only
- # usages identified thus far are in old hungarian, where it doesn't seem to
- # be used as a quoting character. Remove from openers (Ps) for now, for
- # simplicity.
+ # '⹂' 2E42 DOUBLE LOW-REVERSED-9 QUOTATION MARK
+ # is categorized as Ps (open) without matching Pe (close).
+ # It is used in Old Hungarian (written right to left) as quoting character
+ # matching DOUBLE HIGH-REVERSED-9 QUOTATION MARK.
# https://www.unicode.org/L2/L2012/12168r-n4268r-oldhungarian.pdf#page=26
- ucharlists['Ps'].remove('⹂')
+ #
+ # '⹂' 301F LOW DOUBLE PRIME QUOTATION MARK
+ # is categorized as Pe (close) without matching Ps (open).
+ # Move to the place matching 2E42:
+ ucharlists['Pe'].remove('\u301f')
+ ucharlists['Pe'].insert(ucharlists['Ps'].index('⹂'), '\u301f')
- # print(''.join(ucharlists['Ps']).encode('utf-8')
- # print(''.join(ucharlists['Pe']).encode('utf-8')
- # print(''.join(ucharlists['Pi']).encode('utf-8')
- # print(''.join(ucharlists['Pf']).encode('utf-8')
+ # check for balanced lists:
+ if len(ucharlists['Ps']) != len(ucharlists['Pe']):
+ print('Missmatch between "Open" and "Close" categories')
+ print(''.join(ucharlists['Ps']))
+ print(''.join(ucharlists['Pe']))
+ raise AssertionError
+ if len(ucharlists['Pi']) != len(ucharlists['Pf']):
+ print('Missmatch between "initial quote" and "final quote" categories')
+ print(''.join(ucharlists['Pi']))
+ print(''.join(ucharlists['Pf']))
+ raise AssertionError
# The Docutils character categories
# ---------------------------------
@@ -245,14 +251,6 @@
closing_delimiters)]
-def separate_wide_chars(s):
- """Return (s1,s2) with characters above 0xFFFF in s2"""
- maxunicode_narrow = 0xFFFF
- l1 = [ch for ch in s if ord(ch) <= maxunicode_narrow]
- l2 = [ch for ch in s if ord(ch) > maxunicode_narrow]
- return ''.join(l1), ''.join(l2)
-
-
def mark_intervals(s):
"""Return s with shortcut notation for runs of consecutive characters
@@ -281,6 +279,7 @@
def wrap_string(s, startstring="(", endstring=" )", wrap=71):
"""Line-wrap a unicode string literal definition."""
+ s = s.encode('unicode-escape').decode()
c = len(startstring)
left_indent = ' '*(c - len(startstring.lstrip(' ')))
line_start_string = f"\n {left_indent}'"
@@ -299,16 +298,21 @@
def print_differences(old, new, name):
"""List characters missing in old/new."""
if old != new:
- print('new %s:' % name)
- for c in new:
- if c not in old:
- print(' %04x'%ord(c), c, unicodedata.name(c))
- print('removed %s:' % name)
- for c in old:
- if c not in new:
- print(' %04x'%ord(c), unicodedata.name(c))
+ print(f'"{name}" changed')
+ if '-' in old or '-' in new:
+ print('-', old)
+ print('+', new)
+ else:
+ for c in new:
+ if c not in old:
+ print('+ %04x'%ord(c), c, unicodedata.name(c))
+ for c in old:
+ if c not in new:
+ print('- %04x'%ord(c), c, unicodedata.name(c))
+ return True
else:
- print('%s unchanged' % name)
+ print(f'"{name}" unchanged')
+ return False
# Output
@@ -322,7 +326,8 @@
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('-t', '--test', action="store_true",
help='test for changed character categories')
- parser.add_argument('-o', '--out')
+ parser.add_argument('--pairs', action="store_true",
+ help='show openers/closers in human readable form')
args = parser.parse_args()
# (Re)create character patterns
@@ -332,18 +337,11 @@
(o, c, d, cd) = character_category_patterns()
-# Characters in the upper plane require a "wide" build::
-
- o, o_wide = separate_wide_chars(o)
- c, c_wide = separate_wide_chars(c)
- d, d_wide = separate_wide_chars(d)
-
# delimiters: sort and use shortcut for intervals (saves ~150 characters)
# (`openers` and `closers` must be verbose and keep order
# because they are also used in `match_chars()`)::
d = d[:5] + mark_intervals(d[5:])
- d_wide = mark_intervals(d_wide)
# Test: compare module content with re-generated definitions
@@ -363,18 +361,29 @@
' module\n and a regeneration based on Unicode version %s:'
% unicodedata.unidata_version)
- print_differences(openers, o, 'openers')
- if o_wide:
- print('+ openers-wide = r"""%s"""' % o_wide.encode('utf-8'))
- print_differences(closers, c, 'closers')
- if c_wide:
- print('+ closers-wide = r"""%s"""' % c_wide.encode('utf-8'))
-
- print_differences(delimiters, d + d_wide, 'delimiters')
+ delta_o = print_differences(openers, o, 'openers')
+ delta_c = print_differences(closers, c, 'closers')
+ print_differences(delimiters, d, 'delimiters')
print_differences(closing_delimiters, cd, 'closing_delimiters')
+ if delta_o or delta_c:
+ print('\nChanges in "openers" and/or "closers",'
+ '\nCheck open/close pairs with option "--pairs"!')
sys.exit()
+
+# Print debugging output
+# ~~~~~~~~~~~~~~~~~~~~~~
+#
+# Print comparison of `openers` and `closers` in human readable form
+# to allow checking for matching pairs.
+
+ if args.pairs:
+ for o_i, c_i in zip(o, c):
+ print(o_i, c_i,
+ unicodedata.name(o_i), '\t', unicodedata.name(c_i))
+ sys.exit()
+
# Print re-generation of the punctuation_chars module
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
@@ -386,15 +395,9 @@
substitutions = {
'python_version': sys.version.split()[0],
'unidata_version': unicodedata.unidata_version,
- 'openers': wrap_string(o.encode('unicode-escape').decode(),
- startstring="openers = ("),
- 'closers': wrap_string(c.encode('unicode-escape').decode(),
- startstring="closers = ("),
- 'delimiters': wrap_string(d.encode('unicode-escape').decode(),
- startstring="delimiters = ("),
- 'delimiters_wide': wrap_string(
- d_wide.encode('unicode-escape').decode(),
- startstring=" delimiters += (")
+ 'openers': wrap_string(o, startstring="openers = ("),
+ 'closers': wrap_string(c, startstring="closers = ("),
+ 'delimiters': wrap_string(d, startstring="delimiters = ("),
}
print(module_template % substitutions, end='')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-24 20:29:02
|
Revision: 9272
http://sourceforge.net/p/docutils/code/9272
Author: milde
Date: 2022-11-24 20:28:40 +0000 (Thu, 24 Nov 2022)
Log Message:
-----------
Use "pathlib" to simplify path manipulations. No change to behaviour.
Rely on `utils.relative_path()` to normalize paths. No need to use
`os.normpath()` or `os.abspath()` separately.
`utils.DependencyList.add()` accepts `pathlib.Path` instances.
Small code cleanups.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/directives/tables.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/utils/math/math2html.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/docutils/writers/latex2e/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-24 20:28:12 UTC (rev 9271)
+++ trunk/docutils/HISTORY.txt 2022-11-24 20:28:40 UTC (rev 9272)
@@ -53,6 +53,7 @@
* docutils/utils/__init__.py
- New utility function ``xml_declaration()``.
+ - `utils.DependencyList.add()` accepts `pathlib.Path` instances.
* docutils/utils/math/latex2mathml.py
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-11-24 20:28:12 UTC (rev 9271)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2022-11-24 20:28:40 UTC (rev 9272)
@@ -6,9 +6,10 @@
__docformat__ = 'reStructuredText'
-import os.path
+from pathlib import Path
import re
import time
+
from docutils import io, nodes, statemachine, utils
from docutils.parsers.rst import Directive, convert_directive_function
from docutils.parsers.rst import directives, roles, states
@@ -45,8 +46,7 @@
'class': directives.class_option,
'name': directives.unchanged}
- standard_include_path = os.path.join(os.path.dirname(states.__file__),
- 'include')
+ standard_include_path = Path(states.__file__).parent / 'include'
def run(self):
"""Include a file as part of the content of this reST file.
@@ -58,11 +58,11 @@
raise self.warning('"%s" directive disabled.' % self.name)
source = self.state_machine.input_lines.source(
self.lineno - self.state_machine.input_offset - 1)
- source_dir = os.path.dirname(os.path.abspath(source))
path = directives.path(self.arguments[0])
if path.startswith('<') and path.endswith('>'):
- path = os.path.join(self.standard_include_path, path[1:-1])
- path = os.path.normpath(os.path.join(source_dir, path))
+ path = Path(self.standard_include_path) / path[1:-1]
+ else:
+ path = Path(source).parent / path
path = utils.relative_path(None, path)
encoding = self.options.get(
'encoding', self.state.document.settings.input_encoding)
@@ -243,11 +243,8 @@
raise self.error(
'The "file" and "url" options may not be simultaneously '
'specified for the "%s" directive.' % self.name)
- source_dir = os.path.dirname(
- os.path.abspath(self.state.document.current_source))
- path = os.path.normpath(os.path.join(source_dir,
- self.options['file']))
- path = utils.relative_path(None, path)
+ source_dir = Path(self.state.document.current_source).parent
+ path = utils.relative_path(None, source_dir/self.options['file'])
try:
raw_file = io.FileInput(source_path=path,
encoding=encoding,
Modified: trunk/docutils/docutils/parsers/rst/directives/tables.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/tables.py 2022-11-24 20:28:12 UTC (rev 9271)
+++ trunk/docutils/docutils/parsers/rst/directives/tables.py 2022-11-24 20:28:40 UTC (rev 9272)
@@ -10,7 +10,7 @@
import csv
-import os.path
+from pathlib import Path
import warnings
from docutils import io, nodes, statemachine, utils
@@ -310,10 +310,8 @@
nodes.literal_block(self.block_text, self.block_text),
line=self.lineno)
raise SystemMessagePropagation(error)
- source_dir = os.path.dirname(
- os.path.abspath(self.state.document.current_source))
- source = os.path.normpath(os.path.join(source_dir,
- self.options['file']))
+ source_dir = Path(self.state.document.current_source).parent
+ source = source_dir / self.options['file']
source = utils.relative_path(None, source)
try:
csv_file = io.FileInput(source_path=source,
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2022-11-24 20:28:12 UTC (rev 9271)
+++ trunk/docutils/docutils/utils/__init__.py 2022-11-24 20:28:40 UTC (rev 9272)
@@ -11,6 +11,7 @@
import sys
import os
import os.path
+from pathlib import PurePath
import re
import itertools
import warnings
@@ -478,7 +479,15 @@
"""
Build and return a path to `target`, relative to `source` (both files).
- If there is no common prefix, return the absolute path to `target`.
+ Differences to `os.relpath()`:
+
+ * Inverse argument order.
+ * `source` expects path to a FILE (while os.relpath expects a dir)!
+ (Add a "dummy" file name if `source` points to a directory.)
+ * Always use Posix path separator ("/") for the output.
+ * Use `os.sep` for parsing the input (ignored by `os.relpath()`).
+ * If there is no common prefix, return the absolute path to `target`.
+
"""
source_parts = os.path.abspath(source or type(target)('dummy_file')
).split(os.sep)
@@ -763,17 +772,20 @@
else:
self.file = open(output_file, 'w', encoding='utf-8')
- def add(self, *filenames):
+ def add(self, *paths):
"""
- If the dependency `filename` has not already been added,
- append it to self.list and print it to self.file if self.file
- is not None.
+ Append `path` to `self.list` unless it is already there.
+
+ Also append to `self.file` unless it is already there
+ or `self.file is `None`.
"""
- for filename in filenames:
- if filename not in self.list:
- self.list.append(filename)
+ for path in paths:
+ if isinstance(path, PurePath):
+ path = path.as_posix() # use '/' as separator
+ if path not in self.list:
+ self.list.append(path)
if self.file is not None:
- self.file.write(filename+'\n')
+ self.file.write(path+'\n')
def close(self):
"""
Modified: trunk/docutils/docutils/utils/math/math2html.py
===================================================================
--- trunk/docutils/docutils/utils/math/math2html.py 2022-11-24 20:28:12 UTC (rev 9271)
+++ trunk/docutils/docutils/utils/math/math2html.py 2022-11-24 20:28:40 UTC (rev 9272)
@@ -21,7 +21,7 @@
# Support for more math commands from the AMS "math-guide".
# 2.0 2021-12-31 Drop 2.7 compatibility code.
-import os.path
+import pathlib
import sys
import unicodedata
@@ -649,8 +649,8 @@
def usage(self):
"Show correct usage"
- Trace.error('Usage: ' + os.path.basename(Options.location)
- + ' [options] "input string"')
+ Trace.error(f'Usage: {pathlib.Path(Options.location).parent}'
+ ' [options] "input string"')
Trace.error('Convert input string with LaTeX math to MathML')
self.showoptions()
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-11-24 20:28:12 UTC (rev 9271)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-11-24 20:28:40 UTC (rev 9272)
@@ -21,7 +21,8 @@
import os
import os.path
import re
-from urllib.request import url2pathname
+from urllib.request import unquote as unquote_url
+from urllib.request import url2pathname # unquote and use local path sep
import warnings
import docutils
@@ -154,9 +155,8 @@
self.output = self.apply_template()
def apply_template(self):
- with open(self.document.settings.template, 'r',
- encoding='utf-8') as template_file:
- template = template_file.read()
+ with open(self.document.settings.template, encoding='utf-8') as fp:
+ template = fp.read()
subs = self.interpolation_dict()
return template % subs
@@ -809,7 +809,7 @@
self.body.append('\n</pre>\n')
def visit_document(self, node):
- title = (node.get('title', '') or os.path.basename(node['source'])
+ title = (node.get('title') or os.path.basename(node['source'])
or 'untitled Docutils document')
self.head.append(f'<title>{self.encode(title)}</title>\n')
@@ -1062,8 +1062,7 @@
self.document.reporter.error('Cannot embed image %r: %s'
% (uri, err.strerror))
else:
- self.settings.record_dependencies.add(
- uri.replace('\\', '/'))
+ self.settings.record_dependencies.add(unquote_url(uri))
# TODO: insert SVG as-is?
# if mimetype == 'image/svg+xml':
# read/parse, apply arguments,
Modified: trunk/docutils/docutils/writers/html5_polyglot/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-11-24 20:28:12 UTC (rev 9271)
+++ trunk/docutils/docutils/writers/html5_polyglot/__init__.py 2022-11-24 20:28:40 UTC (rev 9272)
@@ -27,7 +27,7 @@
__docformat__ = 'reStructuredText'
import mimetypes
-import os.path
+from pathlib import Path
from docutils import frontend, nodes
from docutils.writers import _html_base
@@ -39,9 +39,8 @@
"""Formats this writer supports."""
default_stylesheets = ['minimal.css', 'plain.css']
- default_stylesheet_dirs = ['.', os.path.abspath(os.path.dirname(__file__))]
- default_template = os.path.join(
- os.path.dirname(os.path.abspath(__file__)), 'template.txt')
+ default_stylesheet_dirs = ['.', str(Path(__file__).parent)]
+ default_template = Path(__file__).parent / 'template.txt'
# use a copy of the parent spec with some modifications
settings_spec = frontend.filter_settings_spec(
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2022-11-24 20:28:12 UTC (rev 9271)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2022-11-24 20:28:40 UTC (rev 9272)
@@ -12,12 +12,11 @@
#
# convention deactivate code by two # i.e. ##.
-import os
+from pathlib import Path
import re
import string
from urllib.request import url2pathname
import warnings
-
try:
import roman
except ImportError:
@@ -27,7 +26,9 @@
from docutils.transforms import writer_aux
from docutils.utils.math import pick_math_environment, unichar2tex
+LATEX_WRITER_DIR = Path(__file__).parent
+
class Writer(writers.Writer):
supported = ('latex', 'latex2e')
@@ -34,7 +35,7 @@
"""Formats this writer supports."""
default_template = 'default.tex'
- default_template_path = os.path.dirname(os.path.abspath(__file__))
+ default_template_path = LATEX_WRITER_DIR
default_preamble = ('% PDF Standard Fonts\n'
'\\usepackage{mathptmx} % Times\n'
'\\usepackage[scaled=.90]{helvet}\n'
@@ -268,15 +269,10 @@
for part in self.visitor_attributes:
setattr(self, part, getattr(visitor, part))
# get template string from file
- templatepath = self.document.settings.template
- try:
- with open(templatepath, encoding='utf-8') as fp:
- template = fp.read()
- except IOError:
- templatepath = os.path.join(self.default_template_path,
- templatepath)
- with open(templatepath, encoding='utf-8') as fp:
- template = fp.read()
+ templatepath = Path(self.document.settings.template)
+ if not templatepath.exists():
+ templatepath = self.default_template_path / templatepath
+ template = templatepath.read_text(encoding='utf-8')
# fill template
self.assemble_parts() # create dictionary of parts
self.output = string.Template(template).substitute(self.parts)
@@ -594,9 +590,7 @@
return ''.join(block).rstrip()
-_docutils_sty = os.path.join(os.path.dirname(os.path.abspath(__file__)),
- 'docutils.sty')
-with open(_docutils_sty, encoding='utf-8') as fp:
+with open(LATEX_WRITER_DIR/'docutils.sty', encoding='utf-8') as fp:
for line in fp:
line = line.strip('% \n')
if not line.endswith('::'):
@@ -1395,30 +1389,31 @@
def stylesheet_call(self, path):
"""Return code to reference or embed stylesheet file `path`"""
+ path = Path(path)
# is it a package (no extension or *.sty) or "normal" tex code:
- (base, ext) = os.path.splitext(path)
- is_package = ext in ['.sty', '']
+ is_package = path.suffix in ('.sty', '')
# Embed content of style file:
if self.settings.embed_stylesheet:
if is_package:
- path = base + '.sty' # ensure extension
+ path = path.with_suffix('.sty') # ensure extension
try:
- with open(path, encoding='utf-8') as f:
- content = f.read()
+ content = path.read_text(encoding='utf-8')
except OSError as err:
- msg = f'Cannot embed stylesheet:\n {err}'
+ msg = f'Cannot embed stylesheet:\n {err}'.replace('\\\\', '/')
self.document.reporter.error(msg)
return '% ' + msg.replace('\n', '\n% ')
else:
self.settings.record_dependencies.add(path)
if is_package:
- content = '\n'.join([r'\makeatletter',
- content,
- r'\makeatother'])
- return '%% embedded stylesheet: %s\n%s' % (path, content)
+ # allow '@' in macro names:
+ content = (r'\makeatletter'
+ f'\n{content}\n'
+ r'\makeatother')
+ return (f'% embedded stylesheet: {path.as_posix()}\n'
+ f'{content}')
# Link to style file:
if is_package:
- path = base # drop extension
+ path = path.parent / path.stem # drop extension
cmd = r'\usepackage{%s}'
else:
cmd = r'\input{%s}'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-25 23:03:44
|
Revision: 9276
http://sourceforge.net/p/docutils/code/9276
Author: milde
Date: 2022-11-25 23:03:41 +0000 (Fri, 25 Nov 2022)
Log Message:
-----------
Update FAQ, add TODO-list example.
Modified Paths:
--------------
trunk/docutils/FAQ.txt
Added Paths:
-----------
trunk/docutils/docs/user/todo-lists.txt
Modified: trunk/docutils/FAQ.txt
===================================================================
--- trunk/docutils/FAQ.txt 2022-11-25 23:03:32 UTC (rev 9275)
+++ trunk/docutils/FAQ.txt 2022-11-25 23:03:41 UTC (rev 9276)
@@ -1,10 +1,6 @@
-.. -*- coding: utf-8 -*-
-
-
.. NOTE TO MAINTAINERS: Please add new questions to the end of their
sections, so section/question numbers remain stable.
-
===========================================
Docutils FAQ (Frequently Asked Questions)
===========================================
@@ -19,8 +15,8 @@
This is a work in progress. If you are reading a local copy, the
-`master copy`_ might be newer. This document uses are relative links;
-if they don't work, please use the `master copy`_.
+`master copy`_ might be newer. This document uses relative links;
+if they don't work, please use the master copy.
Please feel free to ask questions and/or provide answers; send email
to the `Docutils-users`_ mailing list. Project members should feel
@@ -215,13 +211,13 @@
What's the standard filename extension for a reStructuredText file?
-------------------------------------------------------------------
-It's ".txt". Some people would like to use ".rest" or ".rst" or
-".restx", but why bother? ReStructuredText source files are meant to
-be readable as plaintext, and most operating systems already associate
-".txt" with text files. Using a specialized filename extension would
-require that users alter their OS settings, which is something that
-many users will not be willing or able to do.
+It's ".txt". ReStructuredText source files are meant to be readable as
+plaintext, and most operating systems already associate ".txt" with text
+files.
+That said, we see an increasing number of projects settling on
+the extension ".rst".
+
Also see `What's the official MIME type for reStructuredText data?`_
@@ -275,10 +271,10 @@
For example, say you want an em-dash (XML character entity —,
Unicode character U+2014) in your document: use a real em-dash.
-Insert concrete characters (e.g. type a *real* em-dash) into your
+Insert literal characters (e.g. type a *real* em-dash) into your
input file, using whatever encoding suits your application, and tell
Docutils the input encoding. Docutils uses Unicode internally, so the
-em-dash character is a real em-dash internally.
+em-dash character is U+2014 internally.
Emacs users should refer to the `Emacs Support for reStructuredText`__
document. Tips for other editors are welcome.
@@ -286,7 +282,8 @@
__ tools/editors/emacs/README.html
ReStructuredText has no character entity subsystem; it doesn't know
-anything about XML charents. To Docutils, "—" in input text is
+anything about XML character entities.
+To Docutils, "—" in input text is
7 discrete characters; no interpretation happens. When writing HTML,
the "&" is converted to "&", so in the raw output you'd see
"&mdash;". There's no difference in interpretation for text
@@ -294,27 +291,20 @@
character entity interpretation in either case.
If you can't use a Unicode-compatible encoding and must rely on 7-bit
-ASCII, there is a workaround. New in Docutils 0.3.10 is a set of
-`Standard Substitution Definition Sets`_, which provide equivalents of
-XML & HTML character entity sets as substitution definitions. For
-example, the Japanese yen currency symbol can be used as follows::
+ASCII, there is a workaround:
+`Standard Substitution Definition Sets`_ provide equivalents of
+XML & HTML character entity sets as substitution definitions. [#]_
+For example, the Japanese yen currency symbol can be used as follows::
.. include:: <xhtml1-lat1.txt>
|yen| 600 for a complete meal? That's cheap!
-Thanks to David Priest for the original idea.
+.. [#] Thanks to David Priest for the original idea.
-If you insist on using XML-style charents, you'll have to implement a
-pre-processing system to convert to UTF-8 or something. That
-introduces complications though; you can no longer *write* about
-charents naturally; instead of writing "—" you'd have to write
-"&mdash;".
+You can create custom `substitution definitions`_ in your document
+using the "unicode_" directive, e.g.::
-For the common case of long dashes, you might also want to insert the
-following substitution definitions into your document (both of them are
-using the "unicode_" directive)::
-
.. |--| unicode:: U+2013 .. en dash
.. |---| unicode:: U+2014 .. em dash, trimming surrounding whitespace
:trim:
@@ -331,12 +321,9 @@
reStructuredText parser to trim the spaces.
.. _Standard Substitution Definition Sets: docs/ref/rst/definitions.html
+.. _substitution definitions: docs/ref/rst/restructuredtext.html
+ #substitution-definitions
.. _unicode: docs/ref/rst/directives.html#unicode-character-codes
-.. _are available: https://docutils.sourceforge.io/tmp/charents/
-.. _tarball: https://docutils.sourceforge.io/tmp/charents.tgz
-.. _description and instructions:
- https://docutils.sourceforge.io/tmp/charents/README.html
-.. _to-do list: docs/dev/todo.html
How can I generate backticks using a Scandinavian keyboard?
@@ -541,8 +528,9 @@
How can I include mathematical equations in documents?
------------------------------------------------------
-Use the `math directive`_ and `math role`_, available since Docutils 0.8.
+Use `LaTeX math syntax`_ in a `math directive`_ or `math role`_.
+.. _LaTeX math syntax: docs/ref/rst/mathematics.html
.. _math directive: docs/ref/rst/directives.html#math
.. _math role: docs/ref/rst/roles.html#math
@@ -877,6 +865,46 @@
.. [#] The "x-" prefix means it's an unregistered MIME type.
+How can I mark up a TODO list?
+------------------------------
+
+You may use a field list with class argument and some CSS styling.
+For an example see `Docutils TODO lists`_ and its source todo-lists.txt_.
+
+.. _Docutils TODO lists: docs/user/todo-lists.html
+.. _todo-lists.txt: docs/user/todo-lists.txt
+
+
+How can I specify an image grid?
+--------------------------------
+
+In order to arrange images (or other content) in a grid,
+a borderless `list table`_ can be used. For example::
+
+ .. list-table::
+ :class: borderless
+
+ * - .. image:: rst/images/title-scaling.svg
+ - .. image:: rst/images/biohazard.svg
+ * - .. image:: rst/images/biohazard.svg
+ - .. image:: rst/images/biohazard.svg
+
+Use figures, if you want also captions::
+
+ .. list-table::
+ :class: borderless
+
+ * - .. figure:: rst/images/title-scaling.svg
+
+ Figure 1/1
+
+ - .. figure:: rst/images/biohazard.svg
+
+ Figure 1/2
+
+.. _list table: docs/ref/rst/directives.html#list-table
+
+
HTML Writer
===========
@@ -883,16 +911,20 @@
What is the status of the HTML Writer?
--------------------------------------
-The default HTML Writer module, ``docutils/writers/html4css1.py``, is
+The default HTML Writer module, `html4css1`_, is
a proof-of-concept reference implementation. While it is a complete
implementation, some aspects of the HTML it produces may be outdated or
incompatible with older browsers or specialized applications (such as
web templating).
+The `html5 writer`_ generates semantic HTML output compatible with HTML5.
For the full selection see `Docutils HTML writers`_
+.. _html4css1: docs/user/html.html#html4css1
+.. _HTML5 writer: docs/user/html.html#html5
.. _Docutils HTML writers: docs/user/html.html
+
What browsers are supported?
----------------------------
@@ -907,113 +939,119 @@
Unexpected results from tools/rst2html.py: H1, H1 instead of H1, H2. Why?
--------------------------------------------------------------------------
-Here's the question in full:
+This only regards output from the `html4css1`_ writer.
+The `html5 writer`_ uses H1, H2, ...
- I have this text::
+.. class:: details
- Heading 1
- =========
+details
+ Here's the question in full:
- All my life, I wanted to be H1.
+ I have this text::
- Heading 1.1
- -----------
+ Heading 1
+ =========
- But along came H1, and so shouldn't I be H2?
- No! I'm H1!
+ All my life, I wanted to be H1.
- Heading 1.1.1
- *************
+ Heading 1.1
+ -----------
- Yeah, imagine me, I'm stuck at H3! No?!?
+ But along came H1, and so shouldn't I be H2?
+ No! I'm H1!
- When I run it through tools/rst2html.py, I get unexpected results
- (below). I was expecting H1, H2, then H3; instead, I get H1, H1,
- H2::
+ Heading 1.1.1
+ *************
- ...
- <html lang="en">
- <head>
- ...
- <title>Heading 1</title>
- </head>
- <body>
- <div class="document" id="heading-1">
- <h1 class="title">Heading 1</h1> <-- first H1
- <p>All my life, I wanted to be H1.</p>
- <div class="section" id="heading-1-1">
- <h1><a name="heading-1-1">Heading 1.1</a></h1> <-- H1
- <p>But along came H1, and so now I must be H2.</p>
- <div class="section" id="heading-1-1-1">
- <h2><a name="heading-1-1-1">Heading 1.1.1</a></h2>
- <p>Yeah, imagine me, I'm stuck at H3!</p>
- ...
+ Yeah, imagine me, I'm stuck at H3! No?!?
- What gives?
+ When I run it through tools/rst2html.py, I get unexpected results
+ (below). I was expecting H1, H2, then H3; instead, I get H1, H1,
+ H2::
-Check the "class" attribute on the H1 tags, and you will see a
-difference. The first H1 is actually ``<h1 class="title">``; this is
-the document title, and the default stylesheet renders it centered.
-There can also be an ``<h2 class="subtitle">`` for the document
-subtitle.
+ ...
+ <html lang="en">
+ <head>
+ ...
+ <title>Heading 1</title>
+ </head>
+ <body>
+ <div class="document" id="heading-1">
+ <h1 class="title">Heading 1</h1> <-- first H1
+ <p>All my life, I wanted to be H1.</p>
+ <div class="section" id="heading-1-1">
+ <h1><a name="heading-1-1">Heading 1.1</a></h1> <-- H1
+ <p>But along came H1, and so now I must be H2.</p>
+ <div class="section" id="heading-1-1-1">
+ <h2><a name="heading-1-1-1">Heading 1.1.1</a></h2>
+ <p>Yeah, imagine me, I'm stuck at H3!</p>
+ ...
-If there's only one highest-level section title at the beginning of a
-document, it is treated specially, as the document title. (Similarly, a
-lone second-highest-level section title may become the document
-subtitle.) See `How can I indicate the document title? Subtitle?`_ for
-details. Rather than use a plain H1 for the document title, we use ``<h1
-class="title">`` so that we can use H1 again within the document. Why
-do we do this? HTML only has H1-H6, so by making H1 do double duty, we
-effectively reserve these tags to provide 6 levels of heading beyond the
-single document title.
+ What gives?
-With "html4css1", HTML is being used for dumb formatting for nothing
-but final display. A stylesheet *is required*, and one is provided;
-see `Docutils HTML writers`_. Of course, you're
-welcome to roll your own. The default stylesheet provides rules to
-format ``<h1 class="title">`` and ``<h2 class="subtitle">``
-differently from ordinary ``<h1>`` and ``<h2>``::
+ Check the "class" attribute on the H1 tags, and you will see a
+ difference. The first H1 is actually ``<h1 class="title">``; this is
+ the document title, and the default stylesheet renders it centered.
+ There can also be an ``<h2 class="subtitle">`` for the document
+ subtitle.
- h1.title {
- text-align: center }
+ If there's only one highest-level section title at the beginning of a
+ document, it is treated specially, as the document title. (Similarly, a
+ lone second-highest-level section title may become the document
+ subtitle.) See `How can I indicate the document title? Subtitle?`_ for
+ details. Rather than use a plain H1 for the document title, we use ``<h1
+ class="title">`` so that we can use H1 again within the document. Why
+ do we do this? HTML only has H1-H6, so by making H1 do double duty, we
+ effectively reserve these tags to provide 6 levels of heading beyond the
+ single document title.
- h2.subtitle {
- text-align: center }
+ With "html4css1", HTML is being used for dumb formatting for nothing
+ but final display. A stylesheet *is required*, and one is provided;
+ see `Docutils HTML writers`_. Of course, you're
+ welcome to roll your own. The default stylesheet provides rules to
+ format ``<h1 class="title">`` and ``<h2 class="subtitle">``
+ differently from ordinary ``<h1>`` and ``<h2>``::
-If you don't want the top section heading to be interpreted as a
-title at all, disable the `doctitle_xform`_ setting
-(``--no-doc-title`` option). This will interpret your document
-differently from the standard settings, which might not be a good
-idea. If you don't like the reuse of the H1 in the HTML output, you
-can tweak the `initial_header_level`_ setting
-(``--initial-header-level`` option) -- but unless you match its value
-to your specific document, you might end up with bad HTML (e.g. H3
-without H2).
+ h1.title {
+ text-align: center }
-.. _doctitle_xform: docs/user/config.html#doctitle-xform
-.. _initial_header_level: docs/user/config.html#initial-header-level
+ h2.subtitle {
+ text-align: center }
-(Thanks to Mark McEahern for the question and much of the answer.)
+ If you don't want the top section heading to be interpreted as a
+ title at all, disable the `doctitle_xform`_ setting
+ (``--no-doc-title`` option). This will interpret your document
+ differently from the standard settings, which might not be a good
+ idea. If you don't like the reuse of the H1 in the HTML output, you
+ can tweak the `initial_header_level`_ setting
+ (``--initial-header-level`` option) -- but unless you match its value
+ to your specific document, you might end up with bad HTML (e.g. H3
+ without H2).
-.. note:: For the html5 writer, `initial_header_level`_ defaults to
- ``2`` because this is what the `HTML5 standard`__ expects as
- start value for headings nested in <section> elements.
+ .. _doctitle_xform: docs/user/config.html#doctitle-xform
+ .. _initial_header_level: docs/user/config.html#initial-header-level
- .. Sectioning content elements are always considered subsections of
- their nearest ancestor *sectioning root* [#]_ or their nearest
- ancestor element of *sectioning content* [#]_, whichever is nearest,
- [...]
+ (Thanks to Mark McEahern for the question and much of the answer.)
- .. [#] <blockquote>, <body>, <details>, <dialog>, <fieldset>,
- <figure>, <td>
- .. [#] <article>, <aside>, <nav>, <section>
+ .. note:: For the `html5 writer`_, `initial_header_level`_ defaults to
+ ``2`` because this is what the `HTML5 standard`__ expects as
+ start value for headings nested in <section> elements.
- I.e., a top-level <section> is a subsection of <body>.
+ .. Sectioning content elements are always considered subsections of
+ their nearest ancestor *sectioning root* [#]_ or their nearest
+ ancestor element of *sectioning content* [#]_, whichever is nearest,
+ [...]
- __ https://www.w3.org/TR/html53/sections.html#headings-and-sections
+ .. [#] <blockquote>, <body>, <details>, <dialog>, <fieldset>,
+ <figure>, <td>
+ .. [#] <article>, <aside>, <nav>, <section>
+ I.e., a top-level <section> is a subsection of <body>.
+ __ https://www.w3.org/TR/html53/sections.html#headings-and-sections
+
+
How are lists formatted in HTML?
--------------------------------
@@ -1190,27 +1228,30 @@
Version 2.0 of Ed Loper's `Epydoc <http://epydoc.sourceforge.net/>`_
supports reStructuredText-format docstrings for HTML output. Docutils
-0.3 or newer is required. Development of a Docutils-specific
-auto-documentation tool will continue. Epydoc works by importing
-Python modules to be documented, whereas the Docutils-specific tool,
-described above, will parse modules without importing them (as with
-`HappyDoc <http://happydoc.sourceforge.net/>`_, which doesn't support
-reStructuredText).
+0.3 or newer is required.
-The advantages of parsing over importing are security and flexibility;
-the disadvantage is complexity/difficulty.
+Development of a Docutils-specific auto-documentation tool is suspended.
-* Security: untrusted code that shouldn't be executed can be parsed;
- importing a module executes its top-level code.
-* Flexibility: comments and unofficial docstrings (those not supported
- by Python syntax) can only be processed by parsing.
-* Complexity/difficulty: it's a lot harder to parse and analyze a
- module than it is to ``import`` and analyze one.
+.. Epydoc works by importing
+ Python modules to be documented, whereas the Docutils-specific tool,
+ described above, will parse modules without importing them (as with
+ `HappyDoc <http://happydoc.sourceforge.net/>`_, which doesn't support
+ reStructuredText).
-For more details, please see "Docstring Extraction Rules"
-in :PEP:`258`, item 3 ("How").
+ The advantages of parsing over importing are security and flexibility;
+ the disadvantage is complexity/difficulty.
+ * Security: untrusted code that shouldn't be executed can be parsed;
+ importing a module executes its top-level code.
+ * Flexibility: comments and unofficial docstrings (those not supported
+ by Python syntax) can only be processed by parsing.
+ * Complexity/difficulty: it's a lot harder to parse and analyze a
+ module than it is to ``import`` and analyze one.
+ For more details, please see "Docstring Extraction Rules"
+ in :PEP:`258`, item 3 ("How").
+
+
Miscellaneous
=============
Added: trunk/docutils/docs/user/todo-lists.txt
===================================================================
--- trunk/docutils/docs/user/todo-lists.txt (rev 0)
+++ trunk/docutils/docs/user/todo-lists.txt 2022-11-25 23:03:41 UTC (rev 9276)
@@ -0,0 +1,154 @@
+.. include:: ../header.txt
+
+===================
+Docutils TODO lists
+===================
+
+TODO lists allow you to create a list of items with checkboxes.
+In `extended Markdown`_, they are called `task lists`.
+
+Checkbox variants
+=================
+
+[x] ASCII-art checkbox.
+
+[ ] ASCII space character and NBSP are smaller than the x.
+
+[ ] The "figure space" has the correct width but is not easy to type.
+
+You may define substitutions for ballot box and checked ballot box or
+other suitable Unicode characters:
+
+.. |-| unicode:: U+2610
+.. |x| unicode:: U+2611
+.. |y| unicode:: U+1F5F9
+
+|-| U+2610 BALLOT BOX
+
+|x| U+2611 BALLOT BOX WITH CHECK
+
+|y| U+1F5F9 BALLOT BOX WITH BOLD CHECK
+
+List Markup
+===========
+
+Paragraphs
+----------
+
+|x| Simple *paragraphs* are easy for small lists with short values
+
+|-| but not well suited for complex TODO items.
+
+Line Blocks
+-----------
+
+| |x| Line blocks are rendered as "unstyled" lists.
+| |y| They don't need additional styling.
+| |-| However, you cannot nest block elements.
+
+
+Description Lists
+-----------------
+
+.. class:: description
+
+|x|
+ A *description list* works out of the box in HTML5 and XeTeX.
+
+|-|
+ It looks suboptimal in the rST source (definition list with class
+ value "description").
+
+[x]
+ Lists may use ASCII-art or substitutions.
+
+[ ]
+ All list markup variants require special styling based on a
+ preceding class__ directive.
+
+__ https://docutils.sourceforge.io/docs/ref/rst/directives.html#class
+
+Bullet Lists
+------------
+
+.. class:: todo
+
+- |x| bullet lists (similar to the Markdown_ for `task
+ lists`) can be styled accordingly.
+- |-| They don't look good in the rST source.
+- [x] Lists may use ASCII-art or substitutions.
+- [ ] The "figure space" has the correct width.
+
+- |x| Another idea: use bullet lists with ``+`` and ``-`` markers.
+
+ + Clean and simple markup in the source.
+
+ - A new marker character starts a new list :-(
+
+ - Requires change to the writer: Pass the "bullet" attribute to
+ the output document (use `HTML5 "data-" attriibutes`__?).
+
+__ https://html.spec.whatwg.org/#embedding-custom-non-visible-data-with-the-data-*-attributes
+
+Field Lists
+-----------
+
+.. class:: todo
+
+:|x|: Compile this example with ``rst2html5.py``,
+:|y|: compare markup variants,
+:|-|: select the best.
+
+.. class:: todo monospace
+
+:[x]: ASCII-art checkbox.
+:[ ]: The "figure space" has the correct width.
+:[ ]: CSS styling can switch to monospace fonts for the ASCII-art boxes,
+ so an ASCII space character can be used.
+
+.. class:: todo monospace brackets
+
+:x: ASCII-art checkbox - brackets added by CSS.
+: : Simple rST source, easy typing.
+
+.. class:: todo monospace framed
+
+:x: checkbox border added by CSS.
+: : Simple rST source, easy typing.
+
+I recommend a field list with class argument and some CSS styling.
+
+
+.. _Markdown: https://www.markdownguide.org
+.. _extended Markdown: https://www.markdownguide.org/extended-syntax/
+
+
+.. ! The follwing CSS rules are included here as raw HTML to keep the
+ example compact. They compromise the HTML validity, as styling is not
+ allowed in the document body.
+ For production use, place CSS styling rules in a custom style sheet.
+
+.. raw:: html
+
+ <style type="text/css"><!--
+ ul.todo {list-style-type: none;
+ padding-left: 0;}
+ ul.todo > li > p {padding-left: 1.2em;
+ text-indent: -1.2em;}
+
+ dl.todo > dt > .colon {display: none}
+ dl.todo > dd {margin-left: 2.5em;}
+
+ dl.monospace > dt {font-family: monospace;}
+
+ dl.brackets > dt:before {content: '[';}
+ dl.brackets > dt:after {content: ']';}
+
+ dl.framed > dt {border: solid;
+ border-width: thin;
+ padding: 0 0.2em;
+ margin-top: 0.2em;
+ line-height: 0.9;
+ }
+
+ --></style>
Property changes on: trunk/docutils/docs/user/todo-lists.txt
___________________________________________________________________
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-28 23:55:30
|
Revision: 9280
http://sourceforge.net/p/docutils/code/9280
Author: milde
Date: 2022-11-28 23:55:25 +0000 (Mon, 28 Nov 2022)
Log Message:
-----------
Add navigation links to the documentation in the "Docutils root" directory.
Modified Paths:
--------------
trunk/docutils/BUGS.txt
trunk/docutils/COPYING.txt
trunk/docutils/FAQ.txt
trunk/docutils/HISTORY.txt
trunk/docutils/README.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/THANKS.txt
Added Paths:
-----------
trunk/docutils/docs/header0.txt
Modified: trunk/docutils/BUGS.txt
===================================================================
--- trunk/docutils/BUGS.txt 2022-11-28 23:55:13 UTC (rev 9279)
+++ trunk/docutils/BUGS.txt 2022-11-28 23:55:25 UTC (rev 9280)
@@ -1,3 +1,5 @@
+.. include:: docs/header0.txt
+
================
Docutils_ Bugs
================
Modified: trunk/docutils/COPYING.txt
===================================================================
--- trunk/docutils/COPYING.txt 2022-11-28 23:55:13 UTC (rev 9279)
+++ trunk/docutils/COPYING.txt 2022-11-28 23:55:25 UTC (rev 9280)
@@ -1,3 +1,5 @@
+.. include:: docs/header0.txt
+
==================
Copying Docutils
==================
Modified: trunk/docutils/FAQ.txt
===================================================================
--- trunk/docutils/FAQ.txt 2022-11-28 23:55:13 UTC (rev 9279)
+++ trunk/docutils/FAQ.txt 2022-11-28 23:55:25 UTC (rev 9280)
@@ -1,3 +1,5 @@
+.. include:: docs/header0.txt
+
.. NOTE TO MAINTAINERS: Please add new questions to the end of their
sections, so section/question numbers remain stable.
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-28 23:55:13 UTC (rev 9279)
+++ trunk/docutils/HISTORY.txt 2022-11-28 23:55:25 UTC (rev 9280)
@@ -1,3 +1,5 @@
+.. include:: docs/header0.txt
+
==================
Docutils History
==================
Modified: trunk/docutils/README.txt
===================================================================
--- trunk/docutils/README.txt 2022-11-28 23:55:13 UTC (rev 9279)
+++ trunk/docutils/README.txt 2022-11-28 23:55:25 UTC (rev 9280)
@@ -1,3 +1,5 @@
+.. include:: docs/header0.txt
+
==============================
README: Docutils 0.19.1b.dev
==============================
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2022-11-28 23:55:13 UTC (rev 9279)
+++ trunk/docutils/RELEASE-NOTES.txt 2022-11-28 23:55:25 UTC (rev 9280)
@@ -1,4 +1,4 @@
-.. -*- coding: utf-8 -*-
+.. include:: docs/header0.txt
========================
Docutils Release Notes
Modified: trunk/docutils/THANKS.txt
===================================================================
--- trunk/docutils/THANKS.txt 2022-11-28 23:55:13 UTC (rev 9279)
+++ trunk/docutils/THANKS.txt 2022-11-28 23:55:25 UTC (rev 9280)
@@ -1,4 +1,4 @@
-.. -*- coding: utf-8 -*-
+.. include:: docs/header0.txt
Acknowledgements
================
Added: trunk/docutils/docs/header0.txt
===================================================================
--- trunk/docutils/docs/header0.txt (rev 0)
+++ trunk/docutils/docs/header0.txt 2022-11-28 23:55:25 UTC (rev 9280)
@@ -0,0 +1,14 @@
+.. Minimal menu bar for inclusion in documentation sources
+ in the ``docutils/`` parent diretory.
+
+ Attention: this is not a standalone document.
+
+.. header::
+ Docutils__ | Overview__ | About__ | Users__ | Reference__ | Developers__
+
+ __ https://docutils.sourceforge.io
+ __ docs/index.html
+ __ docs/index.html#project-fundamentals
+ __ docs/index.html#user
+ __ docs/index.html#ref
+ __ docs/index.html#howto
Property changes on: trunk/docutils/docs/header0.txt
___________________________________________________________________
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
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-28 23:55:50
|
Revision: 9282
http://sourceforge.net/p/docutils/code/9282
Author: milde
Date: 2022-11-28 23:55:46 +0000 (Mon, 28 Nov 2022)
Log Message:
-----------
Wrap definition lists with "details" class argument in a <div>
with the "id" and "class" values of the list node.
Enables setting an "anchor" or a "class" value for "detail disclosure elments".
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/functional/input/data/html5-features.txt
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-11-28 23:55:35 UTC (rev 9281)
+++ trunk/docutils/HISTORY.txt 2022-11-28 23:55:46 UTC (rev 9282)
@@ -65,6 +65,9 @@
Changes to the HTML output (no space character before closing tag of
XML declaration, order of metadata elements)
don't affect the HTML semantics, styling, and rendering.
+
+ - Wrap definition lists with "details" class argument in a <div>
+ with the "id" and "class" values of the list node.
* docutils/writers/latex2e/__init__.py
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-11-28 23:55:35 UTC (rev 9281)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-11-28 23:55:46 UTC (rev 9282)
@@ -740,7 +740,7 @@
pass
def visit_definition(self, node):
- if "details" in node.parent.parent['classes']:
+ if 'details' in node.parent.parent['classes']:
self.body.append('</summary>\n')
else:
self.body.append('</dt>\n')
@@ -747,21 +747,25 @@
self.body.append(self.starttag(node, 'dd', ''))
def depart_definition(self, node):
- if "details" not in node.parent.parent['classes']:
+ if 'details' not in node.parent.parent['classes']:
self.body.append('</dd>\n')
def visit_definition_list(self, node):
- if "details" not in node['classes']:
+ if 'details' in node['classes']:
+ self.body.append(self.starttag(node, 'div'))
+ else:
classes = ['simple'] if self.is_compactable(node) else []
self.body.append(self.starttag(node, 'dl', classes=classes))
def depart_definition_list(self, node):
- if "details" not in node['classes']:
+ if 'details' in node['classes']:
+ self.body.append('</div>\n')
+ else:
self.body.append('</dl>\n')
# Use a "details" disclosure element if parent has "class" arg "details".
def visit_definition_list_item(self, node):
- if "details" in node.parent['classes']:
+ if 'details' in node.parent['classes']:
atts = {}
if "open" in node.parent['classes']:
atts['open'] = 'open'
@@ -768,7 +772,7 @@
self.body.append(self.starttag(node, 'details', **atts))
def depart_definition_list_item(self, node):
- if "details" in node.parent['classes']:
+ if 'details' in node.parent['classes']:
self.body.append('</details>\n')
def visit_description(self, node):
@@ -1599,11 +1603,11 @@
self.body.append('</tbody>\n')
def visit_term(self, node):
- if "details" in node.parent.parent['classes']:
- self.body.append(self.starttag(node, 'summary', ''))
+ if 'details' in node.parent.parent['classes']:
+ self.body.append(self.starttag(node, 'summary', suffix=''))
else:
# The parent node (definition_list_item) is omitted in HTML.
- self.body.append(self.starttag(node, 'dt', '',
+ self.body.append(self.starttag(node, 'dt', suffix='',
classes=node.parent['classes'],
ids=node.parent['ids']))
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2022-11-28 23:55:35 UTC (rev 9281)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2022-11-28 23:55:46 UTC (rev 9282)
@@ -300,7 +300,7 @@
def depart_definition(self, node):
self.body.append('</dd>\n')
- # don't add "simple" class value
+ # don't add "simple" class value, no special handling of "details"
def visit_definition_list(self, node):
self.body.append(self.starttag(node, 'dl', CLASS='docutils'))
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2022-11-28 23:55:35 UTC (rev 9281)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2022-11-28 23:55:46 UTC (rev 9282)
@@ -1342,15 +1342,19 @@
<h4><a class="toc-backref" href="#toc-entry-47" role="doc-backlink"><span class="sectnum">3.2.2 </span>Details disclosure elements</a></h4>
<p>Items of <a class="reference internal" href="#definition-lists">definition lists</a> with class argument "details" are converted
to <a class="reference external" href="https://www.w3.org/TR/html52/interactive-elements.html#the-details-element">details</a> <a class="footnote-reference brackets" href="#footnote-9" id="footnote-reference-22" role="doc-noteref"><span class="fn-bracket">[</span>9<span class="fn-bracket">]</span></a> disclosure elements with the term becoming the "summary".</p>
+<div class="details" id="closed-details">
<details>
<summary>A summary</summary>
<p>with details only visible after user interaction.</p>
</details>
+</div>
+<div class="details open" id="open-details">
<details open="open">
<summary>Another summary</summary>
<p>with open details because the source list has the additional class
value "open".</p>
</details>
+</div>
</section>
<section id="field-list-variants">
<h4><a class="toc-backref" href="#toc-entry-48" role="doc-backlink"><span class="sectnum">3.2.3 </span>Field List Variants</a></h4>
Modified: trunk/docutils/test/functional/input/data/html5-features.txt
===================================================================
--- trunk/docutils/test/functional/input/data/html5-features.txt 2022-11-28 23:55:35 UTC (rev 9281)
+++ trunk/docutils/test/functional/input/data/html5-features.txt 2022-11-28 23:55:46 UTC (rev 9282)
@@ -102,11 +102,13 @@
Items of `definition lists`_ with class argument "details" are converted
to `details`_ disclosure elements with the term becoming the "summary".
+.. _closed-details:
.. class:: details
A summary
with details only visible after user interaction.
+.. _open-details:
.. class:: details open
Another summary
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-11-28 23:56:00
|
Revision: 9283
http://sourceforge.net/p/docutils/code/9283
Author: milde
Date: 2022-11-28 23:55:57 +0000 (Mon, 28 Nov 2022)
Log Message:
-----------
Use pathlib.Path in utils.find_file_in_dirs().
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 2022-11-28 23:55:46 UTC (rev 9282)
+++ trunk/docutils/HISTORY.txt 2022-11-28 23:55:57 UTC (rev 9283)
@@ -47,7 +47,9 @@
* docutils/utils/__init__.py
- New utility function `xml_declaration()`.
- - `utils.DependencyList.add()` accepts `pathlib.Path` instances.
+ - `DependencyList.add()` accepts `pathlib.Path` instances.
+ - `find_file_in_dirs()` now returns a POSIX path also on Windows;
+ `get_stylesheet_list()` no longer converts "\" to "/".
* docutils/utils/math/latex2mathml.py
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2022-11-28 23:55:46 UTC (rev 9282)
+++ trunk/docutils/docutils/utils/__init__.py 2022-11-28 23:55:57 UTC (rev 9283)
@@ -11,7 +11,7 @@
import sys
import os
import os.path
-from pathlib import PurePath
+from pathlib import PurePath, Path
import re
import itertools
import warnings
@@ -534,9 +534,9 @@
# Return 'stylesheet' or 'stylesheet_path' arguments as list.
#
# The original settings arguments are kept unchanged: you can test
-# with e.g. ``if settings.stylesheet_path:``
+# with e.g. ``if settings.stylesheet_path: ...``.
#
-# Differences to ``get_stylesheet_reference``:
+# Differences to the depracated `get_stylesheet_reference()`:
# * return value is a list
# * no re-writing of the path (and therefore no optional argument)
# (if required, use ``utils.relative_path(source, target)``
@@ -555,8 +555,6 @@
# expand relative paths if found in stylesheet-dirs:
stylesheets = [find_file_in_dirs(path, settings.stylesheet_dirs)
for path in stylesheets]
- if os.sep != '/': # for URLs, we need POSIX paths
- stylesheets = [path.replace(os.sep, '/') for path in stylesheets]
return stylesheets
@@ -566,17 +564,14 @@
Return the first expansion that matches an existing file.
"""
- if os.path.isabs(path):
- return path
+ path = Path(path)
+ if path.is_absolute():
+ return path.as_posix()
for d in dirs:
- if d == '.':
- f = path
- else:
- d = os.path.expanduser(d)
- f = os.path.join(d, path)
- if os.path.exists(f):
- return f
- return path
+ f = Path(d).expanduser() / path
+ if f.exists():
+ return f.as_posix()
+ return path.as_posix()
def get_trim_footnote_ref_space(settings):
Modified: trunk/docutils/test/test_utils.py
===================================================================
--- trunk/docutils/test/test_utils.py 2022-11-28 23:55:46 UTC (rev 9282)
+++ trunk/docutils/test/test_utils.py 2022-11-28 23:55:57 UTC (rev 9283)
@@ -351,13 +351,10 @@
dirs = (os.path.join(TEST_ROOT, 'nonex'),
TEST_ROOT,
os.path.join(TEST_ROOT, '..'))
- found = os.path.relpath(
- os.path.join(utils.find_file_in_dirs('HISTORY.txt', dirs)),
- TEST_ROOT).replace('\\', '/')
- # returns
- # '..\\HISTORY.txt' on windows
- # '../HISTORY.txt' on other platforms
- # 'HISTORY.txt' if not called from docutils directory.
+ found = utils.find_file_in_dirs('HISTORY.txt', dirs)
+ self.assertEqual(found, (TEST_ROOT / '..' / 'HISTORY.txt').as_posix())
+ # normalize
+ found = os.path.relpath(found, TEST_ROOT).replace('\\', '/')
self.assertTrue(found.startswith('..'),
'HISTORY.txt not found in "..".')
# Return `path` if the file exists in the cwd or if there is no match
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-12-01 21:13:00
|
Revision: 9290
http://sourceforge.net/p/docutils/code/9290
Author: milde
Date: 2022-12-01 21:12:57 +0000 (Thu, 01 Dec 2022)
Log Message:
-----------
Update documentation.
Simplify/update instructions for installing,
Simplify/update instructions for building docs
(there is now an up-to-date docutils.conf in the "docutils root" archive path.
Update links.
Modified Paths:
--------------
trunk/docutils/README.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/dev/repository.txt
trunk/docutils/docs/index.txt
Modified: trunk/docutils/README.txt
===================================================================
--- trunk/docutils/README.txt 2022-12-01 16:11:22 UTC (rev 9289)
+++ trunk/docutils/README.txt 2022-12-01 21:12:57 UTC (rev 9290)
@@ -24,7 +24,7 @@
2. Install the latest stable release from PyPi with pip_::
- python3 -m pip install docutils
+ pip install docutils
For alternatives and details, see section `Installation`_ below.
@@ -31,8 +31,7 @@
3. Use the `front-end scripts`_ to convert reStructuredText documents.
Try for example::
- rst2html.py FAQ.txt FAQ.html (Unix)
- docutils FAQ.txt FAQ.html (Unix and Windows)
+ docutils FAQ.txt FAQ.html
See Usage_ below for details.
@@ -40,7 +39,7 @@
Purpose
=======
-The purpose of the Docutils project is to create a set of tools for
+The purpose of the Docutils project is to provide a set of tools for
processing plaintext documentation into useful formats, such as HTML,
LaTeX, troff (man pages), OpenOffice, and native XML. Support for the
following sources has been implemented:
@@ -75,29 +74,28 @@
To run the code, Python_ must be installed.
(Python is pre-installed with most Linux distributions.)
-* Docutils 0.19.1b.dev requires Python 3.7 or later.
-* Docutils 0.16 to 0.18 require Python 2.7 or 3.5+.
-* Docutils 0.14 dropped Python 2.4, 2.5, 3.1 and 3.2 support.
+* Since version 0.19, Docutils requires Python 3.7 or later.
+* Docutils 0.16 to 0.18 require Python 2.7 or 3.5+.
.. _Python: https://www.python.org/.
-Optional Dependencies
----------------------
+Recommendations
+---------------
Docutils uses the following packages for enhanced functionality, if they
are installed:
-* Installation_ is usually done with pip_ or setuptools_.
+* The recommended installer is pip_, setuptools_ works, too.
-* The `Python Imaging Library`_, or PIL, is used for some image
+* The `Python Imaging Library`_ (PIL) is used for some image
manipulation operations.
* The `Pygments`_ package provides syntax highlight of "code" directives
and roles.
-* The `myst`_ or `recommonmark`_ parsers can be used to parse input in
- Markdown format.
+* The `myst`_, `pycmark`_, or `recommonmark`_ parsers can be used to
+ parse input in "Markdown" (CommonMark_) format.
The `Docutils Link List <docs/user/links.html>`__ records projects that
users of Docutils and reStructuredText may find useful.
@@ -107,141 +105,124 @@
.. _Python Imaging Library: http://www.pythonware.com/products/pil/
.. _Pygments: https://pypi.org/project/Pygments/
.. _myst: https://pypi.org/project/myst-docutils/
+.. _pycmark: https://pypi.org/project/pycmark/
.. _recommonmark: https://github.com/rtfd/recommonmark
+.. _CommonMark: https://spec.commonmark.org/0.30/
-Development version
-===================
+Installation
+============
-While we are trying to follow a "release early & often" policy,
-features are added frequently.
-Since the code in the `Docutils version repository`_ is usually in a
-bug-free state, we recommend using a current snapshot or a working copy.
+The `Python Packaging User Guide`_ gives details how to
+`use pip for installing`_.
-Snapshots:
- To get a repository _`snapshot`, go to
- https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/
- and click the download snapshot button.
+* The simplest way is to install the latest *stable release* from PyPi::
-Repository check-out:
- To keep up to date on the latest developments,
- use a `working copy`__ of the `Docutils version repository`_.
+ pip install docutils
-Continue with the `Installation`_ instructions below.
+* To install a *pre-relase*, append the option ``--pre``.
-.. _Docutils version repository: docs/dev/repository.html
-.. _sandbox: https://docutils.sourceforge.io/sandbox/README.html
+* To install a `development version`_ *from source*:
-__ docs/dev/repository.html#checking-out-the-repository
+ 1. Open a shell
+ 2. Go to the directory containing the file ``setup.py``.
-Installation
-============
+ 3. Install the package with **one** of the following commands::
-* The simplest way is to install the latest stable release from PyPi with
- pip_::
+ pip install -e . # editable install
+ pip install . # regular install
+ python setup.py # regular install with setuptools
- python3 -m pip install docutils
+ 4. Optional steps:
- To install a pre-relase, append the option ``--pre``.
+ * `Running the test suite`_
+ * `Converting the documentation`_
-* To install a `development version`_ from source with `setuptools`_:
+ See also the OS-specific installation instructions below and
+ the `Docutils version repository`_ documentation.
- * Go to the directory containing the file ``setup.py``.
+* To install for a *specific Python version*, use this version in the
+ setup call, e.g. ::
- A snapshot_ must be unpacked in a temporary directory
- (**not** directly in Python's ``site-packages``) first.
+ python3.11 -m pip install docutils
- * Run ``setup.py install``.
- See also OS-specific installation instructions below.
+ If the python executable isn't on your path, you'll have to specify the
+ complete path, such as ``/usr/local/bin/python3.11``.
- Optional steps:
-
- * `Running the test suite`_
-
- * `Converting the documentation`_
+ To install for different Python versions, repeat step 3 for every
+ required version. The last installed version will be used for the
+ ``docutils`` command line application.
-* For installing "by hand" or in "development mode", see the
- `editable installs`_ section in the `Docutils version repository`_
- documentation.
+.. _Python Packaging User Guide: https://packaging.python.org/en/latest/
+.. _use pip for installing:
+ https://packaging.python.org/en/latest/tutorials/installing-packages/
+ #use-pip-for-installing
+.. _"editable" install:
+ https://pip.pypa.io/en/stable/topics/local-project-installs/
+ #editable-installs
- .. _editable installs: docs/dev/repository.html#editable-installs
-
GNU/Linux, BSDs, Unix, Mac OS X, etc.
-------------------------------------
-1. Open a shell.
+* Use ``su`` or ``sudo`` for a system-wide
+ installation as ``root``, e.g.::
-2. Go to the directory containing ``setup.py``::
+ sudo pip install docutils
- cd <archive_directory_path>
-3. Install the package (you may need root permissions to complete this
- step)::
+Windows
+-------
- su
- (enter admin password)
- python3 setup.py install
+* The Python FAQ explains `how to run a Python program under Windows`__.
- If the python executable isn't on your path, you'll have to specify
- the complete path, such as ``/usr/local/bin/python``.
+ __ https://docs.python.org/3/faq/windows.html
+ #how-do-i-run-a-python-program-under-windows
- To install for a specific Python version, use this version in the
- setup call, e.g. ::
+* Usually, pip_ is automatically installed if you are using Python
+ downloaded from https://python.org. If not, see the
+ `pip documentation <https://pip.pypa.io/en/stable/installation/>`__.
- python3.7 setup.py install
+* The command window should recognise the word ``py`` as an instruction to
+ start the interpreter, e.g.
- To install for different Python versions, repeat step 3 for every
- required version. The last installed version will be used in the
- `shebang line`_ of the `front-end scripts`_.
+ py -m pip install docutils
- .. _shebang line: https://en.wikipedia.org/wiki/Shebang_%28Unix%29
+ If this does not work, you may have to specify the full path to the
+ Python executable.
-Windows
--------
-Just double-click ``install.py``. If this doesn't work, try the
-following:
+Usage
+=====
-1. Open a DOS Box (Command Shell, MS-DOS Prompt, or whatever they're
- calling it these days).
+Start the "docutils" command line application with::
-2. Go to the directory created by expanding the archive::
+ docutils [options] [<source> [<destination>]]
- cd <archive_directory_path>
+The default action is to convert a reStructuredText_ document to HTML5,
+for example::
-3. Install the package::
+ docutils test.rst test.html
- <path_to_python.exe>\python setup.py install
+Read the ``--help`` option output for details on options and arguments and
+`Docutils Front-End Tools`_ for the full documentation of the various tools.
- To install for a specific python version, specify the Python
- executable for this version.
+For programmatic use of the `docutils` Python package, read the
+`API Reference Material`_ and the source code.
+Remaining questions may be answered in the `Docutils Project
+Documentation`_ or the Docutils-users_ mailing list.
- To install for different Python versions, repeat step 3 for every
- required version.
-
-
-Usage
-=====
-
-There are many front-end tools in the unpacked "tools" subdirectory.
-Installation under Unix places copies in the PATH.
-You may want to begin with the "rst2html.py" front-end tool. Most
-tools take up to two arguments, the source path and destination path,
-with STDIN and STDOUT being the defaults. Use the ``--help`` option to
-the front-end tools for details on options and arguments. See
-`Docutils Front-End Tools`_ for full documentation.
-
-The package modules are continually growing and evolving. The
-``docutils.statemachine`` module is usable independently. It contains
-extensive inline documentation (in reStructuredText format of course).
-
Contributions are welcome!
+.. _reStructuredText: https://docutils.sourceforge.io/rst.html
.. _front-end scripts:
.. _Docutils Front-End Tools: docs/user/tools.html
+.. _API Reference Material: /docs/index.html
+ #api-reference-material-for-client-developers
+.. _Docutils Project Documentation: /docs/index.html
+
Project Files & Directories
===========================
@@ -295,6 +276,32 @@
below.
+Development version
+===================
+
+While we are trying to follow a "release early & often" policy,
+features are added frequently.
+We recommend using a current snapshot or a working copy of the repository.
+
+Repository check-out:
+ To keep up to date on the latest developments,
+ use a `working copy`__ of the `Docutils version repository`_.
+
+Snapshots:
+ To get a repository _`snapshot`, go to
+ https://sourceforge.net/p/docutils/code/HEAD/tree/trunk/docutils/
+ and click the download snapshot button.
+
+ Unpack in a temporary directory,
+ **not** directly in Python's ``site-packages``.
+
+Continue with the `Installation`_ instructions below.
+
+__ docs/dev/repository.html#checking-out-the-repository
+.. _Docutils version repository: docs/dev/repository.html
+.. _sandbox: https://docutils.sourceforge.io/sandbox/README.html
+
+
Converting the documentation
============================
@@ -301,23 +308,18 @@
After unpacking and installing the Docutils package, the following
shell commands will generate HTML for all included documentation::
- cd <archive_directory_path>/tools
- ./buildhtml.py ../
+ cd <archive_directory_path>
+ tools/buildhtml.py .
On Windows systems, type::
- cd <archive_directory_path>\tools
- python buildhtml.py ..
+ cd <archive_directory_path>
+ py tools\buildhtml.py ..
The final directory name of the ``<archive_directory_path>`` is
"docutils" for snapshots. For official releases, the directory may be
called "docutils-X.Y.Z", where "X.Y.Z" is the release version.
-Alternatively::
- cd <archive_directory_path>
- tools/buildhtml.py --config=tools/docutils.conf (Unix)
- python tools\buildhtml.py --config=tools\docutils.conf (Windows)
-
Some files may generate system messages (warnings and errors). The
``docs/user/rst/demo.txt`` file (under the archive directory) contains
five intentional errors. (They test the error reporting mechanism!)
@@ -343,15 +345,17 @@
You should see a long line of periods, one for each test, and then a
summary like this::
- Ran 1111 tests in 24.653s
+ Ran 1744 tests in 5.859s
- OK
- Elapsed time: 26.189 seconds
+ OK (skipped=1)
+ Elapsed time: 6.235 seconds
The number of tests will grow over time, and the times reported will
-depend on the computer running the tests. The difference between the
-two times represents the time required to set up the tests (import
-modules, create data structures, etc.).
+depend on the computer running the tests.
+Some test are skipped, if optional dependencies (`recommendations`_)
+are missing.
+The difference between the two times represents the time required to set
+up the tests (import modules, create data structures, etc.).
A copy of the test output is written to the file ``alltests.out``.
@@ -359,8 +363,7 @@
(see `Bugs <BUGS.html>`_).
Please include all relevant output, information about your operating
system, Python version, and Docutils version. To see the Docutils
-version, look at the test output or use one of the `front-end scripts`_
-with the ``--version`` option, e.g.::
+version, look at the test output or use ::
docutils --version
@@ -376,7 +379,7 @@
============
All documentation can be reached from the `Project Documentation
-Overview`_.
+Overview`_.
The SourceForge `project page`_ has links to the tracker, mailing
lists, and code repository.
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2022-12-01 16:11:22 UTC (rev 9289)
+++ trunk/docutils/RELEASE-NOTES.txt 2022-12-01 21:12:57 UTC (rev 9290)
@@ -29,8 +29,8 @@
.. code:: diff
- - rst2latex.py --use-latex-abstract xmpl.txt > xmpl.tex
- + docutils --writer=latex --use-latex-abstract xmpl.txt > xmpl.tex
+ - rst2latex.py --use-latex-abstract FAQ.txt > FAQ.tex
+ + docutils --writer=latex --use-latex-abstract FAQ.txt > FAQ.tex
Exceptions:
The auxilliary script ``rst2odt_prepstyles.py`` will become
Modified: trunk/docutils/docs/dev/repository.txt
===================================================================
--- trunk/docutils/docs/dev/repository.txt 2022-12-01 16:11:22 UTC (rev 9289)
+++ trunk/docutils/docs/dev/repository.txt 2022-12-01 21:12:57 UTC (rev 9290)
@@ -137,6 +137,7 @@
There are several ways to ensure that edits to the Docutils code are
picked up by Python.
+
We'll assume that the Docutils "trunk" is checked out under the
``~/projects/`` directory.
@@ -144,79 +145,73 @@
python3 -m pip install -e ~/projects/docutils/docutils
- __ https://pip.pypa.io/en/stable/cli/pip_install/#editable-installs
+ __ https://pip.pypa.io/en/stable/topics/local-project-installs/
+ #editable-installs
-2. Install in `development mode`__ with setuptools_.
+2. Install "manually".
- __ https://setuptools.pypa.io/en/latest/userguide/development_mode.html
- #development-mode
+ Ensure that the "docutils" package is in the module search path
+ (``sys.path``) by one of the following actions:
- .. _install manually:
+ a) Set the ``PYTHONPATH`` environment variable.
-3. Install "manually".
+ For the bash shell, add this to your ``~/.profile``::
- Ensure that the "docutils" package is in ``sys.path`` by
- one of the following actions:
-
- * Set the ``PYTHONPATH`` environment variable so that Python
- picks up your local working copy of the code.
-
- For the bash shell, add this to your ``~/.profile``::
-
PYTHONPATH=$HOME/projects/docutils/docutils
export PYTHONPATH
- The first line points to the directory containing the ``docutils``
- package. The second line exports the environment variable.
+ The first line points to the directory containing the ``docutils``
+ package, the second line exports the environment variable.
- * Create a symlink to the docutils package directory somewhere in the
- module search path (``sys.path``), e.g., ::
+ b) Create a symlink to the docutils package directory somewhere in the
+ ``sys.path``, e.g., ::
ln -s ~/projects/docutils/docutils \
/usr/local/lib/python3.9/dist-packages/
- * Use a `path configuration file`__.
+ c) Use a `path configuration file`__.
- __ https://docs.python.org/library/site.html
+ __ https://docs.python.org/library/site.html
- Optionally, add some or all `front-end tools`_
- to the binary search path, e.g.,
- add the ``tools`` directory to the ``PATH`` variable::
+ Optionally, add some or all `front-end tools`_ to the binary search
+ path, e.g.:
+ a) add the ``tools`` directory to the ``PATH`` variable::
+
PATH=$PATH:$HOME/projects/docutils/docutils/tools
export PATH
- or link idividual front-end tools to a suitable place
- in the binary path::
+ or
+ b) link idividual front-end tools to a suitable place in the binary
+ path::
+
ln -s ~/projects/docutils/docutils/tools/docutils-cli.py \
/usr/local/bin/docutils
-5. Reinstall Docutils after any change::
+3. Do a regular install. Repeat after any change. ::
- python3 setup.py install
+ ./setup.py install
.. CAUTION::
- This method is **not** recommended for day-to-day development;
- it's too easy to forget. Confusion inevitably ensues.
+ This method is **not** recommended for day-to-day development!
- If you install Docutils this way, Python will always pick up the
- last-installed copy of the code. If you ever forget to
- reinstall the "docutils" package, Python won't see your latest
- changes.
+ If you ever forget to reinstall the "docutils" package, Python
+ won't see your latest changes. Confusion inevitably ensues.
-A useful addition to the ``docutils`` top-level directory in branches
-and alternate copies of the code is a ``set-PATHS`` file
-containing the following lines::
+Tip:
+ A useful addition to the ``docutils`` top-level directory in
+ *SVN branches* and *alternate copies* of the code is a ``set-PATHS``
+ shell script containing the following lines::
- # source this file
- export PYTHONPATH=$PWD:$PWD
- export PATH=$PWD/tools:$PATH
+ # source this file
+ export PYTHONPATH=$PWD:$PWD
+ export PATH=$PWD/tools:$PATH
-Open a shell for this branch, ``cd`` to the ``docutils`` top-level
-directory, and "source" this file. For example, using the bash
-shell::
+ Open a shell for this branch, ``cd`` to the ``docutils`` top-level
+ directory, and "source" this file. For example, using the bash
+ shell::
$ cd some-branch/docutils
$ . set-PATHS
Modified: trunk/docutils/docs/index.txt
===================================================================
--- trunk/docutils/docs/index.txt 2022-12-01 16:11:22 UTC (rev 9289)
+++ trunk/docutils/docs/index.txt 2022-12-01 21:12:57 UTC (rev 9290)
@@ -201,6 +201,7 @@
:Security: `Deploying Docutils Securely <howto/security.html>`__
* `Inside A Docutils Command-Line Front-End Tool <howto/cmdline-tool.html>`__
+* `Runtime Settings Processing <dev/runtime-settings-processing.html>`__
* `Writing HTML (CSS) Stylesheets for Docutils
<howto/html-stylesheets.html>`__
* `Docutils Internationalization <howto/i18n.html>`__
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-12-01 21:13:42
|
Revision: 9292
http://sourceforge.net/p/docutils/code/9292
Author: milde
Date: 2022-12-01 21:13:38 +0000 (Thu, 01 Dec 2022)
Log Message:
-----------
HTML5: Use dpub-ARIA role "doc-footnote" for footnotes
(instead of ARIA role "note").
No change with "html4css1".
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/test/functional/expected/footnotes_html5.html
trunk/docutils/test/functional/expected/rst_html5_tuftig.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-12-01 21:13:16 UTC (rev 9291)
+++ trunk/docutils/HISTORY.txt 2022-12-01 21:13:38 UTC (rev 9292)
@@ -71,6 +71,9 @@
- Wrap definition lists with "details" class argument in a <div>
with the "id" and "class" values of the list node.
+ - Use dpub-ARIA role "doc-footnote" (instead of ARIA role "note")
+ for footnotes.
+
* docutils/writers/latex2e/__init__.py
- Do not insert ``\usepackage[utf8]{inputenc}`` into UTF-8 encoded
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2022-12-01 21:13:16 UTC (rev 9291)
+++ trunk/docutils/RELEASE-NOTES.txt 2022-12-01 21:13:38 UTC (rev 9292)
@@ -24,9 +24,9 @@
- The ``rst2*.py`` `front end tools`_ will be renamed to ``rst2*``
(dropping the ``.py`` extension). [#]_
- You may use ``docutils`` [#]_ as a future-proof command name,
+ You may use ``docutils`` [#]_ as a future-proof command name,
for example:
-
+
.. code:: diff
- rst2latex.py --use-latex-abstract FAQ.txt > FAQ.tex
@@ -49,7 +49,7 @@
* The rst2html_ front end and ``get_writer_by_name('html')`` select
"html4css1" now and will select "html5" in Docutils 2.0 and later.
- * Use rst2html4_, ``docutils --writer=html4``, or
+ * Use rst2html4_, ``docutils --writer=html4``, or
``get_writer_by_name('html4')`` if you depend on stability of the
generated HTML code, e.g. because you use a custom style sheet or
post-processing that may break otherwise.
@@ -74,13 +74,11 @@
* "html5" writer:
- Stop setting the "footnote-reference" class value for footnote
- references. Since 0.18, you can use the CSS selector
+ references in Docutils 0.21.
+ Since 0.18, you can use the CSS selector
``[role="doc-noteref"]`` instead of ``.footnote-reference``
(see minimal.css for examples).
- - Use dpub-ARIA role "doc-footnote" (instead of ARIA role "note")
- for footnotes in Docutils 0.20.
-
- Move attribution behind the blockquote to comply with the `"living
standard"`__. (HTML5__ allows <cite> elements inside a blockquote.)
@@ -149,6 +147,16 @@
.. _buildhtml.py: docs/user/tools.html#buildhtml-py
+Release 0.20 (unpublished)
+==========================
+
+* Output changes:
+
+ HTML5:
+ Use dpub-ARIA role "doc-footnote" (instead of ARIA role "note")
+ for footnotes.
+
+
Release 0.19 (2022-07-05)
=========================
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2022-12-01 21:13:16 UTC (rev 9291)
+++ trunk/docutils/docutils/writers/_html_base.py 2022-12-01 21:13:38 UTC (rev 9292)
@@ -961,7 +961,7 @@
self.body.append(f'<aside class="footnote-list {label_style}">\n')
self.body.append(self.starttag(node, 'aside',
classes=[node.tagname, label_style],
- role="note"))
+ role="doc-footnote"))
def depart_footnote(self, node):
self.body.append('</aside>\n')
Modified: trunk/docutils/test/functional/expected/footnotes_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/footnotes_html5.html 2022-12-01 21:13:16 UTC (rev 9291)
+++ trunk/docutils/test/functional/expected/footnotes_html5.html 2022-12-01 21:13:38 UTC (rev 9292)
@@ -15,7 +15,7 @@
<p>Paragraphs may contain footnote references (manually numbered<a class="footnote-reference superscript" href="#footnote-1" id="footnote-reference-1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>, anonymous auto-numbered<a class="footnote-reference superscript" href="#footnote-2" id="footnote-reference-2" role="doc-noteref"><span class="fn-bracket">[</span>3<span class="fn-bracket">]</span></a>, labeled auto-numbered<a class="footnote-reference superscript" href="#label" id="footnote-reference-3" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a>, or
symbolic<a class="footnote-reference superscript" href="#footnote-3" id="footnote-reference-4" role="doc-noteref"><span class="fn-bracket">[</span>*<span class="fn-bracket">]</span></a>) or citation references (<a class="citation-reference" href="#cit2002" id="citation-reference-1" role="doc-biblioref">[CIT2002]</a>, <a class="citation-reference" href="#du2015" id="citation-reference-2" role="doc-biblioref">[DU2015]</a>).</p>
<aside class="footnote-list superscript">
-<aside class="footnote superscript" id="footnote-1" role="note">
+<aside class="footnote superscript" id="footnote-1" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#footnote-reference-1">1</a>,<a role="doc-backlink" href="#footnote-reference-5">2</a>)</span>
<p>A footnote contains body elements, consistently indented by at
@@ -22,7 +22,7 @@
least 3 spaces.</p>
<p>This is the footnote's second paragraph.</p>
</aside>
-<aside class="footnote superscript" id="label" role="note">
+<aside class="footnote superscript" id="label" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#footnote-reference-3">1</a>,<a role="doc-backlink" href="#footnote-reference-6">2</a>)</span>
<p>Footnotes may be numbered, either manually (as in<a class="footnote-reference superscript" href="#footnote-1" id="footnote-reference-5" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>) or
@@ -30,7 +30,7 @@
label so it can be referred to from multiple places, both as a
footnote reference (<a class="footnote-reference superscript" href="#label" id="footnote-reference-6" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a>) and as a <a class="reference internal" href="#label">hyperlink reference</a>.</p>
</aside>
-<aside class="footnote superscript" id="footnote-2" role="note">
+<aside class="footnote superscript" id="footnote-2" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-2">3</a><span class="fn-bracket">]</span></span>
<p>This footnote is numbered automatically and anonymously using a
label of "#" only.</p>
@@ -37,16 +37,16 @@
<p>This is the second paragraph.</p>
<p>And this is the third paragraph.</p>
</aside>
-<aside class="footnote superscript" id="footnote-3" role="note">
+<aside class="footnote superscript" id="footnote-3" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-4">*</a><span class="fn-bracket">]</span></span>
<p>Footnotes may also use symbols, specified with a "*" label.
Here's a reference to the next footnote:<a class="footnote-reference superscript" href="#footnote-4" id="footnote-reference-7" role="doc-noteref"><span class="fn-bracket">[</span>†<span class="fn-bracket">]</span></a>.</p>
</aside>
-<aside class="footnote superscript" id="footnote-4" role="note">
+<aside class="footnote superscript" id="footnote-4" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-7">†</a><span class="fn-bracket">]</span></span>
<p>This footnote shows the next symbol in the sequence.</p>
</aside>
-<aside class="footnote superscript" id="footnote-5" role="note">
+<aside class="footnote superscript" id="footnote-5" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>4<span class="fn-bracket">]</span></span>
<p>Here's an unreferenced footnote, with a reference to a
nonexistent footnote:<a class="footnote-reference superscript" href="#footnote-6" id="footnote-reference-8" role="doc-noteref"><span class="fn-bracket">[</span>5<span class="fn-bracket">]</span></a>.</p>
@@ -68,7 +68,7 @@
</div>
<p>Here's a reference to the above, <a class="citation-reference" href="#cit2002" id="citation-reference-3" role="doc-biblioref">[CIT2002]</a>.</p>
<aside class="footnote-list superscript">
-<aside class="footnote superscript" id="footnote-6" role="note">
+<aside class="footnote superscript" id="footnote-6" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-8">5</a><span class="fn-bracket">]</span></span>
<p>this footnote is missing in the standard example document.</p>
</aside>
@@ -76,7 +76,7 @@
<p>Footnotes may contain block elements like lists<a class="footnote-reference superscript" href="#footnote-7" id="footnote-reference-9" role="doc-noteref"><span class="fn-bracket">[</span>6<span class="fn-bracket">]</span></a><a class="footnote-reference superscript" href="#list-note" id="footnote-reference-10" role="doc-noteref"><span class="fn-bracket">[</span>7<span class="fn-bracket">]</span></a><a class="footnote-reference superscript" href="#footnote-8" id="footnote-reference-11" role="doc-noteref"><span class="fn-bracket">[</span>8<span class="fn-bracket">]</span></a>,
admonitions<a class="footnote-reference superscript" href="#footnote-9" id="footnote-reference-12" role="doc-noteref"><span class="fn-bracket">[</span>9<span class="fn-bracket">]</span></a>, or tables<a class="footnote-reference superscript" href="#footnote-10" id="footnote-reference-13" role="doc-noteref"><span class="fn-bracket">[</span>10<span class="fn-bracket">]</span></a>.</p>
<aside class="footnote-list superscript">
-<aside class="footnote superscript" id="footnote-7" role="note">
+<aside class="footnote superscript" id="footnote-7" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-9">6</a><span class="fn-bracket">]</span></span>
<ol class="arabic simple">
<li><p>An ordered list</p></li>
@@ -83,7 +83,7 @@
<li><p>in a footnote.</p></li>
</ol>
</aside>
-<aside class="footnote superscript" id="list-note" role="note">
+<aside class="footnote superscript" id="list-note" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>7<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#footnote-reference-10">1</a>,<a role="doc-backlink" href="#footnote-reference-14">2</a>)</span>
<ul class="simple">
@@ -92,7 +92,7 @@
</ul>
<p>And a trailing paragraph.</p>
</aside>
-<aside class="footnote superscript" id="footnote-8" role="note">
+<aside class="footnote superscript" id="footnote-8" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-11">8</a><span class="fn-bracket">]</span></span>
<dl class="field-list simple">
<dt>Field<span class="colon">:</span></dt>
@@ -103,7 +103,7 @@
</dd>
</dl>
</aside>
-<aside class="footnote superscript" id="footnote-9" role="note">
+<aside class="footnote superscript" id="footnote-9" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-12">9</a><span class="fn-bracket">]</span></span>
<aside class="admonition note">
<p class="admonition-title">Note</p>
@@ -110,7 +110,7 @@
<p>This is a note in a note.</p>
</aside>
</aside>
-<aside class="footnote superscript" id="footnote-10" role="note">
+<aside class="footnote superscript" id="footnote-10" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-13">10</a><span class="fn-bracket">]</span></span>
<table>
<tbody>
Modified: trunk/docutils/test/functional/expected/rst_html5_tuftig.html
===================================================================
--- trunk/docutils/test/functional/expected/rst_html5_tuftig.html 2022-12-01 21:13:16 UTC (rev 9291)
+++ trunk/docutils/test/functional/expected/rst_html5_tuftig.html 2022-12-01 21:13:38 UTC (rev 9292)
@@ -128,7 +128,7 @@
</tbody>
</table>
<aside class="footnote-list superscript">
-<aside class="footnote superscript align-left" id="not-in-margin" role="note">
+<aside class="footnote superscript align-left" id="not-in-margin" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span>
<p>The “align-left” class value ensures this footnote is set
in the main text area.</p>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2022-12-01 21:13:16 UTC (rev 9291)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2022-12-01 21:13:38 UTC (rev 9292)
@@ -472,7 +472,7 @@
<section id="footnotes">
<h3><a class="toc-backref" href="#toc-entry-17" role="doc-backlink"><span class="sectnum">2.11 </span>Footnotes</a></h3>
<aside class="footnote-list brackets">
-<aside class="footnote brackets" id="footnote-1" role="note">
+<aside class="footnote brackets" id="footnote-1" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#footnote-reference-1">1</a>,<a role="doc-backlink" href="#footnote-reference-5">2</a>,<a role="doc-backlink" href="#footnote-reference-9">3</a>)</span>
<p>A footnote contains body elements, consistently indented by at
@@ -479,7 +479,7 @@
least 3 spaces.</p>
<p>This is the footnote's second paragraph.</p>
</aside>
-<aside class="footnote brackets" id="label" role="note">
+<aside class="footnote brackets" id="label" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#footnote-reference-3">1</a>,<a role="doc-backlink" href="#footnote-reference-6">2</a>)</span>
<p>Footnotes may be numbered, either manually (as in <a class="footnote-reference brackets" href="#footnote-1" id="footnote-reference-5" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a>) or
@@ -487,7 +487,7 @@
label so it can be referred to from multiple places, both as a
footnote reference (<a class="footnote-reference brackets" href="#label" id="footnote-reference-6" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a>) and as a <a class="reference internal" href="#label">hyperlink reference</a>.</p>
</aside>
-<aside class="footnote brackets" id="footnote-2" role="note">
+<aside class="footnote brackets" id="footnote-2" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-2">3</a><span class="fn-bracket">]</span></span>
<p>This footnote is numbered automatically and anonymously using a
label of "#" only.</p>
@@ -494,16 +494,16 @@
<p>This is the second paragraph.</p>
<p>And this is the third paragraph.</p>
</aside>
-<aside class="footnote brackets" id="footnote-3" role="note">
+<aside class="footnote brackets" id="footnote-3" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-4">*</a><span class="fn-bracket">]</span></span>
<p>Footnotes may also use symbols, specified with a "*" label.
Here's a reference to the next footnote: <a class="footnote-reference brackets" href="#footnote-4" id="footnote-reference-7" role="doc-noteref"><span class="fn-bracket">[</span>†<span class="fn-bracket">]</span></a>.</p>
</aside>
-<aside class="footnote brackets" id="footnote-4" role="note">
+<aside class="footnote brackets" id="footnote-4" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-7">†</a><span class="fn-bracket">]</span></span>
<p>This footnote shows the next symbol in the sequence.</p>
</aside>
-<aside class="footnote brackets" id="footnote-5" role="note">
+<aside class="footnote brackets" id="footnote-5" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>4<span class="fn-bracket">]</span></span>
<p>Here's an unreferenced footnote, with a reference to a
nonexistent footnote: <a href="#system-message-2"><span class="problematic" id="footnote-reference-8">[5]_</span></a>.</p>
@@ -826,56 +826,56 @@
<section id="target-footnotes">
<h4><a class="toc-backref" href="#toc-entry-59" role="doc-backlink"><span class="sectnum">2.14.6 </span>Target Footnotes</a></h4>
<aside class="footnote-list brackets">
-<aside class="footnote brackets" id="footnote-7" role="note">
+<aside class="footnote brackets" id="footnote-7" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>7<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#footnote-reference-18">1</a>,<a role="doc-backlink" href="#footnote-reference-19">2</a>,<a role="doc-backlink" href="#footnote-reference-20">3</a>,<a role="doc-backlink" href="#footnote-reference-26">4</a>)</span>
<p><a class="reference external" href="http://www.python.org/">http://www.python.org/</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-8" role="note">
+<aside class="footnote brackets" id="footnote-8" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-21">8</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="http://pygments.org/">http://pygments.org/</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-9" role="note">
+<aside class="footnote brackets" id="footnote-9" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-22">9</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://www.w3.org/TR/html52/interactive-elements.html#the-details-element">https://www.w3.org/TR/html52/interactive-elements.html#the-details-element</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-10" role="note">
+<aside class="footnote brackets" id="footnote-10" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-23">10</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://docutils.sourceforge.io/docs/user/config.html#table-style">https://docutils.sourceforge.io/docs/user/config.html#table-style</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-11" role="note">
+<aside class="footnote brackets" id="footnote-11" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-24">11</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="http://tug.ctan.org/tex-archive/macros/latex/contrib/booktabs/booktabs.pdf">http://tug.ctan.org/tex-archive/macros/latex/contrib/booktabs/booktabs.pdf</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-12" role="note">
+<aside class="footnote brackets" id="footnote-12" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-25">12</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://docutils.sourceforge.io/docs/dev/todo.html#interpreted-text">https://docutils.sourceforge.io/docs/dev/todo.html#interpreted-text</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-13" role="note">
+<aside class="footnote brackets" id="footnote-13" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-27">13</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://docutils.sourceforge.io/">https://docutils.sourceforge.io/</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-14" role="note">
+<aside class="footnote brackets" id="footnote-14" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-28">14</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://docutils.sourceforge.io/docs/ref/rst/directives.html">https://docutils.sourceforge.io/docs/ref/rst/directives.html</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-15" role="note">
+<aside class="footnote brackets" id="footnote-15" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-29">15</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://docutils.sourceforge.io/docs/ref/rst/directives.html#metadata">https://docutils.sourceforge.io/docs/ref/rst/directives.html#metadata</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-16" role="note">
+<aside class="footnote brackets" id="footnote-16" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-30">16</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag">https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-17" role="note">
+<aside class="footnote brackets" id="footnote-17" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-31">17</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://stackoverflow.com/questions/39547412/same-font-size-for-h1-and-h2-in-article">https://stackoverflow.com/questions/39547412/same-font-size-for-h1-and-h2-in-article</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-18" role="note">
+<aside class="footnote brackets" id="footnote-18" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-32">18</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://html.spec.whatwg.org/#text-level-semantics">https://html.spec.whatwg.org/#text-level-semantics</a></p>
</aside>
-<aside class="footnote brackets" id="footnote-19" role="note">
+<aside class="footnote brackets" id="footnote-19" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-33">19</a><span class="fn-bracket">]</span></span>
<p><a class="reference external" href="https://html.spec.whatwg.org/multipage/edits.html">https://html.spec.whatwg.org/multipage/edits.html</a></p>
</aside>
@@ -1590,7 +1590,7 @@
advised to use <abbr> instead. The HTML5 writer uses <abbr> for Docutil's
<abbreviation> element.</p>
<aside class="footnote-list brackets">
-<aside class="footnote brackets" id="footnote-6" role="note">
+<aside class="footnote brackets" id="footnote-6" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span><a role="doc-backlink" href="#footnote-reference-11">‡</a><span class="fn-bracket">]</span></span>
<p>Irish Organic Farmers and Growers Association</p>
</aside>
@@ -1721,13 +1721,13 @@
</dd>
</dl>
<aside class="footnote-list brackets">
-<aside class="footnote brackets" id="attribute-optional" role="note">
+<aside class="footnote brackets" id="attribute-optional" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>5<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#footnote-reference-10">1</a>,<a role="doc-backlink" href="#footnote-reference-14">2</a>,<a role="doc-backlink" href="#footnote-reference-16">3</a>,<a role="doc-backlink" href="#footnote-reference-17">4</a>)</span>
<p>Would gain from support for attributes/arguments
to inline roles. See <a class="reference external" href="https://docutils.sourceforge.io/docs/dev/todo.html#interpreted-text">TODO</a> <a class="footnote-reference brackets" href="#footnote-12" id="footnote-reference-25" role="doc-noteref"><span class="fn-bracket">[</span>12<span class="fn-bracket">]</span></a></p>
</aside>
-<aside class="footnote brackets" id="attribute-required" role="note">
+<aside class="footnote brackets" id="attribute-required" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>6<span class="fn-bracket">]</span></span>
<span class="backrefs">(<a role="doc-backlink" href="#footnote-reference-12">1</a>,<a role="doc-backlink" href="#footnote-reference-13">2</a>,<a role="doc-backlink" href="#footnote-reference-15">3</a>)</span>
<p>Requires support for attributes to inline
Modified: trunk/docutils/test/test_writers/test_html5_polyglot_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2022-12-01 21:13:16 UTC (rev 9291)
+++ trunk/docutils/test/test_writers/test_html5_polyglot_parts.py 2022-12-01 21:13:38 UTC (rev 9292)
@@ -699,11 +699,11 @@
<p>Two footnotes <a class="footnote-reference brackets" href="#f1" id="footnote-reference-1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a> <a class="footnote-reference brackets" href="#f2" id="footnote-reference-2" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> and two citations <a class="citation-reference" href="#once" id="citation-reference-1" role="doc-biblioref">[once]</a> <a class="citation-reference" href="#twice" id="citation-reference-2" role="doc-biblioref">[twice]</a>.</p>
<p>The latter are referenced a second time <a class="footnote-reference brackets" href="#f2" id="footnote-reference-3" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> <a class="citation-reference" href="#twice" id="citation-reference-3" role="doc-biblioref">[twice]</a>.</p>
<aside class="footnote-list brackets">
-<aside class="footnote brackets" id="f1" role="note">
+<aside class="footnote brackets" id="f1" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span>
<p>referenced once</p>
</aside>
-<aside class="footnote brackets" id="f2" role="note">
+<aside class="footnote brackets" id="f2" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></span>
<p>referenced twice</p>
</aside>
@@ -723,11 +723,11 @@
<p>Two footnotes <a class="footnote-reference brackets" href="#f1" id="footnote-reference-1" role="doc-noteref"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></a> <a class="footnote-reference brackets" href="#f2" id="footnote-reference-2" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> and two citations <a class="citation-reference" href="#once" id="citation-reference-1" role="doc-biblioref">[once]</a> <a class="citation-reference" href="#twice" id="citation-reference-2" role="doc-biblioref">[twice]</a>.</p>
<p>The latter are referenced a second time <a class="footnote-reference brackets" href="#f2" id="footnote-reference-3" role="doc-noteref"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></a> <a class="citation-reference" href="#twice" id="citation-reference-3" role="doc-biblioref">[twice]</a>.</p>
<aside class="footnote-list brackets">
-<aside class="footnote brackets" id="f1" role="note">
+<aside class="footnote brackets" id="f1" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>1<span class="fn-bracket">]</span></span>
<p>referenced once</p>
</aside>
-<aside class="footnote brackets" id="f2" role="note">
+<aside class="footnote brackets" id="f2" role="doc-footnote">
<span class="label"><span class="fn-bracket">[</span>2<span class="fn-bracket">]</span></span>
<p>referenced twice</p>
</aside>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2022-12-01 21:13:57
|
Revision: 9293
http://sourceforge.net/p/docutils/code/9293
Author: milde
Date: 2022-12-01 21:13:54 +0000 (Thu, 01 Dec 2022)
Log Message:
-----------
The "xetex" writer now ignores settings in the [latex2e writer] config section.
Move settings intended for both, `xetex` and `latex2e` writers
to section [latex writers].
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/writers/xetex/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2022-12-01 21:13:38 UTC (rev 9292)
+++ trunk/docutils/HISTORY.txt 2022-12-01 21:13:54 UTC (rev 9293)
@@ -88,6 +88,10 @@
- Do not output empty "manual" in ``.TH``
+* docutils/writers/xetex/__init__.py
+
+ - Ignore settings in the [latex2e writer] configuration file section.
+
* setup.py
- Fix SetuptoolsDeprecationWarning: ``Installing '' as data is deprecated``
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2022-12-01 21:13:38 UTC (rev 9292)
+++ trunk/docutils/RELEASE-NOTES.txt 2022-12-01 21:13:54 UTC (rev 9293)
@@ -100,15 +100,6 @@
- Remove ``use_verbatim_when_possible`` setting
(use literal_block_env_: verbatim) in Docutils 2.0.
-* "xetex" writer:
-
- - Settings in the [latex2e writer] `configuration file section`__
- will be ignored by the `xetex` writer in Docutils 0.20.
- Move settings intended for both, `xetex` and `latex2e` writers
- to section [latex writers].
-
- __ docs/user/config.html#configuration-file-sections-entries
-
* Remove the "rawsource" argument from `nodes.Text.__init__()`
(deprecated and ignored since Docutils 0.18) in Docutils 2.0.
@@ -156,7 +147,18 @@
Use dpub-ARIA role "doc-footnote" (instead of ARIA role "note")
for footnotes.
+* Configuration changes:
+ - Settings in the [latex2e writer] configuration file section
+ are now ignored by the "xetex" writer.
+ Move settings intended for both, "xetex" and "latex2e" writers
+ to section `[latex writers]`_.
+
+ .. _[latex writers]: docs/user/config.html#latex-writers
+
+* Bugfixes and improvements (see HISTORY_).
+
+
Release 0.19 (2022-07-05)
=========================
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2022-12-01 21:13:38 UTC (rev 9292)
+++ trunk/docutils/docs/user/config.txt 2022-12-01 21:13:54 UTC (rev 9293)
@@ -145,6 +145,9 @@
following section.
+.. _configuration section:
+.. _configuration sections:
+
-------------------------------------
Configuration File Sections & Entries
-------------------------------------
@@ -1901,7 +1904,6 @@
.. _LaTeX2e writer: latex.html#latex2e-writer
.. _pdfTeX: https://www.tug.org/applications/pdftex/
-.. _configuration section: `Configuration File Sections & Entries`_
Writer Specific Defaults
@@ -1938,14 +1940,12 @@
[xetex writer]
~~~~~~~~~~~~~~
-The `XeTeX writer`_ generates a LaTeX source for compilation with `XeTeX or
-LuaTeX`_. It derives from the latex2e writer, and shares all settings
-defined in the `[latex writers]`_ and `[latex2e writer]`_ `configuration
-sections`_.
+The `XeTeX writer`_ generates a LaTeX source for compilation with `XeTeX
+or LuaTeX`_. It derives from the latex2e writer, and shares all settings
+defined in the `[latex writers]`_ `configuration section`_.
.. _XeTeX writer: latex.html#xetex-writer
.. _XeTeX or LuaTeX: https://texfaq.org/FAQ-xetex-luatex
-.. _configuration sections: `Configuration File Sections & Entries`_
Writer Specific Defaults
""""""""""""""""""""""""
Modified: trunk/docutils/docutils/writers/xetex/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/xetex/__init__.py 2022-12-01 21:13:38 UTC (rev 9292)
+++ trunk/docutils/docutils/writers/xetex/__init__.py 2022-12-01 21:13:54 UTC (rev 9293)
@@ -40,9 +40,7 @@
\\setmonofont[HyphenChar=None,Scale=MatchLowercase]{DejaVu Sans Mono}"""
config_section = 'xetex writer'
- # TODO: remove dependency on `latex2e writer`.
- config_section_dependencies = ('writers', 'latex writers',
- 'latex2e writer')
+ config_section_dependencies = ('writers', 'latex writers')
# use a copy of the parent spec with some modifications:
settings_spec = frontend.filter_settings_spec(
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|