|
From: <mi...@us...> - 2025-02-03 09:19:32
|
Revision: 10008
http://sourceforge.net/p/docutils/code/10008
Author: milde
Date: 2025-02-03 09:19:29 +0000 (Mon, 03 Feb 2025)
Log Message:
-----------
LaTeX writer: fix image path on Windows
Fixup for r9996: LaTeX expects a POSIX path.
Thanks to Alan G. Isaac for the report.
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/test_writers/test_latex2e_parts.py
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2025-01-31 10:15:44 UTC (rev 10007)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2025-02-03 09:19:29 UTC (rev 10008)
@@ -2462,7 +2462,7 @@
options = ''
if include_graphics_options:
options = f"[{','.join(include_graphics_options)}]"
- self.out.append(f'\\{cmd}{options}{{{imagepath}}}')
+ self.out.append(f'\\{cmd}{options}{{{imagepath.as_posix()}}}')
self.out.extend(post)
def depart_image(self, node) -> None:
Modified: trunk/docutils/test/test_writers/test_latex2e_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e_parts.py 2025-01-31 10:15:44 UTC (rev 10007)
+++ trunk/docutils/test/test_writers/test_latex2e_parts.py 2025-02-03 09:19:29 UTC (rev 10008)
@@ -306,12 +306,12 @@
# include images with "\includegraphics", load "graphicx" package
["""\
.. image:: blue%20square.png
-.. image:: vectors.svg
+.. image:: /images/vectors.svg
""",
{'body': r"""
\includegraphics{blue square.png}
-\includegraphics{vectors.svg}
+\includegraphics{/images/vectors.svg}
""",
'requirements': '\\usepackage[T1]{fontenc}\n'
'\\usepackage{graphicx}\n',
@@ -1039,12 +1039,12 @@
samples['svg-image'] = ({'stylesheet': 'svg'}, [
["""\
.. image:: blue%20square.png
-.. image:: vectors.svg
+.. image:: /images/vectors.svg
""",
{'body': r"""
\includegraphics{blue square.png}
-\includesvg{vectors.svg}
+\includesvg{/images/vectors.svg}
""",
'requirements': '\\usepackage[T1]{fontenc}\n'
'\\usepackage{graphicx}\n',
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-02-20 10:07:23
|
Revision: 10011
http://sourceforge.net/p/docutils/code/10011
Author: milde
Date: 2025-02-20 10:07:20 +0000 (Thu, 20 Feb 2025)
Log Message:
-----------
Fixes for metadata in LaTeX and ODT.
Just like the HTML writer, LaTeX and ODT writers now use
the `<document>` element's "title" attribute (the "metadata title",
https://docutils.sourceforge.io/docs/ref/doctree.html#title-1)
instead of its `<title>` element in the document metadata.
LaTeX writer:
Encode special characters in the content of the "meta" directive.
Fix "hyperef" keys for "creator" and "producer".
TODO:
Filter nodes with additional fields ("lang", "http-equiv", ...)?
They are HTML-specific and may override equally named keys.
Only if name already present?
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/docutils/writers/odf_odt/__init__.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-02-19 21:25:17 UTC (rev 10010)
+++ trunk/docutils/HISTORY.rst 2025-02-20 10:07:20 UTC (rev 10011)
@@ -180,6 +180,8 @@
- Support SVG image inclusion with the "svg" LaTeX package (see the
`stylesheet`__ configuration setting).
- Add "template" to the parts returned by `Writer.assemble_parts()`.
+ - Use <document> "title" attribute in pdfinfo.
+ - Encode <meta> element content in pdfinfo.
.. _reference-label: docs/user/config.html#reference-label
__ docs/user/config.html#stylesheet-latex-writers
@@ -214,6 +216,7 @@
- Fix conversion of image width in "%" if the height is specified.
- Adjust fallback DPI value (currently not used) to match CSS units.
- Fix errors with ``*.xml`` style files (bug #494).
+ - Use <document> "title" attribute in document metadata.
* pyproject.toml
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2025-02-19 21:25:17 UTC (rev 10010)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2025-02-20 10:07:20 UTC (rev 10011)
@@ -1303,7 +1303,7 @@
self.author_stack = []
self.date = []
- # PDF properties: pdftitle, pdfauthor
+ # PDF properties:
self.pdfauthor = []
self.pdfinfo = []
if settings.language_code != 'en':
@@ -2003,6 +2003,9 @@
self.requirements['babel'] = self.babel()
# * PDF properties
self.pdfsetup.append(PreambleCmds.linking % self.hyperref_options)
+ if self.document.get('title', ''):
+ self.pdfinfo.insert(0, ' pdftitle={%s},' %
+ self.encode(self.document.get('title', '')))
if self.pdfauthor:
authors = self.author_separator.join(self.pdfauthor)
self.pdfinfo.append(' pdfauthor={%s}' % authors)
@@ -2646,18 +2649,20 @@
self.duclass_close(node)
def visit_meta(self, node) -> None:
- name = node.attributes.get('name')
- content = node.attributes.get('content')
- if not name or not content:
- return
- if name in ('author', 'creator', 'keywords', 'subject', 'title'):
+ if 'name' not in node or 'content' not in node:
+ raise nodes.SkipNode # HTML specific or empty metadata
+ # TODO: Filter nodes with additional fields ("lang", "http-equiv", …)?
+ # They are HTML-specific and may override equally named keys.
+ # Only if name already present? See also ODT writer.
+ name = node['name']
+ content = self.encode(node['content'])
+ if name in ('author', 'keywords', 'producer', 'subject', 'title'):
# fields with dedicated hyperref options:
self.pdfinfo.append(' pdf%s={%s},'%(name, content))
- elif name == 'producer':
- self.pdfinfo.append(' addtopdfproducer={%s},'%content)
+ elif name == 'creator':
+ self.pdfinfo.append(' addtopdfcreator={%s},'%content)
else:
# generic interface (case sensitive!)
- # TODO: filter irrelevant nodes ("http-equiv", ...)?
self.pdfinfo.append(' pdfinfo={%s={%s}},'%(name, content))
def depart_meta(self, node) -> None:
@@ -3144,8 +3149,6 @@
if isinstance(node.parent, nodes.document):
self.push_output_collector(self.title)
self.context.append('')
- self.pdfinfo.append(' pdftitle={%s},' %
- self.encode(node.astext()))
# Topic titles (topic, admonition, sidebar)
elif (isinstance(node.parent, nodes.topic)
or isinstance(node.parent, nodes.admonition)
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2025-02-19 21:25:17 UTC (rev 10010)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2025-02-20 10:07:20 UTC (rev 10011)
@@ -747,12 +747,8 @@
el1.text = '1'
el1 = SubElement(root, 'meta:editing-duration', nsdict=METNSD)
el1.text = 'PT00M01S'
- title = self.visitor.get_title()
el1 = SubElement(root, 'dc:title', nsdict=METNSD)
- if title:
- el1.text = title
- else:
- el1.text = '[no title]'
+ el1.text = self.document.get('title', '[no title]')
for prop, value in self.visitor.get_meta_dict().items():
# 'keywords', 'description', and 'subject' have their own fields:
if prop == 'keywords':
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-02-21 23:16:33
|
Revision: 10013
http://sourceforge.net/p/docutils/code/10013
Author: milde
Date: 2025-02-21 23:16:30 +0000 (Fri, 21 Feb 2025)
Log Message:
-----------
Docinfo fixes.
Improve warning messages for problematic docinfo field content.
Use `isinstance()` instead of "name" argument to identify node type
in `LaTeXTranslator.visit_docinfo_item()`.
Keep inline markup in docinfo fields with "use_latex_docinfo".
Modified Paths:
--------------
trunk/docutils/RELEASE-NOTES.rst
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_docinfo.tex
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/test_transforms/test_docinfo.py
Modified: trunk/docutils/RELEASE-NOTES.rst
===================================================================
--- trunk/docutils/RELEASE-NOTES.rst 2025-02-21 23:16:17 UTC (rev 10012)
+++ trunk/docutils/RELEASE-NOTES.rst 2025-02-21 23:16:30 UTC (rev 10013)
@@ -163,6 +163,9 @@
* Remove the "rawsource" argument from `nodes.Text.__init__()`
in Docutils 2.0.
+* Remove the "name" argument from
+ `writers.latex2e.LaTeXTranslator.visit_docinfo_item()` in Docutils 0.24
+
* Remove attributes `nodes.Element.known_attributes`,
`nodes.Element.basic_attributes`, and `nodes.Element.local_attributes`,
in Docutils 2.0.
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2025-02-21 23:16:17 UTC (rev 10012)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2025-02-21 23:16:30 UTC (rev 10013)
@@ -453,7 +453,8 @@
f_body.children = _document.children
return True
# Check failed, add a warning
- content = [f'<{e.tagname}>' for e in f_body.children]
+ content = [f'<{e.tagname}>' for e in f_body.children
+ if not isinstance(e, nodes.system_message)]
if len(content) > 1:
content = '[' + ', '.join(content) + ']'
else:
@@ -491,7 +492,8 @@
field[-1] += self.document.reporter.warning(
f'Cannot extract "{name}" from bibliographic field:\n'
f'Bibliographic field "{name}" must contain either\n'
- ' a single paragraph (with author names separated by one of '
+ ' a single paragraph (with author names separated by a'
+ ' character from the set '
f'"{"".join(self.language.author_separators)}"),\n'
' multiple paragraphs (one per author),\n'
' or a bullet list with one author name per item.\n'
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2025-02-21 23:16:17 UTC (rev 10012)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2025-02-21 23:16:30 UTC (rev 10013)
@@ -1690,7 +1690,7 @@
self.depart_inline(node)
def visit_address(self, node) -> None:
- self.visit_docinfo_item(node, 'address')
+ self.visit_docinfo_item(node)
def depart_address(self, node) -> None:
self.depart_docinfo_item(node)
@@ -1721,7 +1721,7 @@
def visit_author(self, node) -> None:
self.pdfauthor.append(self.attval(node.astext()))
- self.visit_docinfo_item(node, 'author')
+ self.visit_docinfo_item(node)
def depart_author(self, node) -> None:
self.depart_docinfo_item(node)
@@ -1873,7 +1873,7 @@
self.duclass_close(node)
def visit_contact(self, node) -> None:
- self.visit_docinfo_item(node, 'contact')
+ self.visit_docinfo_item(node)
def depart_contact(self, node) -> None:
self.depart_docinfo_item(node)
@@ -1885,13 +1885,13 @@
self.duclass_close(node)
def visit_copyright(self, node) -> None:
- self.visit_docinfo_item(node, 'copyright')
+ self.visit_docinfo_item(node)
def depart_copyright(self, node) -> None:
self.depart_docinfo_item(node)
def visit_date(self, node) -> None:
- self.visit_docinfo_item(node, 'date')
+ self.visit_docinfo_item(node)
def depart_date(self, node) -> None:
self.depart_docinfo_item(node)
@@ -1949,38 +1949,45 @@
self.docinfo.append('\\end{tabularx}\n'
'\\end{center}\n')
- def visit_docinfo_item(self, node, name):
- if self.use_latex_docinfo:
- if name in ('author', 'organization', 'contact', 'address'):
- # We attach these to the last author. If any of them precedes
+ def visit_docinfo_item(self, node, name=None) -> None:
+ # auxiliary method, called by the visitors of "bibliographic elements"
+ if name is not None:
+ warnings.warn('visit_docinfo_item(): argument "name" is obsolete'
+ ' and will be removed in Docutils 0.24',
+ DeprecationWarning, stacklevel=2)
+ if isinstance(node, nodes.address):
+ self.insert_newline = True # preserve newlines
+ if self.use_latex_docinfo and isinstance(
+ node, (nodes.address, nodes.author, nodes.contact,
+ nodes.date, nodes.organization)):
+ self.push_output_collector([]) # see depart_docinfo_item()
+ else:
+ self.out.append('\\textbf{%s}: &\n\t'
+ % self.language_label(node.tagname))
+ if isinstance(node, nodes.address):
+ self.out.append('{\\raggedright\n')
+
+ def depart_docinfo_item(self, node) -> None:
+ self.insert_newline = False # reset change with <address> node
+ if self.use_latex_docinfo and isinstance(
+ node, (nodes.address, nodes.author, nodes.contact,
+ nodes.date, nodes.organization)):
+ text = ''.join(self.out)
+ self.pop_output_collector()
+ if isinstance(node, nodes.date):
+ self.date.append(text)
+ else:
+ # Attach to the last author. If any of them precedes
# the first author, put them in a separate "author" group
# (in lack of better semantics).
- if name == 'author' or not self.author_stack:
+ if isinstance(node, nodes.author) or not self.author_stack:
self.author_stack.append([])
- if name == 'address': # newlines are meaningful
- self.insert_newline = True
- text = self.encode(node.astext())
- self.insert_newline = False
- else:
- text = self.attval(node.astext())
self.author_stack[-1].append(text)
- raise nodes.SkipNode
- elif name == 'date':
- self.date.append(self.attval(node.astext()))
- raise nodes.SkipNode
- self.out.append('\\textbf{%s}: &\n\t' % self.language_label(name))
- if name == 'address':
- self.insert_newline = True
- self.out.append('{\\raggedright\n')
- self.context.append(' } \\\\\n')
else:
- self.context.append(' \\\\\n')
+ if isinstance(node, nodes.address):
+ self.out.append(' }')
+ self.out.append(' \\\\\n')
- def depart_docinfo_item(self, node) -> None:
- self.out.append(self.context.pop())
- # for address we did set insert_newline
- self.insert_newline = False
-
def visit_doctest_block(self, node) -> None:
self.visit_literal_block(node)
@@ -2751,7 +2758,7 @@
pass
def visit_organization(self, node) -> None:
- self.visit_docinfo_item(node, 'organization')
+ self.visit_docinfo_item(node)
def depart_organization(self, node) -> None:
self.depart_docinfo_item(node)
@@ -2864,7 +2871,7 @@
self.out.append('\n')
def visit_revision(self, node) -> None:
- self.visit_docinfo_item(node, 'revision')
+ self.visit_docinfo_item(node)
def depart_revision(self, node) -> None:
self.depart_docinfo_item(node)
@@ -2944,7 +2951,7 @@
self.out.append(self.context.pop() + '\n')
def visit_status(self, node) -> None:
- self.visit_docinfo_item(node, 'status')
+ self.visit_docinfo_item(node)
def depart_status(self, node) -> None:
self.depart_docinfo_item(node)
@@ -3343,7 +3350,7 @@
pass
def visit_version(self, node) -> None:
- self.visit_docinfo_item(node, 'version')
+ self.visit_docinfo_item(node)
def depart_version(self, node) -> None:
self.depart_docinfo_item(node)
Modified: trunk/docutils/test/functional/expected/latex_docinfo.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_docinfo.tex 2025-02-21 23:16:17 UTC (rev 10012)
+++ trunk/docutils/test/functional/expected/latex_docinfo.tex 2025-02-21 23:16:30 UTC (rev 10013)
@@ -29,7 +29,7 @@
\title{}
\author{Foo Fred\\
Food Foomatics \& Friends\\
-fo...@fo...\\
+\href{mailto:fo...@fo...}{fo...@fo...}\\
Fox St 13\\
Foowood \and
Bar Barney\\
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2025-02-21 23:16:17 UTC (rev 10012)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2025-02-21 23:16:30 UTC (rev 10013)
@@ -205,12 +205,12 @@
123 Example Street\\
Example, EX Canada\\
A1B 2C3\\
-go...@py... \and
+\href{mailto:go...@py...}{go...@py...} \and
Me \and
Myself \and
I\\
humankind}
-\date{Now, or yesterday. Or maybe even before yesterday.}
+\date{Now, or yesterday. Or maybe even \emph{before} yesterday.}
%%% Body
\begin{document}
Modified: trunk/docutils/test/test_transforms/test_docinfo.py
===================================================================
--- trunk/docutils/test/test_transforms/test_docinfo.py 2025-02-21 23:16:17 UTC (rev 10012)
+++ trunk/docutils/test/test_transforms/test_docinfo.py 2025-02-21 23:16:30 UTC (rev 10013)
@@ -360,7 +360,7 @@
<paragraph>
Cannot extract "Authors" from bibliographic field:
Bibliographic field "Authors" must contain either
- a single paragraph (with author names separated by one of ";,"),
+ a single paragraph (with author names separated by a character from the set ";,"),
multiple paragraphs (one per author),
or a bullet list with one author name per item.
Note: Leading initials can cause (mis)recognizing names as enumerated list.
@@ -375,7 +375,7 @@
<paragraph>
Cannot extract "Authors" from bibliographic field:
Bibliographic field "Authors" must contain either
- a single paragraph (with author names separated by one of ";,"),
+ a single paragraph (with author names separated by a character from the set ";,"),
multiple paragraphs (one per author),
or a bullet list with one author name per item.
Note: Leading initials can cause (mis)recognizing names as enumerated list.
@@ -393,7 +393,7 @@
<paragraph>
Cannot extract "Authors" from bibliographic field:
Bibliographic field "Authors" must contain either
- a single paragraph (with author names separated by one of ";,"),
+ a single paragraph (with author names separated by a character from the set ";,"),
multiple paragraphs (one per author),
or a bullet list with one author name per item.
Note: Leading initials can cause (mis)recognizing names as enumerated list.
@@ -411,7 +411,7 @@
<paragraph>
Cannot extract "Authors" from bibliographic field:
Bibliographic field "Authors" must contain either
- a single paragraph (with author names separated by one of ";,"),
+ a single paragraph (with author names separated by a character from the set ";,"),
multiple paragraphs (one per author),
or a bullet list with one author name per item.
Note: Leading initials can cause (mis)recognizing names as enumerated list.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-03-06 08:40:52
|
Revision: 10016
http://sourceforge.net/p/docutils/code/10016
Author: milde
Date: 2025-03-06 08:40:49 +0000 (Thu, 06 Mar 2025)
Log Message:
-----------
Improve formatting of LaTeX source for bibliographic fields.
The generated PDF is unchanged.
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
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/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-05 17:06:53 UTC (rev 10015)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-06 08:40:49 UTC (rev 10016)
@@ -1962,10 +1962,14 @@
nodes.date, nodes.organization)):
self.push_output_collector([]) # see depart_docinfo_item()
else:
- self.out.append('\\textbf{%s}: &\n\t'
- % self.language_label(node.tagname))
+ label = self.language_label(node.tagname)
+ self.out.append('\\textbf{%s}: &' % label)
if isinstance(node, nodes.address):
- self.out.append('{\\raggedright\n')
+ self.out.append(' {\\raggedright\n')
+ elif len(label) + len(node.astext()) > 64:
+ self.out.append('\n ')
+ else:
+ self.out.append(' ')
def depart_docinfo_item(self, node) -> None:
self.insert_newline = False # reset change with <address> node
@@ -1985,7 +1989,7 @@
self.author_stack[-1].append(text)
else:
if isinstance(node, nodes.address):
- self.out.append(' }')
+ self.out.append('}')
self.out.append(' \\\\\n')
def visit_doctest_block(self, node) -> None:
Modified: trunk/docutils/test/functional/expected/latex_leavevmode.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_leavevmode.tex 2025-03-05 17:06:53 UTC (rev 10015)
+++ trunk/docutils/test/functional/expected/latex_leavevmode.tex 2025-03-06 08:40:49 UTC (rev 10016)
@@ -162,14 +162,11 @@
% Docinfo
\begin{center}
\begin{tabularx}{\DUdocinfowidth}{lX}
-\textbf{Author}: &
- Hänsel \\
-\textbf{Author}: &
- Gretel \\
-\textbf{Address}: &
- {\raggedright
+\textbf{Author}: & Hänsel \\
+\textbf{Author}: & Gretel \\
+\textbf{Address}: & {\raggedright
123 Example Street\\
-Example, EX Canada } \\
+Example, EX Canada} \\
\textbf{Generic Docinfo List Field}: &
\begin{itemize}
\item This is a list.
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2025-03-05 17:06:53 UTC (rev 10015)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2025-03-06 08:40:49 UTC (rev 10016)
@@ -221,14 +221,11 @@
% Docinfo
\begin{center}
\begin{tabularx}{\DUdocinfowidth}{lX}
-\textbf{Status}: &
- This is a \textquotedbl{}work in progress\textquotedbl{} \\
-\textbf{Revision}: &
- is managed by a version control system. \\
-\textbf{Version}: &
- 1 \\
+\textbf{Status}: & This is a \textquotedbl{}work in progress\textquotedbl{} \\
+\textbf{Revision}: & is managed by a version control system. \\
+\textbf{Version}: & 1 \\
\textbf{Copyright}: &
- This document has been placed in the public domain. You
+ This document has been placed in the public domain. You
may do with it as you wish. You may copy, modify,
redistribute, reattribute, sell, buy, rent, lease,
destroy, or improve it, quote it at length, excerpt,
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2025-03-05 17:06:53 UTC (rev 10015)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2025-03-06 08:40:49 UTC (rev 10016)
@@ -209,33 +209,22 @@
% Docinfo
\begin{center}
\begin{tabularx}{\DUdocinfowidth}{lX}
-\textbf{Author}: &
- David Goodger \\
-\textbf{Address}: &
- {\raggedright
+\textbf{Author}: & David Goodger \\
+\textbf{Address}: & {\raggedright
123 Example Street\\
Example, EX Canada\\
-A1B 2C3 } \\
-\textbf{Contact}: &
- \href{mailto:go...@py...}{go...@py...} \\
-\textbf{Author}: &
- Me \\
-\textbf{Author}: &
- Myself \\
-\textbf{Author}: &
- I \\
-\textbf{Organization}: &
- humankind \\
-\textbf{Date}: &
- Now, or yesterday. Or maybe even \emph{before} yesterday. \\
-\textbf{Status}: &
- This is a “work in progress” \\
-\textbf{Revision}: &
- is managed by a version control system. \\
-\textbf{Version}: &
- 1 \\
+A1B 2C3} \\
+\textbf{Contact}: & \href{mailto:go...@py...}{go...@py...} \\
+\textbf{Author}: & Me \\
+\textbf{Author}: & Myself \\
+\textbf{Author}: & I \\
+\textbf{Organization}: & humankind \\
+\textbf{Date}: & Now, or yesterday. Or maybe even \emph{before} yesterday. \\
+\textbf{Status}: & This is a “work in progress” \\
+\textbf{Revision}: & is managed by a version control system. \\
+\textbf{Version}: & 1 \\
\textbf{Copyright}: &
- This document has been placed in the public domain. You
+ This document has been placed in the public domain. You
may do with it as you wish. You may copy, modify,
redistribute, reattribute, sell, buy, rent, lease,
destroy, or improve it, quote it at length, excerpt,
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2025-03-05 17:06:53 UTC (rev 10015)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2025-03-06 08:40:49 UTC (rev 10016)
@@ -76,33 +76,22 @@
% Docinfo
\begin{center}
\begin{tabularx}{\DUdocinfowidth}{lX}
-\textbf{Author}: &
- David Goodger \\
-\textbf{Address}: &
- {\raggedright
+\textbf{Author}: & David Goodger \\
+\textbf{Address}: & {\raggedright
123 Example Street\\
Example, EX Canada\\
-A1B 2C3 } \\
-\textbf{Contact}: &
- \href{mailto:go...@py...}{go...@py...} \\
-\textbf{Author}: &
- Me \\
-\textbf{Author}: &
- Myself \\
-\textbf{Author}: &
- I \\
-\textbf{Organization}: &
- humankind \\
-\textbf{Date}: &
- Now, or yesterday. Or maybe even \emph{before} yesterday. \\
-\textbf{Status}: &
- This is a “work in progress” \\
-\textbf{Revision}: &
- is managed by a version control system. \\
-\textbf{Version}: &
- 1 \\
+A1B 2C3} \\
+\textbf{Contact}: & \href{mailto:go...@py...}{go...@py...} \\
+\textbf{Author}: & Me \\
+\textbf{Author}: & Myself \\
+\textbf{Author}: & I \\
+\textbf{Organization}: & humankind \\
+\textbf{Date}: & Now, or yesterday. Or maybe even \emph{before} yesterday. \\
+\textbf{Status}: & This is a “work in progress” \\
+\textbf{Revision}: & is managed by a version control system. \\
+\textbf{Version}: & 1 \\
\textbf{Copyright}: &
- This document has been placed in the public domain. You
+ This document has been placed in the public domain. You
may do with it as you wish. You may copy, modify,
redistribute, reattribute, sell, buy, rent, lease,
destroy, or improve it, quote it at length, excerpt,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-03-06 08:41:14
|
Revision: 10017
http://sourceforge.net/p/docutils/code/10017
Author: milde
Date: 2025-03-06 08:41:10 +0000 (Thu, 06 Mar 2025)
Log Message:
-----------
Fix LaTeX docinfo handling of affiliation fields preceding author field.
With "use_latex_docinfo", the content of the bibliographic fields
"address", "contact", and "organization" is attached to the author name.
Reserve the first position for the author name instead of creating an
"author info" list without author if any of these fields appeares before
an "author" or "authors" field.
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/docs/ref/doctree.rst
trunk/docutils/docs/ref/rst/restructuredtext.rst
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/test_writers/test_latex2e_parts.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-03-06 08:40:49 UTC (rev 10016)
+++ trunk/docutils/HISTORY.rst 2025-03-06 08:41:10 UTC (rev 10017)
@@ -189,6 +189,8 @@
and`LaTeXTranslator.fallbacks`.
- Use <document> "title" attribute in pdfinfo.
- Encode <meta> element content in pdfinfo.
+ - Improve docinfo handling with "use_latex_docinfo".
+ - `LaTeXTranslator.pop_output_collector() now returns the popped list.
.. _reference-label: docs/user/config.html#reference-label
__ docs/user/config.html#stylesheet-latex-writers
Modified: trunk/docutils/docs/ref/doctree.rst
===================================================================
--- trunk/docutils/docs/ref/doctree.rst 2025-03-06 08:40:49 UTC (rev 10016)
+++ trunk/docutils/docs/ref/doctree.rst 2025-03-06 08:41:10 UTC (rev 10017)
@@ -611,7 +611,7 @@
Examples
--------
-In reStructuredText, "authors" is one of the registered
+In reStructuredText, the `"authors" field`_ is one of the registered
`bibliographic fields`_::
Document Title
@@ -631,10 +631,8 @@
<author>
Jane Doe
-In reStructuredText, multiple author's names are separated with
-semicolons (";") or commas (","); semicolons take precedence.
-There is currently no way to represent the author's organization,
-address, or contact in a reStructuredText "Authors" field.
+There is currently no way to represent an individual author's <organization>,
+<address>, or <contact> in a reStructuredText `"authors" field`_.
See `\<docinfo>`_ for a more complete example, including processing
context.
@@ -5221,6 +5219,7 @@
.. _auto-symbol: rst/restructuredtext.html#auto-symbol-footnotes
.. _bibliographic data:
.. _bibliographic fields: rst/restructuredtext.html#bibliographic-fields
+.. _"authors" field: rst/restructuredtext.html#authors
.. _block quote: rst/restructuredtext.html#block-quotes
.. _bullet list: rst/restructuredtext.html#bullet-lists
.. _CSS3 length units: rst/restructuredtext.html#length-units
Modified: trunk/docutils/docs/ref/rst/restructuredtext.rst
===================================================================
--- trunk/docutils/docs/ref/rst/restructuredtext.rst 2025-03-06 08:40:49 UTC (rev 10016)
+++ trunk/docutils/docs/ref/rst/restructuredtext.rst 2025-03-06 08:41:10 UTC (rev 10017)
@@ -1003,12 +1003,12 @@
=================== ================
.. compound::
- The "Authors" field may contain
+ The "_`Authors`" field may contain
* a single paragraph consisting of a list of authors, separated by
``;`` or ``,`` (``;`` is checked first, so ``Doe, Jane; Doe,
- John`` will work.) [#i18n]_
- * multiple paragraphs (one per author) or
+ John`` will work), [#i18n]_
+ * multiple paragraphs (one per author), or
* a bullet list whose elements each contain a single paragraph per author.
In some languages (e.g. Swedish), there is no singular/plural distinction
@@ -1017,6 +1017,11 @@
contains a comma, end it with a semicolon to disambiguate:
``:Författare: Doe, Jane;``.
+ There is currently no way to represent an individual author's
+ organization or contact info in a reStructuredText "Authors" field.
+ However, you may use an "Author" field followed by
+ "Organization", "Address", and/or "Contact" for each author.
+
The "Address" field is for a multi-line surface mailing address.
Newlines and whitespace will be preserved.
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-06 08:40:49 UTC (rev 10016)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-06 08:41:10 UTC (rev 10017)
@@ -1193,6 +1193,10 @@
literal = False # literal text (block or inline)
alltt = False # inside `alltt` environment
+ # Nodes affected by "use_latex_docinfo" setting:
+ LATEX_DOCINFO_NODES = (nodes.address, nodes.author, nodes.contact,
+ nodes.date, nodes.organization)
+
def __init__(self, document, babel_class=Babel) -> None:
super().__init__(document)
# Reporter
@@ -1298,9 +1302,8 @@
# Title metadata:
self.title_labels = []
self.subtitle_labels = []
- # (if use_latex_docinfo: collects lists of
- # author/organization/contact/address lines)
- self.author_stack = []
+ # with "use_latex_docinfo", we also need
+ self.author_stack = [['']] # first item reserved for author name
self.date = []
# PDF properties:
@@ -1636,12 +1639,14 @@
self.fallbacks['DUclass'] = PreambleCmds.duclass
self.out.append('\\end{DUclass}\n')
- def push_output_collector(self, new_out) -> None:
+ def push_output_collector(self, new_out: list) -> None:
self.out_stack.append(self.out)
self.out = new_out
- def pop_output_collector(self) -> None:
+ def pop_output_collector(self) -> list:
+ old_out = self.out
self.out = self.out_stack.pop()
+ return old_out
def term_postfix(self, node):
"""
@@ -1957,9 +1962,8 @@
DeprecationWarning, stacklevel=2)
if isinstance(node, nodes.address):
self.insert_newline = True # preserve newlines
- if self.use_latex_docinfo and isinstance(
- node, (nodes.address, nodes.author, nodes.contact,
- nodes.date, nodes.organization)):
+ if self.use_latex_docinfo and isinstance(node,
+ self.LATEX_DOCINFO_NODES):
self.push_output_collector([]) # see depart_docinfo_item()
else:
label = self.language_label(node.tagname)
@@ -1973,19 +1977,21 @@
def depart_docinfo_item(self, node) -> None:
self.insert_newline = False # reset change with <address> node
- if self.use_latex_docinfo and isinstance(
- node, (nodes.address, nodes.author, nodes.contact,
- nodes.date, nodes.organization)):
- text = ''.join(self.out)
- self.pop_output_collector()
+ if self.use_latex_docinfo and isinstance(node,
+ self.LATEX_DOCINFO_NODES):
+ # Collect date and author info for use in `self.make_title()`:
+ text = ''.join(self.pop_output_collector())
if isinstance(node, nodes.date):
self.date.append(text)
+ elif isinstance(node, nodes.author):
+ # Insert author name as first item of an "author info" list.
+ # If author name already set, start a new list.
+ if self.author_stack[-1][0]:
+ self.author_stack.append([text])
+ else:
+ self.author_stack[-1][0] = text
else:
- # Attach to the last author. If any of them precedes
- # the first author, put them in a separate "author" group
- # (in lack of better semantics).
- if isinstance(node, nodes.author) or not self.author_stack:
- self.author_stack.append([])
+ # Append affiliation/contact info to current "author info".
self.author_stack[-1].append(text)
else:
if isinstance(node, nodes.address):
@@ -2023,8 +2029,7 @@
if self.pdfinfo:
self.pdfsetup += [r'\hypersetup{'] + self.pdfinfo + ['}']
# * title (including author(s) and date if using "latex_docinfo")
- if self.title or (self.use_latex_docinfo
- and (self.author_stack or self.date)):
+ if self.title or self.date or self.author_stack != [['']]:
self.make_title() # see below
# * bibliography
if self._bibitems:
@@ -2042,11 +2047,12 @@
def make_title(self) -> None:
# Auxiliary function called by `self.depart_document()`.
#
- # Append ``\title``, ``\author``, and ``\date`` to "titledata".
- # (We need all three, even if empty, to prevent errors
- # and/or automatic display of the current date by \maketitle.)
- # Append ``\maketitle`` to "body_pre_docinfo" parts.
- #
+ # The document title is stored in the "titledata" document part.
+ # Date and author info is included with "use_latex_docinfo".
+ # However, we need the ``\title``, ``\author``, and ``\date``
+ # macros even if empty, to prevent errors and/or automatic
+ # display of the current date by ``\maketitle``.
+
# \title
title_arg = [''.join(self.title)] # ensure len == 1
if self.title:
@@ -2057,15 +2063,16 @@
] + self.subtitle_labels
self.titledata.append(r'\title{%s}' % '%\n '.join(title_arg))
# \author
- author_arg = ['\\\\\n'.join(author_entry)
- for author_entry in self.author_stack]
- self.titledata.append(r'\author{%s}' %
- ' \\and\n'.join(author_arg))
+ # author name(s) and optional affiliation and contact info
+ # cf. https://tex.stackexchange.com/a/377030/288060.
+ authors = ['\\\\\n'.join((field for field in author_entry if field))
+ for author_entry in self.author_stack]
+ self.titledata.append(r'\author{%s}' % ' \\and\n'.join(authors))
# \date
self.titledata.append(r'\date{%s}' % ', '.join(self.date))
# \maketitle
- # Must be in the document body. We add it to `body_pre_docinfo`
- # to allow templates to put `titledata` into the document preamble.
+ # Must be in the document body. Append to "body_pre_docinfo" part
+ # so templates may use the "titledata" part in the document preamble.
self.body_pre_docinfo.append('\\maketitle\n')
def append_bibliogaphy(self) -> None:
Modified: trunk/docutils/test/test_writers/test_latex2e_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e_parts.py 2025-03-06 08:40:49 UTC (rev 10016)
+++ trunk/docutils/test/test_writers/test_latex2e_parts.py 2025-03-06 08:41:10 UTC (rev 10017)
@@ -687,7 +687,6 @@
\date{}
"""
}],
-
# template
["""\
""",
@@ -694,7 +693,46 @@
{'body': '',
'requirements': '\\usepackage[T1]{fontenc}\n'
}],
+# bibliographic fields
+["""
+:contact: here@home
+:organization: Example & Cie.
+:author: Mr. Smith
+:date: yesterday
+:address: 0231 Abendglanz
+ Milky Way 23 b
+""",
+ {'requirements': '\\usepackage[T1]{fontenc}\n'
+ '\\usepackage{tabularx}\n',
+ 'fallbacks': r"""
+% Provide a length variable and set default, if it is new
+\providecommand*{\DUprovidelength}[2]{%
+ \ifdefined#1
+ \else
+ \newlength{#1}\setlength{#1}{#2}%
+ \fi
+}
+% width of docinfo table
+\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
+""",
+ 'pdfsetup': DEFAULT_PARTS['pdfsetup']
+ + '\\hypersetup{\n pdfauthor={Mr. Smith}\n}\n',
+ 'docinfo': r"""
+% Docinfo
+\begin{center}
+\begin{tabularx}{\DUdocinfowidth}{lX}
+\textbf{Contact}: & \href{mailto:here@home}{here@home} \\
+\textbf{Organization}: & Example \& Cie. \\
+\textbf{Author}: & Mr. Smith \\
+\textbf{Date}: & yesterday \\
+\textbf{Address}: & {\raggedright
+0231 Abendglanz\\
+Milky Way 23 b} \\
+\end{tabularx}
+\end{center}
+""",
+ }],
])
samples['book'] = ({'documentclass': 'book'}, [
@@ -942,7 +980,60 @@
}],
])
+samples['LaTeX docinfo'] = ({'use_latex_docinfo': True}, [
+# bibliographic fields
+["""
+:contact: here@home
+:organization: Example & Cie.
+:author: Mr. Smith
+:date: yesterday
+:address: 0231 Abendglanz
+ Milky Way 23 b
+""",
+ {'pdfsetup': DEFAULT_PARTS['pdfsetup']
+ + '\\hypersetup{\n pdfauthor={Mr. Smith}\n}\n',
+ 'titledata': r"""\title{}
+\author{Mr. Smith\\
+\href{mailto:here@home}{here@home}\\
+Example \& Cie.\\
+0231 Abendglanz\\
+Milky Way 23 b}
+\date{yesterday}
+""",
+ 'body_pre_docinfo': '\\maketitle\n',
+ }],
+# bibliographic fields
+["""
+:keywords: custom, docinfo, field
+""",
+ {'requirements': '\\usepackage[T1]{fontenc}\n'
+ '\\usepackage{tabularx}\n',
+ 'fallbacks': r"""
+% Provide a length variable and set default, if it is new
+\providecommand*{\DUprovidelength}[2]{%
+ \ifdefined#1
+ \else
+ \newlength{#1}\setlength{#1}{#2}%
+ \fi
+}
+% width of docinfo table
+\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
+""",
+ 'docinfo': r"""
+% Docinfo
+\begin{center}
+\begin{tabularx}{\DUdocinfowidth}{lX}
+\textbf{keywords}: &
+custom, docinfo, field
+\\
+\end{tabularx}
+\end{center}
+""",
+ }],
+])
+
+
samples['embed_stylesheet'] = ({'stylesheet_path': f'{spam},{ham}',
'embed_stylesheet': True,
'warning_stream': ''}, [
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aa-...@us...> - 2025-03-07 22:58:49
|
Revision: 10020
http://sourceforge.net/p/docutils/code/10020
Author: aa-turner
Date: 2025-03-07 22:58:36 +0000 (Fri, 07 Mar 2025)
Log Message:
-----------
Remove trailing whitespace
Modified Paths:
--------------
trunk/docutils/docs/dev/repository.rst
trunk/docutils/docs/dev/website.rst
trunk/docutils/test/data/config_list_2.rst
trunk/docutils/test/functional/input/rst_html5_tuftig.rst
Modified: trunk/docutils/docs/dev/repository.rst
===================================================================
--- trunk/docutils/docs/dev/repository.rst 2025-03-07 22:49:46 UTC (rev 10019)
+++ trunk/docutils/docs/dev/repository.rst 2025-03-07 22:58:36 UTC (rev 10020)
@@ -147,7 +147,7 @@
__ https://pip.pypa.io/en/stable/topics/local-project-installs/
#editable-installs
-
+
.. _manual install:
2. Install "manually".
Modified: trunk/docutils/docs/dev/website.rst
===================================================================
--- trunk/docutils/docs/dev/website.rst 2025-03-07 22:49:46 UTC (rev 10019)
+++ trunk/docutils/docs/dev/website.rst 2025-03-07 22:58:36 UTC (rev 10020)
@@ -61,7 +61,7 @@
once to create the directories in the filesystem before preparing for
HTML processing.
-#. Any .html document with a corresponding .rst/.txt file is regenerated
+#. Any .html document with a corresponding .rst/.txt file is regenerated
if the .rst/.txt has changed, but no new .html files will be generated.
Therefore *touch* the .html-file and then the .rst/.txt.
Modified: trunk/docutils/test/data/config_list_2.rst
===================================================================
--- trunk/docutils/test/data/config_list_2.rst 2025-03-07 22:49:46 UTC (rev 10019)
+++ trunk/docutils/test/data/config_list_2.rst 2025-03-07 22:58:36 UTC (rev 10020)
@@ -3,9 +3,9 @@
strip-classes: ham, eggs
strip-elements-with-classes: eggs,salt
# `stylesheet` overrides earlier `stylesheet` and `stylesheet_path` settings
-stylesheet: style2.css,
+stylesheet: style2.css,
style3.css
-smartquotes-locales: nl: „”’’,
+smartquotes-locales: nl: „”’’,
cs: »«›‹
[html4css1 writer]
Modified: trunk/docutils/test/functional/input/rst_html5_tuftig.rst
===================================================================
--- trunk/docutils/test/functional/input/rst_html5_tuftig.rst 2025-03-07 22:49:46 UTC (rev 10019)
+++ trunk/docutils/test/functional/input/rst_html5_tuftig.rst 2025-03-07 22:58:36 UTC (rev 10020)
@@ -24,7 +24,7 @@
.. table:: A fullwidth table with LaTeX math commands
- :class: numbered colwidths-auto fullwidth
+ :class: numbered colwidths-auto fullwidth
========= =========== ========= =========== ============= ================
`\arccos` ``\arccos`` `\gcd` ``\gcd`` `\Pr` ``\Pr``
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aa-...@us...> - 2025-03-08 01:31:42
|
Revision: 10027
http://sourceforge.net/p/docutils/code/10027
Author: aa-turner
Date: 2025-03-08 01:31:27 +0000 (Sat, 08 Mar 2025)
Log Message:
-----------
Resolve Ruff lint warnings
Use the ``ET`` import alias for ``xml.etree.ElementTree``.
Modified Paths:
--------------
trunk/docutils/docutils/writers/odf_odt/__init__.py
trunk/docutils/docutils/writers/odf_odt/prepstyles.py
trunk/docutils/test/test_writers/test_odt.py
Modified: trunk/docutils/docutils/writers/odf_odt/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/__init__.py 2025-03-08 01:26:07 UTC (rev 10026)
+++ trunk/docutils/docutils/writers/odf_odt/__init__.py 2025-03-08 01:31:27 UTC (rev 10027)
@@ -26,7 +26,7 @@
import time
import urllib
import weakref
-from xml.etree import ElementTree as etree
+from xml.etree import ElementTree as ET
from xml.dom import minidom
import zipfile
@@ -65,10 +65,10 @@
# that support for the ability to get the parent of an element.
#
_parents = weakref.WeakKeyDictionary()
-if isinstance(etree.Element, type):
- _ElementInterface = etree.Element
+if isinstance(ET.Element, type):
+ _ElementInterface = ET.Element
else:
- _ElementInterface = etree._ElementInterface
+ _ElementInterface = ET._ElementInterface
class _ElementInterfaceWrapper(_ElementInterface):
@@ -570,7 +570,7 @@
updated, new_dom_styles, updated_node = self.update_stylesheet(
self.visitor.get_dom_stylesheet(), language_code, region_code)
if updated:
- s1 = etree.tostring(new_dom_styles)
+ s1 = ET.tostring(new_dom_styles)
self.write_zip_str(zfile, 'styles.xml', s1)
self.store_embedded_files(zfile)
self.copy_from_stylesheet(zfile)
@@ -696,7 +696,7 @@
attrib=MANIFEST_NAMESPACE_ATTRIB,
nsdict=MANIFEST_NAMESPACE_DICT,
)
- doc = etree.ElementTree(root)
+ doc = ET.ElementTree(root)
SubElement(root, 'manifest:file-entry', attrib={
'manifest:media-type': self.MIME_TYPE,
'manifest:full-path': '/',
@@ -727,7 +727,7 @@
attrib=META_NAMESPACE_ATTRIB,
nsdict=META_NAMESPACE_DICT,
)
- doc = etree.ElementTree(root)
+ doc = ET.ElementTree(root)
root = SubElement(root, 'office:meta', nsdict=METNSD)
el1 = SubElement(root, 'meta:generator', nsdict=METNSD)
el1.text = 'Docutils/rst2odf.py/%s' % (VERSION, )
@@ -861,7 +861,7 @@
'office:document-content',
attrib=CONTENT_NAMESPACE_ATTRIB,
)
- self.content_tree = etree.ElementTree(element=root)
+ self.content_tree = ET.ElementTree(element=root)
self.current_element = root
SubElement(root, 'office:scripts')
SubElement(root, 'office:font-face-decls')
@@ -940,16 +940,16 @@
'.xml file' % (stylespath, extension))
self.str_stylesheet = s1
self.str_stylesheetcontent = s2
- self.dom_stylesheet = etree.fromstring(self.str_stylesheet)
+ self.dom_stylesheet = ET.fromstring(self.str_stylesheet)
if not s2:
return
# TODO: dom_stylesheetcontent is never used. Remove?
- self.dom_stylesheetcontent = etree.fromstring(
+ self.dom_stylesheetcontent = ET.fromstring(
self.str_stylesheetcontent)
self.table_styles = self.extract_table_styles(s2)
def extract_table_styles(self, styles_str):
- root = etree.fromstring(styles_str)
+ root = ET.fromstring(styles_str)
table_styles = {}
auto_styles = root.find(
'{%s}automatic-styles' % (CNSD['office'], ))
@@ -1051,7 +1051,7 @@
or self.settings.custom_header
or self.settings.custom_footer):
self.add_header_footer(self.dom_stylesheet)
- return etree.tostring(self.dom_stylesheet)
+ return ET.tostring(self.dom_stylesheet)
def get_dom_stylesheet(self):
return self.dom_stylesheet
@@ -1434,7 +1434,7 @@
def astext(self):
root = self.content_tree.getroot()
- et = etree.ElementTree(root)
+ et = ET.ElementTree(root)
return ToString(et)
def content_astext(self):
@@ -2632,7 +2632,7 @@
lines1.extend((my_lines_str2, '</wrappertag1>'))
s1 = ''.join(lines1)
s1 = s1.encode("utf-8")
- el1 = etree.fromstring(s1)
+ el1 = ET.fromstring(s1)
for child in el1:
self.current_element.append(child)
@@ -2854,7 +2854,7 @@
for k, v in list(CONTENT_NAMESPACE_ATTRIB.items()))
contentstr = '<stuff %s>%s</stuff>' % (attrstr, rawstr, )
contentstr = contentstr.encode("utf-8")
- content = etree.fromstring(contentstr)
+ content = ET.fromstring(contentstr)
if len(content) > 0:
el1 = content[0]
if self.in_header:
Modified: trunk/docutils/docutils/writers/odf_odt/prepstyles.py
===================================================================
--- trunk/docutils/docutils/writers/odf_odt/prepstyles.py 2025-03-08 01:26:07 UTC (rev 10026)
+++ trunk/docutils/docutils/writers/odf_odt/prepstyles.py 2025-03-08 01:31:27 UTC (rev 10027)
@@ -13,7 +13,7 @@
# Author: Michael Schutte <mi...@ui...>
-from xml.etree import ElementTree as etree
+from xml.etree import ElementTree as ET
import sys
import zipfile
@@ -34,9 +34,9 @@
root = None
# some extra effort to preserve namespace prefixes
- for event, elem in etree.iterparse(styles, events=("start", "start-ns")):
+ for event, elem in ET.iterparse(styles, events=("start", "start-ns")):
if event == "start-ns":
- etree.register_namespace(elem[0], elem[1])
+ ET.register_namespace(elem[0], elem[1])
elif event == "start":
if root is None:
root = elem
@@ -55,7 +55,7 @@
for item in zin.infolist():
if item.filename == "styles.xml":
- zout.writestr(item, etree.tostring(root, encoding="UTF-8"))
+ zout.writestr(item, ET.tostring(root, encoding="UTF-8"))
else:
zout.writestr(item, zin.read(item.filename))
Modified: trunk/docutils/test/test_writers/test_odt.py
===================================================================
--- trunk/docutils/test/test_writers/test_odt.py 2025-03-08 01:26:07 UTC (rev 10026)
+++ trunk/docutils/test/test_writers/test_odt.py 2025-03-08 01:31:27 UTC (rev 10027)
@@ -35,7 +35,7 @@
import os
import sys
import unittest
-import xml.etree.ElementTree as etree
+import xml.etree.ElementTree as ET
import zipfile
if __name__ == '__main__':
@@ -113,10 +113,10 @@
payloadfile.seek(0)
zfile = zipfile.ZipFile(payloadfile, 'r')
content1 = zfile.read(filename)
- doc = etree.fromstring(content1)
+ doc = ET.fromstring(content1)
self.reorder_attributes(doc)
# return doc.toprettyxml(indent=' ')
- return etree.tostring(doc)
+ return ET.tostring(doc)
#
# Unit test methods
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aa-...@us...> - 2025-03-08 02:56:05
|
Revision: 10034
http://sourceforge.net/p/docutils/code/10034
Author: aa-turner
Date: 2025-03-08 02:56:03 +0000 (Sat, 08 Mar 2025)
Log Message:
-----------
Merge project metadata long description into README.rst
Modified Paths:
--------------
trunk/docutils/README.rst
trunk/docutils/pyproject.toml
Modified: trunk/docutils/README.rst
===================================================================
--- trunk/docutils/README.rst 2025-03-08 02:51:15 UTC (rev 10033)
+++ trunk/docutils/README.rst 2025-03-08 02:56:03 UTC (rev 10034)
@@ -10,6 +10,11 @@
:Web site: https://docutils.sourceforge.io/
:Copyright: This document has been placed in the public domain.
+Docutils is a modular system for processing documentation
+into useful formats, such as HTML, XML, and LaTeX.
+For input Docutils supports reStructuredText, an easy-to-read,
+what-you-see-is-what-you-get plaintext markup syntax.
+
.. contents::
Modified: trunk/docutils/pyproject.toml
===================================================================
--- trunk/docutils/pyproject.toml 2025-03-08 02:51:15 UTC (rev 10033)
+++ trunk/docutils/pyproject.toml 2025-03-08 02:56:03 UTC (rev 10034)
@@ -3,7 +3,7 @@
# Use flit as a build backend (https://flit.pypa.io/)
# Build with (https://build.pypa.io/)
[build-system]
-requires = ["flit_core>=3.11.0,<4"]
+requires = ["flit_core>=3.11,<4"]
build-backend = "flit_core.buildapi"
# Project metadata
@@ -11,12 +11,7 @@
[project]
name = "docutils"
description = "Docutils -- Python Documentation Utilities"
-readme.text = """
-Docutils is a modular system for processing documentation
-into useful formats, such as HTML, XML, and LaTeX. For
-input Docutils supports reStructuredText, an easy-to-read,
-what-you-see-is-what-you-get plaintext markup syntax.""" # wrap at col 60
-readme.content-type = "text/plain"
+readme = "README.rst"
urls.Changelog = "https://docutils.sourceforge.io/HISTORY.html"
urls.Code = "https://sourceforge.net/p/docutils/code/"
urls.Documentation = "https://docutils.sourceforge.io/docs/"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aa-...@us...> - 2025-03-08 18:12:16
|
Revision: 10037
http://sourceforge.net/p/docutils/code/10037
Author: aa-turner
Date: 2025-03-08 18:12:13 +0000 (Sat, 08 Mar 2025)
Log Message:
-----------
Enable the UP (pyupgrade) category in Ruff
Modified Paths:
--------------
trunk/docutils/.ruff.toml
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/test_transforms/test_substitution_expansion_length_limit.py
Modified: trunk/docutils/.ruff.toml
===================================================================
--- trunk/docutils/.ruff.toml 2025-03-08 10:57:49 UTC (rev 10036)
+++ trunk/docutils/.ruff.toml 2025-03-08 18:12:13 UTC (rev 10037)
@@ -7,9 +7,9 @@
select = [
"A", # flake8-builtins
"C4", # flake8-comprehensions
+ "DTZ", # flake8-datetimez
"E", # pycodestyle
"EXE", # flake8-executable
- "DTZ", # flake8-datetimez
"F", # pyflakes
"FA", # flake8-future-annotations
"FURB", # refurb
@@ -27,6 +27,7 @@
"T10", # flake8-debugger
"TCH", # flake8-type-checking
"TID", # flake8-tidy-imports
+ "UP", # pyupgrade
"W", # pycodestyle
"YTT", # flake8-2020
]
@@ -49,6 +50,8 @@
"PT009", # Use a regular assert instead of unittest-style
"PT027", # Use pytest.raises instead of unittest-style
# We still use unittest.
+
+ "UP031", # Use format specifiers instead of percent format
]
[lint.per-file-ignores]
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-08 10:57:49 UTC (rev 10036)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-08 18:12:13 UTC (rev 10037)
@@ -2065,7 +2065,7 @@
# \author
# author name(s) and optional affiliation and contact info
# cf. https://tex.stackexchange.com/a/377030/288060.
- authors = ['\\\\\n'.join((field for field in author_entry if field))
+ authors = ['\\\\\n'.join(filter(None, author_entry))
for author_entry in self.author_stack]
self.titledata.append(r'\author{%s}' % ' \\and\n'.join(authors))
# \date
Modified: trunk/docutils/test/test_transforms/test_substitution_expansion_length_limit.py
===================================================================
--- trunk/docutils/test/test_transforms/test_substitution_expansion_length_limit.py 2025-03-08 10:57:49 UTC (rev 10036)
+++ trunk/docutils/test/test_transforms/test_substitution_expansion_length_limit.py 2025-03-08 18:12:13 UTC (rev 10037)
@@ -62,7 +62,7 @@
|a| |c| continuation text
""",
-"""\
+f"""\
<document source="test data">
<paragraph>
The billion laughs attack for ReStructuredText:
@@ -69,9 +69,9 @@
<substitution_definition names="a">
lol
<substitution_definition names="b">
-{}
+{b}
<substitution_definition names="c">
-{}
+{c}
<comment xml:space="preserve">
...
<paragraph>
@@ -83,7 +83,7 @@
<system_message backrefs="problematic-1" ids="system-message-1" level="3" line="9" source="test data" type="ERROR">
<paragraph>
Substitution definition "c" exceeds the line-length-limit.
-""".format(b, c)],
+"""],
])
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aa-...@us...> - 2025-03-08 18:53:33
|
Revision: 10039
http://sourceforge.net/p/docutils/code/10039
Author: aa-turner
Date: 2025-03-08 18:53:20 +0000 (Sat, 08 Mar 2025)
Log Message:
-----------
Enable the ISC (flake8-implicit-str-concat) category in Ruff
Modified Paths:
--------------
trunk/docutils/.ruff.toml
trunk/docutils/docutils/parsers/rst/languages/lv.py
trunk/docutils/docutils/transforms/frontmatter.py
trunk/docutils/docutils/transforms/peps.py
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/test_transforms/test_docinfo.py
trunk/docutils/test/test_utils/test__init__.py
Modified: trunk/docutils/.ruff.toml
===================================================================
--- trunk/docutils/.ruff.toml 2025-03-08 18:37:25 UTC (rev 10038)
+++ trunk/docutils/.ruff.toml 2025-03-08 18:53:20 UTC (rev 10039)
@@ -18,6 +18,7 @@
"ICN", # flake8-import-conventions
"INP", # flake8-no-pep420
"INT", # flake8-gettext
+ "ISC", # flake8-implicit-str-concat
"LOG", # flake8-logging
"PERF", # perflint
"PGH", # pygrep-hooks
Modified: trunk/docutils/docutils/parsers/rst/languages/lv.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/languages/lv.py 2025-03-08 18:37:25 UTC (rev 10038)
+++ trunk/docutils/docutils/parsers/rst/languages/lv.py 2025-03-08 18:53:20 UTC (rev 10039)
@@ -98,7 +98,7 @@
'kājenes-atsauce': 'footnote-reference',
'citātā-atsauce': 'citation-reference',
'aizvietojuma-atsauce': 'substitution-reference',
- 'mēr''kis': 'target',
+ 'mērkis': 'target',
'atsauce-uz-uri': 'uri-reference',
'uri': 'uri-reference',
'url': 'uri-reference',
Modified: trunk/docutils/docutils/transforms/frontmatter.py
===================================================================
--- trunk/docutils/docutils/transforms/frontmatter.py 2025-03-08 18:37:25 UTC (rev 10038)
+++ trunk/docutils/docutils/transforms/frontmatter.py 2025-03-08 18:53:20 UTC (rev 10039)
@@ -466,10 +466,14 @@
return False
rcs_keyword_substitutions = [
- (re.compile(r'\$' r'Date: (\d\d\d\d)[-/](\d\d)[-/](\d\d)[ T][\d:]+'
- r'[^$]* \$', re.IGNORECASE), r'\1-\2-\3'),
- (re.compile(r'\$' r'RCSfile: (.+),v \$', re.IGNORECASE), r'\1'),
- (re.compile(r'\$[a-zA-Z]+: (.+) \$'), r'\1')]
+ (re.compile(
+ r'\$' r'Date: (\d\d\d\d)[-/](\d\d)[-/](\d\d)[ T][\d:]+' # NoQA: ISC001
+ r'[^$]* \$', re.IGNORECASE), r'\1-\2-\3'),
+ (re.compile(
+ r'\$' r'RCSfile: (.+),v \$', # NoQA: ISC001
+ re.IGNORECASE), r'\1'),
+ (re.compile(r'\$[a-zA-Z]+: (.+) \$'), r'\1'),
+ ]
def extract_authors(self, field, name, docinfo):
try:
Modified: trunk/docutils/docutils/transforms/peps.py
===================================================================
--- trunk/docutils/docutils/transforms/peps.py 2025-03-08 18:37:25 UTC (rev 10038)
+++ trunk/docutils/docutils/transforms/peps.py 2025-03-08 18:53:20 UTC (rev 10039)
@@ -34,7 +34,7 @@
pep_cvs_url = ('http://hg.python.org'
'/peps/file/default/pep-%04d.txt')
rcs_keyword_substitutions = (
- (re.compile(r'\$' r'RCSfile: (.+),v \$$', re.IGNORECASE), r'\1'),
+ (re.compile(r'\$' r'RCSfile: (.+),v \$$', re.IGNORECASE), r'\1'), # NoQA: ISC001
(re.compile(r'\$[a-zA-Z]+: (.+) \$$'), r'\1'),)
def apply(self):
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-08 18:37:25 UTC (rev 10038)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-08 18:53:20 UTC (rev 10039)
@@ -2581,7 +2581,7 @@
Corresponding rST elements: literal block, parsed-literal, code.
"""
- packages = {'lstlisting': r'\usepackage{listings}' '\n'
+ packages = {'lstlisting': r'\usepackage{listings}' '\n' # NoQA: ISC001
r'\lstset{xleftmargin=\leftmargin}',
'listing': r'\usepackage{moreverb}',
'Verbatim': r'\usepackage{fancyvrb}',
Modified: trunk/docutils/test/test_transforms/test_docinfo.py
===================================================================
--- trunk/docutils/test/test_transforms/test_docinfo.py 2025-03-08 18:37:25 UTC (rev 10038)
+++ trunk/docutils/test/test_transforms/test_docinfo.py 2025-03-08 18:53:20 UTC (rev 10039)
@@ -423,7 +423,7 @@
:Date: (some text) $""" + """Date: 2002/10/08 01:34:23 $ (more text)
:Date: (some text) $""" + """Date: 2005-03-26T16:21:28.693201Z $ (more text)
:Version: (some text) $""" + """Revision: 1.1 $ (more text)
-""",
+""", # NoQA: ISC003
"""\
<document source="test data">
<docinfo>
Modified: trunk/docutils/test/test_utils/test__init__.py
===================================================================
--- trunk/docutils/test/test_utils/test__init__.py 2025-03-08 18:37:25 UTC (rev 10038)
+++ trunk/docutils/test/test_utils/test__init__.py 2025-03-08 18:53:20 UTC (rev 10039)
@@ -349,7 +349,7 @@
# samples for the (un)escaping tests:
escaped = r'escapes: \*one, \\*two, \\\*three in\side no\ space' + '\\'
nulled = ('escapes: \x00*one, \x00\\*two, \x00\\\x00*three'
- + ' in\x00side no\x00 space\x00')
+ ' in\x00side no\x00 space\x00')
unescaped = r'escapes: *one, \*two, \*three inside nospace'
def test_escape2null(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aa-...@us...> - 2025-03-09 01:02:36
|
Revision: 10045
http://sourceforge.net/p/docutils/code/10045
Author: aa-turner
Date: 2025-03-09 01:02:23 +0000 (Sun, 09 Mar 2025)
Log Message:
-----------
Avoid importing the typing module for performance
The ``typing.TYPE_CHECKING`` constant is always False at runtime.
Modified Paths:
--------------
trunk/docutils/docutils/__init__.py
trunk/docutils/docutils/core.py
trunk/docutils/docutils/examples.py
trunk/docutils/docutils/frontend.py
trunk/docutils/docutils/io.py
trunk/docutils/docutils/languages/__init__.py
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/__init__.py
trunk/docutils/docutils/parsers/rst/directives/__init__.py
trunk/docutils/docutils/parsers/rst/directives/misc.py
trunk/docutils/docutils/parsers/rst/languages/__init__.py
trunk/docutils/docutils/readers/__init__.py
trunk/docutils/docutils/utils/__init__.py
trunk/docutils/docutils/writers/__init__.py
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/test/alltests.py
trunk/docutils/tools/buildhtml.py
trunk/docutils/tools/dev/generate_punctuation_chars.py
trunk/docutils/tools/dev/quicktest.py
trunk/docutils/tools/dev/unicode2rstsubs.py
Modified: trunk/docutils/docutils/__init__.py
===================================================================
--- trunk/docutils/docutils/__init__.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/__init__.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -53,8 +53,8 @@
from __future__ import annotations
from collections import namedtuple
-from typing import TYPE_CHECKING
+TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Sequence
from typing import Any, ClassVar, Literal, Protocol, Union
Modified: trunk/docutils/docutils/core.py
===================================================================
--- trunk/docutils/docutils/core.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/core.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -22,7 +22,6 @@
import os
import sys
import warnings
-from typing import TYPE_CHECKING
from docutils import (__version__, __version_details__, SettingsSpec,
io, utils, readers, parsers, writers)
@@ -29,6 +28,7 @@
from docutils.frontend import OptionParser
from docutils.readers import doctree
+TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import TextIO
from docutils.nodes import StrPath
Modified: trunk/docutils/docutils/examples.py
===================================================================
--- trunk/docutils/docutils/examples.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/examples.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -13,10 +13,10 @@
from __future__ import annotations
-from typing import TYPE_CHECKING
from docutils import core, io
+TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Any, Literal
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/frontend.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -64,11 +64,11 @@
import warnings
from optparse import SUPPRESS_HELP
from pathlib import Path
-from typing import TYPE_CHECKING
import docutils
from docutils import io, utils
+TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Iterable, Mapping, Sequence
from typing import Any, ClassVar, Literal, Protocol
Modified: trunk/docutils/docutils/io.py
===================================================================
--- trunk/docutils/docutils/io.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/io.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -17,10 +17,10 @@
import re
import sys
import warnings
-from typing import TYPE_CHECKING
from docutils import TransformSpec
+TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Any, BinaryIO, ClassVar, Final, Literal, TextIO
Modified: trunk/docutils/docutils/languages/__init__.py
===================================================================
--- trunk/docutils/docutils/languages/__init__.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/languages/__init__.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -14,10 +14,11 @@
__docformat__ = 'reStructuredText'
from importlib import import_module
-from typing import TYPE_CHECKING, overload
+from typing import overload
from docutils.utils import normalize_language_tag
+TYPE_CHECKING = False
if TYPE_CHECKING:
import types
from typing import NoReturn, Protocol, TypeVar
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/nodes.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -30,12 +30,12 @@
import unicodedata
import warnings
from collections import Counter
-from typing import TYPE_CHECKING
# import xml.dom.minidom as dom # -> conditional import in Node.asdom()
# and document.asdom()
# import docutils.transforms # -> delayed import in document.__init__()
+TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import (Callable, Iterable, Iterator,
Mapping, Sequence)
Modified: trunk/docutils/docutils/parsers/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/__init__.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/parsers/__init__.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -11,10 +11,10 @@
__docformat__ = 'reStructuredText'
import importlib
-from typing import TYPE_CHECKING
from docutils import Component, frontend, transforms
+TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Final
Modified: trunk/docutils/docutils/parsers/rst/directives/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/__init__.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/parsers/rst/directives/__init__.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -13,12 +13,12 @@
import re
import codecs
from importlib import import_module
-from typing import TYPE_CHECKING
from docutils import nodes, parsers
from docutils.utils import split_escaped_whitespace, escape2null
from docutils.parsers.rst.languages import en as _fallback_language_module
+TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Callable, Sequence
Modified: trunk/docutils/docutils/parsers/rst/directives/misc.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/misc.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/parsers/rst/directives/misc.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -11,7 +11,6 @@
import re
import time
from pathlib import Path
-from typing import TYPE_CHECKING
from urllib.request import urlopen
from urllib.error import URLError
@@ -21,6 +20,7 @@
from docutils.parsers.rst.directives.body import CodeBlock, NumberLines
from docutils.transforms import misc
+TYPE_CHECKING = False
if TYPE_CHECKING:
from docutils.nodes import StrPath
Modified: trunk/docutils/docutils/parsers/rst/languages/__init__.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/languages/__init__.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/parsers/rst/languages/__init__.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -14,10 +14,11 @@
__docformat__ = 'reStructuredText'
-from typing import TYPE_CHECKING, overload
+from typing import overload
from docutils.languages import LanguageImporter
+TYPE_CHECKING = False
if TYPE_CHECKING:
import types
from typing import NoReturn, Protocol
Modified: trunk/docutils/docutils/readers/__init__.py
===================================================================
--- trunk/docutils/docutils/readers/__init__.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/readers/__init__.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -12,11 +12,11 @@
import importlib
import warnings
-from typing import TYPE_CHECKING
from docutils import utils, parsers, Component
from docutils.transforms import universal
+TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Final
Modified: trunk/docutils/docutils/utils/__init__.py
===================================================================
--- trunk/docutils/docutils/utils/__init__.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/utils/__init__.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -18,7 +18,6 @@
import unicodedata
import warnings
from pathlib import PurePath, Path
-from typing import TYPE_CHECKING
from docutils import ApplicationError, DataError
from docutils import io, nodes
@@ -25,6 +24,7 @@
# for backwards compatibility
from docutils.nodes import unescape # noqa: F401 (imported but unused)
+TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Callable, Sequence, Iterable
from typing import Any, Final, Literal, TextIO
Modified: trunk/docutils/docutils/writers/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/__init__.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/writers/__init__.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -14,12 +14,12 @@
import sys
import urllib
from pathlib import Path
-from typing import TYPE_CHECKING
import docutils
from docutils import Component, languages, nodes, utils
from docutils.transforms import universal
+TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Any, Final
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/docutils/writers/_html_base.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -28,7 +28,6 @@
import warnings
import xml.etree.ElementTree as ET
from pathlib import Path
-from typing import TYPE_CHECKING
import docutils
from docutils import frontend, languages, nodes, utils, writers
@@ -38,6 +37,7 @@
from docutils.utils.math import (latex2mathml, math2html, tex2mathml_extern,
unichar2tex, wrap_math_code, MathError)
+TYPE_CHECKING = False
if TYPE_CHECKING:
from docutils.transforms import Transform
Modified: trunk/docutils/test/alltests.py
===================================================================
--- trunk/docutils/test/alltests.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/test/alltests.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -19,7 +19,6 @@
import time
import sys
from pathlib import Path
-from typing import TYPE_CHECKING
# Prepend the "docutils root" to the Python library path
# so we import the local `docutils` package.
@@ -28,6 +27,7 @@
import docutils # NoQA: E402
+TYPE_CHECKING = False
if TYPE_CHECKING:
import types
from typing import TextIO
Modified: trunk/docutils/tools/buildhtml.py
===================================================================
--- trunk/docutils/tools/buildhtml.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/tools/buildhtml.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -29,7 +29,6 @@
import warnings
from fnmatch import fnmatch
from types import SimpleNamespace
-from typing import TYPE_CHECKING
import docutils
import docutils.io
@@ -39,6 +38,7 @@
from docutils.readers import standalone, pep
from docutils.writers import html4css1, html5_polyglot, pep_html
+TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import Literal
Modified: trunk/docutils/tools/dev/generate_punctuation_chars.py
===================================================================
--- trunk/docutils/tools/dev/generate_punctuation_chars.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/tools/dev/generate_punctuation_chars.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -37,8 +37,8 @@
import sys
import unicodedata
-from typing import TYPE_CHECKING
+TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Iterable
Modified: trunk/docutils/tools/dev/quicktest.py
===================================================================
--- trunk/docutils/tools/dev/quicktest.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/tools/dev/quicktest.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -36,7 +36,6 @@
import getopt
import sys
-from typing import TYPE_CHECKING
import docutils
from docutils import frontend
@@ -43,6 +42,7 @@
from docutils.utils import new_document
from docutils.parsers.rst import Parser
+TYPE_CHECKING = False
if TYPE_CHECKING:
from collections.abc import Callable
from typing import TextIO, TypedDict
Modified: trunk/docutils/tools/dev/unicode2rstsubs.py
===================================================================
--- trunk/docutils/tools/dev/unicode2rstsubs.py 2025-03-09 00:56:34 UTC (rev 10044)
+++ trunk/docutils/tools/dev/unicode2rstsubs.py 2025-03-09 01:02:23 UTC (rev 10045)
@@ -24,9 +24,9 @@
import os
import re
import sys
-from typing import TYPE_CHECKING
from xml.parsers.expat import ParserCreate
+TYPE_CHECKING = False
if TYPE_CHECKING:
from typing import BinaryIO, NoReturn, TextIO
from xml.parsers.expat import XMLParserType
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2025-03-21 02:16:25
|
Revision: 10052
http://sourceforge.net/p/docutils/code/10052
Author: grubert
Date: 2025-03-21 02:16:12 +0000 (Fri, 21 Mar 2025)
Log Message:
-----------
text-references: no additional spaces.
Skip references only if content is equal, or only differs by "mailto:".
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_writers/test_manpage.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-03-13 09:43:29 UTC (rev 10051)
+++ trunk/docutils/HISTORY.rst 2025-03-21 02:16:12 UTC (rev 10052)
@@ -213,7 +213,8 @@
- Do not output .UR/.UE macros without refuri in node.
- Use .MT/.ME macros for mailto.uris.
- If macro references is active output refuri always.
- - For text references: no line end after refuri.
+ - For text references: no line end after refuri, no additional spaces.
+ - Skip references only if content is equal, or only differs by "mailto:".
* docutils/writers/null.py
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2025-03-13 09:43:29 UTC (rev 10051)
+++ trunk/docutils/docutils/writers/manpage.py 2025-03-21 02:16:12 UTC (rev 10052)
@@ -1081,17 +1081,18 @@
# TODO insert_URI_breakpoints in text or refuri
if 'refuri' in node:
- # MAYBE check if content is the uri and then text will be duplicated.
- if node['refuri'].endswith(node.astext()):
- self.body.append(" <")
+ # check if content is the uri and only output reference.
+ # MAYBE if only content is ouput hyphens "-" get a backslash.
+ if (node['refuri'] == node.astext()
+ or node['refuri'] == "mailto:"+node.astext()):
+ # without mailto:
+ self.body.append("<%s>" % node.astext())
+ raise nodes.SkipNode
# TODO elif 'refid' in node:
def _depart_reference_no_macro(self, node) -> None:
if 'refuri' in node:
- if node['refuri'].endswith(node.astext()):
- self.body.append("> ")
- else:
- self.body.append(" <%s>" % node['refuri'])
+ self.body.append(" <%s>" % node['refuri'])
# TODO elif 'refid' in node:
def _visit_reference_with_macro(self, node) -> None:
Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py 2025-03-13 09:43:29 UTC (rev 10051)
+++ trunk/docutils/test/test_writers/test_manpage.py 2025-03-21 02:16:12 UTC (rev 10052)
@@ -302,7 +302,7 @@
.UNINDENT
.SH OtHeR SECTION
.sp
-link to <http://docutils.sourceforge.io> \n\
+link to <http://docutils.sourceforge.io>\n\
.sp
With mixed case.
.sp
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-03-30 20:13:21
|
Revision: 10062
http://sourceforge.net/p/docutils/code/10062
Author: milde
Date: 2025-03-30 20:13:14 +0000 (Sun, 30 Mar 2025)
Log Message:
-----------
Fixup of recent changes to LaTeX writer docinfo handling.
Insert a space after the author-separator in "pdfauthor" meta-data entry.
Code formatting and structuring.
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_docinfo.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/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-30 20:13:14 UTC (rev 10062)
@@ -1193,9 +1193,9 @@
literal = False # literal text (block or inline)
alltt = False # inside `alltt` environment
- # Nodes affected by "use_latex_docinfo" setting:
- LATEX_DOCINFO_NODES = (nodes.address, nodes.author, nodes.contact,
- nodes.date, nodes.organization)
+ # Nodes to be stored in the "titledata" part if "use_latex_docinfo" is true
+ TITLEDATA_NODES = (nodes.address, nodes.author, nodes.authors,
+ nodes.contact, nodes.date, nodes.organization)
def __init__(self, document, babel_class=Babel) -> None:
super().__init__(document)
@@ -1695,10 +1695,12 @@
self.depart_inline(node)
def visit_address(self, node) -> None:
+ self.insert_newline = True # preserve newlines
self.visit_docinfo_item(node)
def depart_address(self, node) -> None:
self.depart_docinfo_item(node)
+ self.insert_newline = False
def visit_admonition(self, node) -> None:
# strip the generic 'admonition' from the list of classes
@@ -1960,10 +1962,7 @@
warnings.warn('visit_docinfo_item(): argument "name" is obsolete'
' and will be removed in Docutils 0.24',
DeprecationWarning, stacklevel=2)
- if isinstance(node, nodes.address):
- self.insert_newline = True # preserve newlines
- if self.use_latex_docinfo and isinstance(node,
- self.LATEX_DOCINFO_NODES):
+ if self.use_latex_docinfo and isinstance(node, self.TITLEDATA_NODES):
self.push_output_collector([]) # see depart_docinfo_item()
else:
label = self.language_label(node.tagname)
@@ -1976,9 +1975,7 @@
self.out.append(' ')
def depart_docinfo_item(self, node) -> None:
- self.insert_newline = False # reset change with <address> node
- if self.use_latex_docinfo and isinstance(node,
- self.LATEX_DOCINFO_NODES):
+ if self.use_latex_docinfo and isinstance(node, self.TITLEDATA_NODES):
# Collect date and author info for use in `self.make_title()`:
text = ''.join(self.pop_output_collector())
if isinstance(node, nodes.date):
@@ -1991,7 +1988,7 @@
else:
self.author_stack[-1][0] = text
else:
- # Append affiliation/contact info to current "author info".
+ # Append affiliation & contact info to current "author info".
self.author_stack[-1].append(text)
else:
if isinstance(node, nodes.address):
@@ -2024,7 +2021,7 @@
self.pdfinfo.insert(0, ' pdftitle={%s},' %
self.encode(self.document.get('title', '')))
if self.pdfauthor:
- authors = self.author_separator.join(self.pdfauthor)
+ authors = (self.author_separator + ' ').join(self.pdfauthor)
self.pdfinfo.append(' pdfauthor={%s}' % authors)
if self.pdfinfo:
self.pdfsetup += [r'\hypersetup{'] + self.pdfinfo + ['}']
Modified: trunk/docutils/test/functional/expected/latex_docinfo.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_docinfo.tex 2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/test/functional/expected/latex_docinfo.tex 2025-03-30 20:13:14 UTC (rev 10062)
@@ -21,7 +21,7 @@
\urlstyle{same} % normal text font (alternatives: tt, rm, sf)
\fi
\hypersetup{
- pdfauthor={Foo Fred;Bar Barney}
+ pdfauthor={Foo Fred; Bar Barney}
}
%%% Body
Modified: trunk/docutils/test/functional/expected/latex_leavevmode.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_leavevmode.tex 2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/test/functional/expected/latex_leavevmode.tex 2025-03-30 20:13:14 UTC (rev 10062)
@@ -148,7 +148,7 @@
\fi
\hypersetup{
pdftitle={Styling of Elements in Definition- or Field-List},
- pdfauthor={Hänsel;Gretel}
+ pdfauthor={Hänsel; Gretel}
}
%%% Body
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2025-03-30 20:13:14 UTC (rev 10062)
@@ -191,7 +191,7 @@
pdftitle={reStructuredText Test Document},
pdfkeywords={reStructuredText, test, parser},
pdfinfo={description={A test document, containing at least one example of each reStructuredText construct.}},
- pdfauthor={David Goodger;Me;Myself;I}
+ pdfauthor={David Goodger; Me; Myself; I}
}
\title{reStructuredText Test Document%
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2025-03-30 20:13:14 UTC (rev 10062)
@@ -190,7 +190,7 @@
pdftitle={reStructuredText Test Document},
pdfkeywords={reStructuredText, test, parser},
pdfinfo={description={A test document, containing at least one example of each reStructuredText construct.}},
- pdfauthor={David Goodger;Me;Myself;I}
+ pdfauthor={David Goodger; Me; Myself; I}
}
%%% Body
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2025-03-30 18:28:06 UTC (rev 10061)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2025-03-30 20:13:14 UTC (rev 10062)
@@ -56,7 +56,7 @@
pdftitle={reStructuredText Test Document},
pdfkeywords={reStructuredText, test, parser},
pdfinfo={description={A test document, containing at least one example of each reStructuredText construct.}},
- pdfauthor={David Goodger;Me;Myself;I}
+ pdfauthor={David Goodger; Me; Myself; I}
}
\title{reStructuredText Test Document%
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-03-30 20:13:45
|
Revision: 10063
http://sourceforge.net/p/docutils/code/10063
Author: milde
Date: 2025-03-30 20:13:30 +0000 (Sun, 30 Mar 2025)
Log Message:
-----------
LaTeX writer: Fix formatting of "authors" bibinfo field.
Collect author names from "author" fields nested in "authors".
With "--use-docutils-docinfo", use one "authors" entry instead of separate
"author" entries for the individual author names.
With "--use-latex-docinfo", print author names as one block
to ensure a common author affiliation is centered under all
author names, not just the last (cf. https://tex.stackexchange.com/a/11656/288060).
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/docs/user/latex.rst
trunk/docutils/docutils/writers/latex2e/__init__.py
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/test_writers/test_latex2e_parts.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-03-30 20:13:14 UTC (rev 10062)
+++ trunk/docutils/HISTORY.rst 2025-03-30 20:13:30 UTC (rev 10063)
@@ -189,7 +189,7 @@
and`LaTeXTranslator.fallbacks`.
- Use <document> "title" attribute in pdfinfo.
- Encode <meta> element content in pdfinfo.
- - Improve docinfo handling with "use_latex_docinfo".
+ - Improve formatting of docinfo fields.
- `LaTeXTranslator.pop_output_collector()` now returns the popped list.
.. _reference-label: docs/user/config.html#reference-label
Modified: trunk/docutils/docs/user/latex.rst
===================================================================
--- trunk/docutils/docs/user/latex.rst 2025-03-30 20:13:14 UTC (rev 10062)
+++ trunk/docutils/docs/user/latex.rst 2025-03-30 20:13:30 UTC (rev 10063)
@@ -662,6 +662,32 @@
See section Templates_ and the `TeX FAQ`_ on how to customize the
`style of document titles`_.
+Example:
+ With `use-latex-docinfo`_, author information and date are typeset
+ as part of the document title instead of the `document info`_ table.
+
+ Paper by three authors, two of them from the same organisation::
+
+ Shop Sketches
+ =============
+
+ :authors: * Mr. Mousebender
+ * Mr. Arthur Wensleydale
+ :organization: Ye National Cheese Emporium
+
+ :author: Hr. Hallmackenreuther
+ :organization: Bettengeschäft
+
+ With ``--use-latex-docinfo``, authors and their affiliations are
+ typeset below the title using the standard LaTeX command ``\author``
+ with a `simple hack for the common affiliation`__. [#]_
+
+.. [#] Unfortunately, author names don't wrap if there are more
+ authors than fit on one line in one "authors" field.
+
+__ https://tex.stackexchange.com/a/11656/288060from
+
+
.. _section structure: rst/quickref.html#section-structure
.. _doctitle_xform: config.html#doctitle-xform
.. _TeX FAQ: https://texfaq.org/
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-30 20:13:14 UTC (rev 10062)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2025-03-30 20:13:30 UTC (rev 10063)
@@ -1728,17 +1728,24 @@
def visit_author(self, node) -> None:
self.pdfauthor.append(self.attval(node.astext()))
- self.visit_docinfo_item(node)
+ if isinstance(node.parent, nodes.authors):
+ # ensure output is one item per <author> element (see depart…)
+ self.push_output_collector([])
+ else:
+ self.visit_docinfo_item(node)
def depart_author(self, node) -> None:
- self.depart_docinfo_item(node)
+ if isinstance(node.parent, nodes.authors):
+ author_name = self.pop_output_collector()
+ self.out.append(''.join(author_name))
+ else:
+ self.depart_docinfo_item(node)
def visit_authors(self, node) -> None:
- # not used: visit_author is called anyway for each author.
- pass
+ self.visit_docinfo_item(node)
def depart_authors(self, node) -> None:
- pass
+ self.depart_docinfo_item(node)
def visit_block_quote(self, node) -> None:
self.duclass_open(node)
@@ -1973,16 +1980,33 @@
self.out.append('\n ')
else:
self.out.append(' ')
+ if isinstance(node, nodes.authors):
+ self.push_output_collector([]) # collect author names
def depart_docinfo_item(self, node) -> None:
if self.use_latex_docinfo and isinstance(node, self.TITLEDATA_NODES):
- # Collect date and author info for use in `self.make_title()`:
- text = ''.join(self.pop_output_collector())
+ # Prepare data for use in `self.make_title()`
+ if isinstance(node, nodes.authors):
+ # join author names with "\and" or,
+ # if there is shared author info, with "\quad"
+ # (cf. https://tex.stackexchange.com/a/11656/288060)
+ s = r' \and '
+ for nn in node.findall(include_self=False, descend=False,
+ siblings=True):
+ if isinstance(nn, (nodes.author, nodes.authors)):
+ break
+ if isinstance(nn, (nodes.address, nodes.contact,
+ nodes.organization)):
+ s = r' \quad '
+ else:
+ s = ''
+ text = s.join(self.pop_output_collector())
+
if isinstance(node, nodes.date):
self.date.append(text)
- elif isinstance(node, nodes.author):
- # Insert author name as first item of an "author info" list.
- # If author name already set, start a new list.
+ elif isinstance(node, (nodes.author, nodes.authors)):
+ # Insert author name(s) as first item of an "author info" list,
+ # starting a new list if author name already set:
if self.author_stack[-1][0]:
self.author_stack.append([text])
else:
@@ -1993,6 +2017,13 @@
else:
if isinstance(node, nodes.address):
self.out.append('}')
+ elif isinstance(node, nodes.authors):
+ author_names = self.pop_output_collector()
+ # get last "author separator" that is not in any author name
+ for sep in reversed(self.language_module.author_separators):
+ if not any(sep in name for name in author_names):
+ break
+ self.out.append((sep+' ').join(author_names))
self.out.append(' \\\\\n')
def visit_doctest_block(self, node) -> None:
Modified: trunk/docutils/test/functional/expected/latex_leavevmode.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_leavevmode.tex 2025-03-30 20:13:14 UTC (rev 10062)
+++ trunk/docutils/test/functional/expected/latex_leavevmode.tex 2025-03-30 20:13:30 UTC (rev 10063)
@@ -162,8 +162,7 @@
% Docinfo
\begin{center}
\begin{tabularx}{\DUdocinfowidth}{lX}
-\textbf{Author}: & Hänsel \\
-\textbf{Author}: & Gretel \\
+\textbf{Authors}: & Hänsel, Gretel \\
\textbf{Address}: & {\raggedright
123 Example Street\\
Example, EX Canada} \\
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2025-03-30 20:13:14 UTC (rev 10062)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2025-03-30 20:13:30 UTC (rev 10063)
@@ -206,9 +206,7 @@
Example, EX Canada\\
A1B 2C3\\
\href{mailto:go...@py...}{go...@py...} \and
-Me \and
-Myself \and
-I\\
+Me \quad Myself \quad I\\
humankind}
\date{Now, or yesterday. Or maybe even \emph{before} yesterday.}
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2025-03-30 20:13:14 UTC (rev 10062)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2025-03-30 20:13:30 UTC (rev 10063)
@@ -215,9 +215,7 @@
Example, EX Canada\\
A1B 2C3} \\
\textbf{Contact}: & \href{mailto:go...@py...}{go...@py...} \\
-\textbf{Author}: & Me \\
-\textbf{Author}: & Myself \\
-\textbf{Author}: & I \\
+\textbf{Authors}: & Me, Myself, I \\
\textbf{Organization}: & humankind \\
\textbf{Date}: & Now, or yesterday. Or maybe even \emph{before} yesterday. \\
\textbf{Status}: & This is a “work in progress” \\
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2025-03-30 20:13:14 UTC (rev 10062)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2025-03-30 20:13:30 UTC (rev 10063)
@@ -82,9 +82,7 @@
Example, EX Canada\\
A1B 2C3} \\
\textbf{Contact}: & \href{mailto:go...@py...}{go...@py...} \\
-\textbf{Author}: & Me \\
-\textbf{Author}: & Myself \\
-\textbf{Author}: & I \\
+\textbf{Authors}: & Me, Myself, I \\
\textbf{Organization}: & humankind \\
\textbf{Date}: & Now, or yesterday. Or maybe even \emph{before} yesterday. \\
\textbf{Status}: & This is a “work in progress” \\
Modified: trunk/docutils/test/test_writers/test_latex2e_parts.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e_parts.py 2025-03-30 20:13:14 UTC (rev 10062)
+++ trunk/docutils/test/test_writers/test_latex2e_parts.py 2025-03-30 20:13:30 UTC (rev 10063)
@@ -733,6 +733,41 @@
\end{center}
""",
}],
+["""
+:authors: * \\A. *Smith*
+ * \\B. Miller
+:organization: Example & Cie.
+:author: C. Baker
+:organization: Another Example
+""",
+ {'requirements': '\\usepackage[T1]{fontenc}\n'
+ '\\usepackage{tabularx}\n',
+ 'fallbacks': r"""
+% Provide a length variable and set default, if it is new
+\providecommand*{\DUprovidelength}[2]{%
+ \ifdefined#1
+ \else
+ \newlength{#1}\setlength{#1}{#2}%
+ \fi
+}
+
+% width of docinfo table
+\DUprovidelength{\DUdocinfowidth}{0.9\linewidth}
+""",
+ 'pdfsetup': DEFAULT_PARTS['pdfsetup']
+ + '\\hypersetup{\n pdfauthor={A. Smith; B. Miller; C. Baker}\n}\n',
+ 'docinfo': r"""
+% Docinfo
+\begin{center}
+\begin{tabularx}{\DUdocinfowidth}{lX}
+\textbf{Authors}: & A. \emph{Smith}, B. Miller \\
+\textbf{Organization}: & Example \& Cie. \\
+\textbf{Author}: & C. Baker \\
+\textbf{Organization}: & Another Example \\
+\end{tabularx}
+\end{center}
+""",
+ }],
])
samples['book'] = ({'documentclass': 'book'}, [
@@ -1002,8 +1037,25 @@
""",
'body_pre_docinfo': '\\maketitle\n',
}],
-# bibliographic fields
["""
+:authors: * \\A. *Smith*
+ * \\B. Miller
+:organization: Example & Cie.
+:author: C. Baker
+:organization: Another Example
+""",
+ {'pdfsetup': DEFAULT_PARTS['pdfsetup']
+ + '\\hypersetup{\n pdfauthor={A. Smith; B. Miller; C. Baker}\n}\n',
+ 'titledata': r"""\title{}
+\author{A. \emph{Smith} \quad B. Miller\\
+Example \& Cie. \and
+C. Baker\\
+Another Example}
+\date{}
+""",
+ 'body_pre_docinfo': '\\maketitle\n',
+ }],
+["""
:keywords: custom, docinfo, field
""",
{'requirements': '\\usepackage[T1]{fontenc}\n'
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-04-09 08:56:12
|
Revision: 10077
http://sourceforge.net/p/docutils/code/10077
Author: milde
Date: 2025-04-09 08:55:54 +0000 (Wed, 09 Apr 2025)
Log Message:
-----------
Use `PendingDeprecationWarning` and postpone removal when replacement is in 0.22.
Adam Turner noted DeprecationWarnings for some features where the replacement
functionality is introduced in Docutils 0.22.
As backwards compatibility with 0.21 should not imply DeprecationWarnings,
this commit postpones the removal to Docutils 2.0 and changes the
DeprecationWarnings to PendingDeprecationWarnings.
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/RELEASE-NOTES.rst
trunk/docutils/docutils/parsers/rst/roles.py
trunk/docutils/docutils/readers/__init__.py
trunk/docutils/test/test_publisher.py
trunk/docutils/test/test_readers/test__init__.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-04-08 10:27:44 UTC (rev 10076)
+++ trunk/docutils/HISTORY.rst 2025-04-09 08:55:54 UTC (rev 10077)
@@ -687,7 +687,8 @@
* docutils/parsers/rst/directives/__init__.py
- - `parser_name()` keeps details if converting `ImportError` to `ValueError`.
+ - `parser_name()` keeps details when converting `ImportError`
+ to `ValueError`.
* docutils/parsers/rst/roles.py
Modified: trunk/docutils/RELEASE-NOTES.rst
===================================================================
--- trunk/docutils/RELEASE-NOTES.rst 2025-04-08 10:27:44 UTC (rev 10076)
+++ trunk/docutils/RELEASE-NOTES.rst 2025-04-09 08:55:54 UTC (rev 10077)
@@ -142,6 +142,10 @@
Use `parsers.rst.directives.CSS3_LENGTH_UNITS`. Mind that this
is a tuple, not a list.
+* Remove the "name" argument from
+ `writers.latex2e.LaTeXTranslator.visit_docinfo_item()`
+ (ignored since Docutils 0.22) in Docutils 0.24.
+
* Remove `parsers.rst.directives.CSVTable.HeaderDialect`
in Docutils 1.0.
@@ -158,14 +162,12 @@
* Remove the input encoding auto-detection code in Docutils 1.0.
* Remove `parsers.rst.roles.set_classes()` and
- `parsers.rst.roles.normalized_role_options()` in Docutils 1.0.
+ `parsers.rst.roles.normalized_role_options()`
+ (obsoleted by `parsers.rst.roles.normalize_options()`) in Docutils 2.0.
* Remove the "rawsource" argument from `nodes.Text.__init__()`
in Docutils 2.0.
-* Remove the "name" argument from
- `writers.latex2e.LaTeXTranslator.visit_docinfo_item()` in Docutils 0.24
-
* Remove attributes `nodes.Element.known_attributes`,
`nodes.Element.basic_attributes`, and `nodes.Element.local_attributes`,
in Docutils 2.0.
@@ -178,8 +180,9 @@
* Remove the "reader_name", "parser_name", and "writer_name" arguments of
`core.Publisher.__init__()` and the `core.publish_*()` convenience
- functions in Docutils 2.0. Since Docutils 0.22, you may use "reader",
- "parser", and "writer" arguments for component names as well as instances.
+ functions as well as the "parser_name" argument of `Reader.__init__()`
+ in Docutils 2.0. Since Docutils 0.22, you may use "reader", "parser",
+ and "writer" arguments for component names as well as instances.
Misc
----
Modified: trunk/docutils/docutils/parsers/rst/roles.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/roles.py 2025-04-08 10:27:44 UTC (rev 10076)
+++ trunk/docutils/docutils/parsers/rst/roles.py 2025-04-09 08:55:54 UTC (rev 10077)
@@ -417,7 +417,7 @@
"""Deprecated. Obsoleted by ``normalize_options()``."""
warnings.warn('The auxiliary function roles.set_classes() is obsoleted'
' by roles.normalize_options() and will be removed'
- ' in Docutils 1.0', DeprecationWarning, stacklevel=2)
+ ' in Docutils 2.0', PendingDeprecationWarning, stacklevel=2)
if options and 'class' in options:
assert 'classes' not in options
options['classes'] = options['class']
@@ -427,7 +427,7 @@
def normalized_role_options(options):
warnings.warn('The auxiliary function roles.normalized_role_options() is '
'obsoleted by roles.normalize_options() and will be removed'
- ' in Docutils 1.0', DeprecationWarning, stacklevel=2)
+ ' in Docutils 2.0', PendingDeprecationWarning, stacklevel=2)
return normalize_options(options)
Modified: trunk/docutils/docutils/readers/__init__.py
===================================================================
--- trunk/docutils/docutils/readers/__init__.py 2025-04-08 10:27:44 UTC (rev 10076)
+++ trunk/docutils/docutils/readers/__init__.py 2025-04-09 08:55:54 UTC (rev 10077)
@@ -70,7 +70,7 @@
warnings.warn('Argument "parser_name" will be removed '
'in Docutils 2.0.\n'
' Specify parser name in the "parser" argument.',
- DeprecationWarning, stacklevel=2)
+ PendingDeprecationWarning, stacklevel=2)
if self.parser is None:
self.set_parser(parser_name)
Modified: trunk/docutils/test/test_publisher.py
===================================================================
--- trunk/docutils/test/test_publisher.py 2025-04-08 10:27:44 UTC (rev 10076)
+++ trunk/docutils/test/test_publisher.py 2025-04-09 08:55:54 UTC (rev 10077)
@@ -101,13 +101,13 @@
# synchronize parser attributes of publisher and reader:
self.assertEqual(publisher.reader.parser, publisher.parser)
# the "parser_name" argument is deprecated;
- with self.assertWarnsRegex(DeprecationWarning,
+ with self.assertWarnsRegex(PendingDeprecationWarning,
'Argument "parser_name" will be removed'):
publisher.set_reader('standalone', parser=None, parser_name='rst')
self.assertTrue(isinstance(publisher.parser, parsers.rst.Parser))
self.assertEqual(publisher.reader.parser, publisher.parser)
# "parser" takes precedence
- with self.assertWarns(DeprecationWarning):
+ with self.assertWarns(PendingDeprecationWarning):
publisher.set_reader('standalone', parser, parser_name='rst')
self.assertEqual(publisher.parser, parser)
self.assertEqual(publisher.reader.parser, publisher.parser)
Modified: trunk/docutils/test/test_readers/test__init__.py
===================================================================
--- trunk/docutils/test/test_readers/test__init__.py 2025-04-08 10:27:44 UTC (rev 10076)
+++ trunk/docutils/test/test_readers/test__init__.py 2025-04-09 08:55:54 UTC (rev 10077)
@@ -38,12 +38,12 @@
self.assertEqual(reader.parser, parser)
# # the second argument `parser_name` is deprecated
with self.assertWarnsRegex(
- DeprecationWarning,
+ PendingDeprecationWarning,
'Specify parser name in the "parser" argument.'):
reader = readers.Reader(parser_name='rst')
self.assertTrue(isinstance(reader.parser, parsers.rst.Parser))
# if both arguments are specified, `parser` has precedence:
- with self.assertWarns(DeprecationWarning):
+ with self.assertWarns(PendingDeprecationWarning):
reader = readers.Reader(parser, parser_name='null')
self.assertEqual(reader.parser, parser)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-04-09 14:26:28
|
Revision: 10078
http://sourceforge.net/p/docutils/code/10078
Author: milde
Date: 2025-04-09 14:26:09 +0000 (Wed, 09 Apr 2025)
Log Message:
-----------
Small rST parser fixes.
Add source and line info to <enumerated-list> elements [feature-requests:#41].
Fix line number of "start value not ordinal-1" INFO message
(see also [patches:#213]).
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-04-09 08:55:54 UTC (rev 10077)
+++ trunk/docutils/HISTORY.rst 2025-04-09 14:26:09 UTC (rev 10078)
@@ -107,6 +107,8 @@
* docutils/parsers/rst/states.py
- Raise warning for empty footnotes and citations.
+ - Add source and line info to <enumerated-list> elements.
+ Fix line number of "start value not ordinal-1" INFO message.
* docutils/readers/__init__.py:
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2025-04-09 08:55:54 UTC (rev 10077)
+++ trunk/docutils/docutils/parsers/rst/states.py 2025-04-09 14:26:09 UTC (rev 10078)
@@ -1303,6 +1303,8 @@
if not self.is_enumerated_list_item(ordinal, sequence, format):
raise statemachine.TransitionCorrection('text')
enumlist = nodes.enumerated_list()
+ (enumlist.source,
+ enumlist.line) = self.state_machine.get_source_and_line()
self.parent += enumlist
if sequence == '#':
enumlist['enumtype'] = 'arabic'
@@ -1314,7 +1316,7 @@
enumlist['start'] = ordinal
msg = self.reporter.info(
'Enumerated list start value not ordinal-1: "%s" (ordinal %s)'
- % (text, ordinal))
+ % (text, ordinal), base_node=enumlist)
self.parent += msg
listitem, blank_finish = self.list_item(match.end())
enumlist += listitem
Modified: trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2025-04-09 08:55:54 UTC (rev 10077)
+++ trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2025-04-09 14:26:09 UTC (rev 10078)
@@ -636,7 +636,7 @@
<list_item>
<paragraph>
Four
- <system_message level="1" line="8" source="functional/input/data/standard.rst" type="INFO">
+ <system_message level="1" line="178" source="functional/input/data/standard.rst" type="INFO">
<paragraph>
Enumerated list start value not ordinal-1: "3" (ordinal 3)
<enumerated_list enumtype="upperalpha" prefix="" start="3" suffix=".">
@@ -646,7 +646,7 @@
<list_item>
<paragraph>
D
- <system_message level="1" line="8" source="functional/input/data/standard.rst" type="INFO">
+ <system_message level="1" line="182" source="functional/input/data/standard.rst" type="INFO">
<paragraph>
Enumerated list start value not ordinal-1: "C" (ordinal 3)
<enumerated_list enumtype="lowerroman" prefix="" start="3" suffix=".">
@@ -656,7 +656,7 @@
<list_item>
<paragraph>
iv
- <system_message level="1" line="8" source="functional/input/data/standard.rst" type="INFO">
+ <system_message level="1" line="186" source="functional/input/data/standard.rst" type="INFO">
<paragraph>
Enumerated list start value not ordinal-1: "iii" (ordinal 3)
<section ids="definition-lists" names="definition\ lists">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-04-14 08:53:49
|
Revision: 10084
http://sourceforge.net/p/docutils/code/10084
Author: milde
Date: 2025-04-14 08:53:31 +0000 (Mon, 14 Apr 2025)
Log Message:
-----------
Fix content model of `<figure>` elements.
If an "image" or "figure" directive is used with the "target" option,
the image is nested in a `<reference>` element (to make it {U+201C}clickable{U+201D}).
Therefore, the first child element of a figure may be a `<reference>`
(with nested `<image>`).
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/RELEASE-NOTES.rst
trunk/docutils/docs/ref/docutils.dtd
trunk/docutils/docutils/nodes.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-04-13 15:12:34 UTC (rev 10083)
+++ trunk/docutils/HISTORY.rst 2025-04-14 08:53:31 UTC (rev 10084)
@@ -33,6 +33,8 @@
- Allow multiple <term> elements in a <definition_list_item>.
Fixes feature-request #60
+ - The first element in a <figure> may also be a <reference>
+ (with nested "clickable" <image>).
* docutils/core.py
Modified: trunk/docutils/RELEASE-NOTES.rst
===================================================================
--- trunk/docutils/RELEASE-NOTES.rst 2025-04-13 15:12:34 UTC (rev 10083)
+++ trunk/docutils/RELEASE-NOTES.rst 2025-04-14 08:53:31 UTC (rev 10084)
@@ -229,6 +229,8 @@
Document Tree / Docutils DTD
- Allow multiple <term> elements in a `\<definition_list_item>`__
(third-party writers may need adaption).
+ - The first element in a <figure> may also be a <reference>
+ (with nested "clickable" <image>).
__ docs/ref/doctree.html#definition-list-item
@@ -377,7 +379,7 @@
- Use the same CSV format for the ``:header:`` option and the main data
of the "csv-table_" directive.
- - New option "loading" for the `"image" directive`_.
+ - New option "loading" for the "image_" directive.
Sets the new attribute loading__ of the <image> doctree element.
__ docs/ref/doctree.html#loading
@@ -443,7 +445,6 @@
.. _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
.. _sources: docs/user/config.html#sources
@@ -820,7 +821,7 @@
* docutils/docs/ref/docutils.dtd:
- - Enable validation of Docutils XML documents against the DTD:
+ - Enable validation of Docutils XML documents against the DTD.
* docutils/parsers/rst/:
Modified: trunk/docutils/docs/ref/docutils.dtd
===================================================================
--- trunk/docutils/docs/ref/docutils.dtd 2025-04-13 15:12:34 UTC (rev 10083)
+++ trunk/docutils/docs/ref/docutils.dtd 2025-04-14 08:53:31 UTC (rev 10084)
@@ -552,7 +552,7 @@
<!ELEMENT pending EMPTY>
<!ATTLIST pending %basic.atts;>
-<!ELEMENT figure (image, ((caption, legend?) | legend)) >
+<!ELEMENT figure ((image|reference), ((caption, legend?) | legend)) >
<!ATTLIST figure
%basic.atts;
%align-h.att;
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2025-04-13 15:12:34 UTC (rev 10083)
+++ trunk/docutils/docutils/nodes.py 2025-04-14 08:53:31 UTC (rev 10084)
@@ -561,7 +561,7 @@
'+' (one or more), '*' (zero or more).
NOTE: The default describes the empty element. Derived classes should
- update this value to match teir content model.
+ update this value to match their content model.
Provisional.
"""
@@ -2135,6 +2135,11 @@
# ((%body.elements;)+, attribution?)
+class reference(General, Inline, Referential, TextElement):
+ valid_attributes: Final = Element.valid_attributes + (
+ 'anonymous', 'name', 'refid', 'refname', 'refuri')
+
+
# Lists
# -----
#
@@ -2340,7 +2345,7 @@
class figure(General, Element):
"""A formal figure, generally an illustration, with a title."""
valid_attributes: Final = Element.valid_attributes + ('align', 'width')
- content_model: Final = ((image, '.'),
+ content_model: Final = (((image, reference), '.'),
(caption, '?'),
(legend, '?'),
)
@@ -2568,11 +2573,6 @@
class title_reference(Inline, TextElement): pass
-class reference(General, Inline, Referential, TextElement):
- valid_attributes: Final = Element.valid_attributes + (
- 'anonymous', 'name', 'refid', 'refname', 'refuri')
-
-
class footnote_reference(Inline, Referential, PureTextElement):
valid_attributes: Final = Element.valid_attributes + (
'auto', 'refid', 'refname')
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-04-14 08:54:19
|
Revision: 10085
http://sourceforge.net/p/docutils/code/10085
Author: milde
Date: 2025-04-14 08:54:01 +0000 (Mon, 14 Apr 2025)
Log Message:
-----------
Test "clickable" image in a figure and fix LaTeX writer.
Add a "target" option to a "figure" directive in the standard.rst
functional test file to test handling and validation of an `<image>` wrapped
in a `<reference>` in a `<figure>`.
Fix the LaTeX writer's handling of images nested in a `<reference>`:
* Default to center-aligned images in a figure also if it is "clickable".
* Fix newlines in output of visit_image() and visit_reference().
* Add test cases to the LaTeX writer test.
Modified Paths:
--------------
trunk/docutils/docutils/writers/latex2e/__init__.py
trunk/docutils/test/functional/expected/latex_memoir.tex
trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
trunk/docutils/test/functional/expected/standalone_rst_html5.html
trunk/docutils/test/functional/expected/standalone_rst_latex.tex
trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
trunk/docutils/test/functional/input/data/standard.rst
trunk/docutils/test/test_writers/test_latex2e.py
Modified: trunk/docutils/docutils/writers/latex2e/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/latex2e/__init__.py 2025-04-14 08:53:31 UTC (rev 10084)
+++ trunk/docutils/docutils/writers/latex2e/__init__.py 2025-04-14 08:54:01 UTC (rev 10085)
@@ -2463,7 +2463,9 @@
# alignment defaults:
if 'align' not in attrs:
# Set default align of image in a figure to 'center'
- if isinstance(node.parent, nodes.figure):
+ if (isinstance(node.parent, nodes.figure)
+ or isinstance(node.parent, nodes.reference)
+ and isinstance(node.parent.parent, nodes.figure)):
attrs['align'] = 'center'
self.set_align_from_classes(node)
# pre- and postfix (prefix inserted in reverse order)
@@ -2470,6 +2472,8 @@
pre = []
post = []
include_graphics_options = []
+ if isinstance(node.parent, nodes.reference):
+ pre.append(self.out.pop()) # move \href behind alignment code
align_codes = {
# inline images: by default latex aligns the bottom.
'bottom': ('', ''),
@@ -2877,6 +2881,8 @@
ord('%'): '\\%',
ord('\\'): '\\\\',
}
+ if not (self.is_inline(node) or isinstance(node.parent, nodes.figure)):
+ self.out.append('\n')
# external reference (URL)
if 'refuri' in node:
href = str(node['refuri']).translate(special_chars)
@@ -2897,8 +2903,6 @@
href = self.document.nameids[node['refname']]
else:
raise AssertionError('Unknown reference.')
- if not self.is_inline(node):
- self.out.append('\n')
if self.reference_label:
self.out.append('\\%s{%s}' %
(self.reference_label, href.replace('#', '')))
@@ -2907,7 +2911,7 @@
def depart_reference(self, node) -> None:
self.out.append('}')
- if not self.is_inline(node):
+ if not (self.is_inline(node) or isinstance(node.parent, nodes.figure)):
self.out.append('\n')
def visit_revision(self, node) -> None:
Modified: trunk/docutils/test/functional/expected/latex_memoir.tex
===================================================================
--- trunk/docutils/test/functional/expected/latex_memoir.tex 2025-04-14 08:53:31 UTC (rev 10084)
+++ trunk/docutils/test/functional/expected/latex_memoir.tex 2025-04-14 08:54:01 UTC (rev 10085)
@@ -870,7 +870,7 @@
\begin{DUclass}{figclass1}
\begin{DUclass}{figclass2}
\begin{figure}
-\noindent\makebox[\linewidth][c]{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}}
+\noindent\makebox[\linewidth][c]{\href{https://docutils.sourceforge.io/rst.html}{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}}}
\caption{Plaintext markup syntax and parser system.}
\begin{DUlegend}
\setlength{\DUtablewidth}{\linewidth}%
Modified: trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2025-04-14 08:53:31 UTC (rev 10084)
+++ trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2025-04-14 08:54:01 UTC (rev 10085)
@@ -848,7 +848,7 @@
media, figures might float to a different position if this helps the page
layout.</paragraph>
<figure classes="figclass1 figclass2">
- <image alt="reStructuredText, the markup syntax" classes="class1 class2" uri="../../../docs/user/rst/images/title.png" width="258"></image>
+ <reference refuri="https://docutils.sourceforge.io/rst.html"><image alt="reStructuredText, the markup syntax" classes="class1 class2" uri="../../../docs/user/rst/images/title.png" width="258"></image></reference>
<caption>Plaintext markup syntax and parser system.</caption>
<legend>
<table>
Modified: trunk/docutils/test/functional/expected/standalone_rst_html4css1.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2025-04-14 08:53:31 UTC (rev 10084)
+++ trunk/docutils/test/functional/expected/standalone_rst_html4css1.html 2025-04-14 08:54:01 UTC (rev 10085)
@@ -617,7 +617,9 @@
media, figures might float to a different position if this helps the page
layout.</p>
<div class="figclass1 figclass2 figure">
+<a class="reference external image-reference" href="https://docutils.sourceforge.io/rst.html">
<img alt="reStructuredText, the markup syntax" class="class1 class2" src="../../../docs/user/rst/images/title.png" style="width: 258px;" />
+</a>
<p class="caption">Plaintext markup syntax and parser system.</p>
<div class="legend">
<table border="1" class="docutils">
Modified: trunk/docutils/test/functional/expected/standalone_rst_html5.html
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_html5.html 2025-04-14 08:53:31 UTC (rev 10084)
+++ trunk/docutils/test/functional/expected/standalone_rst_html5.html 2025-04-14 08:54:01 UTC (rev 10085)
@@ -614,7 +614,9 @@
media, figures might float to a different position if this helps the page
layout.</p>
<figure class="figclass1 figclass2">
+<a class="reference external image-reference" href="https://docutils.sourceforge.io/rst.html">
<img alt="reStructuredText, the markup syntax" class="class1 class2" src="../../../docs/user/rst/images/title.png" width="258" />
+</a>
<figcaption>
<p>Plaintext markup syntax and parser system.</p>
<div class="legend">
Modified: trunk/docutils/test/functional/expected/standalone_rst_latex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2025-04-14 08:53:31 UTC (rev 10084)
+++ trunk/docutils/test/functional/expected/standalone_rst_latex.tex 2025-04-14 08:54:01 UTC (rev 10085)
@@ -864,7 +864,7 @@
\begin{DUclass}{figclass1}
\begin{DUclass}{figclass2}
\begin{figure}
-\noindent\makebox[\linewidth][c]{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}}
+\noindent\makebox[\linewidth][c]{\href{https://docutils.sourceforge.io/rst.html}{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}}}
\caption{Plaintext markup syntax and parser system.}
\begin{DUlegend}
\setlength{\DUtablewidth}{\linewidth}%
Modified: trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2025-04-14 08:53:31 UTC (rev 10084)
+++ trunk/docutils/test/functional/expected/standalone_rst_pseudoxml.txt 2025-04-14 08:54:01 UTC (rev 10085)
@@ -1338,7 +1338,8 @@
media, figures might float to a different position if this helps the page
layout.
<figure classes="figclass1 figclass2">
- <image alt="reStructuredText, the markup syntax" classes="class1 class2" uri="../../../docs/user/rst/images/title.png" width="258">
+ <reference refuri="https://docutils.sourceforge.io/rst.html">
+ <image alt="reStructuredText, the markup syntax" classes="class1 class2" uri="../../../docs/user/rst/images/title.png" width="258">
<caption>
Plaintext markup syntax and parser system.
<legend>
@@ -2425,15 +2426,15 @@
<system_message level="1" line="476" source="functional/input/data/standard.rst" type="INFO">
<paragraph>
Hyperlink target "image-target-3" is not referenced.
- <system_message level="1" line="643" source="functional/input/data/standard.rst" type="INFO">
+ <system_message level="1" line="644" source="functional/input/data/standard.rst" type="INFO">
<paragraph>
Hyperlink target "target1" is not referenced.
- <system_message level="1" line="644" source="functional/input/data/standard.rst" type="INFO">
+ <system_message level="1" line="645" source="functional/input/data/standard.rst" type="INFO">
<paragraph>
Hyperlink target "target2" is not referenced.
- <system_message level="1" line="689" source="functional/input/data/standard.rst" type="INFO">
+ <system_message level="1" line="690" source="functional/input/data/standard.rst" type="INFO">
<paragraph>
Hyperlink target "docutils" is not referenced.
- <system_message level="1" line="855" source="functional/input/data/standard.rst" type="INFO">
+ <system_message level="1" line="856" source="functional/input/data/standard.rst" type="INFO">
<paragraph>
Hyperlink target "hyperlink targets" is not referenced.
Modified: trunk/docutils/test/functional/expected/standalone_rst_xetex.tex
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2025-04-14 08:53:31 UTC (rev 10084)
+++ trunk/docutils/test/functional/expected/standalone_rst_xetex.tex 2025-04-14 08:54:01 UTC (rev 10085)
@@ -889,7 +889,7 @@
\begin{DUclass}{figclass1}
\begin{DUclass}{figclass2}
\begin{figure}
-\noindent\makebox[\linewidth][c]{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}}
+\noindent\makebox[\linewidth][c]{\href{https://docutils.sourceforge.io/rst.html}{\includegraphics[width=258bp]{../../../docs/user/rst/images/title.png}}}
\caption{Plaintext markup syntax and parser system.}
\begin{DUlegend}
\setlength{\DUtablewidth}{\linewidth}%
Modified: trunk/docutils/test/functional/input/data/standard.rst
===================================================================
--- trunk/docutils/test/functional/input/data/standard.rst 2025-04-14 08:53:31 UTC (rev 10084)
+++ trunk/docutils/test/functional/input/data/standard.rst 2025-04-14 08:54:01 UTC (rev 10085)
@@ -526,6 +526,7 @@
:figclass: figclass1 figclass2
:class: class1 class2
:alt: reStructuredText, the markup syntax
+ :target: https://docutils.sourceforge.io/rst.html
:width: 258
Plaintext markup syntax and parser system.
Modified: trunk/docutils/test/test_writers/test_latex2e.py
===================================================================
--- trunk/docutils/test/test_writers/test_latex2e.py 2025-04-14 08:53:31 UTC (rev 10084)
+++ trunk/docutils/test/test_writers/test_latex2e.py 2025-04-14 08:54:01 UTC (rev 10085)
@@ -129,9 +129,29 @@
Foo (some raw text)
same paragraph.
"""],
+# images and figures
+["""
+.. image:: larch-mini.jpg
+ :target: larch.jpg
+ :align: center
+""",
+r"""
+\noindent\makebox[\linewidth][c]{\href{larch.jpg}{\includegraphics{larch-mini.jpg}}}
+"""],
+["""\
+.. figure:: larch-mini.jpg
+ :target: larch.jpg
+
+ The larch
+""",
+r"""
+\begin{figure}
+\noindent\makebox[\linewidth][c]{\href{larch.jpg}{\includegraphics{larch-mini.jpg}}}
+\caption{The larch}
+\end{figure}
+"""],
])
-
samples['latex_sectnum'] = ({'sectnum_xform': False}, [
["""\
.. sectnum::
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-04-17 12:22:06
|
Revision: 10091
http://sourceforge.net/p/docutils/code/10091
Author: milde
Date: 2025-04-17 12:21:36 +0000 (Thu, 17 Apr 2025)
Log Message:
-----------
Fix "error_encoding" default in the interactive help output.
While the "error_encoding" configuration setting allows specifying
the error handler after a colon, the default value is just the encoding
of the error stream determined by Python and the related error handler
defaults to the "error_encoding_error_handler" setting's default.
Also fix the output samples in the test suite.
Modified Paths:
--------------
trunk/docutils/docutils/frontend.py
trunk/docutils/test/data/help/docutils.rst
trunk/docutils/test/data/help/rst2html.rst
trunk/docutils/test/data/help/rst2latex.rst
trunk/docutils/test/test_CLI.py
Modified: trunk/docutils/docutils/frontend.py
===================================================================
--- trunk/docutils/docutils/frontend.py 2025-04-17 12:20:57 UTC (rev 10090)
+++ trunk/docutils/docutils/frontend.py 2025-04-17 12:21:36 UTC (rev 10091)
@@ -818,8 +818,7 @@
['--output-encoding-error-handler'],
{'default': 'strict', 'validator': validate_encoding_error_handler}),
('Specify text encoding and optionally error handler '
- 'for error output. Default: %s:%s.'
- % (default_error_encoding, default_error_encoding_error_handler),
+ 'for error output. Default: %s.' % default_error_encoding,
['--error-encoding', '-e'],
{'metavar': '<name[:handler]>', 'default': default_error_encoding,
'validator': validate_encoding_and_error_handler}),
Modified: trunk/docutils/test/data/help/docutils.rst
===================================================================
--- trunk/docutils/test/data/help/docutils.rst 2025-04-17 12:20:57 UTC (rev 10090)
+++ trunk/docutils/test/data/help/docutils.rst 2025-04-17 12:21:36 UTC (rev 10091)
@@ -73,7 +73,7 @@
"xmlcharrefreplace", "backslashreplace".
--error-encoding=<name[:handler]>, -e <name[:handler]>
Specify text encoding and optionally error handler for
- error output. Default: utf-8:backslashreplace.
+ error output. Default: utf-8.
--error-encoding-error-handler=ERROR_ENCODING_ERROR_HANDLER
Specify the error handler for unencodable characters
in error output. Default: backslashreplace.
Modified: trunk/docutils/test/data/help/rst2html.rst
===================================================================
--- trunk/docutils/test/data/help/rst2html.rst 2025-04-17 12:20:57 UTC (rev 10090)
+++ trunk/docutils/test/data/help/rst2html.rst 2025-04-17 12:21:36 UTC (rev 10091)
@@ -74,7 +74,7 @@
"xmlcharrefreplace", "backslashreplace".
--error-encoding=<name[:handler]>, -e <name[:handler]>
Specify text encoding and optionally error handler for
- error output. Default: utf-8:backslashreplace.
+ error output. Default: utf-8.
--error-encoding-error-handler=ERROR_ENCODING_ERROR_HANDLER
Specify the error handler for unencodable characters
in error output. Default: backslashreplace.
Modified: trunk/docutils/test/data/help/rst2latex.rst
===================================================================
--- trunk/docutils/test/data/help/rst2latex.rst 2025-04-17 12:20:57 UTC (rev 10090)
+++ trunk/docutils/test/data/help/rst2latex.rst 2025-04-17 12:21:36 UTC (rev 10091)
@@ -74,7 +74,7 @@
"xmlcharrefreplace", "backslashreplace".
--error-encoding=<name[:handler]>, -e <name[:handler]>
Specify text encoding and optionally error handler for
- error output. Default: utf-8:backslashreplace.
+ error output. Default: utf-8.
--error-encoding-error-handler=ERROR_ENCODING_ERROR_HANDLER
Specify the error handler for unencodable characters
in error output. Default: backslashreplace.
Modified: trunk/docutils/test/test_CLI.py
===================================================================
--- trunk/docutils/test/test_CLI.py 2025-04-17 12:20:57 UTC (rev 10090)
+++ trunk/docutils/test/test_CLI.py 2025-04-17 12:21:36 UTC (rev 10091)
@@ -75,8 +75,9 @@
output, flags=re.DOTALL)
# normalise error encoding default
output = output.replace(
- f'{core.OptionParser.default_error_encoding}:backslashreplace',
- 'utf-8:backslashreplace')
+ 'error output. Default: '
+ f'{core.OptionParser.default_error_encoding}',
+ 'error output. Default: utf-8')
return output
def test_main_help(self):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-04-17 12:22:57
|
Revision: 10092
http://sourceforge.net/p/docutils/code/10092
Author: milde
Date: 2025-04-17 12:22:39 +0000 (Thu, 17 Apr 2025)
Log Message:
-----------
Documentation update.
Complete some missing element descriptions and apply small fixes
in the Document Tree documentation.
Small fixes and reordering in the Documentation Index, release notes,
and "directives" description.
Modified Paths:
--------------
trunk/docutils/RELEASE-NOTES.rst
trunk/docutils/docs/index.rst
trunk/docutils/docs/ref/doctree.rst
trunk/docutils/docs/ref/rst/directives.rst
Modified: trunk/docutils/RELEASE-NOTES.rst
===================================================================
--- trunk/docutils/RELEASE-NOTES.rst 2025-04-17 12:21:36 UTC (rev 10091)
+++ trunk/docutils/RELEASE-NOTES.rst 2025-04-17 12:22:39 UTC (rev 10092)
@@ -90,12 +90,10 @@
* "html5" writer:
- Move attribution behind the blockquote to comply with the
- `"HTML living standard"`__. (The now retired HTML5__ W3C recommendation
- allows <cite> elements inside a blockquote.)
+ `"HTML living standard"`__ [#]_ and adapt CSS stylesheets
+ in Docutils 1.0.
__ https://html.spec.whatwg.org/#the-blockquote-element
- __ https://www.w3.org/TR/2014/REC-html5-20141028/grouping-content.html
- #the-blockquote-element
- 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.
@@ -125,6 +123,13 @@
and LaTeX writers: assume them relative to the *output* directory (as
required for image references in HTML), not the *source* directory.
+.. [#] The now retired `HTML5 W3C recommendation`__ allows <cite> elements
+ inside a blockquote.
+
+__ https://www.w3.org/TR/2014/REC-html5-20141028/grouping-content.html
+ #the-blockquote-element
+
+
Removals
--------
Modified: trunk/docutils/docs/index.rst
===================================================================
--- trunk/docutils/docs/index.rst 2025-04-17 12:21:36 UTC (rev 10091)
+++ trunk/docutils/docs/index.rst 2025-04-17 12:22:39 UTC (rev 10092)
@@ -39,12 +39,12 @@
Client-developers
developers using Docutils as a library,
programmers developing *with* Docutils.
- Component-developers:
+ Component-developers
those who implement application-specific components,
directives, and/or roles, separately from Docutils.
Core-developers
- developers of the Docutils codebase and participants
- in the Docutils project community.
+ contributors to the Docutils codebase and
+ participants in the Docutils project community.
Re-implementers
developers of alternate implementations of Docutils.
@@ -213,14 +213,21 @@
===============================================
Docutils-general:
+ * `Docutils Project Policies <dev/policies.html>`__
+ * `Docutils Testing <dev/testing.html>`__
* `Docutils Hacker's Guide <dev/hacking.html>`__
- * `Docutils Distributor's Guide <dev/distributing.html>`__
* `Docutils To Do List <dev/todo.html>`__
- * `Docutils Project Policies <dev/policies.html>`__
+ * `Docutils Version Repository <dev/repository.html>`__
* `Docutils Web Site <dev/website.html>`__
* `Docutils Release Procedure <dev/release.html>`__
- * `The Docutils Subversion Repository <dev/repository.html>`__
- * `Docutils Testing <dev/testing.html>`__
+ * `Docutils Distributor's Guide <dev/distributing.html>`__
+
+reStructuredText_:
+ * `A Record of reStructuredText Syntax Alternatives
+ <dev/rst/alternatives.html>`__
+ * `Problems With StructuredText <dev/rst/problems.html>`__
+
+Suspended projects and plans:
* `Docstring Semantics <dev/semantics.html>`__ (incomplete)
* `Python Source Reader <dev/pysource.html>`_ (incomplete)
* `Docutils Python DTD <dev/pysource.dtd>`_
@@ -227,11 +234,6 @@
* `Plan for Enthought API Documentation Tool <dev/enthought-plan.html>`_
* `Enthought API Documentation Tool RFP <dev/enthought-rfp.html>`_
-reStructuredText_:
- * `A Record of reStructuredText Syntax Alternatives
- <dev/rst/alternatives.html>`__
- * `Problems With StructuredText <dev/rst/problems.html>`__
-
.. Emacs settings
Local Variables:
Modified: trunk/docutils/docs/ref/doctree.rst
===================================================================
--- trunk/docutils/docs/ref/doctree.rst 2025-04-17 12:21:36 UTC (rev 10091)
+++ trunk/docutils/docs/ref/doctree.rst 2025-04-17 12:22:39 UTC (rev 10092)
@@ -548,9 +548,25 @@
<attribution>
=============
-`To be completed`_.
+The <attribution> element identifies the source of a `\<block_quote>`_.
+:Category: `Body Subelements`_ (simple)
+:Analogues: <attribution> is analogous to the DocBook_ <attribution> element.
+:Processing: Placed below the block quote, usually be preceded by a dash,
+ right aligned, or otherwise set apart from the quotation.
+:Parent: `\<block_quote>`_
+:Children: text data plus `inline elements`_ (`%text.model`_)
+:Attributes: only the `common attributes`_.
+The Docutils HTML and LaTeX writers provide the `"attribution"`_ setting
+to configure the formatting of the `\<attribution>`_.
+
+Examples
+--------
+
+See `\<block_quote>`_.
+
+
<author>
========
@@ -676,7 +692,10 @@
<attribution>
Anne Elk (Miss)
+The `"epigraph"`_ and `"pull-quote"`_ directives produce <block_quote>
+elements, too.
+
<bullet_list>
=============
@@ -729,9 +748,29 @@
<caption>
=========
-`To be completed`_.
+The <caption> element represents the title/caption of a `\<figure>`_. [#]_
+:Category: `Body Subelements`_ (simple)
+:Analogues: The <caption> element is analogous to the DocBook_
+ <title> element (but specific to a `\<figure>`_).
+ The HTML_ <figcaption> element combines <caption>
+ and `\<legend>`_.
+:Processing: Placed above, below, or besides the image it
+ describes. Often preceded by a figure number.
+ May be repeated in a generated "list of figures".
+:Parent: `\<figure>`_
+:Children: text data plus `inline elements`_ (`%text.model`_)
+:Attributes: only the `common attributes`_.
+Examples
+--------
+
+See `\<figure>`_.
+
+.. [#] The title/caption of a `\<table>`_ is represented by
+ a `\<title>`_ element.
+
+
<caution>
=========
@@ -765,15 +804,102 @@
<citation>
==========
-`To be completed`_.
+The <citation> element contains a description of an external
+bibliographic source. It is usually paired with one or more
+`\<citation_reference>`_ elements that represent corresponding
+reference marks in the running text.
+:Category: `Compound Body Elements`_
+:Analogues: <citation> is analogous to the DocBook_ <bibliomixed>
+ element. [#]_
+
+ The "doc-biblioentry" `DPub ARIA`_ role
+ (deprecated in version 1.1) can be used
+ to mark a `conforming HTML emulation`_.
+ The corresponding type in the
+ `EPUB 3 Structural Semantics Vocabulary`_ is "biblioentry".
+
+:Processing: Formatted as entry in a bibliography
+ or similar to a `\<footnote>`_.
+
+:Parents: all elements employing `%body.elements`_ or
+ `%structure.model`_ in their content models
+
+:Children: <citation> elements begin with a `\<label>`_
+ and contain `body elements`_::
+
+ (label, (%body.elements;)+)
+
+:Attributes: the `common attributes`_ and backrefs_.
+
+.. [#] The DocBook_ <citation> element resembles a `\<citation_reference>`_.
+
+Example
+-------
+See `\<citation_reference>`_.
+
+
<citation_reference>
====================
-`To be completed`_.
+The <citation_reference> element represents a cross reference
+to a `\<citation>`_.
+:Category: `Inline Elements`_
+:Analogues: The <citation_reference> element is analogous
+ to the DocBook_ <citation> element.
+ There is no equivalent in HTML. The <a> element can be used
+ to provide a link to the corresponding citation.
+:Processing: Typically enclosed in square brackets.
+:Parents: all elements employing `%text.model`_ in their content models
+:Children: only text data
+:Attributes: refid_, refname_, and the `common attributes`_.
+Example
+-------
+
+reStructuredText syntax for `citation references`_ is similar to a
+`footnote reference`_ except for the use of a `simple reference name`_
+instead of a numerical or symbolic label::
+
+ For details on brontosauruses, see [Elk:70]_.
+
+ .. [Elk:70] `My Theory on Brontosauruses`,
+ Anne Elk, London, 1972.
+
+Pseudo-XML_ fragment simple parsing::
+
+ <paragraph>
+ For details on brontosauruses, see
+ <citation_reference ids="citation-reference-1" refname="elk:70">
+ Elk:70
+ .
+ <citation ids="elk-70" names="elk:70">
+ <label>
+ Elk:70
+ <paragraph>
+ <title_reference>
+ My Theory on Brontosauruses
+ ,
+ Anne Elk, London, 1972.
+
+The ``references.Footnotes`` Docutils transform_ resolves this to::
+
+ <paragraph>
+ For details on brontosauruses, see
+ <citation_reference ids="citation-reference-1" refid="elk-70">
+ Elk:70
+ .
+ <citation backrefs="citation-reference-1" ids="elk-70" names="elk:70">
+ <label>
+ Elk:70
+ <paragraph>
+ <title_reference>
+ My Theory on Brontosauruses
+ ,
+ Anne Elk, London, 1972.
+
<classifier>
============
@@ -826,7 +952,7 @@
The <colspec> element contains specifications for a column in a `\<table>`_.
It is defined in the `Exchange Table Model`_.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (empty)
:Analogues: <colspec> is analogous to the DocBook_ <colspec> element.
The HTML_ <col> element is related but has different semantics.
:Processing: See `colspec`__ in the `Exchange Table Model`.
@@ -851,9 +977,50 @@
<comment>
=========
-`To be completed`_.
+The <comment> element is used for explanatory notes that should not be
+visible in the document rendering.
+:Category: `Simple Body Elements`_
+:Analogues: While most markup languages provide a syntax for comments,
+ the <comment> element has no direct analogues in HTML or DocBook.
+:Processing: Included as comment or skipped in translations to other markup
+ languages. [#]_ Hidden from the document rendering.
+:Parents: all elements employing `%body.elements`_, `%structure.model`_,
+ or `%text.model`_ in their content models
+:Children: only text data
+:Attributes: `xml:space`_ and the `common attributes`_.
+Examples
+--------
+
+In reStructuredText, a comment_ block [#]_ is started by two full stops.
+No processing is done on the content but beware of a misinterpretation as
+`explicit markup construct`_::
+
+ .. This is a *comment*.
+ .. [This] is a *citation*.
+ ..
+ [This] is another *comment*.
+
+Pseudo-XML_ fragment from simple parsing::
+
+ <comment xml:space="preserve">
+ This is a *comment*.
+ <citation ids="this" names="this">
+ <label>
+ This
+ <paragraph>
+ is a
+ <emphasis>
+ citation
+ .
+ <comment xml:space="preserve">
+ [This] is another *comment*.
+
+.. [#] In Docutils, the `"strip_comments"`_ configuration setting
+ triggers the removal of comment elements from the document tree.
+.. [#] There is no syntax for inline comments in reStructuredText.
+
<compound>
==========
@@ -1266,7 +1433,7 @@
The <description> element is the part of an `\<option_list>`_ item that
contains the description of a command-line option or group of options.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (compound)
:Analogues: <description> has no direct analogues in common DTDs.
:Processing: see `\<option_list>`_
:Parent: `\<option_list_item>`_
@@ -1275,7 +1442,7 @@
Examples
--------
-See the examples for the `\<option_list>`_ element.
+See `\<option_list>`_.
<docinfo>
@@ -1527,9 +1694,9 @@
The <entry> element represents one cell of a `\<table>`_.
It is defined in the `Exchange Table Model`_.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (compound)
:Analogues: <entry> is analogous to the DocBook_ <entry> element.
- HTML_ differentiates between header entries <td>
+ HTML_ differentiates between header entries <th>
and data entries <td>.
:Processing: Render content in a table cell. The morecols_ and morerows_
attributes may be used to define an entry spanning several
@@ -1643,7 +1810,7 @@
The <field> element contains one item of a `\<field_list>`_,
a pair of `\<field_name>`_ and `\<field_body>`_ elements.
-:Category: `Body Subelements`_, `Bibliographic Elements`_
+:Category: `Body Subelements`_ (compound), `Bibliographic Elements`_
:Analogues: <field> has no direct analogues in common DTDs.
HTML_ uses <div> elements inside <dl> lists for
grouping <dt>/<dd> pairs.
@@ -1662,7 +1829,7 @@
The <field_body> element is analogous to a database field's data.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (compound)
:Analogues: <field_body> is analogous to the HTML_ <dd> element.
:Processing: see `\<field_list>`_
:Parent: `\<field>`_
@@ -1756,9 +1923,50 @@
<figure>
========
-`To be completed`_.
+The <figure> element groups an `\<image>`_ with a `\<caption>`_
+and/or `\<legend>`_.
+:Category: `Compound Body Elements`_
+:Analogues: The <figure> element is analogous to the HTML_ <figure>
+ element and the DocBook_ <figure> and <informalfigure>
+ elements but limited to images (while HTML and DocBook
+ allow also other main content).
+:Processing: On paged media, figures may float to a different
+ position if this helps the page layout.
+:Parents: all elements employing `%body.elements`_ or
+ `%structure.model`_ in their content models
+:Children: `\<image>`_ or `\<reference>`_ (with nested <image>)
+ followed by `\<caption>`_ or `\<legend>`_ or both.
+:Attributes: align_ (via `%align-h.att`_) , width_,
+ and the `common attributes`_.
+Examples
+--------
+
+The reStructuredText `"figure" directive`_ creates a <figure> element::
+
+ .. figure:: larch-mini.jpg
+ :alt: a larch
+ :target: larch.jpg
+ :class: thumbnail
+ :figclass: numbered
+
+ The larch.
+
+ Larix decidua in Aletschwald.
+
+Pseudo-XML_ fragment from simple parsing::
+
+ <figure classes="numbered">
+ <reference refuri="larch.jpg">
+ <image alt="a larch" classes="thumbnail" uri="larch-mini.jpg">
+ <caption>
+ The larch.
+ <legend>
+ <paragraph>
+ Larix decidua in Aletschwald.
+
+
<footer>
========
@@ -1788,8 +1996,8 @@
A paragraph.
Complete pseudo-XML_ result after parsing and applying transforms_,
-assuming that the datestamp_ command-line option or configuration
-setting has been supplied::
+assuming that the ``--date`` command-line option or `"datestamp"`_
+configuration setting has been supplied::
<document>
<decoration>
@@ -1817,24 +2025,14 @@
The `DocBook \<footnote>`_ element combines features of
<footnote> and `\<footnote_reference>`_.
- The DPub ARIA role `"doc-footnote"`__ may be used to mark a
- (conforming__) `HTML emulation`__ as "ancillary information,
- such as a citation or commentary, that provides additional
- context to a referenced passage of text".
-
- For collections of notes that occur at the end of a section,
- the DPub ARIA role `"doc-endnotes"`__ is more appropriate.
-
+ The HTML standard lists suggestions to `emulate footnotes`_.
+ The `DPub ARIA`_ role "doc-footnote" may be used to mark a
+ `conforming HTML emulation`_ (for collections of notes that
+ occur at the end of a section, "doc-endnotes" is more
+ appropriate).
The corresponding types in the `EPUB 3 Structural Semantics
- Vocabulary`__ are "footnote" and "endnote".
+ Vocabulary`_ are "footnote" and "endnote".
- __ https://www.w3.org/TR/dpub-aria-1.0/#doc-footnote
- __ https://www.w3.org/TR/html-aria/#docconformance
- __ https://www.w3.org/TR/html51/
- common-idioms-without-dedicated-elements.html#footnotes
- __ https://www.w3.org/TR/dpub-aria-1.0/#doc-endnotes
- __ https://www.w3.org/TR/epub-ssv-11/#notes
-
:Processing: A <footnote> element should be set off from the rest of the
document, e.g. with a border or using a smaller font size.
@@ -1845,7 +2043,7 @@
`%structure.model`_ in their content models
:Children: <footnote> elements begin with an optional [#]_ `\<label>`_
- and contain `body elements`_. ::
+ and contain `body elements`_::
(label?, (%body.elements;)+)
@@ -1887,7 +2085,7 @@
brackets.
:Parents: all elements employing `%text.model`_ in their content models
:Children: only text data
-:Attributes: auto_, refid_, refname, and _the `common attributes`_.
+:Attributes: auto_, refid_, refname_, and the `common attributes`_.
Examples
--------
@@ -1923,13 +2121,36 @@
<generated>
===========
-Docutils wraps <generated> elements around text that is inserted
-(generated) by Docutils; i.e., text that was not in the document,
-like section numbers inserted by the "sectnum" directive.
+The <generated> element represents text that is not present in the
+document source but inserted by the processing system.
-`To be completed`_.
+:Category: `Inline Elements`_
+:Analogues: There are no analogies to <generated> in HTML_ or DocBook_.
+:Processing: No special handling required.
+:Parents: all elements employing `%text.model`_ in their content models
+:Children: text data plus `inline elements`_ (`%text.model`_)
+:Attributes: only the `common attributes`_.
+Examples
+--------
+The reStructuredText `"sectnum" directive`_ automatically numbers
+sections and subsections in a document::
+
+ .. section-numbering::
+
+ Anagram quiz
+ ============
+
+Docutils wraps the generated section numbers in <generated> elements::
+
+ <section ids="anagram-quiz" names="anagram\ quiz">
+ <title auto="1">
+ <generated classes="sectnum">
+ 1
+ Anagram quiz
+
+
<header>
========
@@ -2122,15 +2343,47 @@
<label>
=======
-`To be completed`_.
+The <label> element represents the reference label of
+a `\<footnote>`_ or `\<citation>`_.
+:Category: `Body Subelements`_ (simple)
+:Analogues: The <label> element has no direct analogues in HTML.
+ In DocBook_, the label of a footnote is stored as attribute
+ of the <footnote> element and the label of a bibliographic entry
+ is represented by an <abbrev> element.
+:Processing: Rendered prominently, as first token of the footnote or
+ citation. Often enclosed in square brackets.
+:Parents: `\<footnote>`_, `\<citation>`_
+:Children: only text data
+:Attributes: only the `common attributes`_.
+Examples
+--------
+
+See `\<footnote>`_, `\<footnote_reference>`_, and `\<citation_reference>`_.
+
+
<legend>
========
-`To be completed`_.
+The <legend> element contains an extended description of a `\<figure>`_.
+It may complement or replace the figure `\<caption>`_.
+:Category: `Body Subelements`_ (compound)
+:Analogues: The <legend> element is analogous to the DocBook_
+ <caption> element (but specific to a `\<figure>`_).
+ The HTML_ <figcaption> element combines `\<caption>`_
+ and <legend>.
+:Processing: Formatted as a displayed block.
+:Parent: `\<figure>`_
+:Children: `body elements`_
+:Attributes: only the `common attributes`_.
+Examples
+--------
+See `\<figure>`_.
+
+
<line>
======
@@ -2282,9 +2535,52 @@
<literal>
=========
-`To be completed`_.
+The <literal> element represents inline text that is some literal value.
+:Category: `Inline Elements`_
+:Analogues: <literal> is analogous to the DocBook_ <literal> element.
+ HTML_ uses the specific elements <code>, <kbd>, and <samp>
+ for code, input, and output.
+:Processing: Typically rendered in a monospace font.
+ Preservation of line breaks and sequences of
+ whitespace characters is not guaranteed.
+:Parents: all elements employing `%text.model`_ in their content models
+:Children: text data plus `inline elements`_ (`%text.model`_)
+:Attributes: only the `common attributes`_.
+Examples
+--------
+
+In reStructuredText, `inline literals`_, the `"literal" role`_,
+and the `"code" role`_ create <literal> elements.
+So do `custom roles`_ derived from "literal" or "code"::
+
+ .. role:: python(code)
+ :language: python
+
+ The statement :python:`print("hello world")`
+ writes ``"hello world"`` to standard output.
+
+Pseudo-XML_ fragment after parsing and applying the transform_::
+
+ <paragraph>
+ The statement
+ <literal classes="code python">
+ <inline classes="name builtin">
+ print
+ <inline classes="punctuation">
+ (
+ <inline classes="literal string double">
+ "hello world"
+ <inline classes="punctuation">
+ )
+
+ writes
+ <literal>
+ "hello world"
+ to standard output.
+
+
<literal_block>
===============
@@ -2341,7 +2637,7 @@
print(8/2)
-Pseudo-XML_ fragment from simple parsing (with the syntax_highlight_
+Pseudo-XML_ fragment from simple parsing (with the `"syntax_highlight"`_
setting at its default value "long")::
<literal_block classes="code python" xml:space="preserve">
@@ -2517,7 +2813,7 @@
The <option> element groups an option string together with zero or
more option argument placeholders.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (compound)
:Analogues: <option> has no direct analogues in common DTDs.
:Processing: See `\<option_list>`_.
:Parent: `\<option_group>`_
@@ -2542,7 +2838,7 @@
The <option_argument> element contains placeholder text for option
arguments.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (simple)
:Analogues: <option_argument> has no direct analogues in common DTDs.
:Processing: The value of the "delimiter" attribute is prefixed to the
<option_argument>, separating it from its
@@ -2565,12 +2861,12 @@
The <option_group> element groups together one or more `\<option>`_
elements, all synonyms.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (compound)
:Analogues: <option_group> has no direct analogues in common DTDs.
:Processing: Typically `\<option>`_ elements within an <option_group> are
joined together in a comma-separated list.
:Parent: `\<option_list_item>`_
-:Children: one or more `\<option>`_ elements.
+:Children: one or more `\<option>`_ elements
:Attributes: only the `common attributes`_.
Examples
@@ -2592,7 +2888,7 @@
arguments, and the second column contains descriptions.
:Parents: all elements employing `%body.elements`_ or
`%structure.model`_ in their content models
-:Children: one or more `\<option_list_item>`_ elements.
+:Children: one or more `\<option_list_item>`_ elements
:Attributes: only the `common attributes`_.
Examples
@@ -2643,7 +2939,7 @@
The <option_list_item> element is a container for a pair of
`\<option_group>`_ and `\<description>`_ elements.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (compound)
:Analogues: <option_list_item> has no direct analogues in common DTDs.
:Processing: see `\<option_list>`_
:Parent: `\<option_list>`_
@@ -2660,7 +2956,7 @@
The <option_string> element contains the text of a command-line option.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (simple)
:Analogues: <option_string> has no direct analogues in common DTDs.
:Processing: The <option_string> text is typically rendered in a
monospaced typeface.
@@ -2767,7 +3063,7 @@
The reStructuredText parser marks ambiguous or invalid inline syntax as
<problematic> and adds a reference to the associated `\<system_message>`_.
-The behaviour can be configured with the `report_level`_ setting.
+The behaviour can be configured with the `"report_level"`_ setting.
The following paragraph contains unbalanced `inline markup`_::
@@ -2875,7 +3171,7 @@
The <row> element represents one row of a `\<table>`_.
It is defined in the `Exchange Table Model`_.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (compound)
:Analogues: <row> is analogous to the HTML_ <tr> element
and the DocBook_ <row> element.
:Processing: Render content as a table row.
@@ -3269,7 +3565,7 @@
:Attributes: backrefs_, level_, line_, type_, and the `common attributes`_.
In Docutils, the generation of system messages can be configured with the
-`report_level`_ setting.
+`"report_level"`_ setting.
Examples
--------
@@ -3364,7 +3660,7 @@
`\<table>`_ (as distinct from the header rows).
It is defined in the `Exchange Table Model`_.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (compound)
:Analogues: <tbody> is analogous to the <tbody> element in HTML_ and DocBook_.
:Processing: Render content as table body.
:Parent: `\<tgroup>`_
@@ -3404,7 +3700,7 @@
The <tgroup> element identifies a logically complete portion of a `\<table>`_.
It is defined in the `Exchange Table Model`_.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (compound)
:Analogues: <tgroup> is analogous to the DocBook_ <tgroup> element.
There is no corresponding HTML element (the <colgroup>
element has a different purpose and semantics).
@@ -3442,7 +3738,7 @@
`\<table>`_ (as distinct from the body rows).
It is defined in the `Exchange Table Model`_.
-:Category: `Body Subelements`_
+:Category: `Body Subelements`_ (compound)
:Analogues: <thead> is analogous to the <thead> element in HTML_ and DocBook_.
:Processing: Header rows are always rendered at the beginning of the
table and often presented in an alternate typographic style,
@@ -3500,7 +3796,7 @@
elements`_, or a generic `\<admonition>`_. It is also used for the
caption of a `\<table>`_.
-:Category: `Structural Subelements`_, `Body Subelements`_
+:Category: `Structural Subelements`_, `Body Subelements`_ (simple)
:Analogues: <title> is analogous to the DocBook_ <title> element.
In difference to the HTML_ section heading elements
@@ -4194,7 +4490,7 @@
The ``loading`` attribute is used in the `\<image>`_ and `\<figure>`_
elements to indicate the preferred handling by the Docutils writer_. [#]_
-The default depends on the writer and the image_loading_
+The default depends on the writer and the `"image_loading"`_
configuration setting.
New in Docutils 0.21
@@ -4488,8 +4784,8 @@
The ``uri`` attribute is used in the `\<image>`_ and `\<figure>`_
elements to refer to the image via a `URI Reference`_ [#]_. [rfc3986]_
-The `root_prefix`_ configuration setting is applied when a URI Reference
-starting with "/" is converted to a local filesystem path.
+Docutils applies the `"root_prefix"`_ configuration setting when a
+URI Reference starting with "/" is converted to a local filesystem path.
.. [#] Examples are a full URI, an *absolute-path reference* (begins with
a single slash character) or a *relative-path reference* (does not
@@ -5065,8 +5361,8 @@
Identifiers cannot be specified directly in reStructuredText.
Docutils generates them from `reference names`_ or from the
- auto_id_prefix_ (prepending the id_prefix_ and appending numbers
- for disambiguation if required).
+ `"auto_id_prefix"`_ (prepending the `"id_prefix"`_ and
+ appending numbers for disambiguation if required).
.. [#id-vc] The `Docutils Generic DTD`_ cannot use the ID, IDREF,
and IDREFS standard types because elements do not adhere
@@ -5145,6 +5441,12 @@
David Goodger,
https://docutils.sourceforge.io/docs/ref/docutils.dtd.
+.. [dpub-aria] `Digital Publishing WAI-ARIA Module 1.0`,
+ W3C Recommendation, https://www.w3.org/TR/dpub-aria-1.0/.
+
+.. [epub-ssv] `EPUB 3 Structural Semantics Vocabulary`,
+ W3C Group Note, https://www.w3.org/TR/epub-ssv-11/.
+
.. [html.spec] `HTML Living Standard`,
WHATWG (Apple, Google, Mozilla, Microsoft),
https://html.spec.whatwg.org.
@@ -5178,7 +5480,16 @@
.. _DocBook <tip>: https://tdg.docbook.org/tdg/5.1/tip.html
.. _DocBook <warning>: https://tdg.docbook.org/tdg/5.1/warning.html
+.. _DPub ARIA: https://www.w3.org/TR/dpub-aria-1.0/
+.. _conforming HTML emulation: https://www.w3.org/TR/html-aria/#docconformance
+
+.. _EPUB 3 Structural Semantics Vocabulary:
+ https://www.w3.org/TR/epub-ssv-11/
+
.. _HTML: https://html.spec.whatwg.org/multipage/#toc-semantics
+.. _emulate footnotes:
+ https://html.spec.whatwg.org/multipage/semantics-other.html#footnotes
+
.. _Python: https://www.python.org/
.. _XML: https://developer.mozilla.org/en-US/docs/Web/XML/XML_introduction
@@ -5194,14 +5505,16 @@
.. _docutils.nodes:
.. _nodes.py: ../../docutils/nodes.py
-.. _auto_id_prefix: ../user/config.html#auto-id-prefix
-.. _datestamp: ../user/config.html#datestamp
-.. _id_prefix: ../user/config.html#id-prefix
-.. _image_loading: ../user/config.html#image-loading
-.. _report_level: ../user/config.html#report-level
-.. _root_prefix: ../user/config.html#root-prefix
-.. _styleshee...
[truncated message content] |
|
From: <mi...@us...> - 2025-04-17 21:44:34
|
Revision: 10093
http://sourceforge.net/p/docutils/code/10093
Author: milde
Date: 2025-04-17 21:44:18 +0000 (Thu, 17 Apr 2025)
Log Message:
-----------
Change section handling to not rely on exceptions and reparsing.
Use an explicit stack of sections in the memo object instead of raising
an EOFError to find the correct parent section.
Based on [patches:#213] by Arne Skj{U+00E6}rholt.
Fixes [bugs:#346] (duplicate System Messages).
`states.RSTStateMachine.memo.section_bubble_up_kludge`,
`states.RSTStateMachine.memo.section_level`,
states.RSTState.title_inconsistent()`, and `states.Line.eofcheck`
are now ignored and will be removed in Docutils 2.0.
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/RELEASE-NOTES.rst
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/test/test_parsers/test_rst/test_section_headers.py
trunk/docutils/test/test_parsers/test_rst/test_targets.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-04-17 12:22:39 UTC (rev 10092)
+++ trunk/docutils/HISTORY.rst 2025-04-17 21:44:18 UTC (rev 10093)
@@ -111,6 +111,9 @@
- Raise warning for empty footnotes and citations.
- Add source and line info to <enumerated-list> elements.
Fix line number of "start value not ordinal-1" INFO message.
+ - Change section handling to not rely on exceptions and reparsing.
+ Based on patch #213 by Arne Skjærholt.
+ Fixes bug #346 (duplicate System Messages).
* docutils/readers/__init__.py:
Modified: trunk/docutils/RELEASE-NOTES.rst
===================================================================
--- trunk/docutils/RELEASE-NOTES.rst 2025-04-17 12:22:39 UTC (rev 10092)
+++ trunk/docutils/RELEASE-NOTES.rst 2025-04-17 21:44:18 UTC (rev 10093)
@@ -129,7 +129,6 @@
__ https://www.w3.org/TR/2014/REC-html5-20141028/grouping-content.html
#the-blockquote-element
-
Removals
--------
@@ -184,6 +183,11 @@
in Docutils 2.0. Since Docutils 0.22, you may use "reader", "parser",
and "writer" arguments for component names as well as instances.
+* Remove `states.RSTStateMachine.memo.section_bubble_up_kludge`,
+ `states.RSTStateMachine.memo.section_level`,
+ `states.RSTState.title_inconsistent()`, and `states.Line.eofcheck`
+ in Docutils 2.0. Ignored since Docutils 0.22.
+
Misc
----
@@ -212,6 +216,7 @@
__ https://packages.debian.org/source/trixie/python-docutils
+
Release 0.22b.dev (unpublished)
===============================
@@ -287,7 +292,6 @@
`uri2path()` auxiliary method.
Provisional.
-
Removed objects
`docutils.core.Publisher.setup_option_parser()`
internal, obsolete,
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2025-04-17 12:22:39 UTC (rev 10092)
+++ trunk/docutils/docutils/parsers/rst/states.py 2025-04-17 21:44:18 UTC (rev 10093)
@@ -163,8 +163,9 @@
reporter=document.reporter,
language=self.language,
title_styles=[],
- section_level=0,
- section_bubble_up_kludge=False,
+ section_parents=[],
+ section_level=0, # will be removed in Docutils 2.0
+ section_bubble_up_kludge=False, # will be removed
inliner=inliner)
self.document = document
self.attach_observer(document.note_source)
@@ -330,46 +331,42 @@
def check_subsection(self, source, style, lineno) -> bool:
"""
- Check for a valid subsection header. Return True or False.
+ Check for a valid subsection header. Update section data in `memo`.
When a new section is reached that isn't a subsection of the current
- section, back up the line count (use ``previous_line(-x)``), then
- ``raise EOFError``. The current StateMachine will finish, then the
- calling StateMachine can re-examine the title. This will work its way
- back up the calling chain until the correct section level isreached.
-
- @@@ Alternative: Evaluate the title, store the title info & level, and
- back up the chain until that level is reached. Store in memo? Or
- return in results?
-
- :Exception: `EOFError` when a sibling or supersection encountered.
+ section, set `self.parent` to the new section's parent section.
"""
memo = self.memo
title_styles = memo.title_styles
- mylevel = memo.section_level
+ mylevel = len(memo.section_parents)
+ # Determine the level of the new section:
try: # check for existing title style
level = title_styles.index(style) + 1
except ValueError: # new title style
- if len(title_styles) == memo.section_level: # new subsection
- title_styles.append(style)
- return True
- else: # not at lowest level
- self.parent += self.title_inconsistent(source, lineno)
- return False
- if level <= mylevel: # sibling or supersection
- memo.section_level = level # bubble up to parent section
- if len(style) == 2:
- memo.section_bubble_up_kludge = True
- # back up 2 lines for underline title, 3 for overline title
- self.state_machine.previous_line(len(style) + 1)
- raise EOFError # let parent section re-evaluate
- if level == mylevel + 1: # immediate subsection
- return True
- else: # invalid subsection
- self.parent += self.title_inconsistent(source, lineno)
+ title_styles.append(style)
+ level = len(title_styles)
+ # The new level must not be deeper than an immediate child
+ # of the current level:
+ if level > mylevel + 1:
+ self.parent += self.reporter.severe(
+ 'Title level inconsistent:',
+ nodes.literal_block('', source),
+ line=lineno)
return False
+ # Update parent state:
+ if level > mylevel:
+ # new section is subsection of current section
+ memo.section_parents.append(self.parent)
+ memo.section_level += 1
+ else:
+ # new section is sibling or higher up in the section hierarchy
+ memo.section_parents[level:] = []
+ self.parent = memo.section_parents[-1]
+ memo.section_level = len(memo.section_parents)
+ return True
def title_inconsistent(self, sourcetext, lineno):
+ # Ignored. Will be removed in Docutils 2.0.
error = self.reporter.severe(
'Title level inconsistent:', nodes.literal_block('', sourcetext),
line=lineno)
@@ -377,9 +374,6 @@
def new_subsection(self, title, lineno, messages):
"""Append new subsection to document tree. On return, check level."""
- memo = self.memo
- mylevel = memo.section_level
- memo.section_level += 1
section_node = nodes.section()
self.parent += section_node
textnodes, title_messages = self.inline_text(title, lineno)
@@ -390,16 +384,16 @@
section_node += messages
section_node += title_messages
self.document.note_implicit_target(section_node, section_node)
- offset = self.state_machine.line_offset + 1
- absoffset = self.state_machine.abs_line_offset() + 1
- newabsoffset = self.nested_parse(
- self.state_machine.input_lines[offset:], input_offset=absoffset,
- node=section_node, match_titles=True)
- self.goto_line(newabsoffset)
- if memo.section_level <= mylevel: # can't handle next section?
- raise EOFError # bubble up to supersection
- # reset section_level; next pass will detect it properly
- memo.section_level = mylevel
+ # Update state:
+ self.state_machine.node = section_node
+ # Also update the ".parent" attribute in all states.
+ # This is a bit violent, but the state classes copy their .parent from
+ # state_machine.node on creation, so we need to update them. We could
+ # also remove RSTState.parent entirely and replace references to it
+ # with statemachine.node, but that might break code downstream of
+ # docutils.
+ for s in self.state_machine.states.values():
+ s.parent = section_node
def paragraph(self, lines, lineno):
"""
@@ -2950,25 +2944,20 @@
Second line of over- & underlined section title or transition marker.
"""
- eofcheck = 1 # @@@ ???
- """Set to 0 while parsing sections, so that we don't catch the EOF."""
+ eofcheck = 1 # will be removed in Docutils 2.0.
def eof(self, context):
"""Transition marker at end of section or document."""
marker = context[0].strip()
- if self.memo.section_bubble_up_kludge:
- self.memo.section_bubble_up_kludge = False
- elif len(marker) < 4:
+ if len(marker) < 4:
self.state_correction(context)
- if self.eofcheck: # ignore EOFError with sections
- src, srcline = self.state_machine.get_source_and_line()
- # lineno = self.state_machine.abs_line_number() - 1
- transition = nodes.transition(rawsource=context[0])
- transition.source = src
- transition.line = srcline - 1
- # transition.line = lineno
- self.parent += transition
- self.eofcheck = 1
+ src, srcline = self.state_machine.get_source_and_line()
+ # lineno = self.state_machine.abs_line_number() - 1
+ transition = nodes.transition(rawsource=context[0])
+ transition.source = src
+ transition.line = srcline - 1
+ # transition.line = lineno
+ self.parent += transition
return []
def blank(self, match, context, next_state):
@@ -3040,9 +3029,7 @@
line=lineno)
messages.append(msg)
style = (overline[0], underline[0])
- self.eofcheck = 0 # @@@ not sure this is correct
self.section(title.lstrip(), source, style, lineno + 1, messages)
- self.eofcheck = 1
return [], 'Body', []
indent = text # indented title
Modified: trunk/docutils/test/test_parsers/test_rst/test_section_headers.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_section_headers.py 2025-04-17 12:22:39 UTC (rev 10092)
+++ trunk/docutils/test/test_parsers/test_rst/test_section_headers.py 2025-04-17 21:44:18 UTC (rev 10093)
@@ -840,10 +840,6 @@
<paragraph>
Possible incomplete section title.
Treating the overline as ordinary text because it's so short.
- <system_message level="1" line="7" source="test data" type="INFO">
- <paragraph>
- Possible incomplete section title.
- Treating the overline as ordinary text because it's so short.
<section dupnames="..." ids="section-3">
<title>
...
Modified: trunk/docutils/test/test_parsers/test_rst/test_targets.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_targets.py 2025-04-17 12:22:39 UTC (rev 10092)
+++ trunk/docutils/test/test_parsers/test_rst/test_targets.py 2025-04-17 21:44:18 UTC (rev 10093)
@@ -23,6 +23,9 @@
class ParserTestCase(unittest.TestCase):
+
+ maxDiff = None
+
def test_parser(self):
parser = Parser()
settings = get_default_settings(Parser)
@@ -290,7 +293,7 @@
<title>
Title
<pending ids="title-1" names="title">
- <system_message backrefs="title-1" level="1" line="4" source="test data" type="INFO">
+ <system_message backrefs="title-1" level="1" line="7" source="test data" type="INFO">
<paragraph>
Duplicate implicit target name: "title".
.. internal attributes:
@@ -412,7 +415,7 @@
<target dupnames="target" ids="target-4" refuri="Explicit_external_target">
<rubric dupnames="target" ids="target-5">
directive with target
- <system_message backrefs="target-5" level="2" line="4" source="test data" type="WARNING">
+ <system_message backrefs="target-5" level="2" line="19" source="test data" type="WARNING">
<paragraph>
Duplicate explicit target name: "target".
"""],
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-04-18 15:49:03
|
Revision: 10094
http://sourceforge.net/p/docutils/code/10094
Author: milde
Date: 2025-04-18 15:48:45 +0000 (Fri, 18 Apr 2025)
Log Message:
-----------
More precise INFO if explicit target name overrides implicit one.
Modified Paths:
--------------
trunk/docutils/docutils/nodes.py
trunk/docutils/test/test_parsers/test_rst/test_targets.py
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2025-04-17 21:44:18 UTC (rev 10093)
+++ trunk/docutils/docutils/nodes.py 2025-04-18 15:48:45 UTC (rev 10094)
@@ -1904,18 +1904,18 @@
) -> None:
old_id = self.nameids[name]
old_explicit = self.nametypes[name]
+ old_node = self.ids.get(old_id)
self.nametypes[name] = old_explicit or explicit
if explicit:
if old_explicit:
level = 2
if old_id is not None:
- old_node = self.ids[old_id]
if 'refuri' in node:
refuri = node['refuri']
if (old_node['names']
and 'refuri' in old_node
and old_node['refuri'] == refuri):
- level = 1 # just inform if refuri's identical
+ level = 1 # just inform if refuri is identical
if level > 1:
dupname(old_node, name)
self.nameids[name] = None
@@ -1925,21 +1925,21 @@
if msgnode is not None:
msgnode += msg
dupname(node, name)
- else:
+ else: # new explicit, old implicit -> silently overwrite
self.nameids[name] = id
if old_id is not None:
- old_node = self.ids[old_id]
dupname(old_node, name)
- else:
+ else: # new name is implicit
if old_id is not None and not old_explicit:
self.nameids[name] = None
- old_node = self.ids[old_id]
dupname(old_node, name)
dupname(node, name)
if not explicit or (not old_explicit and old_id is not None):
- msg = self.reporter.info(
- 'Duplicate implicit target name: "%s".' % name,
- backrefs=[id], base_node=node)
+ if explicit:
+ s = f'Target name overrides implicit target name "{name}".'
+ else:
+ s = f'Duplicate implicit target name: "{name}".'
+ msg = self.reporter.info(s, backrefs=[id], base_node=node)
if msgnode is not None:
msgnode += msg
Modified: trunk/docutils/test/test_parsers/test_rst/test_targets.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_targets.py 2025-04-17 21:44:18 UTC (rev 10093)
+++ trunk/docutils/test/test_parsers/test_rst/test_targets.py 2025-04-18 15:48:45 UTC (rev 10094)
@@ -271,7 +271,7 @@
Title
<system_message backrefs="title-1" level="1" line="6" source="test data" type="INFO">
<paragraph>
- Duplicate implicit target name: "title".
+ Target name overrides implicit target name "title".
<target ids="title-1" names="title">
<paragraph>
Paragraph.
@@ -295,7 +295,7 @@
<pending ids="title-1" names="title">
<system_message backrefs="title-1" level="1" line="7" source="test data" type="INFO">
<paragraph>
- Duplicate implicit target name: "title".
+ Target name overrides implicit target name "title".
.. internal attributes:
.transform: docutils.transforms.references.TargetNotes
.details:
@@ -394,7 +394,7 @@
TARGET
<system_message backrefs="target-1" level="1" line="8" source="test data" type="INFO">
<paragraph>
- Duplicate implicit target name: "target".
+ Target name overrides implicit target name "target".
<paragraph>
Citation target.
<footnote auto="1" dupnames="target" ids="target-2">
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <gr...@us...> - 2025-04-20 12:34:45
|
Revision: 10095
http://sourceforge.net/p/docutils/code/10095
Author: grubert
Date: 2025-04-20 12:34:28 +0000 (Sun, 20 Apr 2025)
Log Message:
-----------
add uri break points before "."s
Modified Paths:
--------------
trunk/docutils/docutils/writers/manpage.py
trunk/docutils/test/test_writers/test_manpage.py
Modified: trunk/docutils/docutils/writers/manpage.py
===================================================================
--- trunk/docutils/docutils/writers/manpage.py 2025-04-18 15:48:45 UTC (rev 10094)
+++ trunk/docutils/docutils/writers/manpage.py 2025-04-20 12:34:28 UTC (rev 10095)
@@ -96,13 +96,16 @@
# after ampersands
# after number signs
# (?=.) avoids matching the end of string, requires something
-# TODO before each dot or a series of
+# MAYBE require 5 after the break point
NONBREAKING_INSERT_RE = re.compile(r'([/@?&#]+)(?=.)')
+# before each dot or a series of
+NONBREAKING_INSERT_RE2 = re.compile(r'([^\.]+)(?=\.+)(?=.)')
def insert_URI_breakpoints(s):
# TODO only for long URIs ?
- return NONBREAKING_INSERT_RE.sub(r'\1' + NONPRINTING_BREAKPOINT, s)
+ return NONBREAKING_INSERT_RE2.sub(r'\1' + NONPRINTING_BREAKPOINT,
+ NONBREAKING_INSERT_RE.sub(r'\1' + NONPRINTING_BREAKPOINT, s))
class Writer(writers.Writer):
Modified: trunk/docutils/test/test_writers/test_manpage.py
===================================================================
--- trunk/docutils/test/test_writers/test_manpage.py 2025-04-18 15:48:45 UTC (rev 10094)
+++ trunk/docutils/test/test_writers/test_manpage.py 2025-04-20 12:34:28 UTC (rev 10095)
@@ -21,14 +21,15 @@
from docutils.writers import manpage
URI_tests = (
- ("///abc.de", r"///\:abc.de"),
- ("/abc.de/", r"/\:abc.de/"),
- ("http://abc.de", r"http://\:abc.de"),
- ("http://abc.de/fg", r"http://\:abc.de/\:fg"),
- ("http://abc.de/fg?q=abc", r"http://\:abc.de/\:fg?\:q=abc"),
- ("http://abc.de/fg/?q=abc", r"http://\:abc.de/\:fg/?\:q=abc"),
- ("http://abc.de/fg/?q=abc&me#", r"http://\:abc.de/\:fg/?\:q=abc&\:me#"),
- ("me...@ho...", r"me@\:home.here"),
+ ("///abc.de", r"///\:abc\:.de"),
+ ("/abc.de/", r"/\:abc\:.de/"),
+ ("http://abc.de", r"http://\:abc\:.de"),
+ ("http://abc.de/fg", r"http://\:abc\:.de/\:fg"),
+ ("http://abc.de/fg?q=abc", r"http://\:abc\:.de/\:fg?\:q=abc"),
+ ("http://abc.de/fg/?q=abc", r"http://\:abc\:.de/\:fg/?\:q=abc"),
+ ("http://abc.de/fg/?q=abc&me#", r"http://\:abc\:.de/\:fg/?\:q=abc&\:me#"),
+ ("me...@ho...", r"me@\:home\:.here"),
+ ("me...@ho.....", r"me\:..dot@\:home\:.here\:.."),
)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-04-23 15:55:01
|
Revision: 10102
http://sourceforge.net/p/docutils/code/10102
Author: milde
Date: 2025-04-23 15:54:44 +0000 (Wed, 23 Apr 2025)
Log Message:
-----------
New option "figname" for the "figure" directive.
Fixes [feature-requests:#44].
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/RELEASE-NOTES.rst
trunk/docutils/docs/ref/rst/directives.rst
trunk/docutils/docutils/parsers/rst/directives/images.py
trunk/docutils/test/test_parsers/test_rst/test_directives/test_figures.py
trunk/docutils/test/test_writers/test_html4css1.py
trunk/docutils/test/test_writers/test_html5_polyglot.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-04-22 14:04:43 UTC (rev 10101)
+++ trunk/docutils/HISTORY.rst 2025-04-23 15:54:44 UTC (rev 10102)
@@ -90,6 +90,11 @@
- Support CSS3 `length units`_. Fixes feature-request #57.
+* docutils/parsers/rst/directives/images.py
+
+ - New option "figname" for the "figure" directive.
+ Fixes feature-request #44.
+
* docutils/parsers/rst/directives/misc.py
- Pass the included file's path to the parser when the
Modified: trunk/docutils/RELEASE-NOTES.rst
===================================================================
--- trunk/docutils/RELEASE-NOTES.rst 2025-04-22 14:04:43 UTC (rev 10101)
+++ trunk/docutils/RELEASE-NOTES.rst 2025-04-23 15:54:44 UTC (rev 10102)
@@ -57,7 +57,7 @@
* The <footnote> element's first child (<label>) will become mandatory
in Docutils 1.0.
-* The "rst" parser will warn if a "figure" directive is missing both
+* The "rst" parser will warn if a `"figure"`_ directive is missing both
caption and legend in Docutils 1.0.
* To match the definition in the "Exchange Table Model", the
@@ -221,10 +221,12 @@
===============================
reStructuredText:
- Support `CSS3 units`_. This adds "ch", "rem", "vw", "vh", "vmin",
- "vmax", and "Q" to the `supported length units`__.
- Note that some output formats don't support all units.
+ - Support `CSS3 units`_. This adds "ch", "rem", "vw", "vh", "vmin",
+ "vmax", and "Q" to the `supported length units`__. Note that some
+ output formats don't support all units.
+ - New option "figname" for the `"figure"`_ directive.
+
.. _CSS3 units: https://www.w3.org/TR/css-values-3/#lengths
__ docs/ref/rst/restructuredtext.html#length-units
@@ -1050,14 +1052,14 @@
- most directives now support a "name" option that attaches a
reference name. So you can write ::
- .. figure:: image.png
- :name: figure name
+ .. image:: image.png
+ :name: image name
as a short form of ::
- .. _figure name:
+ .. _image name:
- .. figure:: image.png
+ .. image:: image.png
Internationalization:
@@ -1146,9 +1148,7 @@
* reStructuredText:
- Allow length units for all length specifications.
- - Allow percent sign in "scale" argument of "figure" and "image" directives.
- - Bugfix: The "figalign" argument of a figure now works as intended
- (aligning the figure not its contents).
+ - Allow percent sign in "scale" option of "figure" and "image_" directives.
- Align images with class "align-[right|center|left]"
(allows setting the alignment of an image in a figure).
- Hard tabs **in literal inclusions** are replaced by spaces.
@@ -1184,6 +1184,8 @@
- Typeset generic topic as "quote with title".
- Use template (file and configuration option).
- Render doctest blocks as literal blocks (indented).
+ - Bugfix: The "align" argument of a figure now works as documented
+ (aligning the figure, not its contents).
* ODT writer:
@@ -1412,6 +1414,7 @@
.. _csv-table: docs/ref/rst/directives.html#csv-table
.. _"date": docs/ref/rst/directives.html#date
.. _doctest block: docs/ref/rst/restructuredtext.html#doctest-blocks
+.. _"figure": docs/ref/rst/directives.html#figure
.. _identifier normalization:
docs/ref/rst/directives.html#identifier-normalization
.. _image: docs/ref/rst/directives.html#image
Modified: trunk/docutils/docs/ref/rst/directives.rst
===================================================================
--- trunk/docutils/docs/ref/rst/directives.rst 2025-04-22 14:04:43 UTC (rev 10101)
+++ trunk/docutils/docs/ref/rst/directives.rst 2025-04-23 15:54:44 UTC (rev 10102)
@@ -33,11 +33,11 @@
details.
Descriptions below list "doctree elements" (document tree element
-names; XML DTD generic identifiers) corresponding to individual
-directives. For details on the hierarchy of elements, please see `The
-Docutils Document Tree`_ and the `Docutils Generic DTD`_ XML document
-type definition. For directive implementation details, see `Creating
-reStructuredText Directives`_.
+names; XML DTD generic identifiers) corresponding to individual directives.
+For details on the hierarchy of elements, please see `The Docutils
+Document Tree`_ and the `Docutils Generic DTD`_ XML document type definition.
+For directive implementation details, see `Creating reStructuredText
+Directives`_ and the `source <../../../docutils/parsers/rst/directives>`__.
.. _Docutils Generic DTD: ../docutils.dtd
.. _Creating reStructuredText Directives:
@@ -375,17 +375,27 @@
.. _figure options:
-The "figure" directive supports all `options of the "image" directive
-<image options_>`__. These options (except ``align``) are passed on
-to the contained image.
+The "figure" directive supports the `common options`_ and 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
- float and have the text flow around it. The specific behaviour
- depends upon the browser or rendering software used.
+ The horizontal alignment of the figure. The specific behaviour
+ depends upon the browser or rendering software used. In HTML, the
+ values "left" and "right" allow text to flow around the figure.
In addition, the following options are recognized:
+``figclass`` : space separated list of `class names`_
+ Set a `classes attribute`_ value on the <figure> element
+ (the "class__" option is applied to the nested <image>).
+
+ __ `class option`_
+
+``figname`` : text_
+ Add *text* to the `names attribute`_ of the <figure> element
+ (the "name_" option is applied to the nested <image>).
+
``figwidth`` : "image", length_, or percentage_ of current line width
The width of the figure.
Limits the horizontal space used by the figure.
@@ -394,7 +404,7 @@
Library`_). If the image file is not found or the required software is
unavailable, this option is ignored.
- Sets the `width attribute`_ of the <figure> doctree element.
+ Sets the `width attribute`_ of the `\<figure>`_ doctree element.
This option does not scale the included image; use the ``width``
`image option <image options_>`__ for that. ::
@@ -414,10 +424,6 @@
|wrap at this width. |
+---------------------------+
-``figclass`` : space separated list of `class names`_
- Set a `classes attribute`_ value on the figure element. See the
- `class directive`_ below.
-
.. _Python Imaging Library:
.. _Pillow: https://pypi.org/project/Pillow/
@@ -1768,7 +1774,7 @@
Second paragraph.
-The text above is parsed and transformed into this doctree fragment::
+The text above is parsed and transformed into this doctree_ fragment::
<paragraph classes="special">
This is a "special" paragraph.
@@ -2290,7 +2296,8 @@
.. _reStructuredText Standard Definition Files: definitions.html
-.. _The Docutils Document Tree: ../doctree.html
+.. _The Docutils Document Tree:
+.. _doctree: ../doctree.html
.. _identifiers: ../doctree.html#identifiers
.. _inline elements: ../doctree.html#inline-elements
.. _class names: ../doctree.html#class-names
Modified: trunk/docutils/docutils/parsers/rst/directives/images.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/directives/images.py 2025-04-22 14:04:43 UTC (rev 10101)
+++ trunk/docutils/docutils/parsers/rst/directives/images.py 2025-04-23 15:54:44 UTC (rev 10102)
@@ -119,8 +119,10 @@
return directives.length_or_percentage_or_unitless(argument, 'px')
option_spec = Image.option_spec.copy()
+
option_spec['figwidth'] = figwidth_value
option_spec['figclass'] = directives.class_option
+ option_spec['figname'] = directives.unchanged
option_spec['align'] = align
has_content = True
@@ -127,6 +129,7 @@
def run(self):
figwidth = self.options.pop('figwidth', None)
figclasses = self.options.pop('figclass', None)
+ figname = self.options.pop('figname', None)
align = self.options.pop('align', None)
(image_node,) = Image.run(self)
if isinstance(image_node, nodes.system_message):
@@ -149,6 +152,9 @@
figure_node['width'] = figwidth
if figclasses:
figure_node['classes'] += figclasses
+ if figname:
+ figure_node['names'].append(nodes.fully_normalize_name(figname))
+ self.state.document.note_explicit_target(figure_node, figure_node)
if align:
figure_node['align'] = align
if self.content:
Modified: trunk/docutils/test/test_parsers/test_rst/test_directives/test_figures.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_directives/test_figures.py 2025-04-22 14:04:43 UTC (rev 10101)
+++ trunk/docutils/test/test_parsers/test_rst/test_directives/test_figures.py 2025-04-23 15:54:44 UTC (rev 10102)
@@ -146,8 +146,9 @@
"""],
["""\
.. Figure:: picture.png
+ :alt: alternate text
+ :name: img:picture
:height: 100
- :alt: alternate text
:width: 200
:scale: 50
:loading: lazy
@@ -154,14 +155,14 @@
:class: image-class
:figwidth: 300
:figclass: class1 class2
- :name: fig:pix
+ :figname: Fig: pix
A figure with options and this caption.
""",
"""\
<document source="test data">
- <figure classes="class1 class2" width="300px">
- <image alt="alternate text" classes="image-class" height="100" ids="fig-pix" loading="lazy" names="fig:pix" scale="50" uri="picture.png" width="200">
+ <figure classes="class1 class2" ids="fig-pix" names="fig:\\ pix" width="300px">
+ <image alt="alternate text" classes="image-class" height="100" ids="img-picture" loading="lazy" names="img:picture" scale="50" uri="picture.png" width="200">
<caption>
A figure with options and this caption.
"""],
Modified: trunk/docutils/test/test_writers/test_html4css1.py
===================================================================
--- trunk/docutils/test/test_writers/test_html4css1.py 2025-04-22 14:04:43 UTC (rev 10101)
+++ trunk/docutils/test/test_writers/test_html4css1.py 2025-04-23 15:54:44 UTC (rev 10102)
@@ -306,6 +306,7 @@
],
["""\
.. figure:: dummy.png
+ :figname: fig:dummy
The figure's caption.
@@ -314,7 +315,7 @@
The legend's second paragraph.
""",
"""\
-<div class="figure">
+<div class="figure" id="fig-dummy">
<img alt="dummy.png" src="dummy.png" />
<p class="caption">The figure's caption.</p>
<div class="legend">
Modified: trunk/docutils/test/test_writers/test_html5_polyglot.py
===================================================================
--- trunk/docutils/test/test_writers/test_html5_polyglot.py 2025-04-22 14:04:43 UTC (rev 10101)
+++ trunk/docutils/test/test_writers/test_html5_polyglot.py 2025-04-23 15:54:44 UTC (rev 10102)
@@ -326,6 +326,7 @@
],
["""\
.. figure:: dummy.png
+ :figname: fig:dummy
The figure's caption.
@@ -334,7 +335,7 @@
The legend's second paragraph.
""",
"""\
-<figure>
+<figure id="fig-dummy">
<img alt="dummy.png" src="dummy.png" />
<figcaption>
<p>The figure's caption.</p>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mi...@us...> - 2025-04-25 13:14:06
|
Revision: 10104
http://sourceforge.net/p/docutils/code/10104
Author: milde
Date: 2025-04-25 13:13:48 +0000 (Fri, 25 Apr 2025)
Log Message:
-----------
Do not insert <system_message> elements if this results in an invalid doctree.
Add a validity test to fix `nodes.document.set_duplicate_name_id`
and revert addition of <system_message> elements for duplicate explicit targets
if it fails.
Adapt tests.
Revert the no longer required workaround in [r7638].
Cf. [bugs:#489]
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/docutils/nodes.py
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/test/test_parsers/test_rst/test_line_blocks.py
trunk/docutils/test/test_parsers/test_rst/test_targets.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-04-25 12:08:45 UTC (rev 10103)
+++ trunk/docutils/HISTORY.rst 2025-04-25 13:13:48 UTC (rev 10104)
@@ -73,6 +73,8 @@
- Removed `Element.set_class()`.
- Downgrade "duplicate ID" message level from SERIOUS to ERROR.
- Fix recursion in `Element.get_language_code()`.
+ - Do not insert <system_message> elements for duplicate explicit targets
+ if this results in an invalid doctree (cf. bug #489).
* docutils/parsers/docutils_xml.py
Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py 2025-04-25 12:08:45 UTC (rev 10103)
+++ trunk/docutils/docutils/nodes.py 2025-04-25 13:13:48 UTC (rev 10104)
@@ -1923,7 +1923,13 @@
level, 'Duplicate explicit target name: "%s".' % name,
backrefs=[id], base_node=node)
if msgnode is not None:
+ # append <system_message> if valid at this place
msgnode += msg
+ try:
+ msgnode.validate(recursive=False)
+ except ValidationError:
+ msgnode.pop()
+ msg.parent = None
dupname(node, name)
else: # new explicit, old implicit -> silently overwrite
self.nameids[name] = id
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2025-04-25 12:08:45 UTC (rev 10103)
+++ trunk/docutils/docutils/parsers/rst/states.py 2025-04-25 13:13:48 UTC (rev 10104)
@@ -1636,7 +1636,7 @@
def nest_line_block_lines(self, block) -> None:
for index in range(1, len(block)):
- if getattr(block[index], 'indent', None) is None:
+ if block[index].indent is None:
block[index].indent = block[index - 1].indent
self.nest_line_block_segment(block)
Modified: trunk/docutils/test/test_parsers/test_rst/test_line_blocks.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_line_blocks.py 2025-04-25 12:08:45 UTC (rev 10103)
+++ trunk/docutils/test/test_parsers/test_rst/test_line_blocks.py 2025-04-25 13:13:48 UTC (rev 10104)
@@ -322,7 +322,7 @@
* is not recognized.
"""],
["""\
-System messages can appear in place of lines:
+System messages are no longer inserted between <line>s:
| `uff <test1>`_
| `uff <test2>`_
@@ -330,15 +330,12 @@
"""\
<document source="test data">
<paragraph>
- System messages can appear in place of lines:
+ System messages are no longer inserted between <line>s:
<line_block>
<line>
<reference name="uff" refuri="test1">
uff
<target dupnames="uff" ids="uff" refuri="test1">
- <system_message backrefs="uff-1" level="2" line="3" source="test data" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "uff".
<line>
<reference name="uff" refuri="test2">
uff
Modified: trunk/docutils/test/test_parsers/test_rst/test_targets.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_targets.py 2025-04-25 12:08:45 UTC (rev 10103)
+++ trunk/docutils/test/test_parsers/test_rst/test_targets.py 2025-04-25 13:13:48 UTC (rev 10104)
@@ -345,6 +345,8 @@
.. rubric:: this is a title too
:name: title
+The system message is left dangling
+(to be handled by the "universal.Messages" transform).
""",
"""\
<document source="test data">
@@ -355,9 +357,9 @@
First.
<rubric dupnames="title" ids="title-1">
this is a title too
- <system_message backrefs="title-1" level="2" line="9" source="test data" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "title".
+ <paragraph>
+ The system message is left dangling
+ (to be handled by the "universal.Messages" transform).
"""],
["""\
Duplicate targets:
@@ -377,8 +379,14 @@
.. _target: Explicit_external_target
+| Do not insert <system_message> element for duplicate
+| _`target`, if this results in an invalid doctree.
+
.. rubric:: directive with target
:name: Target
+
+:field list: with
+:_`target`: in a field name
""",
"""\
<document source="test data">
@@ -413,11 +421,29 @@
<paragraph>
Duplicate explicit target name: "target".
<target dupnames="target" ids="target-4" refuri="Explicit_external_target">
- <rubric dupnames="target" ids="target-5">
+ <line_block>
+ <line>
+ Do not insert <system_message> element for duplicate
+ <line>
+ <target dupnames="target" ids="target-5">
+ target
+ , if this results in an invalid doctree.
+ <rubric dupnames="target" ids="target-6">
directive with target
- <system_message backrefs="target-5" level="2" line="19" source="test data" type="WARNING">
- <paragraph>
- Duplicate explicit target name: "target".
+ <field_list>
+ <field>
+ <field_name>
+ field list
+ <field_body>
+ <paragraph>
+ with
+ <field>
+ <field_name>
+ <target dupnames="target" ids="target-7">
+ target
+ <field_body>
+ <paragraph>
+ in a field name
"""],
["""\
.. _unescaped colon at end:: no good
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|