|
From: <mi...@us...> - 2024-01-15 16:10:45
|
Revision: 9514
http://sourceforge.net/p/docutils/code/9514
Author: milde
Date: 2024-01-15 16:10:42 +0000 (Mon, 15 Jan 2024)
Log Message:
-----------
latex2mathml revision
Simplify/clarify code.
Raise MathError when pretty-printing a node with missing children
(e.g. the conversion of `\frac{1}` or `x_`).
Better rendering of math accents.
Modified Paths:
--------------
trunk/docutils/docs/ref/rst/mathematics.txt
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/test/functional/expected/math_output_mathml.html
Modified: trunk/docutils/docs/ref/rst/mathematics.txt
===================================================================
--- trunk/docutils/docs/ref/rst/mathematics.txt 2024-01-13 11:10:47 UTC (rev 9513)
+++ trunk/docutils/docs/ref/rst/mathematics.txt 2024-01-15 16:10:42 UTC (rev 9514)
@@ -121,12 +121,12 @@
.. class:: colwidths-auto
- =========== ============= =========== ============= ============== ================
- `\acute{x}` ``\acute{x}`` `\dot{t}` ``\dot{t}`` `\hat{x}` ``\hat{x}``
- `\bar{v}` ``\bar{v}`` `\ddot{t}` ``\ddot{t}`` `\mathring{x}` ``\mathring{x}``
- `\breve{x}` ``\breve{x}`` `\dddot{t}` ``\dddot{t}`` `\tilde{n}` ``\tilde{n}``
- `\check{x}` ``\check{x}`` `\grave{x}` ``\grave{x}`` `\vec{x}` ``\vec{x}``
- =========== ============= =========== ============= ============== ================
+ =========== ============= ============ ============== ============== ================ ========= ===========
+ `\acute{x}` ``\acute{x}`` `\dot{t}` ``\dot{t}`` `\grave{x}` ``\grave{x}`` `\vec{x}` ``\vec{x}``
+ `\bar{v}` ``\bar{v}`` `\ddot{t}` ``\ddot{t}`` `\hat{x}` ``\hat{x}``
+ `\breve{x}` ``\breve{x}`` `\dddot{t}` ``\dddot{t}`` `\mathring{x}` ``\mathring{x}``
+ `\check{x}` ``\check{x}`` `\ddddot{t}` ``\ddddot{t}`` `\tilde{n}` ``\tilde{n}``
+ =========== ============= ============ ============== ============== ================ ========= ===========
When adding an accent to an i or j in math, dotless variants can be
obtained with ``\imath`` and ``\jmath``: `\hat \imath`, `\vec{\jmath}`.
@@ -312,6 +312,8 @@
============= =============== ========== ============ ========== ============ =========== =============
+.. _math alphabet:
+
Mathematical Alphabets
----------------------
@@ -374,7 +376,7 @@
mathematical symbol (for other output formats, results are mixed):
.. math::
- \boldsymbol{\cos(x)\pm\alpha \approx 3\Gamma \quad \forall x\in\mathbb{R}}
+ \boldsymbol{V_i x \pm \cos(\alpha) \approx 3\Gamma \quad \forall x\in\mathbb{R}}
Miscellaneous symbols
@@ -882,9 +884,9 @@
The declarations [#]_ ``\displaystyle``, ``\textstyle``,
``\scriptstyle``, and ``\scriptscriptstyle``, select a symbol size and
-spacing that would be applied in (respectively) display math, inline
-math, first-order subscript, or second-order subscript, even when the
-current context would normally yield some other size.
+spacing that would be applied in display math, inline
+math, first-order subscript, or second-order subscript, respectively
+even when the current context would normally yield some other size.
For example ``:math:`\displaystyle \sum_{n=0}^\infty
\frac{1}{n}``` is printed as `\displaystyle \sum_{n=0}^\infty \frac{1}{n}`
@@ -921,24 +923,34 @@
Font changes
~~~~~~~~~~~~
-Math alphabet macros change the default alphabet ("mathvariant" in
-MathML), leaving some symbols unchanged:
+`Math alphabet`_ macros change the default alphabet, leaving some symbols
+unchanged. In MathML core, the corresponding *Mathematical Alphanumeric
+Symbols* should be used.
-:normal: `abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R`
-:mathrm: `\mathrm{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}`
-:mathit: `\mathit{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}`
-:mathsf: `\mathsf{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}`
-:mathbb: `\mathbb{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}`
-:mathbf: `\mathbf{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}`
-:mathcal: `\mathcal{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}`
-:mathscr: `\mathscr{abs(x) \pm \alpha \approx 3 \Gamma \quad \forall x \in R}`
+:default: `V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}`
+:mathbb: `\mathbb{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
+:mathbf: `\mathbf{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
+:mathbfit: `\mathbfit{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
+:mathcal: `\mathcal{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
+:mathit: `\mathit{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
+:mathrm: `\mathrm{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
+:mathscr: `\mathscr{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
+:mathsf: `\mathsf{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
+:mathsfbfit: `\mathsfbfit{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
+:mathsfit: `\mathsfit{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
+:mathtt: `\mathtt{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
+LaTeX accepts complex functions inside the math alphabet functions:
+
+:mathrm: `\mathrm{\frac{x}{y}}`
+
+
Without additional packages, LaTeX supports "blackboard-bold" only for
capital Latin letters.
Unicode supports also small Latin letters, some Greek letters, and digits:
`\mathbb{A \ldots Z a \ldots z}
\mathbb\Gamma \mathbb{\Pi} \mathbb {\Sigma} \mathbb\gamma \mathbb \pi
-\mathbb{0 \ldots 9}`.
+\mathbb{0 \ldots 9}` but no italic numbers.
Inferred <mrow>s in MathML
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2024-01-13 11:10:47 UTC (rev 9513)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2024-01-15 16:10:42 UTC (rev 9514)
@@ -109,7 +109,6 @@
# operator, fence, or separator -> <mo>
-
stretchables = {
# extensible delimiters allowed in left/right cmds
'backslash': '\\',
@@ -221,25 +220,25 @@
'negthickspace': '-0.2778em', # -5mu = -5/18em
}
-# accents -> <mover stretchy="false">
+# accents: -> <mo stretchy="false"> in <mover>
accents = {
- # TeX: (spacing, combining)
- 'acute': ('´', '\u0301'),
- 'bar': ('ˉ', '\u0304'),
- 'breve': ('˘', '\u0306'),
- 'check': ('ˇ', '\u030C'),
- 'dot': ('˙', '\u0307'),
- 'ddot': ('¨', '\u0308'),
- 'dddot': ('⋯', '\u20DB'),
- 'grave': ('`', '\u0300'),
- 'hat': ('ˆ', '\u0302'),
- 'mathring': ('˚', '\u030A'),
- 'tilde': ('˜', '\u0303'), # tilde ~ or small tilde ˜?
- 'vec': ('→', '\u20d7'), # → too heavy, accents="false"
- # TODO: ddddot
+ # TeX: spacing combining
+ 'acute': '´', # '\u0301'
+ 'bar': 'ˉ', # '\u0304'
+ 'breve': '˘', # '\u0306'
+ 'check': 'ˇ', # '\u030C'
+ 'dot': '˙', # '\u0307'
+ 'ddot': '¨', # '\u0308'
+ 'dddot': '˙˙˙', # '\u20DB' # or … ?
+ 'ddddot': '˙˙˙˙', # '\u20DC' # or ¨¨ ?
+ 'grave': '`', # '\u0300'
+ 'hat': 'ˆ', # '\u0302'
+ 'mathring': '˚', # '\u030A'
+ 'tilde': '~', # '\u0303' # tilde ~ or small tilde ˜?
+ 'vec': '→', # '\u20d7' # → too heavy, use scriptlevel="+1"
}
-# limits etc. -> <mover> or <munder>
+# limits etc. -> <mo> in <mover> or <munder>
over = {
# TeX: (char, offset-correction/em)
'overbrace': ('\u23DE', -0.2), # DejaVu Math -0.6
@@ -340,16 +339,11 @@
ord('&'): '&',
0x2061: '⁡',
}
- _boolstrings = {True: 'true', False: 'false'}
- """String representation of boolean MathML attribute values."""
- html_tagname = 'span'
- """Tag name for HTML representation."""
-
def __init__(self, *children, **attributes):
"""Set up node with `children` and `attributes`.
- Attributes are downcased: Use CLASS to set "class" value.
+ Attributes are downcased to allow using CLASS to set "class" value.
>>> math(mn(3), CLASS='test')
math(mn(3), class='test')
>>> math(CLASS='test').toprettyxml()
@@ -357,8 +351,7 @@
"""
self.children = []
- self.extend(children)
-
+ self += children
self.attributes = {}
for key in attributes.keys():
# Use .lower() to allow argument `CLASS` for attribute `class`
@@ -366,14 +359,13 @@
self.attributes[key.lower()] = attributes[key]
def __repr__(self):
- content = [repr(item) for item in getattr(self, 'children', [])]
+ content = [repr(item) for item in self.children]
if hasattr(self, 'data'):
content.append(repr(self.data))
- if isinstance(self, MathSchema) and self.switch:
+ if getattr(self, 'switch', None):
content.append('switch=True')
content += ["%s=%r"%(k, v) for k, v in self.attributes.items()
if v is not None]
-
return self.__class__.__name__ + '(%s)' % ', '.join(content)
def __len__(self):
@@ -392,8 +384,7 @@
def full(self):
"""Return boolean indicating whether children may be appended."""
- return (self.nchildren is not None
- and len(self) >= self.nchildren)
+ return self.nchildren is not None and len(self) >= self.nchildren
def append(self, child):
"""Append child and return self or first non-full parent.
@@ -414,6 +405,8 @@
self.append(child)
return self
+ __iadd__ = extend # alias for ``+=`` operator
+
def close(self):
"""Close element and return first non-full parent or None."""
parent = self.parent
@@ -421,21 +414,29 @@
parent = parent.parent
return parent
+ # Conversion to (pretty) XML string
def toprettyxml(self):
"""Return XML representation of self as string."""
return ''.join(self._xml())
def _xml(self, level=0):
- return ([self.xml_starttag()]
- + self._xml_body(level)
- + ['</%s>' % self.__class__.__name__])
+ if self.nchildren is not None and len(self) < self.nchildren:
+ raise MathError(f'Node {self.xml_starttag()} misses children.'
+ ' Incomplete source?')
+ return [self.xml_starttag(),
+ *self._xml_body(level),
+ '</%s>' % self.__class__.__name__]
def xml_starttag(self):
- attrs = ('%s="%s"' % (k, str(v).replace('True', 'true').replace('False', 'false'))
- for k, v in self.attributes.items()
- if v is not None)
+ attrs = (f'{k}="{self.a_str(v)}"'
+ for k, v in self.attributes.items() if v is not None)
return '<%s>' % ' '.join((self.__class__.__name__, *attrs))
+ @staticmethod
+ def a_str(v):
+ # Return string representation for attribute value `v`.
+ return str(v).replace('True', 'true').replace('False', 'false')
+
def _xml_body(self, level=0):
xml = []
for child in self.children:
@@ -444,6 +445,7 @@
xml.extend(['\n', ' ' * level])
return xml
+ # display mode
def is_block(self):
"""Return true, if `self` or a parent has ``display='block'``."""
try:
@@ -461,6 +463,9 @@
# '<math>\n <mn>2</mn>\n</math>'
# >>> len(n2)
# 1
+# >>> n2 += [mo('!')]
+# >>> n2
+# math(mn(2), mo('!'))
# >>> eq3 = math(id='eq3', display='block')
# >>> eq3
# math(id='eq3', display='block')
@@ -957,8 +962,8 @@
if name in ordinary:
# <mi mathvariant="normal"> well supported by Chromium but
- # Firefox 115.5.0 puts additional space after the symbol, e.g.
- # <mi mathvariant="normal">∂</mi><mi>t</mi> looks like <mo>∂</mo>…
+ # Firefox 115.5.0 puts additional space around the symbol, e.g.
+ # <mi mathvariant="normal">∂</mi><mi>t</mi> looks like ∂ t, not ∂t
# return node.append(mi(ordinary[name], mathvariant='normal')), string
return node.append(mi(ordinary[name])), string
@@ -1174,10 +1179,12 @@
return entry, string
if name in accents:
- new_node = mover(mo(accents[name][0], stretchy=False), switch=True)
+ accent_node = mo(accents[name], stretchy=False)
+ # mi() would be simpler, but semantically wrong
+ # --- https://w3c.github.io/mathml-core/#operator-fence-separator-or-accent-mo
if name == 'vec':
- new_node.children[0]['accent'] = False # scale down arrow but drop i-dot
- new_node.tex_cmd = name # for HTML export
+ accent_node['scriptlevel'] = '+1' # scale down arrow
+ new_node = mover(accent_node, accent=True, switch=True)
node.append(new_node)
return new_node, string
@@ -1186,7 +1193,6 @@
# but to True on accent node get "textstyle" (full size) symbols on top
new_node = mover(mo(over[name][0], accent=True),
switch=True, accent=False)
- new_node.tex_cmd = name # for HTML export
node.append(new_node)
return new_node, string
@@ -1197,7 +1203,6 @@
if name in under:
new_node = munder(mo(under[name][0]), switch=True)
- new_node.tex_cmd = name # for HTML export
node.append(new_node)
return new_node, string
@@ -1280,7 +1285,7 @@
# >>> handle_cmd('overline', math(), '{981}')
# (mover(mo('_', accent=True), switch=True, accent=False), '{981}')
# >>> handle_cmd('bar', math(), '{x}')
-# (mover(mo('ˉ', stretchy=False), switch=True), '{x}')
+# (mover(mo('ˉ', stretchy=False), switch=True, accent=True), '{x}')
# >>> handle_cmd('xleftarrow', math(), r'[\alpha]{10}')
# (munderover(mo('⟵'), mi('α')), '{10}')
# >>> handle_cmd('xleftarrow', math(), r'[\alpha=5]{10}')
@@ -1387,10 +1392,13 @@
# Return dictionary with attributes to style an <mtable> as align environment:
-# TODO: "columnalign" disregarded by Chromium and webkit
+# TODO: "columnalign" disregarded by Chromium and webkit.
+# Use style="text-align: (right|left|center)" in the <mtd> elements
+# or a (complex) CSS rule for "mtable.align"
def align_attributes(rows):
atts = {'class': 'align',
'displaystyle': True}
+ # get maximal number of (non-escaped) "next column" markup instances:
tabs = max(row.count('&') - row.count(r'\&') for row in rows)
if tabs:
aligns = ['right', 'left'] * tabs
@@ -1407,6 +1415,10 @@
# {'class': 'align', 'displaystyle': True, 'columnalign': 'right left right', 'columnspacing': '0 2em'}
# >>> align_attributes(['a &= b & c &= d'])
# {'class': 'align', 'displaystyle': True, 'columnalign': 'right left right left', 'columnspacing': '0 2em 0'}
+# >>> align_attributes([r'a &= b & c &= d \& e'])
+# {'class': 'align', 'displaystyle': True, 'columnalign': 'right left right left', 'columnspacing': '0 2em 0'}
+# >>> align_attributes([r'a &= b & c &= d & e'])
+# {'class': 'align', 'displaystyle': True, 'columnalign': 'right left right left right', 'columnspacing': '0 2em 0 2em'}
def tex2mathml(tex_math, as_block=False):
@@ -1421,7 +1433,7 @@
math_tree['display'] = 'block'
rows = toplevel_code(tex_math).split(r'\\')
if len(rows) > 1:
- # emulate align* environment with a math table
+ # emulate "align*" environment with a math table
node = mtd()
math_tree.append(mtable(mtr(node),
**align_attributes(rows)))
@@ -1474,10 +1486,6 @@
# </math>
-# TODO: raise error if <sqrt> doesnot have a base character (missing children)
-# >> '\sqrt[3]'
-# Maybe also other nodes...
-
# TODO: look up more symbols from tr25, e.g.
#
#
Modified: trunk/docutils/test/functional/expected/math_output_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_mathml.html 2024-01-13 11:10:47 UTC (rev 9513)
+++ trunk/docutils/test/functional/expected/math_output_mathml.html 2024-01-15 16:10:42 UTC (rev 9514)
@@ -195,7 +195,7 @@
</mfrac>
<mi class="capital-greek">Ψ</mi>
<mo>=</mo>
- <mover>
+ <mover accent="true">
<mi>H</mi>
<mo stretchy="false">ˆ</mo>
</mover>
@@ -212,19 +212,19 @@
<dd><table class="borderless" style="width: 100%;">
<tbody>
<tr><td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>a</mi>
<mo stretchy="false">´</mo>
</mover>
</math> <span class="docutils literal">\acute{a}</span></p></td>
<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>t</mi>
<mo stretchy="false">˙</mo>
</mover>
</math> <span class="docutils literal">\dot{t}</span></p></td>
<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>γ</mi>
<mo stretchy="false">ˆ</mo>
</mover>
@@ -231,59 +231,59 @@
</math> <span class="docutils literal"><span class="pre">\hat{\gamma}</span></span></p></td>
</tr>
<tr><td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>a</mi>
<mo stretchy="false">`</mo>
</mover>
</math> <span class="docutils literal">\grave{a}</span></p></td>
<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>t</mi>
<mo stretchy="false">¨</mo>
</mover>
</math> <span class="docutils literal">\ddot{t}</span></p></td>
<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>α</mi>
- <mo stretchy="false">˜</mo>
+ <mo stretchy="false">~</mo>
</mover>
</math> <span class="docutils literal"><span class="pre">\tilde{\alpha}</span></span></p></td>
</tr>
<tr><td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>x</mi>
<mo stretchy="false">˘</mo>
</mover>
</math> <span class="docutils literal">\breve{x}</span></p></td>
<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>t</mi>
- <mo stretchy="false">⋯</mo>
+ <mo stretchy="false">˙˙˙</mo>
</mover>
</math> <span class="docutils literal">\dddot{t}</span></p></td>
<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>ı</mi>
- <mo stretchy="false" accent="false">→</mo>
+ <mo stretchy="false" scriptlevel="+1">→</mo>
</mover>
</math> <span class="docutils literal"><span class="pre">\vec{\imath}</span></span></p></td>
</tr>
<tr><td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>a</mi>
<mo stretchy="false">ˇ</mo>
</mover>
</math> <span class="docutils literal">\check{a}</span></p></td>
<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>a</mi>
<mo stretchy="false">ˉ</mo>
</mover>
</math> <span class="docutils literal">\bar{a}</span></p></td>
<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mover>
+ <mover accent="true">
<mi>R</mi>
- <mo stretchy="false" accent="false">→</mo>
+ <mo stretchy="false" scriptlevel="+1">→</mo>
</mover>
</math> <span class="docutils literal">\vec{R}</span></p></td>
</tr>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-01-15 16:10:58
|
Revision: 9515
http://sourceforge.net/p/docutils/code/9515
Author: milde
Date: 2024-01-15 16:10:55 +0000 (Mon, 15 Jan 2024)
Log Message:
-----------
Add MathML support for "aligned" environment, fix "align*" in Chrome.
Use CSS rules instead of the deprecated "columnalign" attribute
to style <mtable> as "align*" or "aligned" environment.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/ref/rst/mathematics.txt
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/docutils/writers/html5_polyglot/minimal.css
trunk/docutils/docutils/writers/html5_polyglot/plain.css
trunk/docutils/docutils/writers/html5_polyglot/responsive.css
trunk/docutils/test/functional/expected/math_output_mathml.html
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-01-15 16:10:42 UTC (rev 9514)
+++ trunk/docutils/HISTORY.txt 2024-01-15 16:10:55 UTC (rev 9515)
@@ -97,6 +97,9 @@
- Elimitate side-effect of importing "latex2mathml" on "tex2unichar".
- Sort ℏ (`\hslash`) as "mathord", not "mathalpha".
- Use MathML element <mi> instead of <mo> for character class "mathord".
+ - Use CSS rules instead of the deprecated "columnalign" attribute
+ to style <mtable> as "align" environment. Fixes rendering in Crome.
+ - Support "aligned" environment.
* docutils/utils/roman.py
@@ -113,6 +116,10 @@
- Support video inclusion via `<object>` tags.
+* docutils/writers/html5_polyglot/*.css
+
+ - Move MathML styles to "minimal.css" (required for correct rendering).
+
* docutils/writers/_html_base.py
- Stop setting the "footnote-reference" class value for footnote references.
Modified: trunk/docutils/docs/ref/rst/mathematics.txt
===================================================================
--- trunk/docutils/docs/ref/rst/mathematics.txt 2024-01-15 16:10:42 UTC (rev 9514)
+++ trunk/docutils/docs/ref/rst/mathematics.txt 2024-01-15 16:10:55 UTC (rev 9515)
@@ -80,10 +80,33 @@
.. math::
- a &= (x + y)^2 & b &= (x - y)^2 \\
- &= x^2 + 2xy + y^2 & &= x^2 - 2xy + y^2
+ a & = (x + y)^2 & b & = (x - y)^2 \\
+ & = x^2 + 2xy + y^2 & & = x^2 - 2xy + y^2
+The ``aligned`` environment can be used as a component in a containing
+expression. E.g., ::
+ .. math::
+ \left.
+ \begin{aligned}
+ B' & = -\partial\times E, \\
+ E' & = \partial\times B - 4\pi j,
+ \end{aligned}
+ \right\}
+ \qquad \text{Maxwell’s equations}
+
+results in
+
+.. math::
+ \left.
+ \begin{aligned}
+ B' & = -\partial\times E \\
+ E' & = \partial\times B - 4\pi j
+ \end{aligned}
+ \;\right\}
+ \qquad \text{Maxwell’s equations.}
+
+
.. [#math-syntax] The supported LaTeX commands include AMS extensions
(see, e.g., the `Short Math Guide`_). Some of the shown symbols
require the "amssymb" `LaTeX package`_ (or another package providing
@@ -925,7 +948,7 @@
`Math alphabet`_ macros change the default alphabet, leaving some symbols
unchanged. In MathML core, the corresponding *Mathematical Alphanumeric
-Symbols* should be used.
+Symbols* are used.
:default: `V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}`
:mathbb: `\mathbb{V_R x \pm \cos(\alpha) \approx 3 \Gamma \quad \forall x \in \mathbb{R}}`
@@ -950,7 +973,7 @@
Unicode supports also small Latin letters, some Greek letters, and digits:
`\mathbb{A \ldots Z a \ldots z}
\mathbb\Gamma \mathbb{\Pi} \mathbb {\Sigma} \mathbb\gamma \mathbb \pi
-\mathbb{0 \ldots 9}` but no italic numbers.
+\mathbb{0 \ldots 9}` but no italic digits.
Inferred <mrow>s in MathML
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2024-01-15 16:10:42 UTC (rev 9514)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2024-01-15 16:10:55 UTC (rev 9515)
@@ -283,6 +283,7 @@
'Bmatrix': ('{', '}'),
'vmatrix': ('|', '|'),
'Vmatrix': ('\u2016', '\u2016'), # ‖
+ 'aligned': ('', ''),
'cases': ('{', ''),
}
@@ -445,7 +446,8 @@
xml.extend(['\n', ' ' * level])
return xml
- # display mode
+ # auxiliary methods:
+
def is_block(self):
"""Return true, if `self` or a parent has ``display='block'``."""
try:
@@ -1340,6 +1342,7 @@
if name == 'cases':
wrapper = mrow(mo(left_delimiter, rspace='0.17em'))
attributes['columnalign'] = 'left'
+ attributes['class'] = 'cases'
node.append(wrapper)
node = wrapper
elif name == 'smallmatrix':
@@ -1348,8 +1351,9 @@
wrapper = mstyle(scriptlevel='1')
node.append(wrapper)
node = wrapper
- # TODO: aligned, alignedat
- # take an optional [t], [b] or the default [c]
+ elif name == 'aligned':
+ attributes['class'] = 'ams-align'
+ # TODO: array, aligned & alignedat take an optional [t], [b], or [c].
entry = mtd()
node.append(mtable(mtr(entry), **attributes))
node = entry
@@ -1392,13 +1396,12 @@
# Return dictionary with attributes to style an <mtable> as align environment:
-# TODO: "columnalign" disregarded by Chromium and webkit.
-# Use style="text-align: (right|left|center)" in the <mtd> elements
-# or a (complex) CSS rule for "mtable.align"
+# Not used with HTML. Replaced by CSS rule for "mtable.ams-align" in
+# "minimal.css" as "columnalign" is disregarded by Chromium and webkit.
def align_attributes(rows):
- atts = {'class': 'align',
+ atts = {'class': 'ams-align',
'displaystyle': True}
- # get maximal number of (non-escaped) "next column" markup instances:
+ # get maximal number of non-escaped "next column" markup characters:
tabs = max(row.count('&') - row.count(r'\&') for row in rows)
if tabs:
aligns = ['right', 'left'] * tabs
@@ -1408,17 +1411,17 @@
return atts
# >>> align_attributes(['a = b'])
-# {'class': 'align', 'displaystyle': True}
+# {'class': 'ams-align', 'displaystyle': True}
# >>> align_attributes(['a &= b'])
-# {'class': 'align', 'displaystyle': True, 'columnalign': 'right left', 'columnspacing': '0'}
+# {'class': 'ams-align', 'displaystyle': True, 'columnalign': 'right left', 'columnspacing': '0'}
# >>> align_attributes(['a &= b & a \in S'])
-# {'class': 'align', 'displaystyle': True, 'columnalign': 'right left right', 'columnspacing': '0 2em'}
+# {'class': 'ams-align', 'displaystyle': True, 'columnalign': 'right left right', 'columnspacing': '0 2em'}
# >>> align_attributes(['a &= b & c &= d'])
-# {'class': 'align', 'displaystyle': True, 'columnalign': 'right left right left', 'columnspacing': '0 2em 0'}
+# {'class': 'ams-align', 'displaystyle': True, 'columnalign': 'right left right left', 'columnspacing': '0 2em 0'}
# >>> align_attributes([r'a &= b & c &= d \& e'])
-# {'class': 'align', 'displaystyle': True, 'columnalign': 'right left right left', 'columnspacing': '0 2em 0'}
+# {'class': 'ams-align', 'displaystyle': True, 'columnalign': 'right left right left', 'columnspacing': '0 2em 0'}
# >>> align_attributes([r'a &= b & c &= d & e'])
-# {'class': 'align', 'displaystyle': True, 'columnalign': 'right left right left right', 'columnspacing': '0 2em 0 2em'}
+# {'class': 'ams-align', 'displaystyle': True, 'columnalign': 'right left right left right', 'columnspacing': '0 2em 0 2em'}
def tex2mathml(tex_math, as_block=False):
@@ -1435,8 +1438,8 @@
if len(rows) > 1:
# emulate "align*" environment with a math table
node = mtd()
- math_tree.append(mtable(mtr(node),
- **align_attributes(rows)))
+ math_tree.append(mtable(mtr(node), CLASS='ams-align',
+ displaystyle=True))
parse_latex_math(node, tex_math)
return math_tree.toprettyxml()
@@ -1450,7 +1453,7 @@
# </math>
# >>> print(tex2mathml(r'a & b \\ c & d', as_block=True))
# <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
-# <mtable class="align" displaystyle="true" columnalign="right left" columnspacing="0">
+# <mtable class="ams-align" displaystyle="true">
# <mtr>
# <mtd>
# <mi>a</mi>
@@ -1471,7 +1474,7 @@
# </math>
# >>> print(tex2mathml(r'a \\ b', as_block=True))
# <math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
-# <mtable class="align" displaystyle="true">
+# <mtable class="ams-align" displaystyle="true">
# <mtr>
# <mtd>
# <mi>a</mi>
Modified: trunk/docutils/docutils/writers/html5_polyglot/minimal.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2024-01-15 16:10:42 UTC (rev 9514)
+++ trunk/docutils/docutils/writers/html5_polyglot/minimal.css 2024-01-15 16:10:55 UTC (rev 9515)
@@ -265,6 +265,19 @@
caption-side: bottom;
}
+/* MathML (see "math.css" for --math-output=HTML) */
+math .boldsymbol { font-weight: bold; }
+/* style table similar to AMS "align" or "aligned" environment: */
+mtable.cases > mtr > mtd { text-align: left; }
+mtable.ams-align > mtr > mtd { padding-left: 0; padding-right: 0; }
+mtable.ams-align > mtr > mtd:nth-child(2n) { text-align: left; }
+mtable.ams-align > mtr > mtd:nth-child(2n+1) { text-align: right; }
+mtable.ams-align > mtr > mtd:nth-child(2n+3) { padding-left: 2em; }
+mstyle.mathscr, mi.mathscr {
+ font-family: STIX, XITSMathJax_Script, rsfs10,
+ "Asana Math", Garamond, cursive;
+}
+
/* Document Header and Footer */
header { border-bottom: 1px solid black; }
footer { border-top: 1px solid black; }
Modified: trunk/docutils/docutils/writers/html5_polyglot/plain.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/plain.css 2024-01-15 16:10:42 UTC (rev 9514)
+++ trunk/docutils/docutils/writers/html5_polyglot/plain.css 2024-01-15 16:10:55 UTC (rev 9515)
@@ -279,15 +279,6 @@
pre.code .deleted, code .deleted { background-color: #DEB0A1}
pre.code .inserted, code .inserted { background-color: #A3D289}
-/* Math */
-/* for math-output=MathML (for math-output=HTML, see math.css) */
-math .boldsymbol {
- font-weight: bold;
-}
-mstyle.mathscr, mi.mathscr {
- font-family: STIX, XITSMathJax_Script, rsfs10,
- "Asana Math", Garamond, cursive;
-}
/* Epigraph */
/* Highlights */
Modified: trunk/docutils/docutils/writers/html5_polyglot/responsive.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/responsive.css 2024-01-15 16:10:42 UTC (rev 9514)
+++ trunk/docutils/docutils/writers/html5_polyglot/responsive.css 2024-01-15 16:10:55 UTC (rev 9515)
@@ -351,16 +351,6 @@
width: 40%;
}
-/* Math */
-/* for math-output=MathML (for math-output=HTML, see math.css) */
-math .boldsymbol {
- font-weight: bold;
-}
-mstyle.mathscr, mi.mathscr {
- font-family: STIX, XITSMathJax_Script, rsfs10,
- "Asana Math", Garamond, cursive;
-}
-
/* Adaptive page layout */
/* ==================== */
Modified: trunk/docutils/test/functional/expected/math_output_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_mathml.html 2024-01-15 16:10:42 UTC (rev 9514)
+++ trunk/docutils/test/functional/expected/math_output_mathml.html 2024-01-15 16:10:55 UTC (rev 9515)
@@ -392,7 +392,7 @@
<span class="docutils literal">align</span> environment:</p>
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
- <mtable class="align" displaystyle="true" columnalign="right left" columnspacing="0">
+ <mtable class="ams-align" displaystyle="true">
<mtr>
<mtd>
<msub>
@@ -468,7 +468,7 @@
<mo>=</mo>
<mrow>
<mo rspace="0.17em">{</mo>
- <mtable columnalign="left">
+ <mtable columnalign="left" class="cases">
<mtr>
<mtd>
<mo>−</mo>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-02-01 13:03:05
|
Revision: 9530
http://sourceforge.net/p/docutils/code/9530
Author: milde
Date: 2024-02-01 13:03:02 +0000 (Thu, 01 Feb 2024)
Log Message:
-----------
MathML elements: `toprettyxml()`: close empty elements on the same line.
Makes MathML output shorter and similar to `xml.etree`.
Modified Paths:
--------------
trunk/docutils/docutils/utils/math/mathml_elements.py
trunk/docutils/test/functional/expected/buggy_mathml.html
trunk/docutils/test/functional/expected/math_experiments_mathml_.html
trunk/docutils/test/functional/expected/math_output_mathml.html
trunk/docutils/test/functional/expected/mathematics_mathml_.html
Modified: trunk/docutils/docutils/utils/math/mathml_elements.py
===================================================================
--- trunk/docutils/docutils/utils/math/mathml_elements.py 2024-02-01 13:02:51 UTC (rev 9529)
+++ trunk/docutils/docutils/utils/math/mathml_elements.py 2024-02-01 13:03:02 UTC (rev 9530)
@@ -79,7 +79,7 @@
>>> math(CLASS='test', level=3, split=True)
math(class='test', level='3', split='true')
>>> math(CLASS='test', level=3, split=True).toprettyxml()
- '<math class="test" level="3" split="true">\n</math>'
+ '<math class="test" level="3" split="true"></math>'
"""
self.attrib = {k.lower(): self.a_str(v)
@@ -229,7 +229,8 @@
for child in self.children:
xml.extend(['\n', ' ' * (level+1)])
xml.extend(child._xml(level+1))
- xml.extend(['\n', ' ' * level])
+ if self.children:
+ xml.extend(['\n', ' ' * level])
return xml
# >>> n2 = math(mn(2))
@@ -245,7 +246,7 @@
# >>> eq3
# math(id='eq3', display='block')
# >>> eq3.toprettyxml()
-# '<math id="eq3" display="block">\n</math>'
+# '<math id="eq3" display="block"></math>'
# >>> len(eq3)
# 0
# >>> math(CLASS='bold').xml_starttag()
@@ -391,7 +392,7 @@
nchildren = 0
# >>> mspace(width='2em').toprettyxml()
-# '<mspace width="2em">\n</mspace>'
+# '<mspace width="2em"></mspace>'
# >>> mspace(mn(3))
# Traceback (most recent call last):
# ...
@@ -568,4 +569,4 @@
# >>> t = mtable(displaystyle=True)
# >>> math(t).toprettyxml()
-# '<math>\n <mtable displaystyle="true">\n </mtable>\n</math>'
+# '<math>\n <mtable displaystyle="true"></mtable>\n</math>'
Modified: trunk/docutils/test/functional/expected/buggy_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/buggy_mathml.html 2024-02-01 13:02:51 UTC (rev 9529)
+++ trunk/docutils/test/functional/expected/buggy_mathml.html 2024-02-01 13:03:02 UTC (rev 9530)
@@ -48,7 +48,7 @@
</pre>
<aside class="system-message">
<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">buggy-maths</span>, line 15)</p>
-<p>Unknown LaTeX command "\phy".</p>
+<p>No insertion point for " \phy \, d\gamma". Unbalanced braces in "\int_{-\infty} 3 \sin x}"?</p>
</aside>
<aside class="sidebar">
<p class="sidebar-title">nebenbemerkung</p>
@@ -55,7 +55,7 @@
<p>noch was <span class="math problematic">\sqrt[2]</span></p>
<aside class="system-message">
<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">buggy-maths</span>, line 19)</p>
-<p>Node <mroot> misses children. Incomplete source?</p>
+<p>Last node missing children. Source incomplete?</p>
</aside>
</aside>
<pre class="math problematic">
@@ -63,7 +63,7 @@
</pre>
<aside class="system-message">
<p class="system-message-title">System Message: WARNING/2 (<span class="docutils literal">buggy-maths</span>, line 21)</p>
-<p>Node <mroot> misses children. Incomplete source?</p>
+<p>Last node missing children. Source incomplete?</p>
</aside>
<p>2-zeilig mit align:</p>
<div>
@@ -90,8 +90,7 @@
<mo>+</mo>
<mn>3</mn>
</mtd>
- <mtd>
- </mtd>
+ <mtd></mtd>
</mtr>
</mtable>
</math>
Modified: trunk/docutils/test/functional/expected/math_experiments_mathml_.html
===================================================================
--- trunk/docutils/test/functional/expected/math_experiments_mathml_.html 2024-02-01 13:02:51 UTC (rev 9529)
+++ trunk/docutils/test/functional/expected/math_experiments_mathml_.html 2024-02-01 13:03:02 UTC (rev 9530)
@@ -34,8 +34,7 @@
<mo>≈</mo>
<mn>3</mn>
<mi class="capital-greek">Γ</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi>x</mi>
<mo>∈</mo>
@@ -59,8 +58,7 @@
<mo>≈</mo>
<mn>𝟛</mn>
<mi class="capital-greek">ℾ</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi>𝕩</mi>
<mo>∈</mo>
@@ -85,8 +83,7 @@
<mo>≈</mo>
<mn>𝟑</mn>
<mi class="capital-greek">𝚪</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi>𝐱</mi>
<mo>∈</mo>
@@ -111,8 +108,7 @@
<mo>≈</mo>
<mn>3</mn>
<mi class="capital-greek">𝜞</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi>𝒙</mi>
<mo>∈</mo>
@@ -137,8 +133,7 @@
<mo>≈</mo>
<mn>3</mn>
<mi class="capital-greek">Γ</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi>𝓍</mi>
<mo>∈</mo>
@@ -163,8 +158,7 @@
<mo>≈</mo>
<mn>3</mn>
<mi class="capital-greek">𝛤</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi>𝑥</mi>
<mo>∈</mo>
@@ -189,8 +183,7 @@
<mo>≈</mo>
<mn>3</mn>
<mi class="capital-greek" mathvariant="normal">Γ</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi mathvariant="normal">x</mi>
<mo>∈</mo>
@@ -215,8 +208,7 @@
<mo>≈</mo>
<mn>3</mn>
<mi class="capital-greek">Γ</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi>𝓍</mi>
<mo>∈</mo>
@@ -241,8 +233,7 @@
<mo>≈</mo>
<mn>𝟥</mn>
<mi class="capital-greek">Γ</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi>𝗑</mi>
<mo>∈</mo>
@@ -267,8 +258,7 @@
<mo>≈</mo>
<mn>3</mn>
<mi class="capital-greek">𝞒</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi>𝙭</mi>
<mo>∈</mo>
@@ -293,8 +283,7 @@
<mo>≈</mo>
<mn>3</mn>
<mi class="capital-greek">Γ</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi>𝘹</mi>
<mo>∈</mo>
@@ -319,8 +308,7 @@
<mo>≈</mo>
<mn>𝟹</mn>
<mi class="capital-greek">Γ</mi>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>∀</mi>
<mi>𝚡</mi>
<mo>∈</mo>
@@ -379,8 +367,7 @@
<mo>+</mo>
<mi>x</mi>
<mo>,</mo>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>b</mi>
<mo>=</mo>
<msqrt>
@@ -392,8 +379,7 @@
</msup>
</msqrt>
<mo>,</mo>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mi>c</mi>
<mo>=</mo>
<msqrt>
@@ -547,7 +533,8 @@
<p>tex-token returns "{" for nested groups:</p>
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
- <mtext>das ist ein {toller} text (unescaped \{ and \} is ignored by LaTeX)</mtext>
+ <mtext>das ist ein {toller} text (unescaped \{ and \} is
+ignored by LaTeX)</mtext>
</math>
</div>
</section>
@@ -1131,78 +1118,67 @@
<mi>b</mi>
<mo>)</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">(</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">(</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">)</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mo stretchy="false">[</mo>
<mi>b</mi>
<mo>]</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">[</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">]</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">[</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">]</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mo>{</mo>
<mi>b</mi>
<mo>}</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">{</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">}</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">{</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">}</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mo>⟨</mo>
<mi>b</mi>
<mo>⟩</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">⟨</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">⟩</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">⟨</mo>
<mi>b</mi>
@@ -1217,78 +1193,67 @@
<mi>b</mi>
<mo>⌉</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">⌈</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">⌉</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">⌈</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">⌉</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mo>⌊</mo>
<mi>b</mi>
<mo>⌋</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">⌊</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">⌋</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">⌊</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">⌋</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mo class="mathopen">|</mo>
<mi>b</mi>
<mo>|</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">|</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">|</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">|</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">|</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mo class="mathopen">‖</mo>
<mi>b</mi>
<mo>‖</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">‖</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">‖</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">‖</mo>
<mi>b</mi>
@@ -1303,57 +1268,49 @@
<mi>b</mi>
<mo>⟯</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">⟮</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">⟯</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">⟮</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">⟯</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mi>⎰</mi>
<mi>b</mi>
<mo>⎱</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">⎰</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">⎱</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">⎰</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">⎱</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mo stretchy="false">/</mo>
<mi>b</mi>
<mo>\</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">/</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">\</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">/</mo>
<mi>b</mi>
@@ -1369,78 +1326,67 @@
<mi>b</mi>
<mo>|</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">|</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">|</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">|</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">|</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mo>|</mo>
<mi>b</mi>
<mo>|</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">|</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">|</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">|</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">|</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mo>‖</mo>
<mi>b</mi>
<mo>‖</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">‖</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">‖</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">‖</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">‖</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mo>‖</mo>
<mi>b</mi>
<mo>‖</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">‖</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">‖</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">‖</mo>
<mi>b</mi>
@@ -1455,57 +1401,49 @@
<mi>b</mi>
<mo>⏐</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">⏐</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">⏐</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">⏐</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">⏐</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mo>‖</mo>
<mi>b</mi>
<mo>‖</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">‖</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">‖</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">‖</mo>
<mi>b</mi>
<mo maxsize="2.470em" minsize="2.470em" symmetric="true">‖</mo>
</mrow>
- <mspace width="1em">
- </mspace>
+ <mspace width="1em"></mspace>
<mrow>
<mi>⎪</mi>
<mi>b</mi>
<mo>⎪</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">⎪</mo>
<mi>b</mi>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">⎪</mo>
</mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mrow>
<mo maxsize="2.047em" minsize="2.047em" symmetric="true">⎪</mo>
<mi>b</mi>
@@ -1516,119 +1454,84 @@
<p>Variable-sized operators:</p>
<p>Inline: <math xmlns="http://www.w3.org/1998/Math/MathML">
<mo>∫</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∬</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∭</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨌</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∫</mo>
<mo>⋯</mo>
<mo>∫</mo>
<mo>∮</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo mathsize="75%">∫</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∑</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∏</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∐</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⋀</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⋁</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⋂</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⋃</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨄</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨆</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨀</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨁</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨂</mo>
</math> and Display:</p>
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mo>∫</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∬</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∭</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨌</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∫</mo>
<mo>⋯</mo>
<mo>∫</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∮</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo mathsize="75%">∫</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∑</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∏</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∐</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⋀</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⋁</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⋂</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⋃</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨄</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨆</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨀</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨁</mo>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>⨂</mo>
</math>
</div>
@@ -1639,125 +1542,105 @@
<mn>1</mn>
</msub>
<mi>f</mi>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munder>
<mo movablelimits="true">∫</mo>
<mn>1</mn>
</munder>
<mi>f</mi>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<msub>
<mo>∬</mo>
<mn>1</mn>
</msub>
<mi>f</mi>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<msub>
<mo mathsize="75%">∫</mo>
<mn>1</mn>
</msub>
<mi>f</mi>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munder>
<mo movablelimits="true">∑</mo>
<mn>1</mn>
</munder>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munder>
<mo movablelimits="true">∏</mo>
<mn>1</mn>
</munder>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munder>
<mo movablelimits="true">⋀</mo>
<mn>1</mn>
</munder>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munder>
<mo movablelimits="true">⋂</mo>
<mn>1</mn>
</munder>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munder>
<mo movablelimits="true">⨄</mo>
<mn>1</mn>
</munder>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munder>
<mo movablelimits="true">⨀</mo>
<mn>1</mn>
</munder>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<msup>
<mo>∫</mo>
<mi>N</mi>
</msup>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mover>
<mo movablelimits="true">∫</mo>
<mi>N</mi>
</mover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<msup>
<mo>⨌</mo>
<mi>N</mi>
</msup>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<msup>
<mo>∮</mo>
<mi>N</mi>
</msup>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<msup>
<mo mathsize="75%">∫</mo>
<mi>N</mi>
</msup>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mover>
<mo movablelimits="true">∑</mo>
<mi>N</mi>
</mover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mover>
<mo movablelimits="true">∐</mo>
<mi>N</mi>
</mover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mover>
<mo movablelimits="true">⋁</mo>
<mi>N</mi>
</mover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mover>
<mo movablelimits="true">⋃</mo>
<mi>N</mi>
</mover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mover>
<mo movablelimits="true">⨆</mo>
<mi>N</mi>
</mover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mover>
<mo movablelimits="true">⨂</mo>
<mi>N</mi>
@@ -1771,36 +1654,31 @@
<mn>1</mn>
<mi>N</mi>
</msubsup>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">∫</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<msubsup>
<mo>∬</mo>
<mn>1</mn>
<mi>N</mi>
</msubsup>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<msubsup>
<mo>∭</mo>
<mn>1</mn>
<mi>N</mi>
</msubsup>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<msubsup>
<mo>⨌</mo>
<mn>1</mn>
<mi>N</mi>
</msubsup>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mo>∫</mo>
<mo>⋯</mo>
<msubsup>
@@ -1808,99 +1686,85 @@
<mn>1</mn>
<mi>N</mi>
</msubsup>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<msubsup>
<mo>∮</mo>
<mn>1</mn>
<mi>N</mi>
</msubsup>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<msubsup>
<mo mathsize="75%">∫</mo>
<mn>1</mn>
<mi>N</mi>
</msubsup>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">∑</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">∏</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">∐</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">⋀</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">⋁</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">⋂</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">⋃</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">⨄</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">⨆</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">⨀</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">⨁</mo>
<mn>1</mn>
<mi>N</mi>
</munderover>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<munderover>
<mo movablelimits="true">⨂</mo>
<mn>1</mn>
Modified: trunk/docutils/test/functional/expected/math_output_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/math_output_mathml.html 2024-02-01 13:02:51 UTC (rev 9529)
+++ trunk/docutils/test/functional/expected/math_output_mathml.html 2024-02-01 13:03:02 UTC (rev 9530)
@@ -427,9 +427,8 @@
</mtd>
</mtr>
<mtr>
+ <mtd></mtd>
<mtd>
- </mtd>
- <mtd>
<mo>=</mo>
<mo>∫</mo>
<msub>
Modified: trunk/docutils/test/functional/expected/mathematics_mathml_.html
===================================================================
--- trunk/docutils/test/functional/expected/mathematics_mathml_.html 2024-02-01 13:02:51 UTC (rev 9529)
+++ trunk/docutils/test/functional/expected/mathematics_mathml_.html 2024-02-01 13:03:02 UTC (rev 9530)
@@ -155,8 +155,7 @@
<mi>π</mi>
</msqrt>
<mrow>
- <mspace width="0.25em">
- </mspace>
+ <mspace width="0.25em"></mspace>
<mi>n</mi>
</mrow>
</msup>
@@ -172,8 +171,7 @@
<mo stretchy="false">(</mo>
<mi>x</mi>
<mo stretchy="false">)</mo>
- <mspace width="0.1667em">
- </mspace>
+ <mspace width="0.1667em"></mspace>
<msup>
<mi>e</mi>
<mrow>
@@ -184,8 +182,7 @@
<mi>x</mi>
</mrow>
</msup>
- <mspace width="0.1667em">
- </mspace>
+ <mspace width="0.1667em"></mspace>
<mi mathvariant="normal">d</mi>
<mi>x</mi>
<mo>.</mo>
@@ -234,9 +231,8 @@
</mtd>
</mtr>
<mtr>
+ <mtd></mtd>
<mtd>
- </mtd>
- <mtd>
<mo>=</mo>
<msup>
<mi>x</mi>
@@ -252,9 +248,8 @@
<mn>2</mn>
</msup>
</mtd>
+ <mtd></mtd>
<mtd>
- </mtd>
- <mtd>
<mo>=</mo>
<msup>
<mi>x</mi>
@@ -319,12 +314,10 @@
</mtd>
</mtr>
</mtable>
- <mspace width="0.2778em">
- </mspace>
+ <mspace width="0.2778em"></mspace>
<mo>}</mo>
</mrow>
- <mspac...
[truncated message content] |
|
From: <mi...@us...> - 2024-02-01 13:03:15
|
Revision: 9531
http://sourceforge.net/p/docutils/code/9531
Author: milde
Date: 2024-02-01 13:03:12 +0000 (Thu, 01 Feb 2024)
Log Message:
-----------
Unit tests for MathML elements.
Replace the comments with doctest-tests with a new test module.
Modified Paths:
--------------
trunk/docutils/docutils/utils/math/mathml_elements.py
Added Paths:
-----------
trunk/docutils/test/test_utils/test_math/test_mathml_elements.py
Modified: trunk/docutils/docutils/utils/math/mathml_elements.py
===================================================================
--- trunk/docutils/docutils/utils/math/mathml_elements.py 2024-02-01 13:03:02 UTC (rev 9530)
+++ trunk/docutils/docutils/utils/math/mathml_elements.py 2024-02-01 13:03:12 UTC (rev 9531)
@@ -114,9 +114,9 @@
args = ', '.join(f'{child}' for child in self)
return f'{self.__class__.__name__}({args})'
-# Emulate dictionary access methods for attributes
-# and list-like interface to the child elements
-# (differs from `docutils.nodes.Element` dict/list interface).
+ # Emulate dictionary access methods for attributes
+ # and list-like interface to the child elements
+ # (differs from `docutils.nodes.Element` dict/list interface).
def get(self, key, default=None):
return self.attrib.get(key, default)
@@ -128,9 +128,9 @@
return self.attrib.items()
def iter(self):
- """Return iterator over all subnodes, including nested ones."""
+ """Return iterator over self and all subnodes, including nested."""
+ yield self
for child in self.children:
- yield child
yield from child.iter()
def __len__(self):
@@ -139,9 +139,15 @@
def __getitem__(self, key):
return self.children.__getitem__(key)
- def __setitem__(self, key, element):
- element.parent = self
- self.children.__setitem__(key, element)
+ def __setitem__(self, key, value):
+ if self.nchildren == 0:
+ raise TypeError(f'Element "{self}" does not take children.')
+ if isinstance(value, MathElement):
+ value.parent = self
+ else: # value may be an iterable
+ for e in value:
+ e.parent = self
+ self.children.__setitem__(key, value)
def __delitem__(self, key):
self.children.__delitem__(key)
@@ -233,43 +239,11 @@
xml.extend(['\n', ' ' * level])
return xml
-# >>> n2 = math(mn(2))
-# >>> n2
-# math(mn('2'))
-# >>> n2.toprettyxml()
-# '<math>\n <mn>2</mn>\n</math>'
-# >>> len(n2)
-# 1
-# >>> n2.extend([mo('!')])
-# math(mn('2'), mo('!'))
-# >>> eq3 = math(id='eq3', display='block')
-# >>> eq3
-# math(id='eq3', display='block')
-# >>> eq3.toprettyxml()
-# '<math id="eq3" display="block"></math>'
-# >>> len(eq3)
-# 0
-# >>> math(CLASS='bold').xml_starttag()
-# '<math class="bold">'
-# >>> n2.in_block()
-# False
-# >>> node = n2.append(mrow())
-# >>> node.in_block()
-# False
-# >>> eq3.in_block()
-# True
-# >>> node = eq3.append(mrow())
-# >>> node.in_block()
-# True
-# >>> nested = math(math(math(CLASS='three'), CLASS='two'), CLASS='one')
-# >>> [node for node in nested.iter()]
-# [math(math(class='three'), class='two'), math(class='three')]
-
# Group sub-expressions in a horizontal row
#
# The elements <msqrt>, <mstyle>, <merror>, <mpadded>, <mphantom>,
-# <menclose>, <mtd>, <mscarry>, and <math> treat their contents
+# <menclose>, <mtd>, [...], and <math> treat their contents
# as a single inferred mrow formed from all their children.
# (https://www.w3.org/TR/mathml4/#presm_inferredmrow)
#
@@ -286,6 +260,7 @@
The special attribute `switch` indicates that the last two child
elements are in reversed order and must be switched before XML-export.
+ See `msub` for an example.
"""
nchildren = 2
@@ -301,18 +276,7 @@
self.switch = False
return current_node
-# >>> MathSchema(switch=True, display=True)
-# MathSchema(switch=True, display='true')
-# >>> MathSchema(MathElement(), switch=True)
-# MathSchema(MathElement(), switch=True)
-# >>> MathSchema(MathElement(id='c1'), MathElement(id='c2'), switch=True)
-# MathSchema(MathElement(id='c2'), MathElement(id='c1'))
-# >>> MathSchema(mrow(), mrow(), mrow()) # doctest: +ELLIPSIS
-# Traceback (most recent call last):
-# ...
-# TypeError: Element "MathSchema(...)" takes only 2 children.
-
# Token elements represent the smallest units of mathematical notation which
# carry meaning.
@@ -351,36 +315,30 @@
class mi(MathToken):
"""Identifier, such as a function name, variable or symbolic constant."""
-# >>> mi(mtext('out'))
-# Traceback (most recent call last):
-# ...
-# ValueError: MathToken element expects `str` or number, not "mtext('out')".
-
class mn(MathToken):
"""Numeric literal.
+ >>> mn(3.41).toprettyxml()
+ '<mn>3.41</mn>'
+
Normally a sequence of digits with a possible separator (a dot or a comma).
+ (Values with comma must be specified as `str`.)
"""
-# >>> mn(3.41)
-# mn('3.41')
-
class mo(MathToken):
"""Operator, Fence, Separator, or Accent.
+ >>> mo('<').toprettyxml()
+ '<mo><</mo>'
+
Besides operators in strict mathematical meaning, this element also
includes "operators" like parentheses, separators like comma and
semicolon, or "absolute value" bars.
"""
-# >>> mo('<')
-# mo('<')
-# >>> mo('<').toprettyxml()
-# '<mo><</mo>'
-
class mspace(MathElement):
"""Blank space, whose size is set by its attributes.
@@ -391,14 +349,7 @@
"""
nchildren = 0
-# >>> mspace(width='2em').toprettyxml()
-# '<mspace width="2em"></mspace>'
-# >>> mspace(mn(3))
-# Traceback (most recent call last):
-# ...
-# TypeError: Element "mspace()" does not take children.
-
# General Layout Schemata
# ~~~~~~~~~~~~~~~~~~~~~~~
@@ -438,24 +389,7 @@
self.transfer_attributes(child)
return super().close()
-# Examples:
-#
-# >>> e = mrow(mn('3.5'), mo('<'), mi('x'))
-# >>> e
-# mrow(mn('3.5'), mo('<'), mi('x'))
-# >>> e.toprettyxml()
-# '<mrow>\n <mn>3.5</mn>\n <mo><</mo>\n <mi>x</mi>\n</mrow>'
-# >>> mo('∫', movablelimits=True).toprettyxml()
-# '<mo movablelimits="true">∫</mo>'
-# >>> mtext('comments or annotations').text
-# 'comments or annotations'
-# >>> row = mrow(mi('i', CLASS='boldmath'), mathvariant='normal', CLASS='test')
-# >>> tree = math(row)
-# >>> row.close()
-# math(mi('i', class='boldmath test', mathvariant='normal'))
-
-
class mfrac(MathSchema):
"""Fractions or fraction-like objects such as binomial coefficients."""
@@ -473,8 +407,8 @@
"""Style Change.
In modern browsers, <mstyle> is equivalent to an <mrow> element.
- However, <mstyle> may still be relevant for compatibility with MathML
- implementations outside browsers.
+ However, <mstyle> may still be relevant for compatibility with
+ MathML implementations outside browsers.
"""
@@ -538,21 +472,6 @@
"""Attach accents or limits both under and over an expression."""
-# >>> munder(mi('lim'), mo('-'), accent='false')
-# munder(mi('lim'), mo('-'), accent='false')
-# >>> mu = munder(mo('-'), accent='false', switch=True)
-# >>> mu
-# munder(mo('-'), switch=True, accent='false')
-# >>> mu.append(mi('lim'))
-# >>> mu
-# munder(mi('lim'), mo('-'), accent='false')
-# >>> mu.append(mi('lim'))
-# Traceback (most recent call last):
-# TypeError: Element "munder(mi('lim'), mo('-'))" takes only 2 children.
-# >>> munder(mo('-'), mi('lim'), accent='false', switch=True).toprettyxml()
-# '<munder accent="false">\n <mi>lim</mi>\n <mo>-</mo>\n</munder>'
-
-
# Tabular Math
# ~~~~~~~~~~~~
@@ -566,7 +485,3 @@
class mtd(MathRow):
"""Cell in a table or a matrix"""
-
-# >>> t = mtable(displaystyle=True)
-# >>> math(t).toprettyxml()
-# '<math>\n <mtable displaystyle="true"></mtable>\n</math>'
Added: trunk/docutils/test/test_utils/test_math/test_mathml_elements.py
===================================================================
--- trunk/docutils/test/test_utils/test_math/test_mathml_elements.py (rev 0)
+++ trunk/docutils/test/test_utils/test_math/test_mathml_elements.py 2024-02-01 13:03:12 UTC (rev 9531)
@@ -0,0 +1,375 @@
+#! /usr/bin/env python3
+# :Copyright: © 2024 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,
+# are permitted in any medium without royalty provided the copyright
+# notice and this notice are preserved.
+# This file is offered as-is, without any warranty.
+#
+# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
+
+
+"""
+Test module for utils/__init__.py.
+"""
+
+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__).resolve().parents[1]))
+
+import docutils.utils.math.mathml_elements as mml
+
+TEST_ROOT = Path(__file__).parent # ./test/ from the docutils root
+
+# The index of MathML elements
+# on https://developer.mozilla.org/en-US/docs/Web/MathML/Element
+# Element Nr. of children Description comment
+mathml_elements = """
+ <maction> * Bound actions to sub-expressions DEPRECATED
+ <annotation> 0 Data annotations NOT IMPLEMENTED
+ <annotation-xml> * XML annotations NOT IMPLEMENTED
+ <math> * Top-level element
+ <menclose> 1 Enclosed contents (non-standard)
+ <merror> * Enclosed syntax error messages
+ <mfenced> * Parentheses (non-standard) DEPRECATED
+ <mfrac> 2 Fraction
+ <mi> 0 Identifier
+ <mmultiscripts> * Prescripts and tensor indices NOT IMPLEMENTED
+ <mn> 0 Number
+ <mo> 0 Operator (and similar)
+ <mover> 2 Overscript
+ <mpadded> * Extra padding NOT IMPLEMENTED
+ <mphantom> 1 Invisible content reserving space
+ <mroot> 2 Radical with specified index
+ <mrow> * Grouped sub-expressions
+ <ms> 0 String literal NOT IMPLEMENTED
+ <mspace> 0 Space
+ <msqrt> 1 Square root without an index
+ <mstyle> * Style change (for compatibility)
+ <msub> 2 Subscript
+ <msup> 2 Superscrip
+ <msubsup> 3 Subscript-superscript pair
+ <mtable> * Table or matrix
+ <mtd> * Cell in a table or a matrix
+ <mtext> 0 Text
+ <mtr> * Row in a table or a matrix
+ <munder> 2 Underscript
+ <munderover> 3 Underscript-overscript pair
+ <semantics> * annotations (e.g. text source) NOT IMPLEMENTED
+ """
+
+
+class MathElementTests(unittest.TestCase):
+ """Test the <MathElement> base class."""
+
+ prettyXML = """\
+<math id="root">
+ <math id="c1"></math>
+ <math id="c2">
+ <math id="cc1"></math>
+ </math>
+</math>"""
+
+ def test__init__(self):
+ """Instantiate a MathElement object and test its properties."""
+
+ # No arguments required, the class name is used as XML tag:
+ e1 = mml.MathElement()
+
+ # Positional arguments are stored as children,
+ # named arguments are stored as element attributes:
+ # * argument names are downcased,
+ # * attribute values must be `str`, `boolean`, or numerical
+ # and are stored as `str` (cf. test_a_str() below).
+ e0 = mml.MathElement(e1, CLASS='root', scriptlevel=1)
+ # len() returns the number of children
+ self.assertEqual(len(e0), 1)
+ # Attributes can be accessed using get(), set(), items(), and keys().
+ self.assertEqual(e0.get('class'), 'root')
+ e0.set('scriptlevel', 2)
+ e0.set('displaystyle', True)
+ self.assertEqual(e0.attrib, {'class': 'root',
+ 'scriptlevel': '2',
+ 'displaystyle': 'true'})
+
+ def test_children(self):
+ # positional arguments are stored as children.
+ e4 = mml.MathElement(id='e4')
+ e3 = mml.MathElement(id='e3')
+ e2 = mml.MathElement(e3, e4, id='e2')
+ e1 = mml.MathElement(id='e1')
+ e0 = mml.MathElement(e1, e2, id='e0')
+ # xml.etree uses list syntax to access them
+ self.assertEqual(e0[0], e1)
+ self.assertEqual(e0[1][-1], e4)
+ self.assertEqual(e0[:], [e1, e2]) # list of e0's children
+ # The default iterator yields the immediate children
+ self.assertEqual(tuple(e0), (e1, e2))
+ # The `iter()` method returns `self` and all descendants
+ self.assertEqual(tuple(e0.iter()), (e0, e1, e2, e3, e4))
+
+ # more list-like functions are tested below...
+
+ def test_a_str(self):
+ # test the XML attribute normalisation
+ #
+ # Values are converted to `str`:
+ self.assertEqual(mml.MathElement.a_str(-2), '-2')
+ self.assertEqual(mml.MathElement.a_str(1), '1')
+ self.assertEqual(mml.MathElement.a_str(0), '0')
+ # Booleans are downcased:
+ self.assertEqual(mml.MathElement.a_str(True), 'true')
+ self.assertEqual(mml.MathElement.a_str(False), 'false')
+ # Strings are left as-is:
+ self.assertEqual(mml.MathElement.a_str('+1'), '+1')
+ self.assertEqual(mml.MathElement.a_str('True'), 'True')
+ self.assertEqual(mml.MathElement.a_str(''), '')
+
+ def test__repr__(self):
+ """The representation should match the code to instantiate."""
+ # Watch the idempotent normalisation:
+ # * attribute names are downcased,
+ # * XML attribute values are converted to strings
+ e1 = mml.MathElement(mml.MathElement(level=2), CLASS='root')
+ self.assertEqual(repr(e1),
+ "MathElement(MathElement(level='2'), class='root')")
+ # Also report non-default number of children: (as `int`, not `str`)
+ e1[0].nchildren = 1
+ self.assertEqual(repr(e1[0]), "MathElement(nchildren=1, level='2')")
+
+ def test__str__(self):
+ """Informal string representation for debugging and error reports."""
+ e1 = mml.MathElement(mml.MathElement(level=2), CLASS='root')
+ self.assertEqual(str(e1), 'MathElement(MathElement())')
+
+ def test__setitem__(self):
+ """Setting an item also sets the `parent` attribute on the child."""
+ e1 = mml.MathElement()
+ e1[:] = (mml.MathElement(id=1), mml.MathElement(id=2))
+ self.assertEqual(e1[0].parent, e1)
+ self.assertEqual(e1[0].get('id'), '1')
+ self.assertEqual(e1[1].get('id'), '2')
+ e1[0] = mml.MathElement()
+ self.assertEqual(e1[0].get('id'), None)
+ self.assertEqual(e1[0].parent, e1)
+
+ def test_is_full(self):
+ # A node is "full", if the number of children equals or exceeds
+ # the number of accepted children given in the "nchildren" attribute.
+ e1 = mml.MathElement()
+ self.assertTrue(e1.nchildren is None) # no limit to number of children
+ self.assertFalse(e1.is_full())
+ e1.nchildren = 1 # element expects/accepts one child.
+ self.assertFalse(e1.is_full())
+ e1.nchildren = 0 # element expects/accepts no children.
+ self.assertTrue(e1.is_full())
+
+ def test_close(self):
+ """Closing an element returns first non-closed anchestor or None."""
+ e1 = mml.MathElement(mml.MathElement())
+ self.assertEqual(e1[0].close(), e1)
+ self.assertTrue(e1.close() is None)
+ # When all anchestors are closed, return None as well
+ self.assertTrue(e1[0].close() is None)
+
+ def test_append(self):
+ """Test special features of the "append()" method."""
+ e1 = mml.MathElement()
+ e1.nchildren = 2 # element expects/accepts two children.
+
+ # Appending to an element sets the internal "parent" attribute ...
+ result = e1.append(mml.MathElement(id='c1'))
+ self.assertEqual(e1[0].parent, e1)
+ # ... which is hidden in XML ...
+ self.assertEqual(e1[0].toprettyxml(),
+ '<MathElement id="c1"></MathElement>')
+ # ... and returns the new "insertion point".
+ # If more children may be appended, return self
+ self.assertEqual(result, e1)
+ # If the element is "full" after appending the child,
+ # a non-full anchestor or None is returned:
+ result = e1.append(mml.MathElement(id='c2'))
+ self.assertTrue(result is None)
+
+ # Trying to append to an element that is "full" returns an error:
+ with self.assertRaises(TypeError) as cm:
+ result = e1.append(mml.MathElement())
+ self.assertEqual(str(cm.exception),
+ 'Element "MathElement(MathElement(), MathElement())"'
+ ' takes only 2 children.')
+
+ def test_extend(self):
+ e1 = mml.MathElement()
+ c1 = mml.MathElement(id='c1')
+ c2 = mml.MathElement(id='c2')
+ e1.extend([c1, c2])
+ self.assertEqual([*e1], [c1, c2])
+
+ def test_pop(self):
+ c1 = mml.MathElement(id='c1')
+ c2 = mml.MathElement(id='c2')
+ e1 = mml.MathElement(c1, c2)
+ last_element = e1.pop()
+ self.assertEqual(last_element, c2)
+ self.assertEqual([*e1], [c1])
+ first_element = e1.pop(0)
+ self.assertEqual(first_element, c1)
+ with self.assertRaises(IndexError):
+ e1.pop()
+
+ def test_in_block(self):
+ # Return True, if `self` or an anchestor is a block-level element:
+ e1 = mml.math(display='block')
+ e2 = mml.math(mml.math(id='e3'), id='e2')
+ self.assertTrue(e1.in_block())
+ self.assertFalse(e2.in_block())
+ self.assertFalse(e2[0].in_block())
+ e1.append(e2)
+ self.assertTrue(e2.in_block())
+ self.assertTrue(e2[0].in_block())
+
+ def test_toprettyxml(self):
+ """XML representation of the element/subtree as `str`."""
+ e1 = mml.math(mml.math(level=2), CLASS='root')
+ self.assertEqual(e1.toprettyxml(),
+ '<math class="root">\n'
+ ' <math level="2"></math>\n'
+ '</math>')
+
+
+class MathSchemaTests(unittest.TestCase):
+ """Test `MathSchema` and derived element classes."""
+
+ def test__init__(self):
+ # the optional `switch` argument is stored as internal attribute
+ ms1 = mml.MathSchema(switch=True, id='ms1')
+ self.assertEqual(repr(ms1), "MathSchema(switch=True, id='ms1')")
+ # internal attributes are not exported to XML.
+ self.assertEqual(ms1.toprettyxml(),
+ '<MathSchema id="ms1"></MathSchema>')
+ # the default value is dropped from ``repr()``
+ ms1.switch = False
+ self.assertEqual(repr(ms1), "MathSchema(id='ms1')")
+
+ def test__init__full(self):
+ # when initialized with `nchildren` children and `switch` True,
+ # the children are switched and `switch` is reset:
+ ms2 = mml.MathSchema(mml.mn(1), mml.mn(2), switch=True)
+ self.assertEqual(repr(ms2), "MathSchema(mn('2'), mn('1'))")
+ self.assertEqual(
+ ms2.toprettyxml(),
+ '<MathSchema>\n <mn>2</mn>\n <mn>1</mn>\n</MathSchema>')
+
+ def test_append(self):
+ # appending normalizes the order before switching
+ ms1 = mml.MathSchema(mml.mn(1), switch=True)
+ ms1.append(mml.mn(2))
+ self.assertEqual(repr(ms1), "MathSchema(mn('2'), mn('1'))")
+ # appending to a closed element raises TypeError
+ with self.assertRaises(TypeError) as cm:
+ ms1.append(mml.mn(3))
+ self.assertIn('takes only 2 children', str(cm.exception))
+
+
+class MathTokenTests(unittest.TestCase):
+ """Test MathToken and derived element classes."""
+
+ def test__init__(self):
+ # requires one argument `text` that is stored as the element's text
+ self.assertEqual(repr(mml.mi('x')), "mi('x')")
+ # the argument is converted to a `str`
+ self.assertEqual(repr(mml.mn(42)), "mn('42')")
+ # only one positional argument allowed:
+ with self.assertRaises(TypeError):
+ mml.mo('[', 'stretchy')
+ # text must be `str` or numerical value:
+ with self.assertRaises(ValueError) as cm:
+ mml.mi(mml.mtext('out'))
+ self.assertIn('MathToken element expects `str` or number',
+ str(cm.exception))
+
+ # optional named arguments become XML attributes
+ e1 = mml.mo('[', stretchy=False)
+ self.assertEqual(e1.toprettyxml(), '<mo stretchy="false">[</mo>')
+
+ def test_append(self):
+ # MathTokens don't take child elements.
+ # Appending to MathTokens raises an exception.
+ e1 = mml.mo('[')
+ self.assertEqual(e1.nchildren, 0)
+ with self.assertRaises(TypeError) as cm:
+ e1.append(mml.mi('x'))
+ self.assertEqual(str(cm.exception),
+ 'Element "mo(\'[\')" does not take children.')
+ with self.assertRaises(TypeError) as cm:
+ e1[:] = [mml.mn(3)]
+ self.assertEqual(str(cm.exception),
+ 'Element "mo(\'[\')" does not take children.')
+
+
+class mrowTests(unittest.TestCase):
+ """Test the `mrow` element class."""
+
+ def test_transfer_attributes(self):
+ e1 = mml.mrow(level=1, CLASS='cls1', style='rule1')
+ e2 = mml.mrow(level=2, CLASS='cls2')
+ e3 = mml.mrow(level=3, style='rule3')
+ # e1.attrib -> e2.attrib
+ e1.transfer_attributes(e2)
+ self.assertEqual(e2.get('level'), '1')
+ self.assertEqual(e2.get('class'), 'cls2 cls1')
+ self.assertEqual(e2.get('style'), 'rule1')
+ # e3.attrib -> e1.attrib
+ e3.transfer_attributes(e1)
+ self.assertEqual(e1.get('level'), '3')
+ self.assertEqual(e1.get('class'), 'cls1')
+ self.assertEqual(e1.get('style'), 'rule1; rule3')
+
+ def test_close_only_child(self):
+ # Remove <mrow> if it has a parent and only one child element.
+ # NOTE: this feature may be removed.
+ c1 = mml.math(CLASS='c1')
+ row1 = mml.mrow(c1, CLASS='row1')
+ # if possible, attach child to parent
+ row1.close() # no parent, no removal
+ self.assertEqual(c1.parent, row1)
+
+ root = mml.math(row1) # provide a parent
+ row1.close() # try again
+ self.assertEqual(c1.parent, root)
+ self.assertEqual(root.toprettyxml(),
+ '<math>\n <math class="c1 row1"></math>\n</math>')
+
+
+class MathMLElementTests(unittest.TestCase):
+ """Test classes for "MathML Core" elements."""
+
+ def test_mathml_elements(self):
+ for line in mathml_elements.strip().splitlines():
+ element, nchildren, description = line.split(maxsplit=2)
+ element = element.strip('<>')
+ if 'DEPRECATED' in description or 'NOT IMPLEMENTED' in description:
+ continue
+ cls = getattr(mml, element)
+ if issubclass(cls, mml.MathToken):
+ e = cls('x')
+ self.assertEqual(e.toprettyxml(), f'<{element}>x</{element}>')
+ else:
+ e = cls()
+ self.assertEqual(e.toprettyxml(), f'<{element}></{element}>')
+ if nchildren == '*':
+ self.assertTrue(e.nchildren is None,
+ f'{element}.nchildren == {e.nchildren}')
+ else:
+ self.assertEqual(e.nchildren, int(nchildren),
+ f'{element}.nchildren == {e.nchildren}')
+
+
+if __name__ == '__main__':
+ unittest.main()
Property changes on: trunk/docutils/test/test_utils/test_math/test_mathml_elements.py
___________________________________________________________________
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...> - 2024-02-01 13:03:44
|
Revision: 9533
http://sourceforge.net/p/docutils/code/9533
Author: milde
Date: 2024-02-01 13:03:41 +0000 (Thu, 01 Feb 2024)
Log Message:
-----------
LaTeX to MathML: generate simpler MathML trees, fix `\cfrac`.
MathML Core defines more global attributes as MathML 3.
So we can now get rid of some `<mstyle>` wrappers and attach
styling attributes directly to the to-be-styled elements.
This also fixes
* a misattachment of expressions following continued fractions,
* styling of "smallmatrix" in Chromium,
Modified Paths:
--------------
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/docutils/utils/math/mathml_elements.py
trunk/docutils/test/functional/expected/math_experiments_mathml.html
trunk/docutils/test/functional/expected/mathematics_mathml.html
trunk/docutils/test/test_utils/test_math/test_mathml_elements.py
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2024-02-01 13:03:27 UTC (rev 9532)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2024-02-01 13:03:41 UTC (rev 9533)
@@ -31,7 +31,7 @@
from docutils.utils.math.mathml_elements import (
math, mtable, mrow, mtr, mtd, menclose, mphantom, msqrt, mi, mn, mo,
mtext, msub, msup, msubsup, munder, mover, munderover, mroot, mfrac,
- mspace, mstyle, MathRow)
+ mspace, MathRow)
# Character data
@@ -89,9 +89,8 @@
}
-# math font selection -> <mi mathvariant=...> or <mstyle mathvariant=...>
-# TODO: the "mathvariant" attribute is not supported by Chromium and
-# deprecated in the MathML specs (except with value "normal" for single chars).
+# "mathematical alphabets": map identifiers to the corresponding
+# characters from the "Mathematical Alphanumeric Symbols" block
math_alphabets = {
# 'cmdname': 'mathvariant value' # package
'mathbb': 'double-struck', # amssymb
@@ -301,15 +300,15 @@
# See also https://www.w3.org/TR/MathML3/chapter3.html#presm.scriptlevel
fractions = {
- # name: style_attrs, frac_attrs
- 'frac': ({}, {}),
- 'cfrac': ({'displaystyle': True, 'scriptlevel': 0,
- 'CLASS': 'cfrac'}, {}), # in LaTeX with padding
- 'dfrac': (layout_styles['displaystyle'], {}),
- 'tfrac': (layout_styles['textstyle'], {}),
- 'binom': ({}, {'linethickness': 0}),
- 'dbinom': (layout_styles['displaystyle'], {'linethickness': 0}),
- 'tbinom': (layout_styles['textstyle'], {'linethickness': 0}),
+ # name: attributes
+ 'frac': {},
+ 'cfrac': {'displaystyle': True, 'scriptlevel': 0,
+ 'class': 'cfrac'}, # in LaTeX with padding
+ 'dfrac': layout_styles['displaystyle'],
+ 'tfrac': layout_styles['textstyle'],
+ 'binom': {'linethickness': 0},
+ 'dbinom': layout_styles['displaystyle'] | {'linethickness': 0},
+ 'tbinom': layout_styles['textstyle'] | {'linethickness': 0},
}
delimiter_sizes = ['', '1.2em', '1.623em', '2.047em', '2.470em']
@@ -828,6 +827,8 @@
return new_node, string
if name == 'boxed':
+ # CSS padding is broken in Firefox 115.6.0esr
+ # therefore we still need the deprecated <menclose> element
new_node = menclose(notation='box', CLASS='boxed')
node.append(new_node)
return new_node, string
@@ -848,20 +849,18 @@
return new_node, string
if name in fractions:
- (style_atts, frac_atts) = fractions[name]
+ attributes = fractions[name]
if name == 'cfrac':
optarg, string = tex_optarg(string)
optargs = {'l': 'left', 'r': 'right'}
if optarg in optargs:
- frac_atts = frac_atts.copy()
- frac_atts['numalign'] = optargs[optarg] # "numalign" is deprecated
- frac_atts['class'] = 'numalign-' + optargs[optarg]
- new_node = frac = mfrac(**frac_atts)
+ attributes = attributes.copy()
+ attributes['numalign'] = optargs[optarg] # "numalign" is deprecated
+ attributes['class'] += ' numalign-' + optargs[optarg]
+ new_node = frac = mfrac(**attributes)
if name.endswith('binom'):
new_node = mrow(mo('('), new_node, mo(')'), CLASS='binom')
new_node.nchildren = 3
- if style_atts:
- new_node = mstyle(new_node, **style_atts)
node.append(new_node)
return frac, string
@@ -919,18 +918,12 @@
return new_node, string
if name in layout_styles: # 'displaystyle', 'textstyle', ...
- new_node = mstyle(**layout_styles[name])
- new_node.nchildren = None
- if isinstance(node, mrow) and len(node) == 0:
- # replace node with new_node
- node.parent[node.parent.children.index(node)] = new_node
- new_node.parent = node.parent
- elif node.__class__.__name__ == 'math':
- node.append(new_node)
- else:
+ if len(node) > 0:
raise MathError(rf'Declaration "\{name}" must be first command '
'in a group!')
- return new_node, string
+ for k, v in layout_styles[name].items():
+ node.set(k, v)
+ return node, string
if name.endswith('limits'):
arg, remainder = tex_token(string)
@@ -1076,9 +1069,7 @@
elif name == 'smallmatrix':
attributes['rowspacing'] = '0.02em'
attributes['columnspacing'] = '0.333em'
- wrapper = mstyle(scriptlevel='1')
- node.append(wrapper)
- node = wrapper
+ attributes['scriptlevel'] = '1'
elif name == 'aligned':
attributes['class'] = 'ams-align'
# TODO: array, aligned & alignedat take an optional [t], [b], or [c].
Modified: trunk/docutils/docutils/utils/math/mathml_elements.py
===================================================================
--- trunk/docutils/docutils/utils/math/mathml_elements.py 2024-02-01 13:03:27 UTC (rev 9532)
+++ trunk/docutils/docutils/utils/math/mathml_elements.py 2024-02-01 13:03:41 UTC (rev 9533)
@@ -421,11 +421,16 @@
... specified by the notation attribute.
- Non-standard: Do not use on the Web.
+ Non-standard but still required by Firefox for boxed expressions.
"""
nchildren = 1 # \boxed expects one argument or a group
+class mpadded(MathRow):
+ """Adjust space around content."""
+ # nchildren = 1 # currently not used by latex2mathml
+
+
class mphantom(MathRow):
"""Placeholder: Rendered invisibly but dimensions are kept."""
nchildren = 1 # \phantom expects one argument or a group
Modified: trunk/docutils/test/functional/expected/math_experiments_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/math_experiments_mathml.html 2024-02-01 13:03:27 UTC (rev 9532)
+++ trunk/docutils/test/functional/expected/math_experiments_mathml.html 2024-02-01 13:03:41 UTC (rev 9533)
@@ -958,33 +958,31 @@
</mrow>
<mrow>
<mo>(</mo>
- <mstyle scriptlevel="1">
- <mtable rowspacing="0.02em" columnspacing="0.333em">
- <mtr>
- <mtd>
- <mi>a</mi>
- </mtd>
- <mtd>
- <mi>b</mi>
- </mtd>
- </mtr>
- <mtr>
- <mtd>
- <mi>c</mi>
- </mtd>
- <mtd>
- <mi>d</mi>
- </mtd>
- </mtr>
- </mtable>
- <mo>)</mo>
- </mstyle>
- <mrow>
- <mo>(</mo>
- <mo>⨂</mo>
- <mo>)</mo>
- </mrow>
+ <mtable rowspacing="0.02em" columnspacing="0.333em" scriptlevel="1">
+ <mtr>
+ <mtd>
+ <mi>a</mi>
+ </mtd>
+ <mtd>
+ <mi>b</mi>
+ </mtd>
+ </mtr>
+ <mtr>
+ <mtd>
+ <mi>c</mi>
+ </mtd>
+ <mtd>
+ <mi>d</mi>
+ </mtd>
+ </mtr>
+ </mtable>
+ <mo>)</mo>
</mrow>
+ <mrow>
+ <mo>(</mo>
+ <mo>⨂</mo>
+ <mo>)</mo>
+ </mrow>
</math></p>
</dd>
<dt><math xmlns="http://www.w3.org/1998/Math/MathML">
Modified: trunk/docutils/test/functional/expected/mathematics_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/mathematics_mathml.html 2024-02-01 13:03:27 UTC (rev 9532)
+++ trunk/docutils/test/functional/expected/mathematics_mathml.html 2024-02-01 13:03:41 UTC (rev 9533)
@@ -3411,27 +3411,25 @@
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mo maxsize="1.2em" minsize="1.2em" symmetric="true">(</mo>
- <mstyle scriptlevel="1">
- <mtable rowspacing="0.02em" columnspacing="0.333em">
- <mtr>
- <mtd>
- <mi>a</mi>
- </mtd>
- <mtd>
- <mi>b</mi>
- </mtd>
- </mtr>
- <mtr>
- <mtd>
- <mi>c</mi>
- </mtd>
- <mtd>
- <mi>d</mi>
- </mtd>
- </mtr>
- </mtable>
- <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
- </mstyle>
+ <mtable rowspacing="0.02em" columnspacing="0.333em" scriptlevel="1">
+ <mtr>
+ <mtd>
+ <mi>a</mi>
+ </mtd>
+ <mtd>
+ <mi>b</mi>
+ </mtd>
+ </mtr>
+ <mtr>
+ <mtd>
+ <mi>c</mi>
+ </mtd>
+ <mtd>
+ <mi>d</mi>
+ </mtd>
+ </mtr>
+ </mtable>
+ <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
</mrow>
</math>
that comes closer to fitting within a single text line than a normal
@@ -3846,35 +3844,31 @@
</mrow>
</mfrac>
<mspace width="1em"></mspace>
- <mstyle displaystyle="true" scriptlevel="0">
- <mfrac>
- <mrow>
- <mi>x</mi>
- <mo>+</mo>
- <mn>1</mn>
- </mrow>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- <mspace width="1em"></mspace>
- <mstyle displaystyle="false" scriptlevel="0">
- <mfrac>
- <mrow>
- <mi>x</mi>
- <mo>+</mo>
- <mn>1</mn>
- </mrow>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- </mstyle>
- </mstyle>
+ <mfrac displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mi>x</mi>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
+ <mspace width="1em"></mspace>
+ <mfrac displaystyle="false" scriptlevel="0">
+ <mrow>
+ <mi>x</mi>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
</math>
</div>
<p>and in text: <math xmlns="http://www.w3.org/1998/Math/MathML">
@@ -3891,35 +3885,31 @@
</mrow>
</mfrac>
</math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mfrac>
- <mrow>
- <mi>x</mi>
- <mo>+</mo>
- <mn>1</mn>
- </mrow>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- </mstyle>
+ <mfrac displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mi>x</mi>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
</math>, <math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="false" scriptlevel="0">
- <mfrac>
- <mrow>
- <mi>x</mi>
- <mo>+</mo>
- <mn>1</mn>
- </mrow>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- </mstyle>
+ <mfrac displaystyle="false" scriptlevel="0">
+ <mrow>
+ <mi>x</mi>
+ <mo>+</mo>
+ <mn>1</mn>
+ </mrow>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
</math>.</p>
<p>For binomial expressions such as <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow class="binom">
@@ -3987,106 +3977,98 @@
<mo>=</mo>
<mn>1</mn>
<mo>+</mo>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac>
- <msup>
- <mn>1</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac">
+ <msup>
+ <mn>1</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
+ <mo>+</mo>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac">
+ <msup>
+ <mn>3</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
+ <mo>+</mo>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac">
<msup>
- <mn>3</mn>
+ <mn>5</mn>
<mn>2</mn>
</msup>
<mrow>
<mn>2</mn>
<mo>+</mo>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac>
- <msup>
- <mn>5</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac>
- <msup>
- <mn>7</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mi>⋯</mi>
- </mrow>
- </mfrac>
- </mstyle>
- </mrow>
- </mfrac>
- </mstyle>
- <mspace width="2em"></mspace>
- <mtext>vs.</mtext>
- <mspace width="2em"></mspace>
- <mfrac>
- <mi>π</mi>
- <mn>4</mn>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac">
+ <msup>
+ <mn>7</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
+ <mo>+</mo>
+ <mi>⋯</mi>
+ </mrow>
</mfrac>
- <mo>=</mo>
- <mn>1</mn>
+ </mrow>
+ </mfrac>
+ </mrow>
+ </mfrac>
+ </mrow>
+ </mfrac>
+ <mspace width="2em"></mspace>
+ <mtext>vs.</mtext>
+ <mspace width="2em"></mspace>
+ <mfrac>
+ <mi>π</mi>
+ <mn>4</mn>
+ </mfrac>
+ <mo>=</mo>
+ <mn>1</mn>
+ <mo>+</mo>
+ <mfrac>
+ <msup>
+ <mn>1</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
+ <mo>+</mo>
+ <mfrac>
+ <msup>
+ <mn>3</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
+ <mo>+</mo>
+ <mfrac>
+ <msup>
+ <mn>5</mn>
+ <mn>2</mn>
+ </msup>
+ <mrow>
+ <mn>2</mn>
<mo>+</mo>
<mfrac>
<msup>
- <mn>1</mn>
+ <mn>7</mn>
<mn>2</mn>
</msup>
<mrow>
<mn>2</mn>
<mo>+</mo>
- <mfrac>
- <msup>
- <mn>3</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mfrac>
- <msup>
- <mn>5</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mfrac>
- <msup>
- <mn>7</mn>
- <mn>2</mn>
- </msup>
- <mrow>
- <mn>2</mn>
- <mo>+</mo>
- <mi>⋯</mi>
- </mrow>
- </mfrac>
- </mrow>
- </mfrac>
- </mrow>
- </mfrac>
+ <mi>⋯</mi>
</mrow>
</mfrac>
</mrow>
</mfrac>
- </mstyle>
- </mrow>
- </mfrac>
- </mstyle>
+ </mrow>
+ </mfrac>
+ </mrow>
+ </mfrac>
</math>
</div>
<p>The optional argument <span class="docutils literal">[l]</span> or <span class="docutils literal">[r]</span> for left or right placement of
@@ -4093,38 +4075,32 @@
the numerator is <a class="reference external" href="https://github.com/w3c/mathml/issues/30">not supported by MathML Core</a>:</p>
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac numalign="left" class="numalign-left">
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac numalign-left" numalign="left">
+ <mi>x</mi>
+ <mrow>
<mi>x</mi>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- <mspace width="1em"></mspace>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac>
- <mi>x</mi>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- <mspace width="1em"></mspace>
- <mstyle displaystyle="true" scriptlevel="0" class="cfrac">
- <mfrac numalign="right" class="numalign-right">
- <mi>x</mi>
- <mrow>
- <mi>x</mi>
- <mo>−</mo>
- <mn>1</mn>
- </mrow>
- </mfrac>
- </mstyle>
- </mstyle>
- </mstyle>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
+ <mspace width="1em"></mspace>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac">
+ <mi>x</mi>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
+ <mspace width="1em"></mspace>
+ <mfrac displaystyle="true" scriptlevel="0" class="cfrac numalign-right" numalign="right">
+ <mi>x</mi>
+ <mrow>
+ <mi>x</mi>
+ <mo>−</mo>
+ <mn>1</mn>
+ </mrow>
+ </mfrac>
</math>
</div>
</section>
@@ -4152,104 +4128,92 @@
<td><p><span class="docutils literal">\Biggr</span></p></td>
</tr>
<tr><td><p>Result</p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mo stretchy="false">(</mo>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mo stretchy="false">(</mo>
+ <mi>b</mi>
+ <mo stretchy="false">)</mo>
+ <mo stretchy="false">(</mo>
+ <mfrac>
+ <mi>c</mi>
+ <mi>d</mi>
+ </mfrac>
+ <mo stretchy="false">)</mo>
+</math></p></td>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mo>(</mo>
<mi>b</mi>
- <mo stretchy="false">)</mo>
- <mo stretchy="false">(</mo>
+ <mo>)</mo>
+ </mrow>
+ <mrow>
+ <mo>(</mo>
<mfrac>
<mi>c</mi>
<mi>d</mi>
</mfrac>
- <mo stretchy="false">)</mo>
- </mstyle>
+ <mo>)</mo>
+ </mrow>
</math></p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mrow>
- <mo>(</mo>
- <mi>b</mi>
- <mo>)</mo>
- </mrow>
- <mrow>
- <mo>(</mo>
- <mfrac>
- <mi>c</mi>
- <mi>d</mi>
- </mfrac>
- <mo>)</mo>
- </mrow>
- </mstyle>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mo maxsize="1.2em" minsize="1.2em" symmetric="true">(</mo>
+ <mi>b</mi>
+ <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
+ </mrow>
+ <mrow>
+ <mo maxsize="1.2em" minsize="1.2em" symmetric="true">(</mo>
+ <mfrac>
+ <mi>c</mi>
+ <mi>d</mi>
+ </mfrac>
+ <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
+ </mrow>
</math></p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mrow>
- <mo maxsize="1.2em" minsize="1.2em" symmetric="true">(</mo>
- <mi>b</mi>
- <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
- </mrow>
- <mrow>
- <mo maxsize="1.2em" minsize="1.2em" symmetric="true">(</mo>
- <mfrac>
- <mi>c</mi>
- <mi>d</mi>
- </mfrac>
- <mo maxsize="1.2em" minsize="1.2em" symmetric="true">)</mo>
- </mrow>
- </mstyle>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mo maxsize="1.623em" minsize="1.623em" symmetric="true">(</mo>
+ <mi>b</mi>
+ <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
+ </mrow>
+ <mrow>
+ <mo maxsize="1.623em" minsize="1.623em" symmetric="true">(</mo>
+ <mfrac>
+ <mi>c</mi>
+ <mi>d</mi>
+ </mfrac>
+ <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
+ </mrow>
</math></p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mrow>
- <mo maxsize="1.623em" minsize="1.623em" symmetric="true">(</mo>
- <mi>b</mi>
- <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
- </mrow>
- <mrow>
- <mo maxsize="1.623em" minsize="1.623em" symmetric="true">(</mo>
- <mfrac>
- <mi>c</mi>
- <mi>d</mi>
- </mfrac>
- <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
- </mrow>
- </mstyle>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mo maxsize="2.047em" minsize="2.047em" symmetric="true">(</mo>
+ <mi>b</mi>
+ <mo maxsize="2.047em" minsize="2.047em" symmetric="true">)</mo>
+ </mrow>
+ <mrow>
+ <mo maxsize="2.047em" minsize="2.047em" symmetric="true">(</mo>
+ <mfrac>
+ <mi>c</mi>
+ <mi>d</mi>
+ </mfrac>
+ <mo maxsize="2.047em" minsize="2.047em" symmetric="true">)</mo>
+ </mrow>
</math></p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mrow>
- <mo maxsize="2.047em" minsize="2.047em" symmetric="true">(</mo>
- <mi>b</mi>
- <mo maxsize="2.047em" minsize="2.047em" symmetric="true">)</mo>
- </mrow>
- <mrow>
- <mo maxsize="2.047em" minsize="2.047em" symmetric="true">(</mo>
- <mfrac>
- <mi>c</mi>
- <mi>d</mi>
- </mfrac>
- <mo maxsize="2.047em" minsize="2.047em" symmetric="true">)</mo>
- </mrow>
- </mstyle>
+<td><p><math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <mrow>
+ <mo maxsize="2.470em" minsize="2.470em" symmetric="true">(</mo>
+ <mi>b</mi>
+ <mo maxsize="2.470em" minsize="2.470em" symmetric="true">)</mo>
+ </mrow>
+ <mrow>
+ <mo maxsize="2.470em" minsize="2.470em" symmetric="true">(</mo>
+ <mfrac>
+ <mi>c</mi>
+ <mi>d</mi>
+ </mfrac>
+ <mo maxsize="2.470em" minsize="2.470em" symmetric="true">)</mo>
+ </mrow>
</math></p></td>
-<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <mrow>
- <mo maxsize="2.470em" minsize="2.470em" symmetric="true">(</mo>
- <mi>b</mi>
- <mo maxsize="2.470em" minsize="2.470em" symmetric="true">)</mo>
- </mrow>
- <mrow>
- <mo maxsize="2.470em" minsize="2.470em" symmetric="true">(</mo>
- <mfrac>
- <mi>c</mi>
- <mi>d</mi>
- </mfrac>
- <mo maxsize="2.470em" minsize="2.470em" symmetric="true">)</mo>
- </mrow>
- </mstyle>
-</math></p></td>
</tr>
</tbody>
</table>
@@ -4493,53 +4457,49 @@
<math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mo>(</mo>
- <mstyle scriptlevel="1">
- <mtable rowspacing="0.02em" columnspacing="0.333em">
- <mtr>
- <mtd>
- <mi>a</mi>
- </mtd>
- <mtd>
- <mi>b</mi>
- </mtd>
- </mtr>
- <mtr>
- <mtd>
- <mi>c</mi>
- </mtd>
- <mtd>
- <mi>d</mi>
- </mtd>
- </mtr>
- </mtable>
- <mo>)</mo>
- </mstyle>
+ <mtable rowspacing="0.02em" columnspacing="0.333em" scriptlevel="1">
+ <mtr>
+ <mtd>
+ <mi>a</mi>
+ </mtd>
+ <mtd>
+ <mi>b</mi>
+ </mtd>
+ </mtr>
+ <mtr>
+ <mtd>
+ <mi>c</mi>
+ </mtd>
+ <mtd>
+ <mi>d</mi>
+ </mtd>
+ </mtr>
+ </mtable>
+ <mo>)</mo>
</mrow>
</math>
vs. <math xmlns="http://www.w3.org/1998/Math/MathML">
<mrow>
<mo maxsize="1.623em" minsize="1.623em" symmetric="true">(</mo>
- <mstyle scriptlevel="1">
- <mtable rowspacing="0.02em" columnspacing="0.333em">
- <mtr>
- <mtd>
- <mi>a</mi>
- </mtd>
- <mtd>
- <mi>b</mi>
- </mtd>
- </mtr>
- <mtr>
- <mtd>
- <mi>c</mi>
- </mtd>
- <mtd>
- <mi>d</mi>
- </mtd>
- </mtr>
- </mtable>
- <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
- </mstyle>
+ <mtable rowspacing="0.02em" columnspacing="0.333em" scriptlevel="1">
+ <mtr>
+ <mtd>
+ <mi>a</mi>
+ </mtd>
+ <mtd>
+ <mi>b</mi>
+ </mtd>
+ </mtr>
+ <mtr>
+ <mtd>
+ <mi>c</mi>
+ </mtd>
+ <mtd>
+ <mi>d</mi>
+ </mtd>
+ </mtr>
+ </mtable>
+ <mo maxsize="1.623em" minsize="1.623em" symmetric="true">)</mo>
</mrow>
</math>.</p>
</aside>
@@ -4832,22 +4792,20 @@
spacing that would be applied in display math, inline
math, first-order subscript, or second-order subscript, respectively
even when the current context would normally yield some other size.</p>
-<p>For example <span class="docutils literal"><span class="pre">:math:`\displaystyle</span> <span class="pre">\sum_{n=0}^\infty</span> <span class="pre">\frac{1}{n}`</span></span> is printed as <math xmlns="http://www.w3.org/1998/Math/MathML">
- <mstyle displaystyle="true" scriptlevel="0">
- <munderover>
- <mo movablelimits="true">∑</mo>
- <mrow>
- <mi>n</mi>
- <mo>=</mo>
- <mn>0</mn>
- </mrow>
- <mi>∞</mi>
- </munderover>
- <mfrac>
- <mn>1</mn>
+<p>For example <span class="docutils literal"><span class="pre">:math:`\displaystyle</span> <span class="pre">\sum_{n=0}^\infty</span> <span class="pre">\frac{1}{n}`</span></span> is printed as <math xmlns="http://www.w3.org/1998/Math/MathML" displaystyle="true" scriptlevel="0">
+ <munderover>
+ <mo movablelimits="true">∑</mo>
+ <mrow>
<mi>n</mi>
- </mfrac>
- </mstyle>
+ <mo>=</mo>
+ <mn>0</mn>
+ </mrow>
+ <mi>∞</mi>
+ </munderover>
+ <mfrac>
+ <mn>1</mn>
+ <mi>n</mi>
+ </mfrac>
</math>
rather than <math xmlns="http://www.w3.org/1998/Math/MathML">
<munderover>
@@ -4870,7 +4828,7 @@
<div>
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<mfrac>
- <mstyle displaystyle="false" scriptlevel="1">
+ <mrow displaystyle="false" scriptlevel="1">
<munder>
<mo movablelimits="true">∑</mo>
<mrow>
@@ -4883,8 +4841,8 @@
<mi>z</mi>
<mi>n</mi>
</msup>
- </mstyle>
- <mstyle displaystyle="true" scriptlevel="0">
+ </mrow>
+ <mrow displaystyle="true" scriptlevel="0">
<munder>
<mo movablelimits="true">∏</mo>
<mrow>
@@ -4903,7 +4861,7 @@
<mi>k</mi>
</msup>
<mo stretchy="false">)</mo>
- </mstyle>
+ </mrow>
</mfrac>
<mtext> instead of the default </mtext>
<mfrac>
Modified: trunk/docutils/test/test_utils/test_math/test_mathml_elements.py
===================================================================
--- trunk/docutils/test/test_utils/test_math/test_mathml_elements.py 2024-02-01 13:03:27 UTC (rev 9532)
+++ trunk/docutils/test/test_utils/test_math/test_mathml_elements.py 2024-02-01 13:03:41 UTC (rev 9533)
@@ -35,7 +35,7 @@
<annotation> 0 Data annotations NOT IMPLEMENTED
<annotation-xml> * XML annotations NOT IMPLEMENTED
<math> * Top-level element
- <menclose> 1 Enclosed contents (non-standard)
+ <menclose> 1 Enclosed contents (non-standard) deprecated
<merror> * Enclosed syntax error messages
<mfenced> * Parentheses (non-standard) DEPRECATED
<mfrac> 2 Fraction
@@ -44,7 +44,7 @@
<mn> 0 Number
<mo> 0 Operator (and similar)
<mover> 2 Overscript
- <mpadded> * Extra padding NOT IMPLEMENTED
+ <mpadded> * Extra padding
<mphantom> 1 Invisible content reserving space
<mroot> 2 Radical with specified index
<mrow> * Grouped sub-expressions
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-02-01 13:03:56
|
Revision: 9534
http://sourceforge.net/p/docutils/code/9534
Author: milde
Date: 2024-02-01 13:03:52 +0000 (Thu, 01 Feb 2024)
Log Message:
-----------
LaTeX to MathML: Fix "mathvariant" handling for numbers.
Conversion of \mathtt{0.12} did not use monospaced digits.
Do a per-character lookup/replacement with
"alphanumical mathematical chars" for the "text" of `<mn>`.
While identifiers are usually put in separate `<mi>` elements
and more than one letter in a `<mi>` indicates a function name
that should not change fonts,
numbers in `<mn>` consisting of several digits should be
changed according to the given "mathvariant".
Modified Paths:
--------------
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/test/functional/expected/mathematics_mathml.html
trunk/docutils/test/test_utils/test_math/test_tex2mathml_extern.py
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2024-02-01 13:03:41 UTC (rev 9533)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2024-02-01 13:03:52 UTC (rev 9534)
@@ -988,12 +988,11 @@
if name == 'mathscr':
attributes['class'] = 'mathscr'
arg, string = tex_token_or_group(string)
- # Shortcut for text arg like \mathrm{out}
- # with more than one letter, <mi> defaults to "normal" font
+ # Shortcut for text arg like \mathrm{out} with more than one letter:
if name == 'mathrm' and arg.isalpha() and len(arg) > 1:
- node = node.append(mi(arg))
+ node = node.append(mi(arg)) # <mi> defaults to "normal" font
return node, string
- # Parse as <style> node children
+ # Parse into an <mrow>
container = mrow(**attributes)
node.append(container)
parse_latex_math(container, arg)
@@ -1000,10 +999,14 @@
a2ch = getattr(mathalphabet2unichar,
name.replace('mathscr', 'mathcal'), {})
for subnode in container.iter():
- if isinstance(subnode, (mi, mn)):
+ if isinstance(subnode, mn):
+ # a number may consist of more than one digit
+ subnode.text = ''.join(a2ch.get(ch, ch) for ch in subnode.text)
+ elif isinstance(subnode, mi):
+ # don't convert multi-letter identifiers (functions)
subnode.text = a2ch.get(subnode.text, subnode.text)
- if isinstance(subnode, mi) and name == 'mathrm' and subnode.text.isalpha():
- subnode.set('mathvariant', 'normal')
+ if name == 'mathrm' and subnode.text.isalpha():
+ subnode.set('mathvariant', 'normal')
return container.close(), string
# >>> handle_math_alphabet('mathrm', math(), '\\alpha')
Modified: trunk/docutils/test/functional/expected/mathematics_mathml.html
===================================================================
--- trunk/docutils/test/functional/expected/mathematics_mathml.html 2024-02-01 13:03:41 UTC (rev 9533)
+++ trunk/docutils/test/functional/expected/mathematics_mathml.html 2024-02-01 13:03:52 UTC (rev 9534)
@@ -1751,7 +1751,7 @@
<tr><td><p><span class="docutils literal">\mathtt</span></p></td>
<td><p><span class="docutils literal">\mathtt{0.12}</span></p></td>
<td><p><math xmlns="http://www.w3.org/1998/Math/MathML">
- <mn>0.12</mn>
+ <mn>𝟶.𝟷𝟸</mn>
</math></p></td>
</tr>
</tbody>
Modified: trunk/docutils/test/test_utils/test_math/test_tex2mathml_extern.py
===================================================================
--- trunk/docutils/test/test_utils/test_math/test_tex2mathml_extern.py 2024-02-01 13:03:41 UTC (rev 9533)
+++ trunk/docutils/test/test_utils/test_math/test_tex2mathml_extern.py 2024-02-01 13:03:52 UTC (rev 9534)
@@ -21,7 +21,7 @@
# Testing the conversion with external converters requires additional
# ressources (latexml, blahtexml, ttm, pandoc) and is SLOW
-# (ca. 27.467s without testing "latexml", much slower with "latexml").
+# (ca. 27s without testing "latexml" and 13 min with "latexml").
# Therefore, tests are skipped unless run as stand-alone module:
if __name__ != '__main__':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-02-01 13:04:07
|
Revision: 9535
http://sourceforge.net/p/docutils/code/9535
Author: milde
Date: 2024-02-01 13:04:04 +0000 (Thu, 01 Feb 2024)
Log Message:
-----------
Base MathML element classes on xml.etree.
Use `xml.etree` for a more standard compatible implementation of
MathML element classes.
`xml.etree` comes with methods to represent XML elements,
to convert to XML (since Python 3.9 also indented XML),
search for elements, iterate over nodes etc.
The new module adds an interface to the requirements of latex2mathml:
* Simpler instantiation
- tag name taken from class name,
- attribute names are normalized to lowercase
(allows 'CLASS' for 'class'),
- attribute values may be specified as numbers, booleans, or strings
(converted to `str` before storing).
* "internal" attributes to store a reference to the parent element
and the number of expected children.
* "appending" to and "closing" an element returns the new "active node"
(insertion point).
* Remove redundant `<mrow>` elements when closing.
* toxml() by default returns a Unicode `str` (not `bytes`).
Modified Paths:
--------------
trunk/docutils/docutils/utils/math/latex2mathml.py
trunk/docutils/docutils/utils/math/mathml_elements.py
trunk/docutils/test/test_utils/test_math/test_mathml_elements.py
Modified: trunk/docutils/docutils/utils/math/latex2mathml.py
===================================================================
--- trunk/docutils/docutils/utils/math/latex2mathml.py 2024-02-01 13:03:52 UTC (rev 9534)
+++ trunk/docutils/docutils/utils/math/latex2mathml.py 2024-02-01 13:04:04 UTC (rev 9535)
@@ -578,7 +578,7 @@
attributes = {}
if c == '-' and len(node):
previous_node = node[-1]
- if (getattr(previous_node, 'text', '-') in '([='
+ if (previous_node.text and previous_node.text in '([='
or previous_node.get('class') == 'mathopen'):
attributes['form'] = 'prefix'
node = node.append(mo(anomalous_chars[c], **attributes))
@@ -1163,7 +1163,8 @@
math_tree.append(mtable(mtr(node), CLASS='ams-align',
displaystyle=True))
parse_latex_math(node, tex_math)
- return math_tree.toprettyxml()
+ math_tree.indent_xml()
+ return math_tree.toxml()
# >>> print(tex2mathml('3'))
# <math xmlns="http://www.w3.org/1998/Math/MathML">
Modified: trunk/docutils/docutils/utils/math/mathml_elements.py
===================================================================
--- trunk/docutils/docutils/utils/math/mathml_elements.py 2024-02-01 13:03:52 UTC (rev 9534)
+++ trunk/docutils/docutils/utils/math/mathml_elements.py 2024-02-01 13:04:04 UTC (rev 9535)
@@ -10,7 +10,7 @@
#
# .. _2-Clause BSD license: https://opensource.org/licenses/BSD-2-Clause
-"""MathML element classes.
+"""MathML element classes based on `xml.etree`.
The module is intended for programmatic generation of MathML
and covers the part of `MathML Core`_ that is required by
@@ -27,6 +27,7 @@
# >>> from mathml_elements import *
import numbers
+import xml.etree.ElementTree as ET
GLOBAL_ATTRIBUTES = (
@@ -52,7 +53,7 @@
# Base classes
# ------------
-class MathElement:
+class MathElement(ET.Element):
"""Base class for MathML elements."""
nchildren = None
@@ -60,13 +61,6 @@
# cf. https://www.w3.org/TR/MathML3/chapter3.html#id.3.1.3.2
parent = None
"""Parent node in MathML element tree."""
- xml_entities = {
- # for invalid and invisible characters
- ord('<'): '<',
- ord('>'): '>',
- ord('&'): '&',
- 0x2061: '⁡',
- }
def __init__(self, *children, **attributes):
"""Set up node with `children` and `attributes`.
@@ -78,13 +72,12 @@
>>> math(CLASS='test', level=3, split=True)
math(class='test', level='3', split='true')
- >>> math(CLASS='test', level=3, split=True).toprettyxml()
+ >>> math(CLASS='test', level=3, split=True).toxml()
'<math class="test" level="3" split="true"></math>'
"""
- self.attrib = {k.lower(): self.a_str(v)
- for k, v in attributes.items()}
- self.children = []
+ attrib = {k.lower(): self.a_str(v) for k, v in attributes.items()}
+ super().__init__(self.__class__.__name__, **attrib)
self.extend(children)
@staticmethod
@@ -97,7 +90,7 @@
def __repr__(self):
"""Return full string representation."""
args = [repr(child) for child in self]
- if hasattr(self, 'text'):
+ if self.text:
args.append(repr(self.text))
if self.nchildren != self.__class__.nchildren:
args.append(f'nchildren={self.nchildren}')
@@ -104,41 +97,19 @@
if getattr(self, 'switch', None):
args.append('switch=True')
args += [f'{k}={v!r}' for k, v in self.items() if v is not None]
- return f'{self.__class__.__name__}({", ".join(args)})'
+ return f'{self.tag}({", ".join(args)})'
def __str__(self):
"""Return concise, informal string representation."""
- if getattr(self, 'text', ''):
+ if self.text:
args = repr(self.text)
else:
args = ', '.join(f'{child}' for child in self)
- return f'{self.__class__.__name__}({args})'
+ return f'{self.tag}({args})'
- # Emulate dictionary access methods for attributes
- # and list-like interface to the child elements
- # (differs from `docutils.nodes.Element` dict/list interface).
-
- def get(self, key, default=None):
- return self.attrib.get(key, default)
-
def set(self, key, value):
- self.attrib[key] = self.a_str(value)
+ super().set(key, self.a_str(value))
- def items(self):
- return self.attrib.items()
-
- def iter(self):
- """Return iterator over self and all subnodes, including nested."""
- yield self
- for child in self.children:
- yield from child.iter()
-
- def __len__(self):
- return len(self.children)
-
- def __getitem__(self, key):
- return self.children.__getitem__(key)
-
def __setitem__(self, key, value):
if self.nchildren == 0:
raise TypeError(f'Element "{self}" does not take children.')
@@ -147,14 +118,8 @@
else: # value may be an iterable
for e in value:
e.parent = self
- self.children.__setitem__(key, value)
+ super().__setitem__(key, value)
- def __delitem__(self, key):
- self.children.__delitem__(key)
-
- def __iter__(self):
- return self.children.__iter__()
-
def is_full(self):
"""Return boolean indicating whether children may be appended."""
return self.nchildren is not None and len(self) >= self.nchildren
@@ -183,7 +148,7 @@
else:
status = 'does not take children'
raise TypeError(f'Element "{self}" {status}.')
- self.children.append(element)
+ super().append(element)
element.parent = self
if self.is_full():
return self.close()
@@ -216,27 +181,47 @@
return False
return self.get('display') == 'block'
- # Conversion to (pretty) XML string
- def toprettyxml(self):
- """Return XML representation of self as string."""
- return ''.join(self._xml())
+ # XML output:
- def _xml(self, level=0):
- return [self.xml_starttag(),
- *self._xml_body(level),
- '</%s>' % self.__class__.__name__]
+ def indent_xml(self, space=' ', level=0):
+ """Format XML output with indents.
- def xml_starttag(self):
- attrs = (f'{k}="{v}"' for k, v in self.items() if v is not None)
- return '<%s>' % ' '.join((self.__class__.__name__, *attrs))
+ Use with care:
+ Formatting whitespace is permanently added to the
+ `text` and `tail` attributes of `self` and anchestors!
+ """
+ ET.indent(self, space, level)
- def _xml_body(self, level=0):
- xml = []
- for child in self.children:
- xml.extend(['\n', ' ' * (level+1)])
- xml.extend(child._xml(level+1))
- if self.children:
- xml.extend(['\n', ' ' * level])
+ def unindent_xml(self):
+ """Strip whitespace at the end of `text` and `tail` attributes...
+
+ to revert changes made by the `indent_xml()` method.
+ Use with care, trailing whitespace from the original may be lost.
+ """
+ for e in self.iter():
+ if not isinstance(e, MathToken) and e.text:
+ e.text = e.text.rstrip()
+ if e.tail:
+ e.tail = e.tail.rstrip()
+
+ def toxml(self, encoding=None):
+ """Return an XML representation of the element.
+
+ By default, the return value is a `str` instance. With an explicit
+ `encoding` argument, the result is a `bytes` instance in the
+ specified encoding. The XML default encoding is UTF-8, any other
+ encoding must be specified in an XML document header.
+
+ Name and encoding handling match `xml.dom.minidom.Node.toxml()`;
+ `etree.Element.tostring()` returns `bytes` by default.
+ """
+ xml = ET.tostring(self, encoding or 'unicode',
+ short_empty_elements=False)
+ # Visible representation for "Apply Function" character:
+ try:
+ xml = xml.replace('\u2061', '⁡')
+ except TypeError:
+ xml = xml.replace('\u2061'.encode(encoding), b'⁡')
return xml
@@ -266,7 +251,7 @@
def __init__(self, *children, **kwargs):
self.switch = kwargs.pop('switch', False)
- math.__init__(self, *children, **kwargs)
+ super().__init__(*children, **kwargs)
def append(self, element):
"""Append element. Normalize order and close if full."""
@@ -294,10 +279,7 @@
f' not "{text}".')
self.text = str(text)
- def _xml_body(self, level=0):
- return [str(self.text).translate(self.xml_entities)]
-
# MathML element classes
# ----------------------
@@ -319,7 +301,7 @@
class mn(MathToken):
"""Numeric literal.
- >>> mn(3.41).toprettyxml()
+ >>> mn(3.41).toxml()
'<mn>3.41</mn>'
Normally a sequence of digits with a possible separator (a dot or a comma).
@@ -330,7 +312,7 @@
class mo(MathToken):
"""Operator, Fence, Separator, or Accent.
- >>> mo('<').toprettyxml()
+ >>> mo('<').toxml()
'<mo><</mo>'
Besides operators in strict mathematical meaning, this element also
@@ -382,7 +364,7 @@
if parent is not None and len(self) == 1:
child = self[0]
try:
- parent[parent.children.index(self)] = child
+ parent[list(parent).index(self)] = child
child.parent = parent
except (AttributeError, ValueError):
return None
@@ -454,15 +436,15 @@
# Examples:
#
# The `switch` attribute reverses the order of the last two children:
-# >>> msub(mn(1), mn(2)).toprettyxml()
-# '<msub>\n <mn>1</mn>\n <mn>2</mn>\n</msub>'
-# >>> msub(mn(1), mn(2), switch=True).toprettyxml()
-# '<msub>\n <mn>2</mn>\n <mn>1</mn>\n</msub>'
+# >>> msub(mn(1), mn(2)).toxml()
+# '<msub><mn>1</mn><mn>2</mn></msub>'
+# >>> msub(mn(1), mn(2), switch=True).toxml()
+# '<msub><mn>2</mn><mn>1</mn></msub>'
#
-# >>> msubsup(mi('base'), mn(1), mn(2)).toprettyxml()
-# '<msubsup>\n <mi>base</mi>\n <mn>1</mn>\n <mn>2</mn>\n</msubsup>'
-# >>> msubsup(mi('base'), mn(1), mn(2), switch=True).toprettyxml()
-# '<msubsup>\n <mi>base</mi>\n <mn>2</mn>\n <mn>1</mn>\n</msubsup>'
+# >>> msubsup(mi('base'), mn(1), mn(2)).toxml()
+# '<msubsup><mi>base</mi><mn>1</mn><mn>2</mn></msubsup>'
+# >>> msubsup(mi('base'), mn(1), mn(2), switch=True).toxml()
+# '<msubsup><mi>base</mi><mn>2</mn><mn>1</mn></msubsup>'
class munder(msub):
Modified: trunk/docutils/test/test_utils/test_math/test_mathml_elements.py
===================================================================
--- trunk/docutils/test/test_utils/test_math/test_mathml_elements.py 2024-02-01 13:03:52 UTC (rev 9534)
+++ trunk/docutils/test/test_utils/test_math/test_mathml_elements.py 2024-02-01 13:04:04 UTC (rev 9535)
@@ -81,6 +81,7 @@
# No arguments required, the class name is used as XML tag:
e1 = mml.MathElement()
+ self.assertEqual(e1.tag, 'MathElement')
# Positional arguments are stored as children,
# named arguments are stored as element attributes:
@@ -187,8 +188,7 @@
result = e1.append(mml.MathElement(id='c1'))
self.assertEqual(e1[0].parent, e1)
# ... which is hidden in XML ...
- self.assertEqual(e1[0].toprettyxml(),
- '<MathElement id="c1"></MathElement>')
+ self.assertEqual(e1[0].toxml(), '<MathElement id="c1"></MathElement>')
# ... and returns the new "insertion point".
# If more children may be appended, return self
self.assertEqual(result, e1)
@@ -234,13 +234,40 @@
self.assertTrue(e2.in_block())
self.assertTrue(e2[0].in_block())
- def test_toprettyxml(self):
+ def test_indent_xml(self):
+ """Modify `text` and `tail` to get indented XML output."""
+ c1 = mml.math(id='c1')
+ cc1 = mml.math(id='cc1')
+ c2 = mml.math(cc1, id='c2')
+ root = mml.math(c1, c2, id='root')
+ self.assertTrue('\n' not in str(root))
+ root.indent_xml()
+ self.assertEqual(root.toxml(), self.prettyXML)
+ # You can easily remove the indentation (but not the newlines):
+ root.indent_xml(space='')
+ self.assertEqual(c2.toxml(),
+ '<math id="c2">\n<math id="cc1"></math>\n</math>\n')
+ # Reverting `indent_xml()` requires iterating over all descendants
+ root.unindent_xml()
+ self.assertEqual(c2.toxml(),
+ '<math id="c2"><math id="cc1"></math></math>')
+
+ def test_unindent_xml(self):
+ # see also last assertion in `test_indent_xml()`
+ e1 = mml.math(mml.mtext('Hallo welt!\n'))
+ e1.indent_xml()
+ self.assertEqual(e1.toxml(),
+ '<math>\n <mtext>Hallo welt!\n</mtext>\n</math>')
+ # don't strip whitespace from MathToken's text attributes:
+ e1.unindent_xml()
+ self.assertEqual(e1.toxml(),
+ '<math><mtext>Hallo welt!\n</mtext></math>')
+
+ def test_toxml(self):
"""XML representation of the element/subtree as `str`."""
e1 = mml.math(mml.math(level=2), CLASS='root')
- self.assertEqual(e1.toprettyxml(),
- '<math class="root">\n'
- ' <math level="2"></math>\n'
- '</math>')
+ self.assertEqual(e1.toxml(),
+ '<math class="root"><math level="2"></math></math>')
class MathSchemaTests(unittest.TestCase):
@@ -251,7 +278,7 @@
ms1 = mml.MathSchema(switch=True, id='ms1')
self.assertEqual(repr(ms1), "MathSchema(switch=True, id='ms1')")
# internal attributes are not exported to XML.
- self.assertEqual(ms1.toprettyxml(),
+ self.assertEqual(ms1.toxml(),
'<MathSchema id="ms1"></MathSchema>')
# the default value is dropped from ``repr()``
ms1.switch = False
@@ -262,9 +289,8 @@
# the children are switched and `switch` is reset:
ms2 = mml.MathSchema(mml.mn(1), mml.mn(2), switch=True)
self.assertEqual(repr(ms2), "MathSchema(mn('2'), mn('1'))")
- self.assertEqual(
- ms2.toprettyxml(),
- '<MathSchema>\n <mn>2</mn>\n <mn>1</mn>\n</MathSchema>')
+ self.assertEqual(ms2.toxml(),
+ '<MathSchema><mn>2</mn><mn>1</mn></MathSchema>')
def test_append(self):
# appending normalizes the order before switching
@@ -296,7 +322,7 @@
# optional named arguments become XML attributes
e1 = mml.mo('[', stretchy=False)
- self.assertEqual(e1.toprettyxml(), '<mo stretchy="false">[</mo>')
+ self.assertEqual(e1.toxml(), '<mo stretchy="false">[</mo>')
def test_append(self):
# MathTokens don't take child elements.
@@ -343,8 +369,8 @@
root = mml.math(row1) # provide a parent
row1.close() # try again
self.assertEqual(c1.parent, root)
- self.assertEqual(root.toprettyxml(),
- '<math>\n <math class="c1 row1"></math>\n</math>')
+ self.assertEqual(root.toxml(),
+ '<math><math class="c1 row1"></math></math>')
class MathMLElementTests(unittest.TestCase):
@@ -359,10 +385,10 @@
cls = getattr(mml, element)
if issubclass(cls, mml.MathToken):
e = cls('x')
- self.assertEqual(e.toprettyxml(), f'<{element}>x</{element}>')
+ self.assertEqual(e.toxml(), f'<{element}>x</{element}>')
else:
e = cls()
- self.assertEqual(e.toprettyxml(), f'<{element}></{element}>')
+ self.assertEqual(e.toxml(), f'<{element}></{element}>')
if nchildren == '*':
self.assertTrue(e.nchildren is None,
f'{element}.nchildren == {e.nchildren}')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-02-14 17:43:01
|
Revision: 9538
http://sourceforge.net/p/docutils/code/9538
Author: milde
Date: 2024-02-14 17:42:58 +0000 (Wed, 14 Feb 2024)
Log Message:
-----------
Documentation update.
Harmonize wording and markup in "Docutils Configuration" doc.
Use field-list for "Default" and "Option(s)" when they don't fit
on one line.
Fix broken links.
Small fixes in FAQ.
Modified Paths:
--------------
trunk/docutils/FAQ.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docs/user/tools.txt
trunk/docutils/docutils/writers/html5_polyglot/__init__.py
trunk/docutils/test/data/help/docutils.txt
Modified: trunk/docutils/FAQ.txt
===================================================================
--- trunk/docutils/FAQ.txt 2024-02-01 21:10:43 UTC (rev 9537)
+++ trunk/docutils/FAQ.txt 2024-02-14 17:42:58 UTC (rev 9538)
@@ -941,8 +941,8 @@
Unexpected results from ``rst2html``: H1, H1 instead of H1, H2. Why?
--------------------------------------------------------------------------
-This only regards output from the `html4css1`_ writer.
-The `html5 writer`_ uses H1, H2, ...
+This only regards output from the `html4css1`_ writer and is configurable
+via the initial_header_level_ setting.
.. class:: details
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2024-02-01 21:10:43 UTC (rev 9537)
+++ trunk/docutils/RELEASE-NOTES.txt 2024-02-14 17:42:58 UTC (rev 9538)
@@ -82,6 +82,9 @@
- Change the default value for math_output_ to "MathML" in Docutils 0.22.
+ - Change the default value of the initial_header_level_ setting to None
+ (<h2> if there is a document title, else <h1>) in Docutils 1.0.
+
- Remove option ``--embed-images`` (obsoleted by "image_loading_")
in Docutils 2.0.
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2024-02-01 21:10:43 UTC (rev 9537)
+++ trunk/docutils/docs/user/config.txt 2024-02-14 17:42:58 UTC (rev 9538)
@@ -12,15 +12,32 @@
.. sidebar:: Docutils Security for Web Applications
- For details about securing web applications, please see `Deploying
- Docutils Securely <../howto/security.html>`_.
+ For a discussion about securing web applications, please see
+ `Deploying Docutils Securely <../howto/security.html>`_.
.. contents::
+.. raw:: html
+ <style type="text/css"><!--
+ dl.field-list {--field-indent: 4.7em;}
+ --></style>
+
+
Introduction
============
+Settings priority
+-----------------
+
+Configuration file settings override the built-in defaults, and
+command-line options override all.
+Some settings override also an associated setting; [#override]_
+others append values from the various sources. [#append-values]_
+
+For the technicalities, see `Docutils Runtime Settings`_.
+
+
Configuration Files
-------------------
@@ -27,9 +44,6 @@
Configuration files are used for persistent customization;
they can be set once and take effect every time you use a component,
e.g., via a `front-end tool`_.
-Configuration file settings override the built-in defaults, and
-command-line options override all.
-For the technicalities, see `Docutils Runtime Settings`_.
By default, Docutils checks the following places for configuration
files, in the following order:
@@ -38,23 +52,21 @@
applicable to all Docutils processing on the system.
2. ``./docutils.conf``: This is a project-specific configuration file,
- located in the current directory. The Docutils front end has to be
- executed from the directory containing this configuration file for
- it to take effect (note that this may have nothing to do with the
- location of the source files). Settings in the project-specific
- configuration file will override corresponding settings in the
- system-wide file.
+ located in the current directory.
+ The Docutils front end has to be executed from the directory
+ containing this configuration file for it to take effect (note that
+ this may have nothing to do with the location of the source files).
3. ``~/.docutils``: This is a user-specific configuration file,
- located in the user's home directory. Settings in this file will
- override corresponding settings in both the system-wide and
- project-specific configuration files.
+ located in the user's home directory.
-If more than one configuration file is found, all will be read but
-later entries will override earlier ones. For example, a "stylesheet"
-entry in a user-specific configuration file will override a
-"stylesheet" entry in the system-wide file.
+If more than one configuration file is found, all will be read and
+**later entries** will **override earlier ones**. [#append-values]_
+For example, a "stylesheet" entry in a user-specific configuration file
+will override a "stylesheet" entry in the system-wide file.
+.. _DOCUTILSCONFIG:
+
The default implicit config file paths can be overridden by the
``DOCUTILSCONFIG`` environment variable. ``DOCUTILSCONFIG`` should
contain a colon-separated (semicolon-separated on Windows) sequence of
@@ -63,8 +75,10 @@
Paths are interpreted relative to the current working directory.
Empty path items are ignored.
-In addition, a configuration file may be explicitly specified with the
-``--config`` command-line option. This configuration file is read after
+.. |config| replace:: ``--config``
+
+In addition, configuration files may be explicitly specified with the
+|config|_ command-line option. These configuration files are read after
the three implicit ones listed above (or the ones defined by the
``DOCUTILSCONFIG`` environment variable), and its entries will have
priority.
@@ -73,9 +87,9 @@
Configuration File Syntax
-------------------------
-Configuration files are UTF-8-encoded text files. The
-ConfigParser.py_ module from Python_'s standard library is used to
-read them. From its documentation:
+Configuration files are UTF-8-encoded text files. The ConfigParser.py_
+module from Python_'s standard library is used to read them.
+From its documentation:
The configuration file consists of sections, lead by a "[section]"
header and followed by "name: value" entries, with continuations
@@ -86,43 +100,48 @@
.. Note:: No format string interpolation is done.
-* Configuration file **entry names** correspond to internal runtime
- settings. Underscores ("_") and hyphens ("-") can be used
- interchangeably in entry names; hyphens are automatically converted to
- underscores.
+The following conventions apply to Docutils configuration files:
-* For on/off switch settings (_`booleans`), the following values are
- recognized:
-
+* Configuration file **entry names** correspond to internal `runtime
+ settings`_. Underscores ("_") and hyphens ("-") can be used interchangeably
+ in entry names; hyphens are automatically converted to underscores.
+ Entries with non-applicable or misspelled entry names are silently ignored.
+
+ .. _boolean:
+
+* For **boolean** settings (switches), the following values are
+ recognized (case-independent):
+
.. class:: narrow
:on: "true", "yes", "on", "1"
:off: "false", "no", "off", "0", "" (no value)
-.. _list:
+.. _comma-separated:
-* **List values** are either comma- or colon-delimited:
+* **Lists** are specified either comma- or _`colon-separated`:
- comma-delimited:
+ *comma-separated*:
strip_classes_, strip_elements_with_classes_, smartquotes_locales_,
- stylesheet, stylesheet_dirs, stylesheet_path, legacy_class_functions_,
- use_bibtex_
-
+ stylesheet_, stylesheet_dirs_, stylesheet_path_, use_bibtex_
+
Whitespace around list values is stripped, so you can write, e.g., ::
-
+
strip-classes: ham,eggs,
strip-elements-with-classes: sugar, salt, flour
stylesheet: html4css1.css,
math.css,
- style with spaces.css
-
- colon-delimited:
- expose_internals_, ignore_, prune_
-
+ style sheet with spaces.css
+
+
+ *colon-separated*:
+ ignore_, prune_, expose_internals_
+
Whitespace around the delimiter is not stripped. Write, e.g., ::
-
- expose_internals: b:c:d
+ expose_internals: source:line
+
+
Example
~~~~~~~
@@ -154,19 +173,22 @@
Configuration File Sections & Entries
-------------------------------------
-Below are the Docutils runtime settings, listed by config file
-section.
+Below are the Docutils `runtime settings`_, listed by config file section.
+Sections correspond to Docutils components (module name
+or alias; section names are always in lowercase letters).
.. important:: Any setting may be specified in any section, but only
- settings from *active sections* will be used.
+ settings from "`active sections`_" will be used.
-Sections correspond to
-Docutils components (module name or alias; section names are always in
-lowercase letters). Each Docutils application_ uses a specific set
-of components; corresponding configuration file sections are applied
-when the application is used. Configuration sections are applied in
-general-to-specific order, as follows:
+.. _active sections:
+
+Each Docutils application_ uses a specific set of components;
+`corresponding configuration file sections`__ are "active" when the
+application is used.
+
+Configuration sections are applied in general-to-specific order:
+
1. `[general]`_
2. `[parsers]`_, parser dependencies, and the section specific to the
@@ -182,7 +204,7 @@
on `[html writers]`_ and `[html4css1 writer]`_.
5. `[applications]`_, application dependencies, and the section
- specific to the Application (front-end tool) in use
+ specific to the Application (`front-end tool`_) in use
("[... application]").
Since any setting may be specified in any section, this ordering
@@ -208,7 +230,9 @@
.. _Python: https://www.python.org/
.. _RFC 822: https://www.rfc-editor.org/rfc/rfc822.txt
.. _front-end tool:
+.. _front-end tools:
.. _application: tools.html
+__ ../api/runtime-settings.html#active-sections
[general]
@@ -227,8 +251,8 @@
A trailing "%" is replaced with the tag name (new in Docutils 0.16).
-| *Default*: "%" (changed in 0.18 from "id").
-| *Option*: ``--auto-id-prefix`` (hidden, intended mainly for programmatic use).
+:Default: "%" (changed in 0.18 from "id").
+:Option: ``--auto-id-prefix`` (hidden, intended mainly for programmatic use).
.. _identifier normalization:
../ref/rst/directives.html#identifier-normalization
@@ -240,9 +264,6 @@
Include a time/datestamp in the document footer. Contains a
format string for Python's `time.strftime()`__.
-| *Default*: None.
-| *Options*: ``--date, -d, --time, -t, --no-datestamp``.
-
Configuration file entry examples::
# Equivalent to --date command-line option, results in
@@ -256,6 +277,9 @@
# Disables datestamp; equivalent to --no-datestamp:
datestamp:
+:Default: None.
+:Options: ``--date``, ``-d``, ``--time``, ``-t``, ``--no-datestamp``.
+
__ https://docs.python.org/3/library/time.html#time.strftime
@@ -264,7 +288,7 @@
Report debug-level system messages.
-*Default*: don't (None). *Options*: ``--debug, --no-debug``.
+*Default*: None (disabled). *Options*: ``--debug``, ``--no-debug``.
dump_internals
@@ -273,7 +297,7 @@
At the end of processing, write all internal attributes of the
document (``document.__dict__``) to stderr.
-*Default*: don't (None).
+*Default*: None (disabled).
*Option*: ``--dump-internals`` (hidden, for development use only).
@@ -283,7 +307,7 @@
At the end of processing, write the pseudo-XML representation of
the document to stderr.
-*Default*: don't (None).
+*Default*: None (disabled).
*Option*: ``--dump-pseudo-xml`` (hidden, for development use only).
@@ -292,7 +316,7 @@
At the end of processing, write all Docutils settings to stderr.
-*Default*: don't (None).
+*Default*: None (disabled).
*Option*: ``--dump-settings`` (hidden, for development use only).
@@ -302,7 +326,7 @@
At the end of processing, write a list of all transforms applied
to the document to stderr.
-*Default*: don't (None).
+*Default*: None (disabled).
*Option*: ``--dump-transforms`` (hidden, for development use only).
@@ -311,9 +335,8 @@
The text encoding for error output.
-| *Default*: The encoding reported by ``sys.stderr``, locale encoding,
- or "ascii".
-| *Options*: ``--error-encoding, -e``.
+:Default: The encoding reported by ``sys.stderr``, locale encoding, or "ascii".
+:Options: ``--error-encoding``, ``-e``.
error_encoding_error_handler
@@ -323,8 +346,8 @@
Acceptable values are the `Error Handlers`_ of Python's "codecs" module.
See also output_encoding_error_handler_.
-| *Default*: "backslashreplace"
-| *Options*: ``--error-encoding-error-handler, --error-encoding, -e``.
+:Default: "backslashreplace"
+:Options: ``--error-encoding-error-handler``, ``--error-encoding``, ``-e``.
exit_status_level
@@ -335,18 +358,17 @@
exit. Exit status is the maximum system message level plus 10 (11
for INFO, etc.).
-*Default*: disabled (5). *Option*: ``--exit-status``.
+*Default*: 5 (disabled). *Option*: ``--exit-status``.
expose_internals
----------------
-List_ of internal attributes to expose as external attributes (with
-"internal:" namespace prefix). To specify multiple attributes in
-configuration files, use colons to separate names; on the command
-line, the option may be used more than once.
+List of internal attributes (colon-separated_) to expose
+as external attributes (with "internal:" namespace prefix).
+Values are appended. [#append-values]_
-*Default*: don't (None).
+*Default*: ``[]``.
*Option*: ``--expose-internal-attribute`` (hidden, for development use only).
@@ -353,11 +375,10 @@
footnote_backlinks
------------------
-Enable or disable backlinks from footnotes_ and citations_ to their
-references.
+Enable backlinks from footnotes_ and citations_ to their references.
-| *Default*: enabled (True).
-| *Options*: ``--footnote-backlinks, --no-footnote-backlinks``.
+:Default: True.
+:Options: ``--footnote-backlinks``, ``--no-footnote-backlinks``.
generator
@@ -365,7 +386,8 @@
Include a "Generated by Docutils" credit and link in the document footer.
-*Default*: off (None). *Options*: ``--generator, -g, --no-generator``.
+:Default: None (disabled).
+:Options: ``--generator``, ``-g``, ``--no-generator``.
halt_level
@@ -377,7 +399,7 @@
See also report_level_.
-*Default*: severe (4). *Options*: ``--halt, --strict``.
+*Default*: 4 (severe). *Options*: ``--halt``, ``--strict``.
id_prefix
@@ -388,7 +410,7 @@
format, as it is not subjected to the `identifier normalization`_.
See also auto_id_prefix_.
-*Default*: "" (empty).
+*Default*: "" (no prefix).
*Option*: ``--id-prefix`` (hidden, intended mainly for programmatic use).
@@ -397,8 +419,8 @@
The text encoding for input (use the empty string to restore the default).
-*Default*: auto-detect_ (None). [#]_
-*Options*: ``--input-encoding, -i``. [#i-o-options]_
+*Default*: None (auto-detect_). [#]_
+*Options*: ``--input-encoding``, ``-i``. [#i-o-options]_
.. [#] The default will change to "utf-8" in Docutils 0.22.
.. [#i-o-options] The short options ``-i`` and ``-o`` `will be removed`__
@@ -451,7 +473,7 @@
"language-<language tag>" `class attribute`_, e.g.
``.. class:: language-el-polyton`` for a quote in polytonic Greek.
-*Default*: English ("en"). *Options*: ``--language, -l``.
+*Default*: "en" (English). *Options*: ``--language``, ``-l``.
.. _class attribute: ../ref/doctree.html#classes
@@ -459,9 +481,9 @@
output
------
-The path of the output destination. Use ``-`` for stdout.
+The path of the output destination. Use "-" for `stdout`.
-Obsoletes the ``<destination>`` positional argument
+Obsoletes the `\<destination>`_ positional argument
(cf. `Future changes`_ in the RELEASE-NOTES).
*Default*: None (stdout). *Option*: ``--output``.
@@ -482,7 +504,7 @@
This setting is ignored by the `ODF/ODT Writer`_ which always usues UTF-8.
-*Default*: "utf-8". *Options*: ``--output-encoding, -o``. [#i-o-options]_
+*Default*: "utf-8". *Options*: ``--output-encoding``, ``-o``. [#i-o-options]_
output_encoding_error_handler
@@ -521,13 +543,13 @@
stylesheets. [#dependencies]_ [#pwd]_ The format is one path per
line with forward slashes as separator, the encoding is UTF-8.
-Set it to "``-``" in order to write dependencies to stdout.
+Set it to "-" in order to write dependencies to stdout.
This option is particularly useful in conjunction with programs like
``make`` using ``Makefile`` rules like::
ham.html: ham.txt $(shell cat hamdeps.txt)
- rst2html --record-dependencies=hamdeps.txt ham.txt ham.html
+ rst2html --record-dependencies=hamdeps.txt ham.txt > ham.html
If the filesystem encoding differs from UTF-8, replace the ``cat``
command with a call to a converter, e.g.::
@@ -534,7 +556,7 @@
$(shell iconv -f utf-8 -t latin1 hamdeps.txt)
-*Default*: None. *Option*: ``--record-dependencies``.
+*Default*: None (disabled). *Option*: ``--record-dependencies``.
.. [#dependencies] Images are only added to the dependency list if they
are embedded into the output or the reStructuredText parser extracted
@@ -554,8 +576,8 @@
See also halt_level_.
-| *Default*: warning (2).
-| *Options*: ``--report, -r, --verbose, -v, --quiet, -q``.
+:Default: 2 (warning).
+:Options: ``--report``, ``-r``, ``--verbose``, ``-v``, ``--quiet``, ``-q``.
root_prefix
@@ -567,29 +589,27 @@
Also applied when a writer converts an image URI__ to a local filesystem
path in order to determine the image size or embed the image in the output.
-*Default*: "/" (no change).
-*Option*: ``--root-prefix``
+:Default: "/" (keep paths unchanged).
+:Option: ``--root-prefix``
New in Docutils 0.21.
__ ../ref/rst/directives.html#path
__ ../ref/rst/directives.html#uri
-.. _image: ../ref/rst/directives.html#image
-.. _figure: ../ref/rst/directives.html#figure
sectnum_xform
-------------
-Enable or disable automatic section numbering by Docutils
-(docutils.transforms.parts.SectNum) associated with the `sectnum
-directive`_.
+Enable automatic section numbering by Docutils
+(`docutils.transforms.parts.SectNum`) associated
+with the `sectnum directive`_.
If disabled, section numbers might be added to the output by the
renderer (e.g. by LaTeX or via a CSS style definition).
-| *Default*: enabled (True).
-| *Options*: ``--section-numbering``, ``--no-section-numbering``.
+:Default: True.
+:Options: ``--section-numbering``, ``--no-section-numbering``.
.. _sectnum directive: ../ref/rst/directives.html#sectnum
@@ -600,8 +620,8 @@
Include a "View document source" link in the document footer. URL will
be relative to the destination.
-*Default*: don't (None).
-*Options*: ``--source-link, -s, --no-source-link``.
+:Default: None (disabled).
+:Options: ``--source-link``, ``-s``, ``--no-source-link``.
source_url
@@ -609,8 +629,8 @@
An explicit URL for a "View document source" link, used verbatim.
-| *Default*: compute if source_link (None).
-| *Options*: ``--source-url, --no-source-link``.
+:Default: None (compute from source_link_).
+:Options: ``--source-url``, ``--no-source-link``.
strict_visitor
@@ -617,47 +637,49 @@
--------------
When processing a document tree with the Visitor pattern, raise an
-error if a writer does not support a node type listed as optional. For
-transitional development use.
+error if a writer does not support a node type listed as optional.
+For transitional development use.
-| *Default*: disabled (None).
-| *Option*: ``--strict-visitor`` (hidden, for development use only).
+:Default: None (disabled).
+:Option: ``--strict-visitor`` (hidden, for development use only).
strip_classes
-------------
-Comma-separated list_ of "classes" attribute values to remove from all
-elements in the document tree. The command line option may be used more
-than once.
+List of "classes" attribute values (comma-separated_) that will be
+removed from all elements in the document tree.
+Values are appended. [#append-values]_
+Allows eliding class values that interfere with, e.g, CSS rules from 3rd
+party tools/frameworks.
+
.. WARNING:: Some standard class values are required in order to achieve
the expected output rendering; use with caution.
-*Default*: disabled (None). *Option*: ``--strip-class``.
+*Default*: ``[]``. *Option*: ``--strip-class``.
strip_comments
--------------
-Enable the removal of comment elements from the document tree.
+Enable or disable the removal of comment elements from the document tree.
-*Default*: disabled (None).
-*Options*: ``--strip-comments``, ``--leave-comments``.
+:Default: None (disabled).
+:Options: ``--strip-comments``, ``--leave-comments``.
strip_elements_with_classes
---------------------------
-Comma-separated list_ of "classes" attribute values.
+List of "classes" attribute values (comma-separated_).
+Values are appended. [#append-values]_
Matching elements are removed from the document tree.
-The command line option may be used more than once.
.. WARNING:: Potentially dangerous: may lead to an invalid document tree
- and subsequent writer errors.
- Use with caution.
+ and subsequent writer errors. Use with caution.
-*Default*: disabled (None). *Option*: ``--strip-element-with-class``.
+*Default*: ``[]``. *Option*: ``--strip-element-with-class``.
title
@@ -671,7 +693,8 @@
This setting overrides a displayed `document title`_ and
is overridden by a `"title" directive`_.
-*Default*: none. *Option*: ``--title``.
+:Default: None (the displayed `document title`_).
+:Option: ``--title``.
.. _title attribute: ../ref/doctree.html#title-attribute
.. _document title: ../ref/rst/restructuredtext.html#document-title
@@ -682,24 +705,27 @@
-------------
Enable backlinks from section titles to table of contents entries
-("entry"), to the top of the TOC ("top"), or disable ("none").
+("entry"), to the top of the ToC ("top"), or disable ("none").
-| *Default*: "entry".
-| *Options*: ``--toc-entry-backlinks, --toc-top-backlinks, --no-toc-backlinks``.
+:Default: "entry".
+:Options: ``--toc-entry-backlinks``, ``--toc-top-backlinks``,
+ ``--no-toc-backlinks``.
traceback
---------
-Enable Python tracebacks when halt-level system messages and other
-exceptions occur. Useful for debugging, and essential for issue
+Enable or disable Python tracebacks when halt-level system messages and
+other exceptions occur. Useful for debugging, and essential for issue
reports. Exceptions are allowed to propagate, instead of being
caught and reported (in a user-friendly way) by Docutils.
-| *Default*: disabled (None) unless Docutils is run programmatically
- using the `Publisher Interface`_.
-| *Options*: ``--traceback, --no-traceback``.
+:Default: None (disabled). [#]_
+:Options: ``--traceback``, ``--no-traceback``.
+.. [#] unless Docutils is run programmatically
+ using the `Publisher Interface`_
+
.. _Publisher Interface: ../api/publisher.html
@@ -708,7 +734,7 @@
Path to a file for the output of system messages (warnings). [#pwd]_
-*Default*: stderr (None). *Option*: ``--warnings``.
+*Default*: None (stderr). *Option*: ``--warnings``.
[parsers]
@@ -719,14 +745,14 @@
file_insertion_enabled
----------------------
-Enable or disable directives inserting the contents of
+Enable directives inserting the contents of
external files, such as "include_" directive
or the "raw_" and "csv-table_" directives with option "url" or "file".
A "warning" system message (including the directive text) is inserted
instead. (See also raw_enabled_ for another security-relevant setting.)
-| *Default*: enabled (True).
-| *Options*: ``--file-insertion-enabled, --no-file-insertion``.
+:Default: True.
+:Options: ``--file-insertion-enabled``, ``--no-file-insertion``.
.. _include: ../ref/rst/directives.html#include
.. _raw: ../ref/rst/directives.html#raw
@@ -752,11 +778,11 @@
raw_enabled
-----------
-Enable or disable the "raw_" directive. A "warning" system message
+Enable the "raw_" directive. A "warning" system message
(including the directive text) is inserted instead. See also
file_insertion_enabled_ for another security-relevant setting.
-*Default*: enabled (True). *Options*: ``--raw-enabled, --no-raw``.
+*Default*: True. *Options*: ``--raw-enabled``, ``--no-raw``.
[restructuredtext parser]
@@ -775,16 +801,21 @@
When changing this setting to "True", inline markup characters in
URLs, names and formulas must be escaped to prevent recognition and
- possible errors. Examples::
+ possible errors.
- http://rST_for_all.html (hyperlinks to rST_ and for_)
- x_2, inline_markup (hyperlinks to x_ and inline_)
- 2*x (starts emphasised text)
- a|b (starts a substitution reference)
+ Examples:
+ .. class:: borderless
-| *Default*: disabled (False).
-| *Options*: ``--character-level-inline-markup, --word-level-inline-markup``.
+ =========================== ====================================
+ ``http://rST_for_all.html`` hyperlinks to ``rST_`` and ``for_``
+ ``x_2, inline_markup`` hyperlinks to ``x_`` and ``inline_``
+ ``2*x`` starts emphasised text
+ ``a|b`` starts a substitution reference
+ =========================== ====================================
+:Default: False.
+:Options: ``--character-level-inline-markup``, ``--word-level-inline-markup``.
+
New in Docutils 0.13.
pep_references
@@ -791,10 +822,9 @@
~~~~~~~~~~~~~~
Recognize and link to standalone PEP references (like "PEP 258").
-*Default*: disabled (None); enabled (True) in PEP Reader.
+:Default: None (disabled); True in PEP Reader.
+:Option: ``--pep-references``.
-*Option*: ``--pep-references``.
-
pep_base_url
~~~~~~~~~~~~
Base URL for PEP references.
@@ -813,10 +843,9 @@
~~~~~~~~~~~~~~
Recognize and link to standalone RFC references (like "RFC 822").
-*Default*: disabled (None); enabled (True) in PEP Reader.
+:Default: None (disabled); True in PEP Reader.
+:Option: ``--rfc-references``.
-*Option*: ``--rfc-references``.
-
rfc_base_url
~~~~~~~~~~~~
Base URL for RFC references.
@@ -828,7 +857,7 @@
Activate the SmartQuotes_ transform to
change straight quotation marks to typographic form. `Quote characters`_
are selected according to the language of the current block element (see
-language_code_, smartquotes_locales_, and the `pre-defined quote sets`__).
+language_code_, smartquotes_locales_, and the `pre-defined quote sets`_).
Also changes consecutive runs of hyphen-minus and full stops (``---``,
``--``, ``...``) to em-dash, en-dash, and ellipsis Unicode characters
@@ -836,42 +865,41 @@
Supported values:
-booleans_ (yes/no)
- Use smart quotes?
+:boolean_: Use smart quotes?
+:alt: Use alternative quote set (if defined for the language).
-alt (or "alternative")
- Use alternative quote set (if defined for the language).
+*Default*: None (disabled). *Option*: ``--smart-quotes``.
-*Default*: "no". *Option*: ``--smart-quotes``.
-
New in Docutils 0.10.
.. _SmartQuotes: smartquotes.html
-__ smartquotes.html#localization
+.. _pre-defined quote sets: smartquotes.html#localization
.. _quote characters:
https://en.wikipedia.org/wiki/Non-English_usage_of_quotation_marks
smartquotes_locales
~~~~~~~~~~~~~~~~~~~
-Typographical quotes used by the SmartQuotes_ transform.
-A comma-separated list_ with language tag and a string of four quotes
-(primary open/close, secondary open/close). [#]_
+List with language tag and a string of four typographical quote
+characters (primary open/close, secondary open/close) for use by
+the SmartQuotes_ transform.
+Values are appended. [#append-values]_
Example:
Ensure a correct leading apostrophe in ``'s Gravenhage`` in Dutch (at the
cost of incorrect opening single quotes) and set French quotes to double
- and single guillemets with inner padding::
+ and single guillemets with inner padding [#]_::
smartquote-locales: nl: „”’’,
fr: « : »:‹ : ›
-*Default*: None. *Option*: ``--smartquotes-locales``.
+:Default: SmartQuotes' `pre-defined quote sets`_.
+:Option: ``--smartquotes-locales``.
New in Docutils 0.14.
.. [#] If more than one character per quote is required (e.g. padding in
- French quotes), a colon-separated list may be used as value.
+ French quotes), a colon-separated list may be used for the quote set.
syntax_highlight
~~~~~~~~~~~~~~~~
@@ -880,14 +908,11 @@
Supported values:
-long
- Use hierarchy of long token type names.
-short
- Use short token type names. (For use with
- `Pygments-generated stylesheets`_.)
-none
- No code parsing. Use this to avoid the "Pygments not
- found" warning when Pygments is not installed.
+:long: Use hierarchy of long token type names.
+:short: Use short token type names.
+ (For use with `Pygments-generated stylesheets`_.)
+:none: No code parsing. Use this to avoid the "Pygments not
+ found" warning when Pygments is not installed.
*Default*: "long". *Option*: ``--syntax-highlight``.
@@ -910,12 +935,12 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Remove spaces before `footnote references`_?
-| *Default*: None [#]_
-| *Options*: ``--trim-footnote-reference-space, --leave-footnote-reference-space``.
+:Default: None (depends on the `footnote_references setting`_ [#]_).
+:Options: ``--trim-footnote-reference-space``,
+ ``--leave-footnote-reference-space``.
-.. [#] Depending on the writer-specific `footnote_references setting`_.
- The footnote space is trimmed if the reference style is "superscript",
- and it is left if the reference style is "brackets".
+.. [#] The footnote space is trimmed if the reference style is "superscript",
+ and it is left if the reference style is "brackets".
.. _myst:
@@ -924,8 +...
[truncated message content] |
|
From: <mi...@us...> - 2024-02-17 10:37:26
|
Revision: 9542
http://sourceforge.net/p/docutils/code/9542
Author: milde
Date: 2024-02-17 10:37:23 +0000 (Sat, 17 Feb 2024)
Log Message:
-----------
Revert [r9410] "Prevent the 'theme' default overriding 'theme_url'."
As documented in docutils/docs/user/config.html#override,
"Client programs which specify defaults that override other settings must
do the overriding explicitly". This affects not only "theme"/"theme_url",
but also "stlesheet"/"stylesheet_path" (HTML and LaTeX), and
"footnote_references"/"trim_footnote_reference_space".
Exlicitly override "theme" in the S5 functional test setup instead.
Modified Paths:
--------------
trunk/docutils/docutils/writers/s5_html/__init__.py
trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py
Modified: trunk/docutils/docutils/writers/s5_html/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/s5_html/__init__.py 2024-02-17 10:37:13 UTC (rev 9541)
+++ trunk/docutils/docutils/writers/s5_html/__init__.py 2024-02-17 10:37:23 UTC (rev 9542)
@@ -44,9 +44,8 @@
'destination file (output HTML). Note that existing theme files '
'will not be overwritten (unless --overwrite-theme-files is used).',
['--theme'],
- {'metavar': '<name>', 'overrides': 'theme_url'
- # default is set later as it would override theme-url
- }),
+ {'default': 'default', 'metavar': '<name>',
+ 'overrides': 'theme_url'}),
('Specify an S5 theme URL. The destination file (output HTML) will '
'link to this theme; nothing will be copied. Overrides --theme.',
['--theme-url'],
@@ -174,10 +173,13 @@
self.theme_files_copied = None
def setup_theme(self):
- if self.document.settings.theme_url:
+ if self.document.settings.theme:
+ self.copy_theme()
+ elif self.document.settings.theme_url:
self.theme_file_path = self.document.settings.theme_url
else:
- self.copy_theme()
+ raise docutils.ApplicationError(
+ 'No theme specified for S5/HTML writer.')
def copy_theme(self):
"""
@@ -188,9 +190,6 @@
from the specified theme, any base themes, and 'default'.
"""
settings = self.document.settings
- if not settings.theme:
- # set default here to avoid overriding theme-url.
- settings.theme = self.default_theme
path = find_theme(settings.theme)
theme_paths = [path]
self.theme_files_copied = {}
Modified: trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py
===================================================================
--- trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py 2024-02-17 10:37:13 UTC (rev 9541)
+++ trunk/docutils/test/functional/tests/standalone_rst_s5_html_1.py 2024-02-17 10:37:23 UTC (rev 9542)
@@ -7,6 +7,8 @@
settings_overrides = {
'sectsubtitle_xform': True,
'theme_url': 'ui/small-black', # don't attempt to copy theme files
+ 'theme': None, # explicitely reset overriding option
+ # (cf. ../../../docs/user/config.html#override)
# local copy of default stylesheet:
'stylesheet_path': 'functional/input/data/html4css1.css',
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-02-17 10:37:38
|
Revision: 9543
http://sourceforge.net/p/docutils/code/9543
Author: milde
Date: 2024-02-17 10:37:34 +0000 (Sat, 17 Feb 2024)
Log Message:
-----------
New and fixed options for the "buildhtml.py" front end tool.
New option "rst-sources": The default converts all files matching the
patterns "*.txt" or "*.rst".
Evaluate "prune" setting values as glob-style patterns,
this is the behaviour documented in the online help.
Matching uses `fnmatch.fnmatch()`
(no special handling of "/", "\" and ".").
The default prunes auxiliary directories for popular version
control tools and Python.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/user/tools.txt
trunk/docutils/docutils.conf
trunk/docutils/tools/buildhtml.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-02-17 10:37:23 UTC (rev 9542)
+++ trunk/docutils/HISTORY.txt 2024-02-17 10:37:34 UTC (rev 9543)
@@ -134,8 +134,6 @@
* docutils/writers/html5_polyglot/\*.css
- - Embed SVG images as ``<svg>`` instead of data-URI
- (not used by "html4css1"). Fixes [feature-request:#100].
- Move MathML styles to "minimal.css" (required for correct rendering).
* docutils/writers/_html_base.py
@@ -152,6 +150,8 @@
- Consider the root-prefix_ setting when converting an image URI
to a local filesystem path.
- New <image> attribute "loading" overrides "image-loading" setting.
+ - Embed SVG images as ``<svg>`` instead of data-URI
+ (not used by "html4css1"). Fixes [feature-request:#100].
- Write system messages for errors/warnings during the writing stage
(image transformations, math content conversion, ...).
@@ -185,7 +185,12 @@
__ docs/user/config.html#theme-url
__ docs/user/config.html#theme
+* tools/buildhtml.py
+ - New option `rst_sources`_.
+ Match `prune` values with `fnmatch.fnmatch()`.
+
+
Release 0.20.1 (2023-05-17)
===========================
@@ -4374,6 +4379,7 @@
.. _output_encoding: docs/user/config.html#output-encoding
.. _raw_enabled: docs/user/config.html#raw-enabled
.. _reference_label: docs/user/config.html#reference-label
+.. _rst_sources: docs/user/config.html#rst-sources
.. _smart_quotes: docs/user/config.html#smart-quotes
.. _strip_classes: docs/user/config.html#strip-classes
.. _strip_elements_with_classes: docs/user/config.html#strip-elements-with-classes
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2024-02-17 10:37:23 UTC (rev 9542)
+++ trunk/docutils/RELEASE-NOTES.txt 2024-02-17 10:37:34 UTC (rev 9543)
@@ -196,9 +196,11 @@
* Configuration changes:
- - New configuration setting root-prefix_.
+ - New configuration setting root_prefix_.
Configurable root directory for included files.
+ - New configuration setting rst_sources_ for the "buildhtml.py" application.
+
- Simpler and more secure `input encoding`_ default behaviour:
Do not use the locale encoding as fallback if Python is started in
@@ -247,7 +249,8 @@
.. _input encoding: docs/api/publisher.html#encodings
.. _csv-table: docs/ref/rst/directives.html#csv-table
.. _"image" directive: docs/ref/rst/directives.html#image
-.. _root-prefix: docs/user/config.html#root-prefix
+.. _root_prefix: docs/user/config.html#root-prefix
+.. _rst_sources: docs/user/config.html#rst-sources
Release 0.20.1 (2023-05-17)
Modified: trunk/docutils/docs/user/tools.txt
===================================================================
--- trunk/docutils/docs/user/tools.txt 2024-02-17 10:37:23 UTC (rev 9542)
+++ trunk/docutils/docs/user/tools.txt 2024-02-17 10:37:34 UTC (rev 9543)
@@ -343,9 +343,9 @@
The ``buildhtml.py`` script can be found in the ``/tools`` directory of
the "docutils" source. It is not included in binary packages. [#]_
-Use ``buildhtml.py`` to generate ``*.html`` from all the ``*.txt`` files
-(including PEPs) in each <directory> given, and their subdirectories
-too. (Use the ``--local`` option to skip subdirectories.)
+Use ``buildhtml.py`` to generate ``*.html`` from all the reStructuredText
+source files (including PEPs) in each <directory> given, and their
+subdirectories too. (Use the ``--local`` option to skip subdirectories.)
Usage::
Modified: trunk/docutils/docutils.conf
===================================================================
--- trunk/docutils/docutils.conf 2024-02-17 10:37:23 UTC (rev 9542)
+++ trunk/docutils/docutils.conf 2024-02-17 10:37:34 UTC (rev 9543)
@@ -24,4 +24,4 @@
writer: html5
# Prevent tools/buildhtml.py from processing certain text files.
ignore: GPL2.txt:header.txt:header0.txt:header2.txt:cheatsheet.txt
-prune: .svn:.hg:build:dist:docs/.svn:docutils:docutils.egg-info:licenses:test:tools
+prune: build:dist:docutils:docutils.egg-info:licenses:test:tools
Modified: trunk/docutils/tools/buildhtml.py
===================================================================
--- trunk/docutils/tools/buildhtml.py 2024-02-17 10:37:23 UTC (rev 9542)
+++ trunk/docutils/tools/buildhtml.py 2024-02-17 10:37:34 UTC (rev 9543)
@@ -5,12 +5,11 @@
# Copyright: This module has been placed in the public domain.
"""
-Generates .html from all the .txt files in a directory.
+Generate .html from all reStructuredText files in a directory.
-Ordinary .txt files are understood to be standalone reStructuredText.
-Files named ``pep-*.txt`` are interpreted as reStructuredText PEPs.
+Source files are understood to be standalone reStructuredText documents.
+Files with names starting ``pep-`` are interpreted as reStructuredText PEPs.
"""
-# Once PySource is here, build .html from .py as well.
__docformat__ = 'reStructuredText'
@@ -29,7 +28,7 @@
import docutils
import docutils.io
-from docutils import core, frontend, utils, ApplicationError
+from docutils import core, frontend, ApplicationError
from docutils.parsers import rst
from docutils.readers import standalone, pep
from docutils.writers import html4css1, html5_polyglot, pep_html
@@ -36,9 +35,8 @@
usage = '%prog [options] [<directory> ...]'
-description = ('Generates .html from all the reStructuredText .txt files '
- '(including PEPs) in each <directory> '
- '(default is the current directory).')
+description = ('Generate .html from all reStructuredText files '
+ 'in each <directory> (default is the current directory).')
class SettingsSpec(docutils.SettingsSpec):
@@ -47,7 +45,9 @@
Runtime settings & command-line options for the "buildhtml" front end.
"""
- prune_default = ['.hg', '.bzr', '.git', '.svn', 'CVS']
+ prune_default = ['/*/.hg', '/*/.bzr', '/*/.git', '/*/.svn',
+ '/*/.venv', '/*/__pycache__']
+ rst_sources_default = ['*.rst', '*.txt']
# Can't be included in OptionParser below because we don't want to
# override the base class.
@@ -61,16 +61,25 @@
'validator': frontend.validate_boolean}),
('Do not scan subdirectories for files to process.',
['--local'], {'dest': 'recurse', 'action': 'store_false'}),
- ('Do not process files in <directory> (shell globbing patterns, '
+ ('Do not process files in <directory> (glob-style patterns, '
'separated by colons). This option may be used '
- 'more than once to specify multiple directories. Default: "%s".'
+ 'more than once to add more patterns. Default: "%s".'
% ':'.join(prune_default),
['--prune'],
{'metavar': '<directory>', 'action': 'append',
'validator': frontend.validate_colon_separated_string_list,
'default': prune_default}),
+ ('Process all files matching any of the given '
+ 'glob-style patterns (separated by colons). '
+ 'This option overwrites the default or config-file values. '
+ f'Default: "{":".join(rst_sources_default)}".',
+ ['--rst-sources'],
+ {'metavar': '<patterns>',
+ 'default': rst_sources_default,
+ 'validator': frontend.validate_colon_separated_string_list}),
('Recursively ignore files matching any of the given '
- 'wildcard (shell globbing) patterns (separated by colons).',
+ 'glob-style patterns (separated by colons). '
+ 'This option may be used more than once to add more patterns.',
['--ignore'],
{'metavar': '<patterns>', 'action': 'append',
'default': [],
@@ -191,7 +200,11 @@
Copy the setting defaults, overlay the startup config file settings,
then the local config file settings, then the command-line options.
- Assumes the current directory has been set.
+
+ If `directory` is not None, it is searched for a file "docutils.conf"
+ which is parsed after standard configuration files.
+ Path settings in this configuration file are resolved relative
+ to `directory`, not the current working directory.
"""
publisher = self.publishers[publisher_name]
with warnings.catch_warnings():
@@ -206,9 +219,12 @@
directory)
settings.update(local_config, publisher.option_parser)
settings.update(self.settings_spec.__dict__, publisher.option_parser)
+ # remove duplicate entries from "appending" settings:
+ settings.ignore = list(set(settings.ignore))
+ settings.prune = list(set(settings.prune))
return settings
- def run(self, directory=None, recurse=1):
+ def run(self, directory=None, recurse=True):
recurse = recurse and self.initial_settings.recurse
if directory:
self.directories = [directory]
@@ -217,37 +233,37 @@
else:
self.directories = [os.getcwd()]
for directory in self.directories:
- for root, dirs, files in os.walk(directory):
- # os.walk by default this recurses down the tree,
- # influence by modifying dirs.
- if not recurse:
- del dirs[:]
- self.visit(root, files, dirs)
+ directory = os.path.abspath(directory)
+ for dirpath, dirnames, filenames in os.walk(directory):
+ # `os.walk()` by default recurses down the tree,
+ # we modify `dirnames` in-place to control the behaviour.
+ if recurse:
+ dirnames.sort()
+ else:
+ del dirnames[:]
+ self.visit(dirpath, dirnames, filenames)
- def visit(self, directory, names, subdirectories):
- settings = self.get_settings('', directory)
+ def visit(self, dirpath, dirnames, filenames):
+ settings = self.get_settings('', dirpath)
errout = docutils.io.ErrorOutput(encoding=settings.error_encoding)
- if settings.prune and (os.path.abspath(directory) in settings.prune):
- errout.write('/// ...Skipping directory (pruned): %s\n' %
- directory)
+ if match_patterns(dirpath, settings.prune):
+ errout.write('/// ...Skipping directory (pruned): %s\n'
+ % os.path.relpath(dirpath))
sys.stderr.flush()
- del subdirectories[:]
+ del dirnames[:] # modify in-place to control `os.walk()` run
return
if not self.initial_settings.silent:
- errout.write('/// Processing directory: %s\n' % directory)
+ errout.write('/// Processing directory: %s\n'
+ % os.path.relpath(dirpath))
sys.stderr.flush()
- # settings.ignore grows many duplicate entries as we recurse
- # if we add patterns in config files or on the command line.
- for pattern in utils.uniq(settings.ignore):
- for i in range(len(names) - 1, -1, -1):
- if fnmatch(names[i], pattern):
- # Modify in place!
- del names[i]
- for name in names:
- if name.endswith('.txt'):
- self.process_txt(directory, name)
+ for name in sorted(filenames):
+ if match_patterns(name, settings.ignore):
+ continue
+ if match_patterns(name, settings.rst_sources):
+ self.process_txt(dirpath, name)
def process_txt(self, directory, name):
+ # TODO change name to `process_rst_source_file()`?
if name.startswith('pep-'):
publisher = 'PEPs'
else:
@@ -256,7 +272,7 @@
errout = docutils.io.ErrorOutput(encoding=settings.error_encoding)
pub_struct = self.publishers[publisher]
settings._source = os.path.normpath(os.path.join(directory, name))
- settings._destination = settings._source[:-4] + '.html'
+ settings._destination = os.path.splitext(settings._source)[0] + '.html'
if not self.initial_settings.silent:
errout.write(' ::: Processing: %s\n' % name)
sys.stderr.flush()
@@ -272,5 +288,22 @@
errout.write(f' {type(err).__name__}: {err}\n')
+def match_patterns(name, patterns):
+ """Return True, if `name` matches any item of the sequence `patterns`.
+
+ Matching is done with `fnmatch.fnmatch`. It resembles shell-style
+ globbing, but without special treatment of path separators and '.'
+ (in contrast to the `glob module` and `pathlib.PurePath.match()`).
+ For example, "``/*.py``" matches "/a/b/c.py".
+
+ PROVISIONAL.
+ TODO: use `pathlib.PurePath.match()` once this supports "**".
+ """
+ for pattern in patterns:
+ if fnmatch(name, pattern):
+ return True
+ return False
+
+
if __name__ == "__main__":
Builder().run()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-02-17 10:37:50
|
Revision: 9544
http://sourceforge.net/p/docutils/code/9544
Author: milde
Date: 2024-02-17 10:37:45 +0000 (Sat, 17 Feb 2024)
Log Message:
-----------
Additions for config.txt
Add preface and description of "rst_sources" setting
to section [buildhtml application].
Clarify glob-style pattern behaviour.
Modified Paths:
--------------
trunk/docutils/docs/user/config.txt
trunk/docutils/docutils/utils/__init__.py
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2024-02-17 10:37:34 UTC (rev 9543)
+++ trunk/docutils/docs/user/config.txt 2024-02-17 10:37:45 UTC (rev 9544)
@@ -135,7 +135,7 @@
*colon-separated*:
- ignore_, prune_, expose_internals_
+ ignore_, prune_, rst_sources_, expose_internals_
Whitespace around the delimiter is not stripped. Write, e.g., ::
@@ -481,7 +481,9 @@
output
------
-The path of the output destination. Use "-" for `stdout`.
+The path of the output destination.
+An existing file will be overwritten without warning.
+Use "-" for `stdout`.
Obsoletes the `\<destination>`_ positional argument
(cf. `Future changes`_ in the RELEASE-NOTES).
@@ -538,10 +540,10 @@
record_dependencies
-------------------
-Path to a file where Docutils will write a list of files that were
-required to generate the output, e.g. included files or embedded
-stylesheets. [#dependencies]_ [#pwd]_ The format is one path per
-line with forward slashes as separator, the encoding is UTF-8.
+Path to a file where Docutils will write a list of files that
+were required to generate the output, e.g. included files or embedded
+stylesheets. [#dependencies]_ The format is one path per line with
+forward slashes as separator, the encoding is UTF-8.
Set it to "-" in order to write dependencies to stdout.
@@ -732,7 +734,7 @@
warning_stream
--------------
-Path to a file for the output of system messages (warnings). [#pwd]_
+Path [#pwd]_ to a file for the output of system messages (warnings).
*Default*: None (stderr). *Option*: ``--warnings``.
@@ -1290,7 +1292,7 @@
stylesheet_dirs
~~~~~~~~~~~~~~~
List of directories where stylesheets can be found (comma-separated_).
-Used by the stylesheet_path_ setting when expanding relative path arguments.
+Used by the stylesheet_path_ setting when resolving relative path arguments.
See also `stylesheet_dirs [latex writers]`_.
@@ -2124,7 +2126,7 @@
odf_config_file
~~~~~~~~~~~~~~~
-Specify a configuration/mapping file path [#pwd]_ for additional ODF options.
+Path [#pwd]_ to a configuration/mapping file for additional ODF options.
In particular, this file may contain a mapping of default style names to
names used in the resulting output file.
See section `How to use custom style names`__ in the
@@ -2137,9 +2139,8 @@
stylesheet
~~~~~~~~~~
-Specify a stylesheet URL, used verbatim.
-See section `Styles and Classes`_ in the ODT Writer documentation
-for details.
+Path [#pwd]_ to a style file. See section `Styles and Classes`_
+in the ODT Writer documentation for details.
:Default: "writers/odf_odt/styles.odt" in the installation directory.
:Option: ``--stylesheet``.
@@ -2171,7 +2172,7 @@
[applications]
==============
-Some Docutils `front-end tools`_ provide additional settings.
+Some `front end tools`_ provide additional settings.
.. _buildhtml:
@@ -2179,6 +2180,14 @@
[buildhtml application]
-----------------------
+buildhtml.py_ generates HTML documents from all reStructuredText source
+files in a set of directories and their subdirectories.
+All visited directories are scanned for "docutils.conf" files which are
+parsed after the standard configuration files. Path settings [#pwd]_ in
+these files are resolved relative to the respective directory.
+
+The output_ setting is ignored.
+
dry_run
~~~~~~~
Do not process files, show files that would be processed.
@@ -2187,7 +2196,7 @@
ignore
~~~~~~
-List of wildcard (shell globing) patterns (colon-separated_).
+List of glob-style patterns [#globbing]_ (colon-separated_).
Values are appended. [#append-values]_
Matching files are silently ignored.
@@ -2196,11 +2205,27 @@
prune
~~~~~
-List directories to skip (colon-separated_).
+List of glob-style patterns [#globbing]_ (colon-separated_).
Values are appended. [#append-values]_
-*Default*: ['.hg', '.bzr', '.git', '.svn', 'CVS']. *Option*: ``--prune``.
+Patterns are expanded similar to path settings [#pwd]_ and matched
+against the absolute path of to-be-processed directories. Matching
+directories are skipped. This way, a directory can be marked as
+to-be-pruned by a "./docutils.conf" file containing ::
+ [buildhtml application]
+ prune: '.'
+
+The default patterns skip auxiliary directories from Python or
+popular version control tools anywhere. [#]_
+
+:Default: ``['/*/.hg', '/*/.bzr', '/*/.git', '/*/.svn',
+ '/*/.venv', '/*/__pycache__']``.
+:Option: ``--prune``.
+
+.. [#] The leading "/" prevents expansion with pwd and
+ ``fnmatch('/*')`` matches any absolute path.
+
recurse
~~~~~~~
Recursively scan subdirectories.
@@ -2207,6 +2232,16 @@
*Default*: True (recurse). *Options*: ``--recurse``, ``--local``.
+rst_sources
+~~~~~~~~~~~
+List of glob-style [#globbing]_ patterns specifying files to process as
+reStructuredText source (colon-separated_). Values in configuration files
+overwrite the default and are overwritten by the command line option.
+
+*Default*: ``['*.rst', '*.txt']``. *Option*: ``--rst-sources``.
+
+New in Docutils 0.21.
+
silent
~~~~~~
Work silently (no progress messages).
@@ -2229,7 +2264,23 @@
.. _HTML writer: html.html
.. _default HTML writer: html.html#html
+.. [#globbing] Pattern matching is done with the `fnmatch module`_.
+ It resembles shell-style globbing, but without special treatment
+ of path separators and '.' (in contrast__ to the `glob module`_ and
+ `pathlib.PurePath.match()`_).
+ For example, "``/*.py``" matches "/a/b/c.py".
+ Provisional: will use `pathlib.PurePath.match()` once this supports "**".
+
+.. _fnmatch module:
+ https://docs.python.org/3/library/fnmatch.html#module-fnmatch
+.. _glob module:
+ https://docs.python.org/3/library/glob.html#module-glob
+.. _pathlib.PurePath.match():
+ https://docs.python.org/3/library/pathlib.html#pathlib.PurePath.match
+__ https://github.com/python/cpython/issues/106747
+
+
[docutils application]
--------------------------
@@ -2236,9 +2287,8 @@
Docutils' `generic front end`_ tool allows combining “reader”, “parser”,
and “writer” components from the Docutils package or 3rd party plug-ins.
-| New in 0.17. Config file support added in 0.18.
- Renamed in 0.19 (the old section name "docutils-cli application"
- is kept as alias).
+| New in 0.17. Config file support added in 0.18. Renamed in 0.19
+ (the old section name "docutils-cli application" is kept as alias).
| Support for reader/parser import names added in 0.19.
.. _generic front end: tools.html#generic-command-line-front-end
@@ -2290,15 +2340,17 @@
config
~~~~~~
-Path [#pwd]_ to a configuration file to read (if it exists).
-Settings override defaults and earlier settings. The config
-file is processed immediately. Multiple ``--config`` options may
-be specified; each will be processed in turn.
+Path to an additional configuration file.
+The file is processed immediately (if it exists) with
+settings overriding defaults and earlier settings.
Filesystem path settings [#pwd]_ contained within the config file will be
interpreted relative to the config file's location (*not* relative to the
current working directory).
+Multiple ``--config`` options may be specified;
+each will be processed in turn.
+
*Default*: None. *Option*: ``--config``.
@@ -2408,6 +2460,9 @@
.. _option lists: ../ref/rst/restructuredtext.html#option-lists
.. _tables: ../ref/rst/restructuredtext.html#tables
+.. _front end tools: tools.html
+.. _buildhtml.py: tools.html#buildhtml-py
+
.. _BCP 47: https://www.rfc-editor.org/rfc/bcp/bcp47.txt
.. _Error Handlers:
https://docs.python.org/3/library/codecs.html#error-handlers
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2024-02-17 10:37:34 UTC (rev 9543)
+++ trunk/docutils/docutils/utils/__init__.py 2024-02-17 10:37:45 UTC (rev 9544)
@@ -503,11 +503,12 @@
Differences to `pathlib.PurePath.relative_to(other)`:
- * Object oriented interface.
+ * pathlib offers an object oriented interface.
* `source` expects path to a FILE while `other` expects a DIRECTORY.
- * No default value for `other`.
- * Raise ValueError if relative path cannot be determined.
- * Fails if target is not a subpath of `other` (no ".." inserted).
+ * `target` defaults to the cwd, no default value for `other`.
+ * `relative_path()` always returns a path (relative or absolute),
+ while `PurePath.relative_to()` raises a ValueError
+ if `target` is not a subpath of `other` (no ".." inserted).
"""
source_parts = os.path.abspath(source or type(target)('dummy_file')
).split(os.sep)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-02-17 10:38:09
|
Revision: 9546
http://sourceforge.net/p/docutils/code/9546
Author: milde
Date: 2024-02-17 10:38:06 +0000 (Sat, 17 Feb 2024)
Log Message:
-----------
Fix mismatch between Docutils DTD and actual behaviour.
The rST parser sets the "xml:space" attribute on the `<math_block>`
doctree element since support this element in Docutils 0.8.
The documentation of the new element in the DTD missed this fact.
Add "xml:space" to the !ATTLIST so that "Docutils XML" documents
containing math blocks validate.
The `<raw>` element may only contain text, no inline elements.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/ref/docutils.dtd
trunk/docutils/docutils/nodes.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-02-17 10:37:56 UTC (rev 9545)
+++ trunk/docutils/HISTORY.txt 2024-02-17 10:38:06 UTC (rev 9546)
@@ -29,6 +29,9 @@
* docs/ref/docutils.dtd
- The <image> element accepts the new attribute "loading".
+ - The <math_block> element uses the attribute "xml:space"
+ (actually since Docutils 0.8).
+ - The <raw> element may contain text only (no inline elements).
* docutils/frontend.py
Modified: trunk/docutils/docs/ref/docutils.dtd
===================================================================
--- trunk/docutils/docs/ref/docutils.dtd 2024-02-17 10:37:56 UTC (rev 9545)
+++ trunk/docutils/docs/ref/docutils.dtd 2024-02-17 10:38:06 UTC (rev 9546)
@@ -468,7 +468,9 @@
that is typeset as mathematical notation (display formula).
-->
<!ELEMENT math_block (#PCDATA)>
-<!ATTLIST math_block %basic.atts;>
+<!ATTLIST math_block
+ %basic.atts;
+ %fixedspace.att;>
<!ELEMENT line_block (line | line_block)+>
<!ATTLIST line_block %basic.atts;>
@@ -594,7 +596,7 @@
type NMTOKEN #IMPLIED>
<!-- Used to pass raw data through the system. Also inline. -->
-<!ELEMENT raw %text.model;>
+<!ELEMENT raw (#PCDATA)>
<!ATTLIST raw
%basic.atts;
%fixedspace.att;
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2024-02-17 10:37:56 UTC (rev 9545)
+++ trunk/docutils/docutils/nodes.py 2024-02-17 10:38:06 UTC (rev 9546)
@@ -1119,10 +1119,17 @@
"""An element which directly contains preformatted text."""
def __init__(self, rawsource='', text='', *children, **attributes):
- TextElement.__init__(self, rawsource, text, *children, **attributes)
+ super().__init__(rawsource, text, *children, **attributes)
self.attributes['xml:space'] = 'preserve'
+# TODO: PureTextElement(TextElement):
+# """An element which only contains text, no children."""
+# For elements in the DTD that directly employ #PCDATA in their definition:
+# citation_reference, comment, footnote_reference, label, math, math_block,
+# option_argument, option_string, raw,
+
+
# ========
# Mixins
# ========
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-02-27 16:14:43
|
Revision: 9549
http://sourceforge.net/p/docutils/code/9549
Author: milde
Date: 2024-02-27 16:14:41 +0000 (Tue, 27 Feb 2024)
Log Message:
-----------
Refactor HTML writer functions for definition lists.
In HTML, the optional "term classifier" is nested in the `<dt>` element.
Up to now, the closing `<dt>` was added in `visit_definition()`.
This is, however, problematic if we want to allow a "definition_list_item" with
multiple "term"s (cf. [feature-requests:60]).
Now, `</dt>` is appended in `depart_term()`, but only if no "classifier" node
follows. `depart_classifier()` also calls `depart_term()` so that `</dt>` is
added after the last "classifier".
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-02-26 11:51:40 UTC (rev 9548)
+++ trunk/docutils/HISTORY.txt 2024-02-27 16:14:41 UTC (rev 9549)
@@ -145,7 +145,7 @@
Since 0.18, you can use the CSS selector ``[role="doc-noteref"]``.
- Support reading/embedding images also with "file:" URI.
- Warn, if image scaling fails because the image file cannot be read.
- - Support video inclusion via `<video>` tags
+ - Support video inclusion via ``<video>`` tags
(moved here from writers/html5_polyglot/__init__.py).
- New auxiliary function `HTMLTranslator.uri2imagepath()`
ensures the image file can also be read when
@@ -154,9 +154,11 @@
to a local filesystem path.
- New <image> attribute "loading" overrides "image-loading" setting.
- Embed SVG images as ``<svg>`` instead of data-URI
- (not used by "html4css1"). Fixes [feature-request:#100].
+ (not used by "html4css1"). Fixes [feature-requests:#100].
- Write system messages for errors/warnings during the writing stage
(image transformations, math content conversion, ...).
+ - Close ``<dt>`` element in `depart_term()` to allow a `definition_list_item`
+ with multiple `term`\ s (cf. [feature-requests:60]).
.. _root-prefix: docs/user/config.html#root-prefix
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2024-02-26 11:51:40 UTC (rev 9548)
+++ trunk/docutils/RELEASE-NOTES.txt 2024-02-27 16:14:41 UTC (rev 9549)
@@ -80,7 +80,8 @@
__ https://www.w3.org/TR/2014/REC-html5-20141028/grouping-content.html
#the-blockquote-element
- - Change the default value for math_output_ to "MathML" in Docutils 0.22.
+ - Change the default value for math_output_ to "MathML"
+ in Docutils 0.22.
- Change the default value of the initial_header_level_ setting to None
(<h2> if there is a document title, else <h1>) in Docutils 1.0.
@@ -105,12 +106,20 @@
.. _reference-label: docs/user/config.html#reference-label
-* "null" writer: output will change to the empty string in Docutils 0.22.
+* "null" writer: output will change to the empty string
+ in Docutils 0.22.
Misc
----
+* Document tree:
+ Allow multiple <term> elements in a <definition_list_item>
+ in Docutils 0.22 (cf. `feature-requests:60`__).
+ Third-party writers may need adaption.
+
+ __ https://sourceforge.net/p/docutils/feature-requests/60/
+
* Remove `parsers.rst.directives.CSVTable.HeaderDialect`
in Docutils 0.22.
@@ -135,7 +144,7 @@
__ docs/ref/transforms.html
* Remove mistranslated localizations of the "admonition" directive name in
- Docutils 0.22 or later.
+ Docutils 0.22.
Use the English term, matching translations introduced in Docutils 0.21,
or specific admonitions instead of "aanmaning" (nl),
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2024-02-26 11:51:40 UTC (rev 9548)
+++ trunk/docutils/docutils/writers/_html_base.py 2024-02-27 16:14:41 UTC (rev 9549)
@@ -804,15 +804,12 @@
def depart_citation_reference(self, node):
self.body.append(']</a>')
- # classifier
- # ----------
- # don't insert classifier-delimiter here (done by CSS)
-
def visit_classifier(self, node):
self.body.append(self.starttag(node, 'span', '', CLASS='classifier'))
def depart_classifier(self, node):
self.body.append('</span>')
+ self.depart_term(node) # close the term element after last classifier
def visit_colspec(self, node):
self.colspecs.append(node)
@@ -881,10 +878,7 @@
pass
def visit_definition(self, node):
- if 'details' in node.parent.parent['classes']:
- self.body.append('</summary>\n')
- else:
- self.body.append('</dt>\n')
+ if 'details' not in node.parent.parent['classes']:
self.body.append(self.starttag(node, 'dd', ''))
def depart_definition(self, node):
@@ -1705,9 +1699,14 @@
ids=node.parent['ids']))
def depart_term(self, node):
- # Leave the end tag to `self.visit_definition()`,
- # in case there's a classifier.
- pass
+ # Nest (optional) classifier(s) in the <dt> element
+ if isinstance(node.next_node(descend=False, siblings=True),
+ nodes.classifier):
+ return # depart_classifier() calls this function again
+ if 'details' in node.parent.parent['classes']:
+ self.body.append('</summary>\n')
+ else:
+ self.body.append('</dt>\n')
def visit_tgroup(self, node):
self.colspecs = []
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2024-02-26 11:51:40 UTC (rev 9548)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2024-02-27 16:14:41 UTC (rev 9549)
@@ -278,6 +278,7 @@
def depart_classifier(self, node):
self.body.append('</span>')
+ self.depart_term(node) # close the <dt> after last classifier
# ersatz for first/last pseudo-classes
def visit_compound(self, node):
@@ -293,7 +294,6 @@
# ersatz for first/last pseudo-classes, no special handling of "details"
def visit_definition(self, node):
- self.body.append('</dt>\n')
self.body.append(self.starttag(node, 'dd', ''))
self.set_first_last(node)
@@ -881,7 +881,11 @@
ids=node.parent['ids']))
def depart_term(self, node):
- pass
+ # Nest (optional) classifier(s) in the <dt> element
+ if isinstance(node.next_node(descend=False, siblings=True),
+ nodes.classifier):
+ return # depart_classifier() calls this function again
+ self.body.append('</dt>\n')
# hard-coded vertical alignment
def visit_thead(self, node):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-03-08 10:03:18
|
Revision: 9550
http://sourceforge.net/p/docutils/code/9550
Author: milde
Date: 2024-03-08 10:03:16 +0000 (Fri, 08 Mar 2024)
Log Message:
-----------
Small fix for target-highlight in "responsive" stylesheet (HTML5).
Highlight heading of target section also with explicit hyperlink target.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/html5_polyglot/responsive.css
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-02-27 16:14:41 UTC (rev 9549)
+++ trunk/docutils/HISTORY.txt 2024-03-08 10:03:16 UTC (rev 9550)
@@ -138,6 +138,7 @@
* docutils/writers/html5_polyglot/\*.css
- Move MathML styles to "minimal.css" (required for correct rendering).
+ - Highlight heading of target section also with explicit hyperlink target.
* docutils/writers/_html_base.py
Modified: trunk/docutils/docutils/writers/html5_polyglot/responsive.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/responsive.css 2024-02-27 16:14:41 UTC (rev 9549)
+++ trunk/docutils/docutils/writers/html5_polyglot/responsive.css 2024-03-08 10:03:16 UTC (rev 9550)
@@ -286,9 +286,11 @@
font-size: smaller;
margin-left: 0.2em;
}
-/* highlight the target of the current URL */
+/* highlight specific targets of the current URL */
section:target > h2, section:target > h3, section:target > h4,
section:target > h5, section:target > h6,
+span:target + h2, span:target + h3, span:target + h4,
+span:target + h5, span:target + h6,
.contents :target,
.contents:target > .topic-title,
[role="doc-biblioentry"]:target > .label,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-03-08 23:41:25
|
Revision: 9551
http://sourceforge.net/p/docutils/code/9551
Author: milde
Date: 2024-03-08 23:41:22 +0000 (Fri, 08 Mar 2024)
Log Message:
-----------
Revise "reStructuredText Directives" plus small documentation updates.
Update HISTORY.
Small additions for "The Docutils Document Tree".
Fix option name and link in "Docutils Configuration".
Adapt link in "reStructuredText Interpreted Text Roles".
"reStructuredText Directives":
* Sort option lists by name.
* Use ``literal`` for directive option names
(except when the name is also a hyperlink).
* Provide more cross-links.
* Repeat option name in introduction sentence to the option list.
* Use space (instead of hyphen) in ``_class option:`` hyperlink target
(no change to the generated id).
* Shorten descriptions if possible without loss of clarity.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docs/ref/doctree.txt
trunk/docutils/docs/ref/rst/directives.txt
trunk/docutils/docs/ref/rst/roles.txt
trunk/docutils/docs/user/config.txt
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-03-08 10:03:16 UTC (rev 9550)
+++ trunk/docutils/HISTORY.txt 2024-03-08 23:41:22 UTC (rev 9551)
@@ -24,15 +24,20 @@
- Updated build stystem to use Flit_ (patch #186 by Adam Turner).
Removed ``setup.py``.
+ - Provide ``rst2*`` "console_scripts" `entry points`_
+ (without the ``.py`` extension) instead of installing the
+ ``rst2*.py`` front end tools in the binary PATH.
+
.. _Flit: https://github.com/pypa/flit/
* docs/ref/docutils.dtd
- - The <image> element accepts the new attribute "loading".
- - The <math_block> element uses the attribute "xml:space"
- (actually since Docutils 0.8).
- - The <raw> element may contain text only (no inline elements).
+ - The <image> element accepts a new attribute "loading".
+ - Fix definitions (no change to actual behaviour):
+ * The <math_block> element uses the attribute "xml:space".
+ * The <raw> element may contain text only (no inline elements).
+
* docutils/frontend.py
- Allow `validate_*()` functions to be called with just the "value"
Modified: trunk/docutils/docs/ref/doctree.txt
===================================================================
--- trunk/docutils/docs/ref/doctree.txt 2024-03-08 10:03:16 UTC (rev 9550)
+++ trunk/docutils/docs/ref/doctree.txt 2024-03-08 23:41:22 UTC (rev 9551)
@@ -4146,6 +4146,8 @@
The default depends on the writer and the image_loading_
configuration setting.
+New in Docutils 0.21
+
.. [#] Currently only recognized by the HTML5 writer.
The ODF/ODT writer always embeds images in the
output document, XML and LaTeX writers link to the image.
@@ -4304,11 +4306,16 @@
Attribute type: `CDATA`_. Default value: none.
-The ``title`` attribute stores the title metadata of a `\<document>`_.
-This title is typically not part of the rendered document. It may for
-example be used in HTML's ``title`` element.
+The ``title`` attribute stores the *metadata title* of a `\<document>`_.
+It is set by the `"title" directive`_ or the `DocTitle transform`_.
+This title is typically not part of the rendered document.
+It may for example be used in HTML's ``title`` element and shown in a
+browser's title bar or a page's tab.
+.. _"title" directive: rst/directives.html#title
+.. _DocTitle transform: ../api/transforms.html#frontmatter-doctitle
+
``uri``
=======
@@ -4329,8 +4336,8 @@
``xml:space``
=============
-`Attribute type`: `EnumeratedType`_, one of "default" or "preserve".
-Default value: "preserve" (fixed).
+| Attribute type: `EnumeratedType`_, one of "default" or "preserve".
+| Default value: "preserve" (fixed).
The ``xml:space`` attribute is a standard XML attribute for
whitespace-preserving elements. It is used by the `<address>`_,
@@ -4713,6 +4720,7 @@
`\<substitution_reference>`_, `\<subtitle>`_, `\<superscript>`_,
`\<target>`_, `\<term>`_, `\<title>`_, `\<title_reference>`_, `\<version>`_
+
.. _transform:
.. _transforms: ../api/transforms.html
Modified: trunk/docutils/docs/ref/rst/directives.txt
===================================================================
--- trunk/docutils/docs/ref/rst/directives.txt 2024-03-08 10:03:16 UTC (rev 9550)
+++ trunk/docutils/docs/ref/rst/directives.txt 2024-03-08 23:41:22 UTC (rev 9551)
@@ -39,9 +39,6 @@
type definition. For directive implementation details, see `Creating
reStructuredText Directives`_.
-.. _Directives: restructuredtext.html#directives
-.. _reStructuredText Markup Specification: restructuredtext.html
-.. _The Docutils Document Tree: ../doctree.html
.. _Docutils Generic DTD: ../docutils.dtd
.. _Creating reStructuredText Directives:
../../howto/rst-directives.html
@@ -209,7 +206,7 @@
.. class:: field-indent-13em
:Directive Type: "image"
-:Doctree Element: `\<image>`_
+:Doctree Elements: `\<image>`_, `\<reference>`_ (only with option "target_")
:Directive Arguments: one, required (image URI_)
:Directive Options: `see below <image options_>`__
:Directive Content: none
@@ -243,8 +240,21 @@
.. _image options:
-Recognizes the common options class_ and name_ as well as
+The "image" directive recognizes the common options class_ and name_
+as well as
+``align`` : "top", "middle", "bottom", "left", "center", or "right"
+ The alignment of the image, equivalent to the HTML ``<img>`` tag's
+ deprecated "align" attribute or the corresponding "vertical-align" and
+ "text-align" CSS properties.
+ The values "top", "middle", and "bottom"
+ control an image's vertical alignment (relative to the text
+ baseline); they are only useful for inline images (substitutions).
+ The values "left", "center", and "right" control an image's
+ horizontal alignment, allowing the image to float and have the
+ text flow around it. The specific behaviour depends upon the
+ browser or rendering software used.
+
``alt`` : text_
Alternate text: a short description of the image, displayed by
applications that cannot display images, or spoken by applications
@@ -252,50 +262,40 @@
``height`` : length_
The desired height of the image.
- Used to reserve space or scale the image vertically. When the "scale"
+ Used to reserve space or scale the image vertically. When the ``scale``
option is also specified, they are combined. For example, a height of
200px and a scale of 50 is equivalent to a height of 100px with no scale.
-``width`` : length_ or percentage_ of the current line width
- The width of the image.
- Used to reserve space or scale the image horizontally. As with "height"
- above, when the "scale" option is also specified, they are combined.
+``loading`` : "embed", "link", or "lazy"
+ Indicate the preferred handling by the Docutils Writer. [#]_
+ :embed: Embed the image into the output document. [#]_
+ :link: Refer to the image via its URI.
+ :lazy: Refer to the image. The HTML5 writer additionally
+ specifies the `lazy loading attribute`_.
+
+ (New in Docutils 0.21.)
+
``scale`` : integer percentage (the "%" symbol is optional)
The uniform scaling factor of the image. The default is "100 %", i.e.
no scaling.
- If no "height" or "width" options are specified, the `Python
+ If no ``height`` or ``width`` options are specified, the `Python
Imaging Library` (PIL/Pillow_) may be used to determine them, if
it is installed and the image file is available.
-``align`` : "top", "middle", "bottom", "left", "center", or "right"
- The alignment of the image, equivalent to the HTML ``<img>`` tag's
- deprecated "align" attribute or the corresponding "vertical-align" and
- "text-align" CSS properties.
- The values "top", "middle", and "bottom"
- control an image's vertical alignment (relative to the text
- baseline); they are only useful for inline images (substitutions).
- The values "left", "center", and "right" control an image's
- horizontal alignment, allowing the image to float and have the
- text flow around it. The specific behaviour depends upon the
- browser or rendering software used.
+ .. _target:
``target`` : URI_ or `reference name`_
- Makes the image into a hyperlink reference ("clickable"). The
- option argument may be a URI (relative or absolute), or a
- `reference name`_ with underscore suffix (e.g. ```a name`_``).
+ Nest the image in a hyperlink reference element (make it "clickable").
+ The option argument may be a URI_ or a `reference name`_
+ with underscore suffix (e.g. ```a name`_``).
-``loading`` : ["embed", "link", "lazy"]
- Indicate the preferred handling by the Docutils Writer. [#]_
+``width`` : length_ or percentage_ of the current line width
+ The width of the image.
+ Used to reserve space or scale the image horizontally. As with ``height``
+ above, when the ``scale`` option is also specified, they are combined.
- :embed: Embed the image into the output document. [#]_
- :link: Refer to the image via its URI.
- :lazy: Refer to the image. The HTML5 writer additionally
- specifies the `lazy loading attribute`_.
-
- (New in Docutils 0.21.)
-
.. [#] Currently only recognized by the `HTML5 writer`_
(overriding the `image_loading`_ configuration setting).
The ODF/ODT writer always embeds images in the
@@ -306,8 +306,6 @@
.. [#] SVG images are directly included, other images are base64_ encoded
and included as a `data URI`_.
-.. _image element: ../doctree.html#image
-.. _"loading" attribute: ../doctree.html#loading
.. _image_loading: ../../user/config.html#image-loading
.. _lazy loading attribute: https://html.spec.whatwg.org/multipage/
urls-and-fetching.html#lazy-loading-attributes
@@ -360,9 +358,9 @@
.. _figure options:
-The "figure" directive supports all of the options of the "image"
-directive (see `image options`_ above). These options (except
-"align") are passed on to the contained image.
+The "figure" directive supports all `options of the "image" directive
+<image options_>`__. These options (except ``align``) are passed on
+to the contained image.
``align`` : "left", "center", or "right"
The horizontal alignment of the figure, allowing the image to
@@ -381,8 +379,8 @@
Sets the "width" attribute of the "figure" doctree element.
- This option does not scale the included image; use the "width"
- `image`_ option for that. ::
+ This option does not scale the included image; use the ``width``
+ `image option <image options_>`_ for that. ::
+---------------------------+
| figure |
@@ -592,7 +590,8 @@
when Pygments_ is not installed or the language is not in the
`supported languages and markup formats`_.
-For inline code, use the `"code" role`_.
+For code in external files, use the "include_" directive with the
+``code`` option. For inline code, use the `"code" role`_.
.. _code options:
@@ -606,7 +605,6 @@
.. _Pygments: https://pygments.org/
.. _syntax_highlight: ../../user/config.html#syntax-highlight
.. _supported languages and markup formats: https://pygments.org/languages/
-.. _"code" role: roles.html#code
Math
@@ -641,7 +639,6 @@
For inline formulas, use the `"math" role`_.
.. _LaTeX math syntax: ../../ref/rst/mathematics.html
-.. _"math" role: roles.html#math
.. _math_output: ../../user/config.html#math-output
@@ -866,7 +863,7 @@
``align`` : "left", "center", or "right"
The horizontal alignment of the table (new in Docutils 0.13).
-``width`` : length_ or percentage_
+``width`` : length_ or percentage_ of the current line width
Sets the width of the table to the specified length or percentage
of the line width. If omitted, the renderer determines the width
of the table based on its contents or the column ``widths``.
@@ -876,20 +873,27 @@
``widths`` : "auto", "grid", or a `list of integers`_
Explicitly set column widths.
Specifies relative widths if used with the ``width`` option.
- Overrides a `table_style`_ setting or class value "colwidths-auto".
- The default depends on the `table_style`_ configuration setting.
+ Possible values:
- *"auto"* delegates the determination of column widths to the backend
- (LaTeX, the HTML browser, ...).
- Default for the `html5 writer`_
+ .. class:: field-indent-4em run-in
- *"grid"* determines column widths from the widths of the input columns
- (in characters).
- Default for most writers.
+ :auto: Delegate the determination of column widths to the backend
+ (LaTeX, the HTML browser, ...).
- A *list of integers* is used instead of the input column widths.
- Implies *"grid"*.
+ :grid: Determine column widths from the widths of the input columns
+ (in characters).
+ :list of integers: Must match the number of table columns.
+ Used instead of the input column widths. Implies *"grid"*.
+
+ The default depends on the writer. Most writers default to *grid*. [#]_
+
+ .. [#] The `html5 writer`_ defaults to *auto*.
+ The default for the HTML and LaTeX writers can be configured
+ with the `table_style`_ configuration setting or the special class
+ values "colwidths-auto"/"colwidths-grid").
+
+
.. _reStructuredText table: restructuredtext.html#tables
.. _table_style: ../../user/config.html#table-style
@@ -918,14 +922,16 @@
(comma-separated values) [#CSV]_ data. The data may be internal
(an integral part of the document) or external (a separate file).
-* Block markup and inline markup within cells is supported. Line ends
- are recognized within quoted cells.
+* Block markup and inline markup within cells is supported.
+ Line ends are recognized within quoted cells.
* There is no support for checking that the number of columns in each
row is the same. The directive automatically adds empty entries at
the end of short rows.
- .. Add "strict" option to verify input?
+ .. TODO
+ Add option ``missing-cells`` with keywords "strict", "fill", "span"?
+ (cf. [feature-requests:#103])
Example::
@@ -960,8 +966,8 @@
``escape`` : character_
A character used to escape the delimiter_ or quote_ characters from
the CSV parser. The default is no escape character -- fields may
- contain delimiter or newline characters if they are quoted, two quote
- characters stand for a literal one, e.g., ``"He said, ""Hi!"""``.
+ contain delimiter or newline characters if they are quoted, two quote_
+ characters stand for a literal one, e.g., ``"""Hi!"", he said."``.
.. Caution:: Setting ``escape`` to ``\`` (backslash) interferes with
the reStructuredText `escaping mechanism`_ (applied after CSV
@@ -1002,6 +1008,11 @@
``url`` : URI_
An Internet URI reference to a CSV data file.
+``width`` : length_ or percentage_ of the current line width
+ Sets the width of the table to the specified length or percentage
+ of the line width. If omitted, the renderer determines the width
+ of the table based on its contents or the column ``widths``.
+
``widths`` : `list of integers`_ or "auto"
A list of relative column widths.
The default is equal-width columns (100%/#columns).
@@ -1009,11 +1020,6 @@
"auto" delegates the determination of column widths to the backend
(LaTeX, the HTML browser, ...).
-``width`` : length_ or percentage_
- Sets the width of the table to the specified length or percentage
- of the line width. If omitted, the renderer determines the width
- of the table based on its contents or the column ``widths``.
-
.. [#CSV] CSV (comma separated values) is a common data format generated
by spreadsheet applications and commercial databases. Despite the
"comma" in its name, the field delimiter_ may be any Unicode character.
@@ -1086,7 +1092,7 @@
.. _table width:
-``width`` : length_ or percentage_
+``width`` : length_ or percentage_ of the current line width
Sets the width of the table to the specified length or percentage
of the line width. If omitted, the renderer determines the width
of the table based on its contents or the column ``widths``.
@@ -1100,7 +1106,11 @@
"auto" delegates the determination of column widths to the backend
(LaTeX, the HTML browser, ...).
+ .. TODO
+ Add option ``missing-cells`` with keywords "strict", "fill", "span"?
+ (cf. [feature-requests:#103])
+
----------------
Document Parts
----------------
@@ -1118,10 +1128,10 @@
:Directive Options: `see below <contents options_>`__
:Directive Content: none
-The "contents" directive generates a table of contents (TOC) in a
-topic_. Topics, and therefore tables of contents, may occur anywhere
-a section or transition may occur. Body elements and topics may not
-contain tables of contents.
+The "contents" directive generates a table of contents (TOC) in
+a `\<topic>`_ element. Topics, and therefore tables of contents,
+may occur anywhere a section or transition may occur.
+Body elements and topics may not contain tables of contents.
Here's the directive in its simplest form::
@@ -1139,7 +1149,7 @@
.. contents:: Here's a very long Table of
Contents title
-Options may be specified for the directive, using a field list::
+Directive options may be specified using a field list::
.. contents:: Table of Contents
:depth: 2
@@ -1151,8 +1161,12 @@
.. _contents options:
-The following options are recognized:
+The "contents" directive recognizes the common option class_ as well as
+``backlinks`` : "entry" or "top" or "none"
+ Generate links from section headers back to the table of contents
+ entries, the table of contents itself, or generate no back-links.
+
``depth`` : integer_
The number of section levels that are collected in the table of
contents. The default is unlimited depth.
@@ -1162,15 +1176,7 @@
subsections of the section in which the directive is given. If no
explicit title is given, the table of contents will not be titled.
-``backlinks`` : "entry" or "top" or "none"
- Generate links from section headers back to the table of contents
- entries, the table of contents itself, or generate no back-links.
-``class`` : text_ (list of `class names`_)
- Set a `classes attribute`_ value on the topic element. See the
- `class directive`_ below.
-
-
.. _sectnum:
.. _section-numbering:
@@ -1195,7 +1201,7 @@
level has a number, separated by periods. For example, the title of section
1, subsection 2, subsubsection 3 would have "1.2.3" prefixed.
-The "sectnum" directive does its work in two passes: the initial parse
+The directive does its work in two passes: the initial parse
and a transform. During the initial parse, a "pending" element is
generated which acts as a placeholder, storing any options internally.
At a later stage in the processing, the "pending" element triggers a
@@ -1205,7 +1211,7 @@
.. _sectnum options:
-The following options are recognized:
+The "sectnum" directive recognizes the following options:
``depth`` : integer_
The number of section levels that are numbered by this directive.
@@ -1348,15 +1354,22 @@
Directives for Substitution Definitions
-----------------------------------------
-The directives in this section may only be used in `substitution
-definitions`_. They may not be used directly, in standalone context.
-The `image`_ directive may be used both in substitution definitions
-and in the standalone context.
+The directives introduced in this section may only be used in
+`substitution definitions`_. They may not be used directly,
+in standalone context.
.. _substitution definitions:
.. _substitution definition: restructuredtext.html#substitution-definitions
+Inline Images
+=============
+
+The `image`_ directive can be used both, stand-alone (to define
+block-level images) and in substitution definitions to define
+inline images.
+
+
.. _replace:
Replacement Text
@@ -1450,7 +1463,7 @@
.. _unicode options:
-The following options are recognized:
+The "unicode" directive recognizes the following options:
``ltrim`` : flag_
Whitespace to the left of the substitution reference is removed.
@@ -1505,8 +1518,8 @@
.. class:: field-indent-13em
:Directive Type: "include"
-:Doctree Elements: Depend on data being included
- (`\<literal_block>`_ with ``code`` or ``literal`` option).
+:Doctree Elements: Depend on data being included;
+ `\<literal_block>`_ with ``code`` or ``literal`` option.
:Directive Arguments: one, required (path_ to the file to include)
:Directive Options: `see below <include options_>`__
:Directive Content: none
@@ -1550,26 +1563,22 @@
.. include:: <isonum.txt>
The current set of standard "include" data files consists of sets of
-substitution definitions. See `reStructuredText Standard Definition
-Files`__ for details.
+substitution definitions. See `reStructuredText Standard Definition Files
+<definitions.html>`__ for details.
-__ definitions.html
-
.. _include options:
-The following options are recognized:
+The "include" directive recognizes the following options:
-``start-line`` : integer_
- Only the content starting from this line will be included.
- (As usual in Python, the first line has index 0 and negative values
- count from the end.)
+``code`` : text_ (formal language, optional)
+ The argument and the included content are passed to
+ the code_ directive (useful for program listings).
-``end-line`` : integer_
- Only the content up to (but excluding) this line will be included.
+``encoding`` : encoding_
+ The text encoding of the external file.
+ Defaults to the document's input_encoding_.
-``start-after`` : text_
- Only the content after the first occurrence of the specified *text*
- in the external data file will be included.
+ .. _input_encoding: ../../user/config.html#input-encoding
``end-before`` : text_
Only the content before the first occurrence of the specified *text*
@@ -1576,29 +1585,31 @@
in the external data file (but after any ``start-after`` text)
will be included.
-``parser`` : text_ (parser name)
- Parse the included content with the specified parser.
- (New in Docutils 0.17)
+``end-line`` : integer_
+ Only the content up to (but excluding) this line will be included.
``literal`` : flag_
The entire included text is inserted into the document as a single
literal block.
-``code`` : text_ (formal language, optional)
- The argument and the included content are passed to
- the code_ directive (useful for program listings).
-
``number-lines`` : integer_ (start line number, optional)
Precede every included line with a line number.
The optional argument is the number of the first line (default 1).
Works only with ``code`` or ``literal``.
-``encoding`` : encoding_
- The text encoding of the external file.
- Defaults to the document's input_encoding_.
+``parser`` : text_ (parser name)
+ Parse the included content with the specified parser.
+ (New in Docutils 0.17)
- .. _input_encoding: ../../user/config.html#input-encoding
+``start-after`` : text_
+ Only the content after the first occurrence of the specified *text*
+ in the external data file will be included.
+``start-line`` : integer_
+ Only the content starting from this line will be included.
+ (As usual in Python, the first line has index 0 and negative values
+ count from the end.)
+
``tab-width`` : integer_
Number of spaces for hard tab expansion.
Must be a positive integer, except for literal inclusions and code,
@@ -1607,12 +1618,12 @@
.. _tab_width: ../../user/config.html#tab-width
-With ``code`` or ``literal`` the common options class_ and
-name_ are recognized as well.
+With ``code`` or ``literal`` the common options class_ and name_
+are recognized as well.
-Combining ``start/end-line`` and ``start-after/end-before`` is possible. The
-text markers will be searched in the specified lines (further limiting the
-included content).
+Combining ``start-line``/``end-line`` and ``start-after``/``end-before``
+is possible. The text markers will be searched in the specified lines
+(further limiting the included content).
.. _raw:
@@ -1626,8 +1637,8 @@
:Doctree Element: `\<raw>`_
:Directive Arguments: one or more, required (output format types)
:Directive Options: `see below <raw options_>`__
-:Directive Content: Stored verbatim, uninterpreted. None (empty) if a
- "file" or "url" option given.
+:Directive Content: Stored verbatim, uninterpreted.
+ None (empty) if a ``file`` or ``url`` option given.
:Configuration Setting: raw_enabled_
.. WARNING::
@@ -1674,9 +1685,10 @@
\setlength{\parindent}{0pt}
-Raw data can also be read from an external file, specified in a
-directive option. In this case, the content block must be empty. For
-example::
+Raw data can also be read from an external file, specified in the
+``file`` or ``url`` directive option.
+In this case, the content block must be empty.
+For example::
.. raw:: html
:file: inclusion.html
@@ -1686,8 +1698,12 @@
.. _raw options:
-Recognizes the common option class_ and
+The "raw" directive recognizes the common option class_ and
+``encoding`` : encoding_
+ The text encoding of the external raw data (with ``file`` or ``url``).
+ Defaults to the main document's `input_encoding`_ (if specified).
+
``file`` : path_
The local filesystem path of a raw data file to be included.
@@ -1694,13 +1710,7 @@
``url`` : URI_
An Internet URI reference to a raw data file to be included.
-``encoding`` : encoding_
- The text encoding of the external raw data (with ``file`` or ``url``).
- Defaults to the main document's `input_encoding`_ (if specified).
-.. _"raw" role: roles.html#raw
-
-
.. _class directive:
Class
@@ -1923,7 +1933,7 @@
Depending on the base role, the following options may be recognized by the
"role" directive:
-.. _class-option (role directive):
+.. _role directive class option:
class : space separated list of `class names`_
Set the `classes attribute`_ value on the element produced
@@ -1948,15 +1958,14 @@
_`format` : space-separated list of output format names (`writer names`_)
Specify the generated <raw> element's `format attribute`_.
- Only recognized with the `:raw:`_ base role.
+ Only recognized with the `"raw" <"raw" role_>`__ base role.
_`language` : text
Name of a formal language, passed to Pygments_ for syntax highlighting.
See `supported languages and markup formats`_ for recognized values.
- Only recognized with the `:code:`_ base role.
+ Only recognized with the `"code" <"code" role>`__ base role.
-.. _reStructuredText Interpreted Text Roles: roles.html
.. _writer names: ../../user/config.html#writer-docutils-application
@@ -2132,10 +2141,10 @@
Most of the directives that generate doctree elements support the following
options:
-.. _class-option:
+.. _class option:
.. _class:
-``class`` : space separated list of `class names`_
+``class`` : text_ (space separated list of `class names`_)
Set a `classes attribute`_ value on the doctree element generated by
the directive. See also the `class directive`_.
@@ -2187,10 +2196,11 @@
no value.
.. _integer:
+ .. _list of integers:
*integer*
integer number.
- A _`list of integers` may be comma- or whitespace-separated.
+ A *list of integers* may be comma- or whitespace-separated.
.. _length:
@@ -2213,16 +2223,18 @@
.. _URI:
*URI*
- `Uniform Resource Identifier`_.
+ `Uniform Resource Identifier`__.
Whitespace is removed, cf. `External hyperlink targets`_.
+ __ https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
+
.. _codecs: https://docs.python.org/3/library/codecs.html
.. _Standard Encodings:
https://docs.python.org/3/library/codecs.html#standard-encodings
-.. _Uniform Resource Identifier:
- https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
+.. _reStructuredText Markup Specification: restructuredtext.html
+.. _Directives: restructuredtext.html#directives
.. _escaping mechanism: restructuredtext.html#escaping-mechanism
.. _external hyperlink targets:
restructuredtext.html#external-hyperlink-targets
@@ -2233,10 +2245,13 @@
.. _reference name:
.. _reference names: restructuredtext.html#reference-names
+.. _reStructuredText Interpreted Text Roles:
.. _interpreted text role: roles.html
-.. _`:code:`: roles.html#code
-.. _`:raw:`: roles.html#raw
+.. _"code" role: roles.html#code
+.. _"math" role: roles.html#math
+.. _"raw" role: roles.html#raw
+.. _The Docutils Document Tree: ../doctree.html
.. _identifier keys: ../doctree.html#ids-type
.. _inline elements: ../doctree.html#inline-elements
.. _class names: ../doctree.html#classname
@@ -2275,6 +2290,7 @@
.. _<note>: ../doctree.html#note
.. _<pending>: ../doctree.html#pending
.. _<raw>: ../doctree.html#raw
+.. _<reference>: ../doctree.html#reference
.. _<rubric>: ../doctree.html#rubric
.. _<sidebar>: ../doctree.html#sidebar
.. _<system_message>: ../doctree.html#system-message
@@ -2283,6 +2299,7 @@
.. _<title>: ../doctree.html#title
.. _<topic>: ../doctree.html#topic
.. _<warning>: ../doctree.html#warning
+.. _"loading" attribute: ../doctree.html#loading
Modified: trunk/docutils/docs/ref/rst/roles.txt
===================================================================
--- trunk/docutils/docs/ref/rst/roles.txt 2024-03-08 10:03:16 UTC (rev 9550)
+++ trunk/docutils/docs/ref/rst/roles.txt 2024-03-08 23:41:22 UTC (rev 9551)
@@ -409,7 +409,7 @@
.. _"math" directive: directives.html#math
.. _"raw" directive: directives.html#raw
.. _options: directives.html#role-options
-.. _"class" option: directives.html#class-option-role-directive
+.. _"class" option: directives.html#role-directive-class-option
.. _"format" o...
[truncated message content] |
|
From: <mi...@us...> - 2024-03-08 23:41:34
|
Revision: 9552
http://sourceforge.net/p/docutils/code/9552
Author: milde
Date: 2024-03-08 23:41:31 +0000 (Fri, 08 Mar 2024)
Log Message:
-----------
"Transforms" documentation revision.
Add cross-links.
Add description for DocInfo, DocTitle, and SectSubTitle transforms,
and their complex pre-conditions.
Fix/update transformation class docstrings.
Modified Paths:
--------------
trunk/docutils/docs/api/transforms.txt
trunk/docutils/docutils/transforms/frontmatter.py
Modified: trunk/docutils/docs/api/transforms.txt
===================================================================
--- trunk/docutils/docs/api/transforms.txt 2024-03-08 23:41:22 UTC (rev 9551)
+++ trunk/docutils/docs/api/transforms.txt 2024-03-08 23:41:31 UTC (rev 9552)
@@ -12,14 +12,18 @@
.. contents::
+ :depth: 2
-Transforms change the document tree in-place, add to the tree, or prune it.
-Transforms resolve references and footnote numbers, process interpreted
-text, and do other context-sensitive processing. Each transform is a
-subclass of ``docutils.transforms.Transform``.
+Introduction
+============
+Transforms change the `document tree`_ in-place, add to the tree, or prune it.
+Transforms resolve references and footnote numbers, process
+`interpreted text`_, and do other context-sensitive processing.
+Each transform is a subclass of `docutils.transforms.Transform`.
+
There are `transforms added by components`_, others (e.g.
-``parts.Contents``) are added by the parser, if a corresponding directive is
+``parts.Contents``) are added by the parser, if a corresponding directive_ is
found in the document.
To add a transform, components (objects inheriting from
@@ -35,90 +39,89 @@
258`_. (The ``default_transforms()`` attribute of component classes mentioned
there is deprecated. Use the ``get_transforms()`` method instead.)
-.. _PEP 258: ../peps/pep-0258.html#transformer
+.. _priority:
-
Transforms Listed in Priority Order
===================================
-Transform classes each have a default_priority attribute which is used by
+Transform classes each have a `default priority` attribute which is used by
the Transformer to apply transforms in order (low to high). The default
priority can be overridden when adding transforms to the Transformer object.
-============================== ============================ ========
-Transform: module.Class Added By Priority
-============================== ============================ ========
-misc.class "class" (d/p) 210
+================================== ============================ ========
+Transform: module.Class Added By Priority
+================================== ============================ ========
+misc_.ClassAttribute `"class"`_ (d/p) 210
-references.Substitutions standalone (r), pep (r) 220
+references_.Substitutions standalone (r), pep (r) 220
-references.PropagateTargets standalone (r), pep (r) 260
+references_.PropagateTargets standalone (r), pep (r) 260
-frontmatter.DocTitle standalone (r) 320
+frontmatter.\ DocTitle_ standalone (r) 320
-frontmatter.DocInfo standalone (r) 340
+frontmatter.\ DocInfo_ standalone (r) 340
-frontmatter.SectSubTitle standalone (r) 350
+frontmatter.\ SectSubTitle_ standalone (r) 350
-peps.Headers pep (r) 360
+peps_.Headers pep (r) 360
-peps.Contents pep (r) 380
+peps_.Contents pep (r) 380
-universal.StripClasses... Writer (w) 420
+universal_.StripClassesAndElements Writer (w) 420
-references.AnonymousHyperlinks standalone (r), pep (r) 440
+references_.AnonymousHyperlinks standalone (r), pep (r) 440
-references.IndirectHyperlinks standalone (r), pep (r) 460
+references_.IndirectHyperlinks standalone (r), pep (r) 460
-peps.TargetNotes pep (r) 520
+peps_.TargetNotes pep (r) 520
-references.TargetNotes peps.TargetNotes (t/p) 0
+references_.TargetNotes peps.TargetNotes (t/p) 0
-misc.CallBack peps.TargetNotes (t/p) 1
+misc_.CallBack peps.TargetNotes (t/p) 1
-references.TargetNotes "target-notes" (d/p) 540
+references_.TargetNotes `"target-notes"`_ (d/p) 540
-references.Footnotes standalone (r), pep (r) 620
+references_.Footnotes standalone (r), pep (r) 620
-references.ExternalTargets standalone (r), pep (r) 640
+references_.ExternalTargets standalone (r), pep (r) 640
-references.InternalTargets standalone (r), pep (r) 660
+references_.InternalTargets standalone (r), pep (r) 660
-parts.SectNum "sectnum" (d/p) 710
+parts_.SectNum `"sectnum"`_ (d/p) 710
-parts.Contents "contents" (d/p), 720
- peps.Contents (t/p)
+parts_.Contents `"contents"`_ (d/p), 720
+ peps.Contents (t/p)
-universal.StripComments Reader (r) 740
+universal_.StripComments Reader (r) 740
-peps.PEPZero peps.Headers (t/p) 760
+peps_.PEPZero peps.Headers (t/p) 760
-components.Filter *not used* 780
+components.Filter *not used* 780
-universal.Decorations Reader (r) 820
+universal_.Decorations Reader (r) 820
-misc.Transitions standalone (r), pep (r) 830
+misc_.Transitions standalone (r), pep (r) 830
-universal.ExposeInternals Reader (r) 840
+universal_.ExposeInternals Reader (r) 840
-references.DanglingReferences standalone (r), pep (r) 850
+references_.DanglingReferences standalone (r), pep (r) 850
-universal.SmartQuotes Parser 855
+universal_.SmartQuotes Parser 855
-universal.Messages Writer (w) 860
+universal_.Messages Writer (w) 860
-universal.FilterMessages Writer (w) 870
+universal_.FilterMessages Writer (w) 870
-universal.TestMessages DocutilsTestSupport 880
+universal_.TestMessages DocutilsTestSupport 880
-writer_aux.Compound *not used, to be removed* 910
+writer_aux_.Compound *not used, to be removed* 910
-writer_aux.Admonitions _html_base (w), 920
- latex2e (w)
+writer_aux_.Admonitions _html_base (w), 920
+ latex2e (w)
-misc.CallBack n/a 990
-============================== ============================ ========
+misc_.CallBack n/a 990
+================================== ============================ ========
Key:
@@ -130,7 +133,7 @@
Transform Priority Range Categories
-===================================
+-----------------------------------
==== ==== ================================================
Priority
@@ -151,7 +154,6 @@
Transforms added by components
===============================
-
readers.Reader:
| universal.Decorations,
| universal.ExposeInternals,
@@ -207,3 +209,395 @@
writers.odf_odt.Writer:
removes references.DanglingReferences
+
+
+Transforms Reference
+====================
+
+Incomplete. See also `Transforms Listed in Priority Order`_
+and the sources in `docutils/transforms`__.
+
+__ https://docutils.sourceforge.io/docutils/transforms/
+
+
+DocInfo
+-------
+
+.. class:: field-indent-12em
+
+:Module: frontmatter_
+:Added by: standalone Reader
+:Default priority_: 340
+:Configuration_ setting: docinfo_xform_ (default: True)
+
+Given a document starting [#pre-docinfo]_ with a field list, the DocInfo
+transform converts fields with registered `bibliographic field`_ names to
+the corresponding document tree elements becoming child elements of the
+`\<docinfo>`_ element (except for a "dedication" and "abstract", which
+become `\<topic>`_ elements after <docinfo>).
+
+.. [#pre-docinfo] A document title and subtitle, header and footer,
+ as well as body elements that do not show up in the output
+ before the field list don't prevent the DocInfo transformation.
+ See the `DocTitle examples`_ and `PreBibliographic Elements`_
+ in the Appendix for details.
+
+For example, this document fragment::
+
+ <document>
+ <title>
+ Document Title
+ <field_list>
+ <field>
+ <field_name>
+ Author
+ <field_body>
+ <paragraph>
+ A. Name
+ <field>
+ <field_name>
+ Status
+ <field_body>
+ <paragraph>
+ $RCSfile$
+ ...
+
+will be transformed to::
+
+ <document>
+ <title>
+ Document Title
+ <docinfo>
+ <author>
+ A. Name
+ <status>
+ frontmatter.py
+ ...
+
+
+DocTitle
+--------
+
+.. class:: field-indent-12em
+
+:Module: frontmatter_
+:Added by: standalone Reader
+:Default priority_: 320
+:Configuration_ setting: doctitle_xform_ (default: True)
+
+Under the conditions explained below, the DocTitle transform converts
+the document's first section title(s) to a document title and
+subtitle.
+
+1. If the document contains a single top-level section as its first body
+ element, [#pre-doctitle]_ the top-level section's title is used
+ as `document title`_ and default `metadata title`_. The top-level
+ section's contents become the document's immediate contents.
+
+ .. _step 2:
+
+2. If step 1 successfully determines the document title, the transform
+ checks for a subtitle:
+ If the lone top-level section itself contains a single second-level
+ section as its first element, [#pre-doctitle]_ that section's
+ title is promoted to the document's subtitle, and that section's
+ contents become the document's immediate contents.
+
+The transform can be disabled with the doctitle_xform_ configuration
+setting or the corresponding ``--no-doc-title`` command line option.
+
+.. [#pre-doctitle] Header and footer as well as body elements that
+ do not show up in the output before the section don't stop the
+ transformation of the section title to document title or subtitle.
+ See `PreBibliographic Elements`_ in the Appendix for details.
+
+.. _DocTitle examples:
+
+Examples
+~~~~~~~~
+
+The input text ::
+
+ Top-Level Title
+ ===============
+ A paragraph.
+
+is parsed to the following document tree::
+
+ <document>
+ <section names="top-level\ title">
+ <title>
+ Top-Level Title
+ <paragraph>
+ A paragraph.
+
+The DocTitle transform converts it to::
+
+ <document names="top-level\ title" title="Top-Level Title">
+ <title>
+ Top-Level Title
+ <paragraph>
+ A paragraph.
+
+Given this input with a lone section and sub-section::
+
+ Top-Level Title
+ ===============
+ Second-Level Title
+ ~~~~~~~~~~~~~~~~~~
+
+ A paragraph.
+
+the result after parsing and running the DocTitle transform is::
+
+ <document names="top-level\ title">
+ <title>
+ Top-Level Title
+ <subtitle names="second-level\ title">
+ Second-Level Title
+ <paragraph>
+ A paragraph.
+
+(Note that the implicit hyperlink target generated by the
+"Second-Level Title" is preserved on the "subtitle" element
+itself.)
+
+--------------
+
+The following examples do *not* comply with the conditions:
+
+i. More than one top-level section::
+
+ Top-Level Title
+ ===============
+ A paragraph.
+
+ Another Top-Level Title
+ =======================
+ Another paragraph.
+
+ The DocTitle transform will leave the document tree as-is.
+ The document has no title. It is recommended to set the
+ `metadata title`_ with the `"title"`_ directive.
+
+#. More than one second-level section::
+
+ Top-Level Title
+ ===============
+ Second-Level Title
+ ~~~~~~~~~~~~~~~~~~
+ A paragraph.
+
+ Another Second-Level Title
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ Another paragraph.
+
+ Step 2 is skipped. "Top-Level Title" becomes the document title;
+ "Second-Level Title" and "Another Second-Level Title" become titles of
+ top-level sections.
+
+ This is what you normally want in a document with title but no
+ subtitle.
+
+#. Body elements before the first section: [#pre-doctitle]_ ::
+
+ .. note:: This element would not stop the transform, if it were
+ nested in a header.
+
+ Top-Level Title
+ ===============
+ A paragraph.
+
+ The DocTitle transform will leave the document tree as-is.
+ The document has no title.
+
+
+#. A `configuration file`_ entry "``doctitle_xform: False``"
+ or converting with the CLI command ::
+
+ docutils --no-doc-title example.rst > example.html
+
+ The DocTitle transform is skipped. The document has no title.
+
+
+SectSubTitle
+------------
+
+.. class:: field-indent-12em
+
+:Module: frontmatter_
+:Added by: standalone Reader
+:Default priority_: 350
+:Configuration_ setting: sectsubtitle_xform_ (default: False)
+
+The SectSubTitle transform works like `step 2`_ of the DocTitle_
+transform, but for sections.
+
+For example, ::
+
+ <section>
+ <title>
+ Title
+ <section>
+ <title>
+ Subtitle
+ ...
+
+is transformed into ::
+
+ <section>
+ <title>
+ Title
+ <subtitle>
+ Subtitle
+ ...
+
+This transform is disabled by default.
+
+
+Appendix
+========
+
+PreBibliographic Elements
+-------------------------
+
+The document tree elements `\<comment>`_, `\<decoration>`_,
+`\<footer>`_, `\<header>`_, `\<meta>`_, `\<pending>`_, `\<raw>`_,
+`\<substitution_definition>`_, `\<subtitle>`_, `\<system_message>`_,
+`\<target>`_, and `\<title>`_ are ignored when the DocTitle_ and DocInfo_
+transforms check for elements before frontmatter candidates.
+
+This means that in the reStructuredText source, comments_,
+`hyperlink targets`_, `substitution definitions`_, and the directives_
+`"class"`_, `"default-role"`_, `"footer"`_, `"header"`_, `"meta"`_,
+`"raw"`_, `"sectnum"`_, `"sectnum"`_, `"target-notes"`_, and `"title"`_
+may be placed before the `document title`_ or `bibliographic fields`_.
+
+The DocTitle_ transform inserts document title and subtitle before these
+elements. DocInfo_ inserts the bibliographic fields before
+`\<comment>`_, `\<raw>`_, `\<substitution_definition>`_, and `\<target>`_.
+
+For example, the document source::
+
+ .. a comment
+ .. |today| date::
+ .. _hypertarget: http://example.org
+ .. class:: spam
+ .. role:: ham
+ .. default-role:: ham
+ .. footer:: footer text
+ .. header:: header text
+ .. meta:: :test: value
+ .. raw:: html
+
+ raw html text
+ .. sectnum::
+ .. target-notes::
+ .. title:: metadata document title
+
+ Top-Level Title
+ ===============
+ Second-Level Title
+ ~~~~~~~~~~~~~~~~~~
+
+ :date: |today|
+
+is parsed and transformed to::
+
+ <document ids="top-level-title" names="top-level\ title"
+ title="metadata document title">
+ <title>
+ Top-Level Title
+ <subtitle ids="second-level-title" names="second-level\ title">
+ Second-Level Title
+ <meta content="value" name="test">
+ <decoration>
+ <header>
+ <paragraph>
+ header text
+ <footer>
+ <paragraph>
+ footer text
+ <docinfo>
+ <date>
+ 2024-03-01
+ <comment xml:space="preserve">
+ a comment
+ <substitution_definition names="today">
+ 2024-03-01
+ <target ids="hypertarget" names="hypertarget" refuri="http://example.org">
+ <raw classes="spam" format="html" xml:space="preserve">
+ raw html text
+
+
+
+.. References
+ ==========
+
+.. _PEP 258: ../peps/pep-0258.html#transformer
+
+.. _configuration:
+.. _configuration file:
+.. _configuration setting: ../user/config.html
+.. _docinfo_xform: ../user/config.html#docinfo-xform
+.. _doctitle_xform: ../user/config.html#doctitle-xform
+.. _sectsubtitle_xform: ../user/config.html#sectsubtitle-xform
+
+.. _directive:
+.. _directives: ../ref/rst/directives.html
+.. _"class": ../ref/rst/directives.html#class
+.. _"contents": ../ref/rst/directives.html#contents
+.. _"default-role": ../ref/rst/directives.html#default-role
+.. _"footer": ../ref/rst/directives.html#footer
+.. _"header": ../ref/rst/directives.html#header
+.. _"meta": ../ref/rst/directives.html#meta
+.. _"raw": ../ref/rst/directives.html#raw
+.. _"sectnum": ../ref/rst/directives.html#sectnum
+.. _"target-notes": ../ref/rst/directives.html#target-notes
+.. _"title": ../ref/rst/directives.html#title
+
+.. _document tree: ../ref/doctree.html
+.. _`<comment>`: ../ref/doctree.html#comment
+.. _`<docinfo>`: ../ref/doctree.html#docinfo
+.. _`<decoration>`: ../ref/doctree.html#decoration
+.. _`<footer>`: ../ref/doctree.html#footer
+.. _`<header>`: ../ref/doctree.html#header
+.. _`<meta>`: ../ref/doctree.html#meta
+.. _`<pending>`: ../ref/doctree.html#pending
+.. _`<raw>`: ../ref/doctree.html#raw
+.. _`<substitution_definition>`: ../ref/doctree.html#substitution-definition
+.. _`<subtitle>`: ../ref/doctree.html#subtitle
+.. _`<system_message>`: ../ref/doctree.html#system-message
+.. _`<target>`: ../ref/doctree.html#target
+.. _`<title>`: ../ref/doctree.html#title
+.. _`<topic>`: ../ref/doctree.html#topic
+.. _metadata title: ../ref/doctree.html#title-attribute
+
+.. reStructuredText Markup Specification
+.. _bibliographic field:
+.. _bibliographic fields:
+ ../ref/rst/restructuredtext.html#bibliographic-fields
+.. _comments: ../ref/rst/restructuredtext.html#comments
+.. _document title: ../ref/rst/restructuredtext.html#document-title
+.. _hyperlink targets: ../ref/rst/restructuredtext.html#hyperlink-targets
+.. _interpreted text: ../ref/rst/restructuredtext.html#interpreted-text
+.. _registered bibliographic field names:
+ ../ref/rst/restructuredtext.html#bibliographic-field-names
+.. _substitution definitions:
+ ../ref/rst/restructuredtext.html#substitution-definitions
+
+.. transform class sources
+.. _frontmatter:
+ https://docutils.sourceforge.io/docutils/transforms/frontmatter.py
+.. _misc:
+ https://docutils.sourceforge.io/docutils/transforms/misc.py
+.. _parts:
+ https://docutils.sourceforge.io/docutils/transforms/parts.py
+.. _peps:
+ https://docutils.sourceforge.io/docutils/transforms/peps.py
+.. _references:
+ https://docutils.sourceforge.io/docutils/transforms/references.py
+.. _universal:
+ https://docutils.sourceforge.io/docutils/transforms/universal.py
+.. _writer_aux:
+ https://docutils.sourceforge.io/docutils/transforms/writer_aux.py
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2024-03-08 23:41:22 UTC (rev 9551)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2024-03-08 23:41:31 UTC (rev 9552)
@@ -3,7 +3,7 @@
# Copyright: This module has been placed in the public domain.
"""
-Transforms related to the front matter of a document or a section
+Transforms_ related to the front matter of a document or a section
(information found before the main text):
- `DocTitle`: Used to transform a lone top level section's title to
@@ -17,6 +17,8 @@
- `DocInfo`: Used to transform a bibliographic field list into docinfo
elements.
+
+.. _transforms: https://docutils.sourceforge.io/docs/api/transforms.html
"""
__docformat__ = 'reStructuredText'
@@ -145,47 +147,24 @@
two-step transform to "raise" or "promote" the title(s) (and their
corresponding section contents) to the document level.
- 1. If the document contains a single top-level section as its
- first non-comment element, the top-level section's title
- becomes the document's title, and the top-level section's
- contents become the document's immediate contents. The lone
- top-level section header must be the first non-comment element
- in the document.
+ 1. If the document contains a single top-level section as its first
+ element (instances of `nodes.PreBibliographic` are ignored),
+ the top-level section's title becomes the document's title, and
+ the top-level section's contents become the document's immediate
+ contents. The title is also used for the <document> element's
+ "title" attribute default value.
- For example, take this input text::
-
- =================
- Top-Level Title
- =================
-
- A paragraph.
-
- Once parsed, it looks like this::
-
- <document>
- <section names="top-level title">
- <title>
- Top-Level Title
- <paragraph>
- A paragraph.
-
- After running the DocTitle transform, we have::
-
- <document names="top-level title">
- <title>
- Top-Level Title
- <paragraph>
- A paragraph.
-
2. If step 1 successfully determines the document title, we
continue by checking for a subtitle.
- If the lone top-level section itself contains a single
- second-level section as its first non-comment element, that
- section's title is promoted to the document's subtitle, and
- that section's contents become the document's immediate
- contents. Given this input text::
+ If the lone top-level section itself contains a single second-level
+ section as its first "non-PreBibliographic" element, that section's
+ title is promoted to the document's subtitle, and that section's
+ contents become the document's immediate contents.
+ Example:
+ Given this input text::
+
=================
Top-Level Title
=================
@@ -195,8 +174,7 @@
A paragraph.
- After parsing and running the Section Promotion transform, the
- result is::
+ After parsing and running the DocTitle transform, the result is::
<document names="top-level title">
<title>
@@ -207,16 +185,13 @@
A paragraph.
(Note that the implicit hyperlink target generated by the
- "Second-Level Title" is preserved on the "subtitle" element
+ "Second-Level Title" is preserved on the <subtitle> element
itself.)
- Any comment elements occurring before the document title or
- subtitle are accumulated and inserted as the first body elements
- after the title(s).
+ Any `nodes.PreBibliographic` instances occurring before the
+ document title or subtitle are accumulated and inserted as
+ the first body elements after the title(s).
- This transform also sets the document's metadata title
- (document['title']).
-
.. _reStructuredText: https://docutils.sourceforge.io/rst.html
"""
@@ -294,12 +269,12 @@
Specification`_ for a high-level description. This transform
should be run *after* the `DocTitle` transform.
- Given a field list as the first non-comment element after the
- document title and subtitle (if present), registered bibliographic
+ If the document contains a field list as the first element (instances
+ of `nodes.PreBibliographic` are ignored), registered bibliographic
field names are transformed to the corresponding DTD elements,
- becoming child elements of the "docinfo" element (except for a
- dedication and/or an abstract, which become "topic" elements after
- "docinfo").
+ becoming child elements of the <docinfo> element (except for a
+ dedication and/or an abstract, which become <topic> elements after
+ <docinfo>).
For example, given this document fragment after parsing::
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2024-03-10 11:34:29
|
Revision: 9554
http://sourceforge.net/p/docutils/code/9554
Author: grubert
Date: 2024-03-10 11:34:27 +0000 (Sun, 10 Mar 2024)
Log Message:
-----------
manpage: Add multiple definition list term support
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/manpage.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-03-08 23:41:41 UTC (rev 9553)
+++ trunk/docutils/HISTORY.txt 2024-03-10 11:34:27 UTC (rev 9554)
@@ -174,6 +174,7 @@
* docutils/writers/manpage.py
+ - Add multiple definition list term support, see feature #60.
- Add preprocessor hinting tbl first line, see bugs #477.
- Change tbl-Tables using box option, see bugs #475.
- Apply literal block patch #205. Use ``.EE`` and ``.EX`` macros.
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2024-03-08 23:41:41 UTC (rev 9553)
+++ trunk/docutils/docutils/writers/manpage.py 2024-03-10 11:34:27 UTC (rev 9554)
@@ -203,6 +203,7 @@
self._in_literal = False
self.header_written = 0
self._line_block = 0
+ self._second_term = False # multiple term in definition list
self.authors = []
self.section_level = 0
self._indent = [0]
@@ -231,7 +232,6 @@
'reference': (r'\fI\%', r'\fP'),
'emphasis': ('\\fI', '\\fP'),
'strong': ('\\fB', '\\fP'),
- 'term': ('\n.B ', '\n'),
'title_reference': ('\\fI', '\\fP'),
'topic-title': ('.SS ',),
@@ -1097,10 +1097,20 @@
pass
def visit_term(self, node):
- self.body.append(self.defs['term'][0])
+ if self._second_term:
+ self._second_term = False
+ else:
+ self.body.append('\n.B ')
def depart_term(self, node):
- self.body.append(self.defs['term'][1])
+ _next = None
+ if isinstance(node.parent, nodes.definition_list_item):
+ _next = next(node.findall(condition=None, include_self=False,
+ descend=False, siblings=True, ascend=False))
+ if _next and isinstance(_next, nodes.term):
+ self.body.append('\\fR,\\fB \\')
+ self._second_term = True
+ self.body.append('\n')
def visit_tgroup(self, node):
pass
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-03-11 14:55:07
|
Revision: 9555
http://sourceforge.net/p/docutils/code/9555
Author: milde
Date: 2024-03-11 14:55:04 +0000 (Mon, 11 Mar 2024)
Log Message:
-----------
LaTeX writers: more compact description list.
Drop empty line before `\end{description}`.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_cornercases.tex
trunk/docutils/test/functional/expected/latex_leavevmode.tex
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-03-10 11:34:27 UTC (rev 9554)
+++ trunk/docutils/HISTORY.txt 2024-03-11 14:55:04 UTC (rev 9555)
@@ -171,6 +171,7 @@
* docutils/writers/latex2e/__init__.py
- Fix placement of hyperlink target (label) for tables (bug #440).
+ - More compact option-list and description-list.
* docutils/writers/manpage.py
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2024-03-10 11:34:27 UTC (rev 9554)
+++ trunk/docutils/docutils/nodes.py 2024-03-11 14:55:04 UTC (rev 9555)
@@ -316,7 +316,7 @@
Return the first node in the iterator returned by findall(),
or None if the iterable is empty.
- Parameter list is the same as of traverse. Note that `include_self`
+ Parameter list is the same as of `findall()`. Note that `include_self`
defaults to False, though.
"""
try:
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2024-03-10 11:34:27 UTC (rev 9554)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2024-03-11 14:55:04 UTC (rev 9555)
@@ -1911,7 +1911,7 @@
pass
def depart_definition(self, node):
- self.out.append('\n') # TODO: just pass?
+ pass
def visit_definition_list(self, node):
self.duclass_open(node)
@@ -1925,7 +1925,8 @@
pass
def depart_definition_list_item(self, node):
- pass
+ if node.next_node(descend=False, siblings=True) is not None:
+ self.out.append('\n') # TODO: just pass?
def visit_description(self, node):
self.out.append(' ')
Modified: trunk/docutils/test/functional/expected/latex_cornercases.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_cornercases.tex 2024-03-10 11:34:27 UTC (rev 9554)
+++ trunk/docutils/test/functional/expected/latex_cornercases.tex 2024-03-11 14:55:04 UTC (rev 9555)
@@ -253,7 +253,6 @@
\item[-v] verbose
\end{DUoptionlist}
-
\end{description}
@@ -682,7 +681,6 @@
\begin{description}
\item[{definition:}]
list
-
\end{description}
&
cell 3, 2
@@ -858,7 +856,6 @@
\item[{{[}bracketed{]}}]
description term
-
\end{description}
The OT1 font-encoding differs from ASCII for the less-than, greater-than
@@ -924,7 +921,6 @@
\item[{Example:}]
a long URL that should wrap in the output
\url{https://docutils.sourceforge.io/docs/user/latex.html\#id79}
-
\end{description}
If the argument contains any \textquotedbl{}\%\textquotedbl{}, \textquotedbl{}\#\textquotedbl{}, or \textquotedbl{}\textasciicircum{}\textasciicircum{}\textquotedbl{}, or ends with \texttt{\textbackslash{}}, it can't
Modified: trunk/docutils/test/functional/expected/latex_leavevmode.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_leavevmode.tex 2024-03-10 11:34:27 UTC (rev 9554)
+++ trunk/docutils/test/functional/expected/latex_leavevmode.tex 2024-03-11 14:55:04 UTC (rev 9555)
@@ -226,9 +226,7 @@
\begin{description}
\item[{Yes.}]
Independent of the nesting level.
-
\end{description}
-
\end{description}
\item[{Option List}] \leavevmode
@@ -313,7 +311,6 @@
LaTeX environment.
\end{DUadmonition}
\end{DUclass}
-
\end{description}
@@ -344,7 +341,6 @@
\item This holds for all elements that normally need \texttt{\textbackslash{}leavevmode}.
\end{itemize}
-
\end{description}
@@ -401,7 +397,6 @@
\item[{Raw Block Text}] \leavevmode
“Raw” blocks are always preceded by
\verb|\leavevmode|, just in case.
-
\end{description}
\end{document}
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2024-03-10 11:34:27 UTC (rev 9554)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2024-03-11 14:55:04 UTC (rev 9555)
@@ -472,7 +472,6 @@
\item[{Term}] (\textbf{classifier one})(\textbf{classifier two})
Definition
-
\end{description}
@@ -1373,7 +1372,6 @@
\begin{description}
\item[{a definition}]
list,
-
\end{description}
a paragraph, an image:
\includegraphics{../../../docs/user/rst/images/biohazard.png}
@@ -1875,7 +1873,6 @@
$\vec{R}$ \texttt{\textbackslash{}vec\{R\}}
\\
\end{longtable*}
-
\end{description}
% \widetilde{xxx}
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2024-03-10 11:34:27 UTC (rev 9554)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2024-03-11 14:55:04 UTC (rev 9555)
@@ -473,7 +473,6 @@
\item[{Term}] (\textbf{classifier one})(\textbf{classifier two})
Definition
-
\end{description}
@@ -1394,7 +1393,6 @@
\begin{description}
\item[{a definition}]
list,
-
\end{description}
a paragraph, an image:
\includegraphics{../../../docs/user/rst/images/biohazard.png}
@@ -1897,7 +1895,6 @@
$\vec{R}$ \texttt{\textbackslash{}vec\{R\}}
\\
\end{longtable*}
-
\end{description}
% \widetilde{xxx}
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2024-03-10 11:34:27 UTC (rev 9554)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2024-03-11 14:55:04 UTC (rev 9555)
@@ -475,7 +475,6 @@
\item[{Term}] (\textbf{classifier one})(\textbf{classifier two})
Definition
-
\end{description}
@@ -1433,7 +1432,6 @@
\begin{description}
\item[{a definition}]
list,
-
\end{description}
a paragraph, an image:
\includegraphics{../../../docs/user/rst/images/biohazard.png}
@@ -1936,7 +1934,6 @@
$\vec{R}$ \texttt{\textbackslash{}vec\{R\}}
\\
\end{longtable*}
-
\end{description}
% \widetilde{xxx}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-03-11 17:48:36
|
Revision: 9556
http://sourceforge.net/p/docutils/code/9556
Author: milde
Date: 2024-03-11 17:48:33 +0000 (Mon, 11 Mar 2024)
Log Message:
-----------
More compact option-lists with "latex" writers. Fix "leavevmode" test.
Drop the empty line between option list items in LaTeX output.
Fix examples for enumerated list nested in option list
and description term with classifier in "latex_leavevmode" functional
test sample.
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_cornercases.tex
trunk/docutils/test/functional/expected/latex_leavevmode.tex
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/functional/input/latex_leavevmode.txt
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2024-03-11 14:55:04 UTC (rev 9555)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2024-03-11 17:48:33 UTC (rev 9556)
@@ -2707,7 +2707,7 @@
pass
def visit_option_group(self, node):
- self.out.append('\n\\item[')
+ self.out.append('\\item[')
# flag for first option
self.context.append(0)
@@ -2720,7 +2720,7 @@
self.fallbacks['_providelength'] = PreambleCmds.providelength
self.fallbacks['optionlist'] = PreambleCmds.optionlist
self.duclass_open(node)
- self.out.append('\\begin{DUoptionlist}')
+ self.out.append('\\begin{DUoptionlist}\n')
def depart_option_list(self, node):
self.out.append('\\end{DUoptionlist}\n')
Modified: trunk/docutils/test/functional/expected/latex_cornercases.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_cornercases.tex 2024-03-11 14:55:04 UTC (rev 9555)
+++ trunk/docutils/test/functional/expected/latex_cornercases.tex 2024-03-11 17:48:33 UTC (rev 9556)
@@ -241,7 +241,6 @@
\begin{quote}
\begin{DUoptionlist}
\item[-{}-help] show help
-
\item[-v] verbose
\end{DUoptionlist}
\end{quote}
@@ -250,7 +249,6 @@
\item[{In a definition list:}] \leavevmode
\begin{DUoptionlist}
\item[-{}-help] show help
-
\item[-v] verbose
\end{DUoptionlist}
\end{description}
Modified: trunk/docutils/test/functional/expected/latex_leavevmode.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_leavevmode.tex 2024-03-11 14:55:04 UTC (rev 9555)
+++ trunk/docutils/test/functional/expected/latex_leavevmode.tex 2024-03-11 17:48:33 UTC (rev 9556)
@@ -232,11 +232,14 @@
\item[{Option List}] \leavevmode
\begin{DUoptionlist}
\item[-h] Show help
-
\item[-v] Be verbose
+\item[-{}-rare]
+\begin{enumerate}
+\renewcommand{\labelenumi}{\alph{enumi})}
+\item This description starts with an enumeration
-\item[-{}-rare] a) This description starts with an enumeration
-c) but does not need \texttt{\textbackslash{}leavevmode}.
+\item but does not need \texttt{\textbackslash{}leavevmode}.
+\end{enumerate}
\end{DUoptionlist}
\item[{Literal Block}] \leavevmode
@@ -335,11 +338,11 @@
paragraph automatically, with or without \texttt{\textbackslash{}leavevmode}, so
\texttt{\textbackslash{}leavevmode} isn’t needed.
-\item[{Term with Classifier: classifier}] \leavevmode
+\item[{Term with Classifier}] (\textbf{classifier})
\begin{itemize}
-\item After a \emph{classifier}, \texttt{\textbackslash{}leavevmode} is not required.
+\item After a \emph{classifier}, \texttt{\textbackslash{}leavevmode} is not required
-\item This holds for all elements that normally need \texttt{\textbackslash{}leavevmode}.
+\item because the classifier is added (in parentheses) after the term.
\end{itemize}
\end{description}
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2024-03-11 14:55:04 UTC (rev 9555)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2024-03-11 17:48:33 UTC (rev 9556)
@@ -506,30 +506,20 @@
\begin{DUoptionlist}
\item[-a] command-line option \textquotedbl{}a\textquotedbl{}
-
\item[-b file] options can have arguments
and long descriptions
-
\item[-{}-long] options can be long, too
-
\item[-{}-input=file] long options can also have arguments
-
\item[/V] DOS/VMS-style option
-
\item[-{}-very-long-option] The description can also start on the next line.
The description may contain multiple body elements,
regardless of where it starts.
-
\item[-x, -y, -z] Multiple options are an \textquotedbl{}option group\textquotedbl{}.
-
\item[-v, -{}-verbose] Commonly-seen: short \& long options.
-
\item[-1 file, -{}-one=file, -{}-two file] Multiple options with arguments.
-
\item[-f <{[}path{]}file>] Option argumens must start with a letter
or be wrapped in angle brackets.
-
\item[-d <src dest>] Angle brackets are also required if an
option expects more than one argument.
\end{DUoptionlist}
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2024-03-11 14:55:04 UTC (rev 9555)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2024-03-11 17:48:33 UTC (rev 9556)
@@ -507,30 +507,20 @@
\begin{DUoptionlist}
\item[-a] command-line option “a”
-
\item[-b file] options can have arguments
and long descriptions
-
\item[-{}-long] options can be long, too
-
\item[-{}-input=file] long options can also have arguments
-
\item[/V] DOS/VMS-style option
-
\item[-{}-very-long-option] The description can also start on the next line.
The description may contain multiple body elements,
regardless of where it starts.
-
\item[-x, -y, -z] Multiple options are an “option group”.
-
\item[-v, -{}-verbose] Commonly-seen: short \& long options.
-
\item[-1 file, -{}-one=file, -{}-two file] Multiple options with arguments.
-
\item[-f <{[}path{]}file>] Option argumens must start with a letter
or be wrapped in angle brackets.
-
\item[-d <src dest>] Angle brackets are also required if an
option expects more than one argument.
\end{DUoptionlist}
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2024-03-11 14:55:04 UTC (rev 9555)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2024-03-11 17:48:33 UTC (rev 9556)
@@ -509,30 +509,20 @@
\begin{DUoptionlist}
\item[-a] command-line option “a”
-
\item[-b file] options can have arguments
and long descriptions
-
\item[--long] options can be long, too
-
\item[--input=file] long options can also have arguments
-
\item[/V] DOS/VMS-style option
-
\item[--very-long-option] The description can also start on the next line.
The description may contain multiple body elements,
regardless of where it starts.
-
\item[-x, -y, -z] Multiple options are an “option group”.
-
\item[-v, --verbose] Commonly-seen: short \& long options.
-
\item[-1 file, --one=file, --two file] Multiple options with arguments.
-
\item[-f <{[}path{]}file>] Option argumens must start with a letter
or be wrapped in angle brackets.
-
\item[-d <src dest>] Angle brackets are also required if an
option expects more than one argument.
\end{DUoptionlist}
Modified: trunk/docutils/test/functional/input/latex_leavevmode.txt
===================================================================
--- trunk/docutils/test/functional/input/latex_leavevmode.txt 2024-03-11 14:55:04 UTC (rev 9555)
+++ trunk/docutils/test/functional/input/latex_leavevmode.txt 2024-03-11 17:48:33 UTC (rev 9556)
@@ -42,7 +42,7 @@
-h Show help
-v Be verbose
--rare a) This description starts with an enumeration
- c) but does not need ``\leavevmode``.
+ b) but does not need ``\leavevmode``.
Literal Block
::
@@ -109,9 +109,9 @@
paragraph automatically, with or without ``\leavevmode``, so
``\leavevmode`` isn't needed.
-Term with Classifier: classifier
- - After a *classifier*, ``\leavevmode`` is not required.
- - This holds for all elements that normally need ``\leavevmode``.
+Term with Classifier : classifier
+ - After a *classifier*, ``\leavevmode`` is not required
+ - because the classifier is added (in parentheses) after the term.
Ambiguous cases
***************
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-03-14 10:30:42
|
Revision: 9560
http://sourceforge.net/p/docutils/code/9560
Author: milde
Date: 2024-03-14 10:30:39 +0000 (Thu, 14 Mar 2024)
Log Message:
-----------
Rename new "buildhtml.py" setting "rst_source" to "source".
Keep it simple.
Future-proof (no need to change name in case we add
support for a configurable parser component).
Modified Paths:
--------------
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docs/user/tools.txt
trunk/docutils/tools/buildhtml.py
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2024-03-13 18:50:24 UTC (rev 9559)
+++ trunk/docutils/RELEASE-NOTES.txt 2024-03-14 10:30:39 UTC (rev 9560)
@@ -208,7 +208,7 @@
- New configuration setting root_prefix_.
Configurable root directory for included files.
- - New configuration setting rst_sources_ for the "buildhtml.py" application.
+ - New configuration setting sources_ for the "buildhtml.py" application.
- Simpler and more secure `input encoding`_ default behaviour:
@@ -259,7 +259,7 @@
.. _csv-table: docs/ref/rst/directives.html#csv-table
.. _"image" directive: docs/ref/rst/directives.html#image
.. _root_prefix: docs/user/config.html#root-prefix
-.. _rst_sources: docs/user/config.html#rst-sources
+.. _sources: docs/user/config.html#sources
Release 0.20.1 (2023-05-17)
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2024-03-13 18:50:24 UTC (rev 9559)
+++ trunk/docutils/docs/user/config.txt 2024-03-14 10:30:39 UTC (rev 9560)
@@ -112,11 +112,9 @@
* For **boolean** settings (switches), the following values are
recognized (case-independent):
- .. class:: narrow
+ :True: "true", "yes", "on", "1"
+ :False: "false", "no", "off", "0", "" (no value)
- :on: "true", "yes", "on", "1"
- :off: "false", "no", "off", "0", "" (no value)
-
.. _comma-separated:
* **Lists** are specified either comma- or _`colon-separated`:
@@ -135,7 +133,7 @@
*colon-separated*:
- ignore_, prune_, rst_sources_, expose_internals_
+ ignore_, prune_, sources_, expose_internals_
Whitespace around the delimiter is not stripped. Write, e.g., ::
@@ -872,8 +870,6 @@
*Default*: None (disabled). *Option*: ``--smart-quotes``.
-New in Docutils 0.10.
-
.. _SmartQuotes: smartquotes.html
.. _pre-defined quote sets: smartquotes.html#localization
.. _quote characters:
@@ -918,8 +914,6 @@
*Default*: "long". *Option*: ``--syntax-highlight``.
-New in Docutils 0.9.
-
.. _Pygments: https://pygments.org/
.. _code: ../ref/rst/directives.html#code
.. _Pygments-generated stylesheets:
@@ -1262,8 +1256,6 @@
to "MathML" in Docutils 0.22.
:Option: ``--math-output``.
-New in Docutils 0.8.
-
.. _math directive: ../ref/rst/directives.html#math
.. _MathJax: http://www.mathjax.org/
.. _MathML: https://www.w3.org/TR/MathML/
@@ -1719,7 +1711,7 @@
~~~~~~~~~~~~~~
LaTeX code that will be inserted in the document preamble.
Can be used to load packages with options or (re-) define LaTeX
-macros without writing a custom style file (new in Docutils 0.7).
+macros without writing a custom style file.
:Default: writer dependent (see `[latex2e writer]`_, `[xetex writer]`_).
:Option: ``--latex-preamble``.
@@ -2180,7 +2172,7 @@
[buildhtml application]
-----------------------
-buildhtml.py_ generates HTML documents from all reStructuredText source
+buildhtml.py_ generates HTML documents from reStructuredText source
files in a set of directories and their subdirectories.
All visited directories are scanned for "docutils.conf" files which are
parsed after the standard configuration files. Path settings [#pwd]_ in
@@ -2197,33 +2189,32 @@
ignore
~~~~~~
List of glob-style patterns [#globbing]_ (colon-separated_).
+Source files with matching filename are silently ignored.
Values are appended. [#append-values]_
-Matching files are silently ignored.
-
*Default*: ``[]``. *Option*: ``--ignore``.
prune
~~~~~
List of glob-style patterns [#globbing]_ (colon-separated_).
-Values are appended. [#append-values]_
+Matching directories are skipped. Values are appended. [#append-values]_
Patterns are expanded similar to path settings [#pwd]_ and matched
-against the absolute path of to-be-processed directories. Matching
-directories are skipped. This way, a directory can be marked as
-to-be-pruned by a "./docutils.conf" file containing ::
+against the absolute path of to-be-processed directories.
+Example: a directory is pruned if it contains a "docutils.conf" file
+with the lines ::
[buildhtml application]
prune: '.'
The default patterns skip auxiliary directories from Python or
-popular version control tools anywhere. [#]_
+popular version control tools anywhere [#]_.
:Default: ``['/*/.hg', '/*/.bzr', '/*/.git', '/*/.svn',
'/*/.venv', '/*/__pycache__']``.
-:Option: ``--prune``.
+:Option: ``--prune``.
-.. [#] The leading "/" prevents expansion with pwd and
+.. [#] The leading "/" prevents expansion with `pwd`;
``fnmatch('/*')`` matches any absolute path.
recurse
@@ -2230,13 +2221,14 @@
~~~~~~~
Recursively scan subdirectories.
-*Default*: True (recurse). *Options*: ``--recurse``, ``--local``.
+*Default*: True. *Options*: ``--recurse``, ``--local``.
-rst_sources
-~~~~~~~~~~~
-List of glob-style [#globbing]_ patterns specifying files to process as
-reStructuredText source (colon-separated_). Values in configuration files
-overwrite the default and are overwritten by the command line option.
+sources
+~~~~~~~
+List of glob-style [#globbing]_ patterns (colon-separated_).
+Files with matching filename are treated as source documents.
+Values in configuration files overwrite the default and are
+overwritten by the command line option.
*Default*: ``['*.rst', '*.txt']``. *Option*: ``--rst-sources``.
@@ -2270,7 +2262,7 @@
`pathlib.PurePath.match()`_).
For example, "``/*.py``" matches "/a/b/c.py".
- Provisional: will use `pathlib.PurePath.match()` once this supports "**".
+ Provisional: may use `pathlib.PurePath.match()` once this supports "**".
.. _fnmatch module:
https://docs.python.org/3/library/fnmatch.html#module-fnmatch
@@ -2296,8 +2288,7 @@
reader
~~~~~~
Reader component name.
-One of "standalone", "pep",
-or the import name of a plug-in reader module.
+One of "standalone", "pep", or the import name of a plug-in reader module.
*Default*: "standalone".
*Option*: ``--reader``
Modified: trunk/docutils/docs/user/tools.txt
===================================================================
--- trunk/docutils/docs/user/tools.txt 2024-03-13 18:50:24 UTC (rev 9559)
+++ trunk/docutils/docs/user/tools.txt 2024-03-14 10:30:39 UTC (rev 9560)
@@ -169,7 +169,7 @@
rst2html test.txt > test.html
-Now open the "``test.html``" file in your favorite browser to see the
+Now open the "``test.html``" file in your favourite browser to see the
results. To get a footer with a link to the source file, date & time
of processing, and links to the Docutils project, add some options::
@@ -238,7 +238,7 @@
rst2s5 slides.txt --output=slides.html
-Now open the "``slides.html``" file in your favorite browser, switch
+Now open the "``slides.html``" file in your favourite browser, switch
to full-screen mode, and enjoy the results.
.. _S5: http://meyerweb.com/eric/tools/s5/
@@ -329,7 +329,7 @@
.. [#copy-theme] Theme files can only be copied by Docutils, if the
output_ destination path is specified.
-
+
.. _output: config.html#output
buildhtml.py
@@ -343,16 +343,16 @@
The ``buildhtml.py`` script can be found in the ``/tools`` directory of
the "docutils" source. It is not included in binary packages. [#]_
-Use ``buildhtml.py`` to generate ``*.html`` from all the reStructuredText
-source files (including PEPs) in each <directory> given, and their
-subdirectories too. (Use the ``--local`` option to skip subdirectories.)
-
Usage::
buildhtml.py [options] [<directory> ...]
-The current directory (including all subdirectories) is chosen by default if
-no directory is specified.
+Use ``buildhtml.py`` to generate ``*.html`` from reStructuredText
+source files in each <directory> given, and their subdirectories too.
+The current directory is chosen by default if no directory is specified.
+Use the ``--local`` option to skip all subdirectories.
+See `[buildhtml application]`_ in `Docutils Configuration`_
+for more specific selection options.
After unpacking the Docutils source package, you can ``cd`` into its root
directory (``docutils-X.Y/`` where "X.Y" is the release version, for
@@ -361,16 +361,11 @@
tools/buildhtml.py
-Some files may generate system messages
-(docs/user/rst/demo.txt contains intentional errors); use the
-``--quiet`` option to suppress all warnings. The ``--config`` option
-ensures that the correct settings are in place (a ``docutils.conf``
-`configuration file`_ in the current directory is picked up
-automatically). Command-line options may be used to override config
-file settings or replace them altogether.
+Some files may generate system messages (docs/user/rst/demo.txt contains
+intentional errors); use the ``--quiet`` option to suppress all warnings.
.. [#] The Debian package "python3-docutils" includes the script
- under the name ``rst-builthtml``.
+ under the name ``rst-buildhtml``.
.. _[buildhtml application]: config.html#buildhtml-application
.. _configuration file: `configuration files`_
Modified: trunk/docutils/tools/buildhtml.py
===================================================================
--- trunk/docutils/tools/buildhtml.py 2024-03-13 18:50:24 UTC (rev 9559)
+++ trunk/docutils/tools/buildhtml.py 2024-03-14 10:30:39 UTC (rev 9560)
@@ -47,7 +47,7 @@
prune_default = ['/*/.hg', '/*/.bzr', '/*/.git', '/*/.svn',
'/*/.venv', '/*/__pycache__']
- rst_sources_default = ['*.rst', '*.txt']
+ sources_default = ['*.rst', '*.txt']
# Can't be included in OptionParser below because we don't want to
# override the base class.
@@ -54,13 +54,28 @@
settings_spec = (
'Build-HTML Options',
None,
- (('Recursively scan subdirectories for files to process. This is '
+ (('Process all files matching any of the given '
+ 'glob-style patterns (separated by colons). '
+ 'This option overwrites the default or config-file values. '
+ f'Default: "{":".join(sources_default)}".',
+ ['--sources'],
+ {'metavar': '<patterns>',
+ 'default': sources_default,
+ 'validator': frontend.validate_colon_separated_string_list}),
+ ('Recursively ignore files matching any of the given '
+ 'glob-style patterns (separated by colons). '
+ 'This option may be used more than once to add more patterns.',
+ ['--ignore'],
+ {'metavar': '<patterns>', 'action': 'append',
+ 'default': [],
+ 'validator': frontend.validate_colon_separated_string_list}),
+ ('Do not scan subdirectories for files to process.',
+ ['--local'], {'dest': 'recurse', 'action': 'store_false'}),
+ ('Recursively scan subdirectories for files to process. This is '
'the default.',
['--recurse'],
{'action': 'store_true', 'default': 1,
'validator': frontend.validate_boolean}),
- ('Do not scan subdirectories for files to process.',
- ['--local'], {'dest': 'recurse', 'action': 'store_false'}),
('Do not process files in <directory> (glob-style patterns, '
'separated by colons). This option may be used '
'more than once to add more patterns. Default: "%s".'
@@ -69,21 +84,6 @@
{'metavar': '<directory>', 'action': 'append',
'validator': frontend.validate_colon_separated_string_list,
'default': prune_default}),
- ('Process all files matching any of the given '
- 'glob-style patterns (separated by colons). '
- 'This option overwrites the default or config-file values. '
- f'Default: "{":".join(rst_sources_default)}".',
- ['--rst-sources'],
- {'metavar': '<patterns>',
- 'default': rst_sources_default,
- 'validator': frontend.validate_colon_separated_string_list}),
- ('Recursively ignore files matching any of the given '
- 'glob-style patterns (separated by colons). '
- 'This option may be used more than once to add more patterns.',
- ['--ignore'],
- {'metavar': '<patterns>', 'action': 'append',
- 'default': [],
- 'validator': frontend.validate_colon_separated_string_list}),
('Docutils writer, one of "html", "html4", "html5". '
'Default: "html" (use Docutils\' default HTML writer).',
['--writer'],
@@ -259,7 +259,7 @@
for name in sorted(filenames):
if match_patterns(name, settings.ignore):
continue
- if match_patterns(name, settings.rst_sources):
+ if match_patterns(name, settings.sources):
self.process_txt(dirpath, name)
def process_txt(self, directory, name):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-03-14 16:34:52
|
Revision: 9561
http://sourceforge.net/p/docutils/code/9561
Author: milde
Date: 2024-03-14 16:34:48 +0000 (Thu, 14 Mar 2024)
Log Message:
-----------
Documentation fixes. Prepare release 0.21.rc1
Fix typos, links,
Harmonise spacing and markup.
Verify authorship of "literal block" patch for the manpage writer
(forwarded from a Debian bug report discussion as patch #205).
Use NBSP between program name and version number.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docs/ref/rst/directives.txt
trunk/docutils/docs/ref/rst/restructuredtext.txt
trunk/docutils/docs/user/config.txt
trunk/docutils/docs/user/slide-shows.txt
trunk/docutils/docutils/parsers/commonmark_wrapper.py
trunk/docutils/docutils/utils/math/mathml_elements.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-03-14 10:30:39 UTC (rev 9560)
+++ trunk/docutils/HISTORY.txt 2024-03-14 16:34:48 UTC (rev 9561)
@@ -14,16 +14,14 @@
.. contents::
-Changes since 0.20.1
-====================
+Release 0.21.rc1
+================
* General
- Drop support for Python 3.7 and 3.8.
-
- - Updated build stystem to use Flit_ (patch #186 by Adam Turner).
+ - Updated build system to use Flit_ (patch #186 by Adam Turner).
Removed ``setup.py``.
-
- Provide ``rst2*`` "console_scripts" `entry points`_
(without the ``.py`` extension) instead of installing the
``rst2*.py`` front end tools in the binary PATH.
@@ -33,6 +31,7 @@
* docs/ref/docutils.dtd
- The <image> element accepts a new attribute "loading".
+
- Fix definitions (no change to actual behaviour):
* The <math_block> element uses the attribute "xml:space".
@@ -51,23 +50,21 @@
Do not use the locale encoding as fallback if Python is started in
`UTF-8 mode`_. Stop using "latin1" as second fallback.
- Remove BOM (U+FEFF ZWNBSP at start of data) only if the `input_encoding`_
+ Remove BOM (U+FEFF ZWNBSP at start of data) only if the "input_encoding"
configuration setting is None, '', 'utf-8-sig', 'utf-16', or 'utf-32'.
Do not remove other ZWNBSPs.
+ .. _UTF-8 mode: https://docs.python.org/3/library/os.html#utf8-mode
+ .. _input encoding: docs/api/publisher.html#encodings
+
- Auto-close `FileInput.source` in case of reading/decoding errors.
- .. _UTF-8 mode: https://docs.python.org/3/library/os.html#utf8-mode
- .. _input encoding: docs/api/publisher.html#encodings
-
* docutils/languages/, docutils/parsers/rst/languages/
- Mark/Fix mistranslated localizations of the "admonition" directive
name. In Docutils, "admonition" is used as a generic term for
"advice"/"advisory"/"remark", not a reprimand.
-
- Add support for Georgian language (patch #204 by Temuri Doghonadze).
-
- Update/complete Catalan translations (patch #203 by Antoni Bella Pérez).
* docutils/nodes.py
@@ -83,8 +80,8 @@
- Use the same CSV format for the ``:header:`` option and the main data
of the "csv-table" directive.
- - Move `parsers.rst.directives.Table.process_header_option()` to
- `parsers.rst.directives.CSVTable`.
+ - Move `parsers.rst.directives.Table.process_header_option()` method
+ to `parsers.rst.directives.CSVTable`.
* docutils/parsers/rst/states.py
@@ -93,7 +90,7 @@
* docutils/parsers/rst/directives/misc.py,
docutils/parsers/rst/directives/tables.py
- - Consider the root-prefix_ setting when including files with
+ - Consider the new root_prefix_ setting when including files with
"include", "raw", or "csv-table" directives.
* docutils/utils/math/*
@@ -102,7 +99,6 @@
abusing `SyntaxError` for LaTeX math syntax errors.
- Unify interface of LaTeX -> MathML conversion functions.
Improve error reporting.
- - Elimitate side-effect of importing "latex2mathml" on "tex2unichar".
- Sort ℏ (`\hslash`) as "mathord", not "mathalpha".
* docutils/utils/math/latex2mathml.py
@@ -112,7 +108,7 @@
Use CSS rules instead of the deprecated "columnalign" attribute
to style <mtable> as "align" environment.
- Use Mathematical Alphanumeric Symbols instead of `<mstyle>` with
+ Use Mathematical Alphanumeric Symbols instead of <mstyle> with
"mathvariant" attribute.
- Use <mi> instead of <mo> for character class "mathord".
@@ -119,26 +115,28 @@
- Support "aligned" environment.
+ - Eliminate side-effect on later import of "tex2unichar".
+
* docutils/utils/math/mathml_elements.py
- - New module defining MathML element classes (outsourced from
- latex2mathml.py).
+ - New module defining MathML element classes
+ (outsourced from latex2mathml.py).
- Base MathML element classes on `xml.etree.ElementTree`.
* docutils/utils/roman.py
- Update to version `1.4 <https://pypi.org/project/roman/4.1/>`__.
- Fixes feature-requests:#95 (license is now ZPL 2.1).
+ Fixes feature-request #95 (license is now ZPL 2.1).
* docutils/utils/smartquotes.py
- Pre-compile regexps once, not with every call of `educateQuotes()`
- (patch #206 by Chris Sewell); simplify regexps; skip replacement
- rules if there is nothing to replace.
+ (patch #206 by Chris Sewell).
+ - Simplify regexps; skip replacement rules if there is nothing to replace.
* docutils/writers/html4css1/__init__.py
- - Support video inclusion via `<object>` tags.
+ - Support video inclusion via ``<object>`` tags.
* docutils/writers/html5_polyglot/\*.css
@@ -153,33 +151,31 @@
- Warn, if image scaling fails because the image file cannot be read.
- Support video inclusion via ``<video>`` tags
(moved here from writers/html5_polyglot/__init__.py).
- - New auxiliary function `HTMLTranslator.uri2imagepath()`
- ensures the image file can also be read when
- CWD and output directory differ.
- - Consider the root-prefix_ setting when converting an image URI
+ - New auxiliary method `HTMLTranslator.uri2imagepath()` ensures the
+ image file can also be read when CWD and output directory differ.
+ - Consider the root_prefix_ setting when converting an image URI
to a local filesystem path.
- - New <image> attribute "loading" overrides "image-loading" setting.
- - Embed SVG images as ``<svg>`` instead of data-URI
- (not used by "html4css1"). Fixes [feature-requests:#100].
- - Write system messages for errors/warnings during the writing stage
+ - New `\<image>`_ attribute "loading" overrides image_loading_ setting.
+ - Embed SVG images as ``<svg>`` instead of data-URI.
+ Fixes feature-request #100.
+ - Generate system messages for errors/warnings during the writing stage
(image transformations, math content conversion, ...).
- - Close ``<dt>`` element in `depart_term()` to allow a `definition_list_item`
- with multiple `term`\ s (cf. [feature-requests:60]).
+ - Close ``<dt>`` element in `depart_term()` to allow a
+ "definition_list_item" with multiple "terms" (cf. feature-request #60).
- .. _root-prefix: docs/user/config.html#root-prefix
-
* docutils/writers/latex2e/__init__.py
- Fix placement of hyperlink target (label) for tables (bug #440).
- - More compact option-list and description-list.
+ - More compact LaTeX source for option-lists and description-lists
+ (no change in output).
* docutils/writers/manpage.py
- Add multiple definition list term support, see feature #60.
- - Add preprocessor hinting tbl first line, see bugs #477.
- - Change tbl-Tables using box option, see bugs #475.
+ - Add preprocessor hinting tbl first line, see bug #477.
+ - Change tbl-Tables using box option, see bug #475.
- Apply literal block patch #205. Use ``.EE`` and ``.EX`` macros.
- Thanks to G. Branden Robinson (I assume).
+ Thanks to G. Branden Robinson.
* docutils/writers/odf_odt/__init__.py
@@ -191,17 +187,13 @@
* docutils/writers/s5_html/__init__.py
- Warn if the S5 writer cannot copy the theme files.
+ - Programmatic customization of theme_url_ setting no longer
+ overridden by the default for theme_.
- - Programmatic customization of "theme_url__" setting no longer
- overridden by the default for "theme__".
-
- __ docs/user/config.html#theme-url
- __ docs/user/config.html#theme
-
* tools/buildhtml.py
- - New option `rst_sources`_.
- Match `prune` values with `fnmatch.fnmatch()`.
+ - New configuration setting `sources`_.
+ - Match `prune`_ values with `fnmatch.fnmatch()`.
Release 0.20.1 (2023-05-17)
@@ -589,11 +581,9 @@
* docutils/nodes.py
- - Make meta__ a standard Docutils doctree node. Writers may ignore
- `meta` nodes if they are not supported by the output format.
+ - Make `\<meta>`_ a standard Docutils doctree node. Writers may ignore
+ <meta> nodes if they are not supported by the output format.
- __ docs/ref/doctree.html#meta
-
- document.make_id(): Do not strip leading number and hyphen characters
from `name` if the `id_prefix`_ setting is non-empty.
@@ -853,14 +843,11 @@
- Use HTML text-level tags <small>, <s>, <q>, <dfn>, <var>, <samp>, <kbd>,
<i>, <b>, <u>, <mark>, and <bdi> if a unique, matching class value
- is found in `inline`__ and `literal`__ elements.
+ is found in `\<inline>`_ and `\<literal>`_ elements.
Use <ins> and <del> if a unique matching class value
is found in `inline`, `literal`, or `container` elements.
Use <small> for generated code line numbers.
- __ docs/ref/doctree.html#inline
- __ docs/ref/doctree.html#literal
-
- Fix bug #398: properly close link tag to "schema.dcterms".
- Add a `viewport meta tag`__ to fix rendering in mobile browsers.
@@ -990,12 +977,12 @@
* docutils/statemachine.py
- - Patch [ 158 ]: Speed up patterns by saving compiled versions (eric89gxl)
+ - Patch [ 158 ] Speed up patterns by saving compiled versions (eric89gxl)
* docutils/transforms/universal.py
- - Fix [ 332 ]: Standard backslash escape for smartquotes.
- - Fix [ 342 ]: No escape in roles descending from `inline literal`.
+ - Fix [ 332 ] Standard backslash escape for smartquotes.
+ - Fix [ 342 ] No escape in roles descending from `inline literal`.
* docutils/utils/__init__.py
@@ -1028,12 +1015,12 @@
* test/alltests.py
- - Fix: 377 ResourceWarning: unclosed file python3.8
+ - Fix [ 377 ] ResourceWarning: unclosed file python3.8
Close alltests.out with atexit.
* test/functional/*
- - Fix: 377 ResourceWarning: unclosed file python3.8
+ - Fix [ 377 ] ResourceWarning: unclosed file python3.8
Read defaults file with context.
- Set `auto_id_prefix`_ to "%" (expands to tag-names).
@@ -1046,7 +1033,7 @@
* test/test_writers/test_odt.py
- - Fix [ 359 ]: Test suite fails on Python 3.8. odt XML sorting.
+ - Fix [ 359 ] Test suite fails on Python 3.8. odt XML sorting.
Use ElementTree instead of minidom.
* tools/buildhtml.py
@@ -1059,7 +1046,7 @@
source: branches/rel-0.15
-Bugs #366 fix release for python2 only.
+Fix [ 366 ] circular dependency. Release for Python 2 only.
Release 0.15 (2019-07-20)
@@ -1067,7 +1054,7 @@
* General
- - Dropped support for Python 2.4, 2.5, 3.1, and 3.2.
+ - Dropped support for Python 2.4, 2.5, 3.1, and 3.2.
- Infrastructure automation.
* docs/ref/docutils.dtd
@@ -1379,7 +1366,6 @@
.. _polyglot: https://www.w3.org/TR/html-polyglot/
.. _HTML 5: https://www.w3.org/TR/html5/
-.. _XHTML 1.0: https://www.w3.org/TR/xhtml1/
Release 0.12 (2014-07-06)
@@ -1608,7 +1594,7 @@
- New reStructuredText "code" role and directive and "code" option
of the "include" directive with syntax highlighting by Pygments_.
- Fix parse_option_marker for option arguments containing ``=``.
- - Fix [ 2993756 ]: import Python Imaging Library's Image module
+ - Fix [ 2993756 ] import Python Imaging Library's Image module
via ``import PIL`` as starting with PIL 1.2,
"PIL lives in the PIL namespace only" (announcement__).
@@ -4390,10 +4376,12 @@
.. _math_output: docs/user/config.html#math-output
.. _output: docs/user/config.html#output
.. _output_encoding: docs/user/config.html#output-encoding
+.. _prune: docs/user/config.html#prune
.. _raw_enabled: docs/user/config.html#raw-enabled
.. _reference_label: docs/user/config.html#reference-label
-.. _rst_sources: docs/user/config.html#rst-sources
+.. _root_prefix: docs/user/config.html#root-prefix
.. _smart_quotes: docs/user/config.html#smart-quotes
+.. _sources: docs/user/config.html#sources
.. _strip_classes: docs/user/config.html#strip-classes
.. _strip_elements_with_classes: docs/user/config.html#strip-elements-with-classes
.. _stylesheet: docs/user/config.html#stylesheet
@@ -4401,6 +4389,8 @@
.. _stylesheet_path: docs/user/config.html#stylesheet-path
.. _syntax_highlight: docs/user/config.html#syntax-highlight
.. _table_style: docs/user/config.html#table-style
+.. _theme: docs/user/config.html#theme
+.. _theme_url: docs/user/config.html#theme-url
.. _traceback: docs/user/config.html#traceback
.. _use_bibtex: docs/user/config.html#use-bibtex
.. _use_latex_abstract: docs/user/config.html#use-latex-abstract
@@ -4408,7 +4398,12 @@
.. _use_latex_toc: docs/user/config.html#use-latex-toc
.. _view_mode: docs/user/config.html#view-mode
+.. _<meta>: docs/ref/doctree.html#meta
+.. _<image>: docs/ref/doctree.html#image
+.. _<inline>: docs/ref/doctree.html#inline
+.. _<literal>: docs/ref/doctree.html#literal
+
..
Local Variables:
mode: indented-text
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2024-03-14 10:30:39 UTC (rev 9560)
+++ trunk/docutils/RELEASE-NOTES.txt 2024-03-14 16:34:48 UTC (rev 9561)
@@ -170,8 +170,8 @@
.. _buildhtml.py: docs/user/tools.html#buildhtml-py
-Release 0.21 (unpublished)
-==========================
+Release 0.21.rc1 (unpublished)
+==============================
* General:
Modified: trunk/docutils/docs/ref/rst/directives.txt
===================================================================
--- trunk/docutils/docs/ref/rst/directives.txt 2024-03-14 10:30:39 UTC (rev 9560)
+++ trunk/docutils/docs/ref/rst/directives.txt 2024-03-14 16:34:48 UTC (rev 9561)
@@ -314,7 +314,6 @@
.. [#] SVG images are directly included, other images are base64_ encoded
and included as a `data URI`_.
-.. _image_loading: ../../user/config.html#image-loading
.. _lazy loading attribute: https://html.spec.whatwg.org/multipage/
urls-and-fetching.html#lazy-loading-attributes
.. _base64: https://en.wikipedia.org/wiki/Base64
@@ -573,7 +572,7 @@
:Directive Arguments: one, optional (formal language)
:Directive Options: `see below <code options_>`__
:Directive Content: Becomes the body of the literal block.
-:Configuration Setting: syntax_highlight_.
+:Configuration Setting: syntax_highlight_
The "code" directive constructs a literal block. If the code language is
specified, the content is parsed by the Pygments_ syntax highlighter and
@@ -611,7 +610,6 @@
.. _sandbox/stylesheets: https://docutils.sourceforge.io/sandbox/stylesheets/
.. _Pygments: https://pygments.org/
-.. _syntax_highlight: ../../user/config.html#syntax-highlight
.. _supported languages and markup formats: https://pygments.org/languages/
@@ -647,7 +645,6 @@
For inline formulas, use the `"math" role`_.
.. _LaTeX math syntax: ../../ref/rst/mathematics.html
-.. _math_output: ../../user/config.html#math-output
Rubric
@@ -850,6 +847,7 @@
:Directive Arguments: one, optional (table title)
:Directive Options: `see below <table options_>`__
:Directive Content: A normal `reStructuredText table`_.
+:Configuration Setting: table_style_
The "table" directive is used to associate a
title with a table or specify options, e.g.::
@@ -902,10 +900,6 @@
values "colwidths-auto"/"colwidths-grid").
-.. _reStructuredText table: restructuredtext.html#tables
-.. _table_style: ../../user/config.html#table-style
-
-
.. _csv-table:
CSV Table
@@ -919,6 +913,7 @@
:Directive Options: `see below <csv-table options_>`__
:Directive Content: A CSV (comma-separated values) table
or (with the `file`_ or `url`_ options) none.
+:Configuration Settings: table_style_, file_insertion_enabled_
.. WARNING::
@@ -1052,6 +1047,7 @@
:Directive Arguments: one, optional (table title)
:Directive Options: `see below <list-table options_>`__
:Directive Content: A uniform two-level bullet list.
+:Configuration Setting: table_style_
(This is an initial implementation; `further ideas`__ may be implemented
in the future.)
@@ -1135,6 +1131,7 @@
:Directive Arguments: one, optional: title
:Directive Options: `see below <contents options_>`__
:Directive Content: none
+:Configuration Settings: toc_backlinks_, use_latex_toc_, generate_oowriter_toc_
The "contents" directive generates a table of contents (TOC) in
a `\<topic>`_ element. Topics, and therefore tables of contents,
@@ -1242,9 +1239,7 @@
numbering for a document split over several source files. The
default is 1.
-.. _sectnum_xform: ../../user/config.html#sectnum-xform
-
.. _header:
.. _footer:
@@ -1543,8 +1538,6 @@
The "include" directive represents a potential security hole. It
can be disabled with the "file_insertion_enabled_" runtime setting.
- .. _file_insertion_enabled: ../../user/config.html#file-insertion-enabled
-
The "include" directive reads a text file. The directive argument is
the path to the file to be included, relative to the document containing
the directive. Unless the options ``literal``, ``code``, or ``parser``
@@ -1591,8 +1584,6 @@
The text encoding of the external file.
Defaults to the document's input_encoding_.
- .. _input_encoding: ../../user/config.html#input-encoding
-
``end-before`` : text_
Only the content before the first occurrence of the specified *text*
in the external data file (but after any ``start-after`` text)
@@ -1629,8 +1620,6 @@
where a negative value prevents expansion of hard tabs.
Defaults to the tab_width_ configuration setting.
- .. _tab_width: ../../user/config.html#tab-width
-
With ``code`` or ``literal`` the common options class_ and name_
are recognized as well.
@@ -1652,7 +1641,7 @@
:Directive Options: `see below <raw options_>`__
:Directive Content: Stored verbatim, uninterpreted.
None (empty) if a ``file`` or ``url`` option given.
-:Configuration Setting: raw_enabled_
+:Configuration Settings: raw_enabled_, file_insertion_enabled_
.. WARNING::
@@ -1661,8 +1650,6 @@
Insertion of external files can be disabled with the
"file_insertion_enabled_" runtime setting.
- .. _raw_enabled: ../../user/config.html#raw-enabled
-
.. Caution::
The "raw" directive is a stop-gap measure allowing the author to
@@ -2114,10 +2101,11 @@
.. class:: field-indent-13em
:Directive Type: "title"
-:Doctree Element: none (sets the document's `title attribute`_)
+:Doctree Element: sets the `\<document>`_ element's `title attribute`_)
:Directive Arguments: one, required (the title text)
:Directive Options: none
:Directive Content: none
+:Configuration Setting: `title <"title" configuration setting_>`__
The "title" directive specifies the document title as metadata, which
does not become part of the document body. It overrides the
@@ -2125,10 +2113,7 @@
setting`_. For example, in HTML output the metadata document title
appears in the title bar of the browser window.
-.. _document title: restructuredtext.html#document-title
-.. _"title" configuration setting: ../../user/config.html#title
-
Restructuredtext-Test-Directive
===============================
@@ -2248,6 +2233,7 @@
.. _reStructuredText Markup Specification: restructuredtext.html
.. _Directives: restructuredtext.html#directives
+.. _document title: restructuredtext.html#document-title
.. _escaping mechanism: restructuredtext.html#escaping-mechanism
.. _external hyperlink targets:
restructuredtext.html#external-hyperlink-targets
@@ -2257,6 +2243,7 @@
.. _percentage: restructuredtext.html#percentage-units
.. _reference name:
.. _reference names: restructuredtext.html#reference-names
+.. _reStructuredText table: restructuredtext.html#tables
.. _reStructuredText Interpreted Text Roles:
.. _interpreted text role: roles.html
@@ -2264,9 +2251,24 @@
.. _"math" role: roles.html#math
.. _"raw" role: roles.html#raw
-.. _The Docutils Document Tree: ../doctree.html
+.. Docutils Configuration
+.. _file_insertion_enabled: ../../user/config.html#file-insertion-enabled
+.. _generate_oowriter_toc: ../../user/config.html#generate-oowriter-toc
+.. _image_loading: ../../user/config.html#image-loading
+.. _input_encoding: ../../user/config.html#input-encoding
+.. _math_output: ../../user/config.html#math-output
+.. _raw_enabled: ../../user/config.html#raw-enabled
+.. _sectnum_xform: ../../user/config.html#sectnum-xform
+.. _syntax_highlight: ../../user/config.html#syntax-highlight
+.. _tab_width: ../../user/config.html#tab-width
+.. _table_style: ../../user/config.html#table-style
+.. _"title" configuration setting: ../../user/config.html#title
+.. _toc_backlinks: ../../user/config.html#toc-backlinks
+.. _use_latex_toc: ../../user/config.html#use-latex-toc
+
.. _reStructuredText Standard Definition Files: definitions.html
+.. _The Docutils Document Tree: ../doctree.html
.. _identifier keys: ../doctree.html#ids-type
.. _inline elements: ../doctree.html#inline-elements
.. _class names: ../doctree.html#classname
@@ -2286,6 +2288,7 @@
.. _<container>: ../doctree.html#container
.. _<danger>: ../doctree.html#danger
.. _<decoration>: ../doctree.html#decoration
+.. _<document>: ../doctree.html#document
.. _<error>: ../doctree.html#error
.. _<figure>: ../doctree.html#figure
.. _<footer>: ../doctree.html#footer
Modified: trunk/docutils/docs/ref/rst/restructuredtext.txt
===================================================================
--- trunk/docutils/docs/ref/rst/restructuredtext.txt 2024-03-14 10:30:39 UTC (rev 9560)
+++ trunk/docutils/docs/ref/rst/restructuredtext.txt 2024-03-14 16:34:48 UTC (rev 9561)
@@ -25,7 +25,7 @@
constructs to indicate the structure of a document. These constructs
are equally easy to read in raw and processed forms. This document is
itself an example of reStructuredText (raw, if you are reading the
-text file, or processed, if you are reading an HTML document, for
+`text file`__, or processed, if you are reading an HTML document, for
example). The reStructuredText parser is a component of Docutils_.
Simple, implicit markup is used to indicate special constructs, such
@@ -45,6 +45,7 @@
`Literal blocks`_ (in which no markup processing is done) are used for
examples throughout this document, to illustrate the plaintext markup.
+__ restructuredtext.txt
.. contents::
Modified: trunk/docutils/docs/user/config.txt
===================================================================
--- trunk/docutils/docs/user/config.txt 2024-03-14 10:30:39 UTC (rev 9560)
+++ trunk/docutils/docs/user/config.txt 2024-03-14 16:34:48 UTC (rev 9561)
@@ -366,7 +366,7 @@
as external attributes (with "internal:" namespace prefix).
Values are appended. [#append-values]_
-*Default*: ``[]``.
+*Default*: empty list.
*Option*: ``--expose-internal-attribute`` (hidden, for development use only).
@@ -584,7 +584,8 @@
-----------
Base directory, prepended to a filesystem path__ starting with "/" when
-including files with the "include_", "raw_", or "csv-table_" directives.
+including files with the `"include"`_, `"raw"`_, or `"csv-table"`_
+directives.
Also applied when a writer converts an image URI__ to a local filesystem
path in order to determine the image size or embed the image in the output.
@@ -603,7 +604,7 @@
Enable automatic section numbering by Docutils
(`docutils.transforms.parts.SectNum`) associated
-with the `sectnum directive`_.
+with the `"sectnum" directive`_.
If disabled, section numbers might be added to the output by the
renderer (e.g. by LaTeX or via a CSS style definition).
@@ -611,9 +612,7 @@
:Default: True.
:Options: ``--section-numbering``, ``--no-section-numbering``.
-.. _sectnum directive: ../ref/rst/directives.html#sectnum
-
source_link
-----------
@@ -657,7 +656,7 @@
.. WARNING:: Some standard class values are required in order to achieve
the expected output rendering; use with caution.
-*Default*: ``[]``. *Option*: ``--strip-class``.
+*Default*: empty list. *Option*: ``--strip-class``.
strip_comments
@@ -679,7 +678,7 @@
.. WARNING:: Potentially dangerous: may lead to an invalid document tree
and subsequent writer errors. Use with caution.
-*Default*: ``[]``. *Option*: ``--strip-elements-with-class``.
+*Default*: empty list. *Option*: ``--strip-elements-with-class``.
title
@@ -697,8 +696,6 @@
:Option: ``--title``.
.. _title attribute: ../ref/doctree.html#title-attribute
-.. _document title: ../ref/rst/restructuredtext.html#document-title
-.. _"title" directive: ../ref/rst/directives.html#metadata-document-title
toc_backlinks
@@ -705,7 +702,7 @@
-------------
Enable backlinks from section titles to table of contents entries
-("entry"), to the top of the ToC ("top"), or disable ("none").
+("entry"), to the top of the ToC ("top"), or disable (False).
:Default: "entry".
:Options: ``--toc-entry-backlinks``, ``--toc-top-backlinks``,
@@ -745,9 +742,9 @@
file_insertion_enabled
----------------------
-Enable directives inserting the contents of
-external files, such as "include_" directive
-or the "raw_" and "csv-table_" directives with option "url" or "file".
+Enable directives inserting the contents of external files,
+such as `"include"`_ directive or the `"raw"`_ and `"csv-table"`_
+directives with option "url" or "file".
A "warning" system message (including the directive text) is inserted
instead. (See also raw_enabled_ for another security-relevant setting.)
@@ -754,15 +751,11 @@
:Default: True.
:Options: ``--file-insertion-enabled``, ``--no-file-insertion``.
-.. _include: ../ref/rst/directives.html#include
-.. _raw: ../ref/rst/directives.html#raw
-.. _csv-table: ../ref/rst/directives.html#csv-table
-
line_length_limit
-----------------
-Maximal number of characters in an input line or `substitution`_
+Maximal number of characters in an input line or `"substitution"`_
definition. To prevent extraordinary high processing times or memory
usage for certain input constructs, a "warning" system message is
inserted instead.
@@ -772,13 +765,11 @@
New in Docutils 0.17.
-.. _substitution: ../ref/rst/directives.html#substitution
-
raw_enabled
-----------
-Enable the "raw_" directive. A "warning" system message
+Enable the `"raw" directive`_. A "warning" system message
(including the directive text) is inserted instead. See also
file_insertion_enabled_ for another security-relevant setting.
@@ -901,7 +892,7 @@
syntax_highlight
~~~~~~~~~~~~~~~~
-Token type names used by Pygments_ when parsing contents of the code_
+Token type names used by Pygments_ when parsing contents of the `"code"`_
directive and role.
Supported values:
@@ -915,7 +906,6 @@
*Default*: "long". *Option*: ``--syntax-highlight``.
.. _Pygments: https://pygments.org/
-.. _code: ../ref/rst/directives.html#code
.. _Pygments-generated stylesheets:
https://pygments.org/docs/cmdline/#generating-styles
@@ -1107,7 +1097,6 @@
:Default: True.
:Options: ``--compact-lists``, ``--no-compact-lists``.
-.. _"class" directive: ../ref/rst/directives.html#class
compact_field_lists
~~~~~~~~~~~~~~~~~~~
@@ -1158,7 +1147,7 @@
math_output
~~~~~~~~~~~
-The format of mathematical content (`math directive`_ and role) in
+The format of mathematical content (`"math" directive`_ and role) in
the output document. Supported values are (case insensitive):
HTML:
@@ -1256,7 +1245,6 @@
to "MathML" in Docutils 0.22.
:Option: ``--math-output``.
-.. _math directive: ../ref/rst/directives.html#math
.. _MathJax: http://www.mathjax.org/
.. _MathML: https://www.w3.org/TR/MathML/
.. _blahtexml: http://gva.noekeon.org/blahtexml/
@@ -1275,7 +1263,7 @@
Overrides also stylesheet_path_. [#override]_
See also `stylesheet [latex writers]`_.
-*Default*: ``[]``. *Option*: ``--stylesheet``.
+*Default*: empty list. *Option*: ``--stylesheet``.
.. _stylesheet_dirs:
@@ -1347,16 +1335,14 @@
:colwidths-auto:
Delegate the determination of table column widths to the back-end
(leave out the ``<colgroup>`` column specification).
- Overridden by the "widths" option of the `table directive`_.
+ Overridden by the "widths" option of the `"table" directive`_.
:colwidths-grid:
Write column widths determined from the source to the HTML file.
- Overridden by the "widths" option of the `table directive`_.
+ Overridden by the "widths" option of the `"table" directive`_.
*Default*: "". *Option*: ``--table-style``.
-.. _table directive: ../ref/rst/directives.html#table
-
.. _template [html writers]:
template
@@ -1469,7 +1455,6 @@
New in Docutils 0.18.
-.. _"image" directive: ../ref/rst/directives.html#image
.. _lazy loading attribute: https://html.spec.whatwg.org/multipage/
urls-and-fetching.html#lazy-loading-attributes
@@ -1741,7 +1726,7 @@
table width and keeps the ratio of specified column widths.
Custom table and/or column widths can be set with the respective options
-of the `table directive`_. See also `Generating LaTeX with Docutils`__.
+of the `"table" directive`_. See also `Generating LaTeX with Docutils`__.
:Default: True (will change to False in Docutils 1.0).
:Options: ``--legacy-column-widths``, ``--new-column-widths``.
@@ -1763,13 +1748,11 @@
:Default: "" (use "alltt" with quoting of whitespace and special chars).
:Option: ``--literal-block-env``.
-.. [#] A <literal-block> element originating from a `parsed literal`_ or
- code_ directive may contain inline elements. LaTeX' verbatim-like
+.. [#] A <literal-block> element originating from a `"parsed-literal"`_ or
+ `"code"`_ directive may contain inline elements. LaTeX'...
[truncated message content] |
|
From: <mi...@us...> - 2024-03-14 16:35:06
|
Revision: 9562
http://sourceforge.net/p/docutils/code/9562
Author: milde
Date: 2024-03-14 16:35:03 +0000 (Thu, 14 Mar 2024)
Log Message:
-----------
Link to the document top from the ToC heading.
Add a "back"-link to "#top" (unless toc_backlinks_ is False).
For the definition of "#top" see the HTML standard section
"Scrolling to a fragment"
https://html.spec.whatwg.org/multipage/browsing-the-web.html#scrolling-to-a-fragment
(point 10 in the second list).
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html5_polyglot/responsive.css
trunk/docutils/test/functional/expected/misc_rst_html5.html
trunk/docutils/test/functional/expected/pep_html.html
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-03-14 16:34:48 UTC (rev 9561)
+++ trunk/docutils/HISTORY.txt 2024-03-14 16:35:03 UTC (rev 9562)
@@ -162,6 +162,8 @@
(image transformations, math content conversion, ...).
- Close ``<dt>`` element in `depart_term()` to allow a
"definition_list_item" with multiple "terms" (cf. feature-request #60).
+ - Link to the document "#top" from the ToC heading
+ (unless toc_backlinks_ is False).
* docutils/writers/latex2e/__init__.py
@@ -4391,6 +4393,7 @@
.. _table_style: docs/user/config.html#table-style
.. _theme: docs/user/config.html#theme
.. _theme_url: docs/user/config.html#theme-url
+.. _toc_backlinks: docs/user/config.html#toc-backlinks
.. _traceback: docs/user/config.html#traceback
.. _use_bibtex: docs/user/config.html#use-bibtex
.. _use_latex_abstract: docs/user/config.html#use-latex-abstract
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2024-03-14 16:34:48 UTC (rev 9561)
+++ trunk/docutils/docutils/writers/_html_base.py 2024-03-14 16:35:03 UTC (rev 9562)
@@ -1745,6 +1745,10 @@
# TODO: use role="heading" or <h1>? (HTML5 only)
self.body.append(
self.starttag(node, 'p', '', CLASS='topic-title'))
+ if (self.settings.toc_backlinks
+ and 'contents' in node.parent['classes']):
+ self.body.append('<a class="reference internal" href="#top">')
+ close_tag = '</a></p>\n'
elif isinstance(node.parent, nodes.sidebar):
# TODO: use role="heading" or <h1>? (HTML5 only)
self.body.append(
@@ -1753,8 +1757,7 @@
self.body.append(
self.starttag(node, 'p', '', CLASS='admonition-title'))
elif isinstance(node.parent, nodes.table):
- self.body.append(
- self.starttag(node, 'caption', ''))
+ self.body.append(self.starttag(node, 'caption', ''))
close_tag = '</caption>\n'
elif isinstance(node.parent, nodes.document):
self.body.append(self.starttag(node, 'h1', '', CLASS='title'))
Modified: trunk/docutils/docutils/writers/html5_polyglot/responsive.css
===================================================================
--- trunk/docutils/docutils/writers/html5_polyglot/responsive.css 2024-03-14 16:34:48 UTC (rev 9561)
+++ trunk/docutils/docutils/writers/html5_polyglot/responsive.css 2024-03-14 16:35:03 UTC (rev 9562)
@@ -276,7 +276,8 @@
a:hover {
text-decoration: underline;
}
-*:hover > a.toc-backref:after {
+*:hover > a.toc-backref:after,
+.topic-title:hover > a:after {
content: " \2191"; /* ↑ UPWARDS ARROW */
color: grey;
}
Modified: trunk/docutils/test/functional/expected/misc_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/misc_rst_html5.html 2024-03-14 16:34:48 UTC (rev 9561)
+++ trunk/docutils/test/functional/expected/misc_rst_html5.html 2024-03-14 16:35:03 UTC (rev 9562)
@@ -14,7 +14,7 @@
<h1 class="title">Additional tests with HTML 5</h1>
<nav class="contents" id="contents" role="doc-toc">
-<p class="topic-title">Contents</p>
+<p class="topic-title"><a class="reference internal" href="#top">Contents</a></p>
<ul class="simple">
<li><p><a class="reference internal" href="#section-heading-levels" id="toc-entry-1">Section heading levels</a></p></li>
<li><p><a class="reference internal" href="#level-1" id="toc-entry-2">Level 1</a></p>
Modified: trunk/docutils/test/functional/expected/pep_html.html
===================================================================
--- trunk/docutils/test/functional/expected/pep_html.html 2024-03-14 16:34:48 UTC (rev 9561)
+++ trunk/docutils/test/functional/expected/pep_html.html 2024-03-14 16:35:03 UTC (rev 9562)
@@ -51,7 +51,7 @@
</table>
<hr />
<div class="contents topic" id="contents">
-<p class="topic-title">Contents</p>
+<p class="topic-title"><a class="reference internal" href="#top">Contents</a></p>
<ul class="simple">
<li><a class="reference internal" href="#abstract" id="toc-entry-1">Abstract</a></li>
<li><a class="reference internal" href="#copyright" id="toc-entry-2">Copyright</a></li>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2024-03-14 16:34:48 UTC (rev 9561)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2024-03-14 16:35:03 UTC (rev 9562)
@@ -84,7 +84,7 @@
They are transformed from section titles after parsing. -->
<!-- bibliographic fields (which also require a transform): -->
<div class="contents topic" id="table-of-contents">
-<p class="topic-title">Table of Contents</p>
+<p class="topic-title"><a class="reference internal" href="#top">Table of Contents</a></p>
<ul class="auto-toc simple">
<li><a class="reference internal" href="#structural-elements" id="toc-entry-1">1 Structural Elements</a><ul class="auto-toc">
<li><a class="reference internal" href="#section-title" id="toc-entry-2">1.1 Section Title</a></li>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2024-03-14 16:34:48 UTC (rev 9561)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2024-03-14 16:35:03 UTC (rev 9562)
@@ -83,7 +83,7 @@
They are transformed from section titles after parsing. -->
<!-- bibliographic fields (which also require a transform): -->
<nav class="contents" id="table-of-contents" role="doc-toc">
-<p class="topic-title">Table of Contents</p>
+<p class="topic-title"><a class="reference internal" href="#top">Table of Contents</a></p>
<ul class="auto-toc simple">
<li><p><a class="reference internal" href="#structural-elements" id="toc-entry-1"><span class="sectnum">1 </span>Structural Elements</a></p>
<ul class="auto-toc">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2024-03-16 16:45:24
|
Revision: 9576
http://sourceforge.net/p/docutils/code/9576
Author: grubert
Date: 2024-03-16 16:45:21 +0000 (Sat, 16 Mar 2024)
Log Message:
-----------
Skip footer to avoid the link to document source in the manpage.
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/manpage.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-03-16 16:36:35 UTC (rev 9575)
+++ trunk/docutils/HISTORY.txt 2024-03-16 16:45:21 UTC (rev 9576)
@@ -173,6 +173,7 @@
* docutils/writers/manpage.py
+ - Skip footer to avoid the link to document source in the manpage.
- Add multiple definition list term support, see feature #60.
- Add preprocessor hinting tbl first line, see bug #477.
- Change tbl-Tables using box option, see bug #475.
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2024-03-16 16:36:35 UTC (rev 9575)
+++ trunk/docutils/docutils/writers/manpage.py 2024-03-16 16:45:21 UTC (rev 9576)
@@ -698,6 +698,8 @@
def visit_footer(self, node):
self.document.reporter.warning('"footer" not supported',
base_node=node)
+ # avoid output the link to document source
+ raise nodes.SkipNode
def depart_footer(self, node):
pass
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2024-03-17 23:31:07
|
Revision: 9581
http://sourceforge.net/p/docutils/code/9581
Author: milde
Date: 2024-03-17 23:31:04 +0000 (Sun, 17 Mar 2024)
Log Message:
-----------
Fix "latex" writer broken in [r9541].
Adding the "template" setting to the list of registered
"relative paths" prevented finding the default template file
in the LATEX_WRITER_DIR.
Unfortunately, the test suite did not detect this breakage.
It seems only to happen when using the "latex" writer from the command line
(via rst2latex or docutils --writer="latex").
Modified Paths:
--------------
trunk/docutils/docs/ref/doctree.txt
trunk/docutils/docs/ref/rst/directives.txt
trunk/docutils/docutils/writers/latex2e/__init__.py
Modified: trunk/docutils/docs/ref/doctree.txt
===================================================================
--- trunk/docutils/docs/ref/doctree.txt 2024-03-17 23:30:55 UTC (rev 9580)
+++ trunk/docutils/docs/ref/doctree.txt 2024-03-17 23:31:04 UTC (rev 9581)
@@ -3936,11 +3936,13 @@
the following attributes: ids_, names_ or dupnames_, source_, and
classes_.
+In addition to the XML attribute type, the Python datatype of attribute
+values in Docutils `node` objects is stated (in parentheses).
``alt``
=======
-Attribute type: `CDATA`_. Default value: none.
+Attribute type: `CDATA`_ (str). Default value: none.
The ``alt`` attribute is used to store a text description in the
`\<image>`_ element.
@@ -3949,7 +3951,7 @@
``align``
=========
-Attribute type: `CDATA`_. Default value: none (inherit).
+Attribute type: `CDATA`_ (str). Default value: none (inherit).
The ``align`` attribute is used in the `\<figure>`_, `\<image>`_, and
`\<table>`_ elements (via the `%align-h.att;`_ and `%align-hv.att;`_
@@ -3959,7 +3961,7 @@
``anonymous``
=============
-Attribute type: `yesorno`_. Default value: none (implies no).
+Attribute type: `yesorno`_ (int). Default value: none (implies no).
The ``anonymous`` attribute is used for unnamed hyperlinks in the
`\<target>`_ and `\<reference>`_ elements (via the `%anonymous.att;`_
@@ -3969,7 +3971,7 @@
``auto``
========
-Attribute type: `CDATA`_. Default value: none.
+Attribute type: `CDATA`_ (str). Default value: none.
The ``auto`` attribute is used to indicate automatically-numbered
`\<footnote>`_, `\<footnote_reference>`_ and `\<title>`_ elements
@@ -3979,7 +3981,7 @@
``backrefs``
============
-Attribute type: `idrefs.type`_. Default value: none.
+Attribute type: `idrefs.type`_ (list[str]). Default value: none.
The ``backrefs`` attribute contains a space-separated list of identifier_
references, used for backlinks from `\<footnote>`_, `\<citation>`_, and
@@ -3989,7 +3991,7 @@
``bullet``
==========
-Attribute type: `CDATA`_. Default value: none.
+Attribute type: `CDATA`_ (str). Default value: none.
The ``bullet`` attribute is used in the `\<bullet_list>`_ element to
record the style of bullet from the input data. In documents processed
@@ -4000,10 +4002,10 @@
``classes``
===========
-Attribute type: `classnames.type`_. Default value: none.
+Attribute type: `classnames.type`_ (list[str]). Default value: none.
-The ``classes`` attribute is a space separated list containing zero or more
-`class names`_.
+The ``classes`` attribute is a space separated list containing zero or
+more `class names`_.
The purpose of the attribute is to indicate an "is-a" variant relationship,
to allow an extensible way of defining sub-classes of existing elements.
@@ -4029,7 +4031,7 @@
``colwidth``
============
-Attribute type: `CDATA`_. Default value: "1*"
+Attribute type: `CDATA`_ (int). Default value: "1*" (`sic!`__)
Column width specification used in the `\<colspec>`_ element.
Defined in the exchange-table-model_.
@@ -4044,20 +4046,17 @@
interpreted as “pt” if neither a proportion nor a fixed unit is
specified.
-.. important:: Docutils uses "CSS units" as indicated in the
- `reStructuredText specification`__: The pica is abbreviated "pc"
- and there is support for the additional units "px", "em", and "ex".
+__
- Currently, Docutils interprets unitless numbers in the ``colwidth``
- attribute as proportions.
+.. important::
+ Currently, Docutils only allows unitless integers in the ``colwidth``
+ attribute and interprets them as proportions.
- __ rst/restructuredtext.html#units
-
``delimiter``
=============
-Attribute type: `CDATA`_. Default value: none.
+Attribute type: `CDATA`_ (str). Default value: none.
The ``delimiter`` attribute is used in the `\<option_argument>`_ element
and contains the text preceding the <option_argument>: either the text
@@ -4068,7 +4067,7 @@
``dupnames``
============
-Attribute type: `refnames.type`_. Default value: none.
+Attribute type: `refnames.type`_ (list[str]). Default value: none.
``dupnames`` is one of the `common attributes`_, shared by all
Docutils elements. It replaces the `names`_ attribute when there
@@ -4086,10 +4085,10 @@
``format``
==========
-Attribute type: NMTOKENS_. Default value: none.
+Attribute type: NMTOKENS_ (str). Default value: none.
-The ``format`` attribute is a space separated list containing one or more
-output format names.
+The ``format`` attribute is a string containing one or more space
+separated output format names.
The ``format`` attribute is used in the `\<raw>`_ element.
@@ -4097,7 +4096,7 @@
``height``
==========
-Attribute type: measure_. Default value: none.
+Attribute type: measure_ (str). Default value: none.
The ``height`` attribute is used in the `\<image>`_ element.
@@ -4105,7 +4104,7 @@
``ids``
=======
-Attribute type: `ids.type`_. Default value: none.
+Attribute type: `ids.type`_ (list[str]). Default value: none.
The ``ids`` attribute is a space separated list containing one or more
unique `identifier keys`_, typically assigned by the system.
@@ -4122,7 +4121,7 @@
``level``
=========
-Attribute type: number_. Default value: none.
+Attribute type: number_ (int). Default value: none.
The ``level`` attribute is used in the `\<system_message>`_ element.
@@ -4130,7 +4129,7 @@
``ltrim``
=========
-Attribute type: `yesorno`_. Default value: none (implies no).
+Attribute type: `yesorno`_ (int). Default value: none (implies no).
The ``ltrim`` attribute is used in the `\<substitution_definition>`_ element.
@@ -4160,15 +4159,15 @@
``morecols``
============
-Attribute type: number_. Default value: none.
+Attribute type: number_ (int). Default value: none.
-The ``morecols`` attribute is used in the `\<table>`_ element.
+The ``morecols`` attribute is used in the `\<entry>`_ element.
``names``
=========
-Attribute type: `refnames.type`_. Default value: none.
+Attribute type: `refnames.type`_ (list[str]). Default value: none.
The ``names`` attribute is a space-separated list containing
`normalized`_ `reference names`_ of an element. Whitespace inside a
@@ -4197,7 +4196,7 @@
``prefix``
==========
-Attribute type: `CDATA`_. Default value: none.
+Attribute type: `CDATA`_ (str). Default value: none.
The ``prefix`` attribute is used in the `\<enumerated_list>`_ element.
@@ -4238,7 +4237,7 @@
``refuri``
==========
-Attribute type: `CDATA`_. Default value: none.
+Attribute type: `CDATA`_ (str). Default value: none.
The ``refuri`` attribute contains an external reference to a URI/URL.
It is used by the `\<target>`_, `\<reference>`_,
@@ -4249,7 +4248,7 @@
``rtrim``
=========
-Attribute type: `yesorno`_. Default value: none (implies no).
+Attribute type: `yesorno`_ (int). Default value: none (implies no).
The ``rtrim`` attribute is used in the `\<substitution_definition>`_ element.
@@ -4257,7 +4256,7 @@
``scale``
==========
-Attribute type: number_. Default value: none.
+Attribute type: number_ (int). Default value: none.
The ``scale`` attribute is used in the `\<image>`_ element to store
a uniform scaling factor (integer percentage value).
@@ -4266,7 +4265,7 @@
``source``
==========
-Attribute type: `CDATA`_. Default value: none.
+Attribute type: `CDATA`_ (str). Default value: none.
The ``source`` attribute is used to store the path or URL to the
source text that was used to produce the document tree. It is one of
@@ -4284,7 +4283,7 @@
``stub``
=========
-Attribute type: `yesorno`_. Default value: none.
+Attribute type: `yesorno`_ (int). Default value: none.
The ``stub`` attribute is used in the `\<colspec>`_ element.
It marks a table column containing *stubs* (row titles, on the left).
@@ -4294,7 +4293,7 @@
``suffix``
==========
-Attribute type: `CDATA`_. Default value: none.
+Attribute type: `CDATA`_ (str). Default value: none.
The ``suffix`` attribute is used in the `\<enumerated_list>`_ element.
@@ -4304,11 +4303,11 @@
``title``
=========
-Attribute type: `CDATA`_. Default value: none.
+Attribute type: `CDATA`_ (str). Default value: none.
The ``title`` attribute stores the *metadata title* of a `\<document>`_.
It is set by the `"title" directive`_ or the `DocTitle transform`_.
-This title is typically not part of the rendered document.
+This title is typically not part of the rendered document.
It may for example be used in HTML's ``title`` element and shown in a
browser's title bar or a page's tab.
@@ -4319,7 +4318,7 @@
``uri``
=======
-Attribute type: `CDATA`_. Default value: none.
+Attribute type: `CDATA`_ (str). Default value: none.
The ``uri`` attribute is used in the `\<image>`_ and `\<figure>`_ elements
to refer to the image via its Universal Resource Indicator.
@@ -4328,7 +4327,7 @@
``width``
==========
-Attribute type: measure_. Default value: none.
+Attribute type: measure_ (str). Default value: none.
The ``width`` attribute is used in the `\<figure>`_, `\<image>`_, and `\<table>`_ element.
@@ -4340,7 +4339,7 @@
| Default value: "preserve" (fixed).
The ``xml:space`` attribute is a standard XML attribute for
-whitespace-preserving elements. It is used by the `<address>`_,
+whitespace-preserving elements. It is used by the `\<address>`_,
`\<comment>`_, `\<doctest_block>`_, `\<literal_block>`_, `\<math_block>`_,
and `\<raw>`_ elements (via the `%fixedspace.att;`_ parameter entity).
It is a fixed attribute, meant to communicate to an XML parser that the
Modified: trunk/docutils/docs/ref/rst/directives.txt
===================================================================
--- trunk/docutils/docs/ref/rst/directives.txt 2024-03-17 23:30:55 UTC (rev 9580)
+++ trunk/docutils/docs/ref/rst/directives.txt 2024-03-17 23:31:04 UTC (rev 9581)
@@ -2194,11 +2194,9 @@
no value.
.. _integer:
- .. _list of integers:
*integer*
- integer number.
- A *list of integers* may be comma- or whitespace-separated.
+ A _`list of integers` may be comma- or whitespace-separated.
.. _length:
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2024-03-17 23:30:55 UTC (rev 9580)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2024-03-17 23:31:04 UTC (rev 9581)
@@ -274,7 +274,7 @@
# get template string from file
templatepath = Path(self.document.settings.template)
if not templatepath.exists():
- templatepath = self.default_template_path / templatepath
+ templatepath = self.default_template_path / templatepath.name
template = templatepath.read_text(encoding='utf-8')
# fill template
self.assemble_parts() # create dictionary of parts
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2024-03-24 17:40:06
|
Revision: 9584
http://sourceforge.net/p/docutils/code/9584
Author: grubert
Date: 2024-03-24 17:40:03 +0000 (Sun, 24 Mar 2024)
Log Message:
-----------
change UR/UE macros to use the dot request character
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_writers/test_manpage.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-03-24 17:26:00 UTC (rev 9583)
+++ trunk/docutils/HISTORY.txt 2024-03-24 17:40:03 UTC (rev 9584)
@@ -175,7 +175,7 @@
- Skip footer to avoid the link to document source in the manpage.
- Add multiple definition list term support, see feature #60.
- - Use ``'UR`` and ``'UE`` macros for reference markup.
+ - Use ``.UR`` and ``.UE`` macros for reference markup.
- Add preprocessor hinting tbl first line, see bug #477.
- Change tbl-Tables using box option, see bug #475.
- Apply literal block patch #205. Use ``.EE`` and ``.EX`` macros.
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2024-03-24 17:26:00 UTC (rev 9583)
+++ trunk/docutils/docutils/writers/manpage.py 2024-03-24 17:40:03 UTC (rev 9584)
@@ -1002,13 +1002,13 @@
def visit_reference(self, node):
"""E.g. link or email address."""
- self.body.append("\n'UR ")
+ self.body.append("\n.UR ")
if 'refuri' in node:
if not node['refuri'].endswith(node.astext()):
self.body.append("%s\n" % node['refuri'])
def depart_reference(self, node):
- self.body.append("\n'UE\n")
+ self.body.append("\n.UE\n")
def visit_revision(self, node):
self.visit_docinfo_item(node, 'revision')
Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py 2024-03-24 17:26:00 UTC (rev 9583)
+++ trunk/docutils/test/test_writers/test_manpage.py 2024-03-24 17:40:03 UTC (rev 9584)
@@ -195,8 +195,8 @@
.SH OTHER SECTION
.sp
link to
-'UR http://docutils.sourceforge.io
-'UE
+.UR http://docutils.sourceforge.io
+.UE
.sp
With mixed case.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|