|
From: <mi...@us...> - 2024-02-27 16:14:43
|
Revision: 9549
http://sourceforge.net/p/docutils/code/9549
Author: milde
Date: 2024-02-27 16:14:41 +0000 (Tue, 27 Feb 2024)
Log Message:
-----------
Refactor HTML writer functions for definition lists.
In HTML, the optional "term classifier" is nested in the `<dt>` element.
Up to now, the closing `<dt>` was added in `visit_definition()`.
This is, however, problematic if we want to allow a "definition_list_item" with
multiple "term"s (cf. [feature-requests:60]).
Now, `</dt>` is appended in `depart_term()`, but only if no "classifier" node
follows. `depart_classifier()` also calls `depart_term()` so that `</dt>` is
added after the last "classifier".
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/RELEASE-NOTES.txt
trunk/docutils/docutils/writers/_html_base.py
trunk/docutils/docutils/writers/html4css1/__init__.py
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-02-26 11:51:40 UTC (rev 9548)
+++ trunk/docutils/HISTORY.txt 2024-02-27 16:14:41 UTC (rev 9549)
@@ -145,7 +145,7 @@
Since 0.18, you can use the CSS selector ``[role="doc-noteref"]``.
- Support reading/embedding images also with "file:" URI.
- Warn, if image scaling fails because the image file cannot be read.
- - Support video inclusion via `<video>` tags
+ - Support video inclusion via ``<video>`` tags
(moved here from writers/html5_polyglot/__init__.py).
- New auxiliary function `HTMLTranslator.uri2imagepath()`
ensures the image file can also be read when
@@ -154,9 +154,11 @@
to a local filesystem path.
- New <image> attribute "loading" overrides "image-loading" setting.
- Embed SVG images as ``<svg>`` instead of data-URI
- (not used by "html4css1"). Fixes [feature-request:#100].
+ (not used by "html4css1"). Fixes [feature-requests:#100].
- Write system messages for errors/warnings during the writing stage
(image transformations, math content conversion, ...).
+ - Close ``<dt>`` element in `depart_term()` to allow a `definition_list_item`
+ with multiple `term`\ s (cf. [feature-requests:60]).
.. _root-prefix: docs/user/config.html#root-prefix
Modified: trunk/docutils/RELEASE-NOTES.txt
===================================================================
--- trunk/docutils/RELEASE-NOTES.txt 2024-02-26 11:51:40 UTC (rev 9548)
+++ trunk/docutils/RELEASE-NOTES.txt 2024-02-27 16:14:41 UTC (rev 9549)
@@ -80,7 +80,8 @@
__ https://www.w3.org/TR/2014/REC-html5-20141028/grouping-content.html
#the-blockquote-element
- - Change the default value for math_output_ to "MathML" in Docutils 0.22.
+ - Change the default value for math_output_ to "MathML"
+ in Docutils 0.22.
- Change the default value of the initial_header_level_ setting to None
(<h2> if there is a document title, else <h1>) in Docutils 1.0.
@@ -105,12 +106,20 @@
.. _reference-label: docs/user/config.html#reference-label
-* "null" writer: output will change to the empty string in Docutils 0.22.
+* "null" writer: output will change to the empty string
+ in Docutils 0.22.
Misc
----
+* Document tree:
+ Allow multiple <term> elements in a <definition_list_item>
+ in Docutils 0.22 (cf. `feature-requests:60`__).
+ Third-party writers may need adaption.
+
+ __ https://sourceforge.net/p/docutils/feature-requests/60/
+
* Remove `parsers.rst.directives.CSVTable.HeaderDialect`
in Docutils 0.22.
@@ -135,7 +144,7 @@
__ docs/ref/transforms.html
* Remove mistranslated localizations of the "admonition" directive name in
- Docutils 0.22 or later.
+ Docutils 0.22.
Use the English term, matching translations introduced in Docutils 0.21,
or specific admonitions instead of "aanmaning" (nl),
Modified: trunk/docutils/docutils/writers/_html_base.py
===================================================================
--- trunk/docutils/docutils/writers/_html_base.py 2024-02-26 11:51:40 UTC (rev 9548)
+++ trunk/docutils/docutils/writers/_html_base.py 2024-02-27 16:14:41 UTC (rev 9549)
@@ -804,15 +804,12 @@
def depart_citation_reference(self, node):
self.body.append(']</a>')
- # classifier
- # ----------
- # don't insert classifier-delimiter here (done by CSS)
-
def visit_classifier(self, node):
self.body.append(self.starttag(node, 'span', '', CLASS='classifier'))
def depart_classifier(self, node):
self.body.append('</span>')
+ self.depart_term(node) # close the term element after last classifier
def visit_colspec(self, node):
self.colspecs.append(node)
@@ -881,10 +878,7 @@
pass
def visit_definition(self, node):
- if 'details' in node.parent.parent['classes']:
- self.body.append('</summary>\n')
- else:
- self.body.append('</dt>\n')
+ if 'details' not in node.parent.parent['classes']:
self.body.append(self.starttag(node, 'dd', ''))
def depart_definition(self, node):
@@ -1705,9 +1699,14 @@
ids=node.parent['ids']))
def depart_term(self, node):
- # Leave the end tag to `self.visit_definition()`,
- # in case there's a classifier.
- pass
+ # Nest (optional) classifier(s) in the <dt> element
+ if isinstance(node.next_node(descend=False, siblings=True),
+ nodes.classifier):
+ return # depart_classifier() calls this function again
+ if 'details' in node.parent.parent['classes']:
+ self.body.append('</summary>\n')
+ else:
+ self.body.append('</dt>\n')
def visit_tgroup(self, node):
self.colspecs = []
Modified: trunk/docutils/docutils/writers/html4css1/__init__.py
===================================================================
--- trunk/docutils/docutils/writers/html4css1/__init__.py 2024-02-26 11:51:40 UTC (rev 9548)
+++ trunk/docutils/docutils/writers/html4css1/__init__.py 2024-02-27 16:14:41 UTC (rev 9549)
@@ -278,6 +278,7 @@
def depart_classifier(self, node):
self.body.append('</span>')
+ self.depart_term(node) # close the <dt> after last classifier
# ersatz for first/last pseudo-classes
def visit_compound(self, node):
@@ -293,7 +294,6 @@
# ersatz for first/last pseudo-classes, no special handling of "details"
def visit_definition(self, node):
- self.body.append('</dt>\n')
self.body.append(self.starttag(node, 'dd', ''))
self.set_first_last(node)
@@ -881,7 +881,11 @@
ids=node.parent['ids']))
def depart_term(self, node):
- pass
+ # Nest (optional) classifier(s) in the <dt> element
+ if isinstance(node.next_node(descend=False, siblings=True),
+ nodes.classifier):
+ return # depart_classifier() calls this function again
+ self.body.append('</dt>\n')
# hard-coded vertical alignment
def visit_thead(self, node):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|