|
From: <mi...@us...> - 2024-05-31 14:42:08
|
Revision: 9722
http://sourceforge.net/p/docutils/code/9722
Author: milde
Date: 2024-05-31 14:42:06 +0000 (Fri, 31 May 2024)
Log Message:
-----------
xml-writer: improve formatting with "indents" setting.
Do not increase indentation of follow-up lines inside inline elements.
when formatting XML output with "indents".
Modified Paths:
--------------
trunk/docutils/HISTORY.txt
trunk/docutils/docutils/writers/docutils_xml.py
trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt 2024-05-31 14:41:57 UTC (rev 9721)
+++ trunk/docutils/HISTORY.txt 2024-05-31 14:42:06 UTC (rev 9722)
@@ -56,6 +56,13 @@
docutils version in header
- Stop converting text to full capitals (bug #481).
+* docutils/writers/docutils-xml.py
+
+ - Do not increase indentation of follow-up lines inside inline elements.
+ when formatting with `indents`_.
+
+
+
Release 0.21.2 (2024-04-23)
===========================
Modified: trunk/docutils/docutils/writers/docutils_xml.py
===================================================================
--- trunk/docutils/docutils/writers/docutils_xml.py 2024-05-31 14:41:57 UTC (rev 9721)
+++ trunk/docutils/docutils/writers/docutils_xml.py 2024-05-31 14:42:06 UTC (rev 9722)
@@ -119,7 +119,8 @@
if not self.in_simple:
self.output.append(self.indent*self.level)
self.output.append(node.starttag(xml.sax.saxutils.quoteattr))
- self.level += 1
+ if not isinstance(node, nodes.Inline):
+ self.level += 1
# `nodes.literal` is not an instance of FixedTextElement by design,
# see docs/ref/rst/restructuredtext.html#inline-literals
if isinstance(node, (nodes.FixedTextElement, nodes.literal)):
@@ -131,7 +132,8 @@
def default_departure(self, node):
"""Default node depart method."""
- self.level -= 1
+ if not isinstance(node, nodes.Inline):
+ self.level -= 1
if not self.in_simple:
self.output.append(self.indent*self.level)
self.output.append(node.endtag())
Modified: trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml
===================================================================
--- trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2024-05-31 14:41:57 UTC (rev 9721)
+++ trunk/docutils/test/functional/expected/standalone_rst_docutils_xml.xml 2024-05-31 14:42:06 UTC (rev 9722)
@@ -241,7 +241,7 @@
(<reference refuri="http://www.python.org">http://www.python.org</reference>), external hyperlinks (<reference name="Python" refuri="http://www.python.org/">Python</reference> <footnote_reference auto="1" ids="footnote-reference-10" refid="footnote-6">5</footnote_reference>), internal
cross-references (<reference name="example" refid="example">example</reference>), external hyperlinks with embedded URIs
(<reference name="Python web site" refuri="http://www.python.org">Python web site</reference>), <reference anonymous="1" name="anonymous hyperlink references" refuri="http://www.python.org/">anonymous hyperlink
- references</reference> <footnote_reference auto="1" ids="footnote-reference-14" refid="footnote-6">5</footnote_reference> (<reference anonymous="1" name="a second reference" refuri="https://docutils.sourceforge.io/">a second reference</reference> <footnote_reference auto="1" ids="footnote-reference-15" refid="footnote-8">7</footnote_reference>), footnote references (manually
+ references</reference> <footnote_reference auto="1" ids="footnote-reference-14" refid="footnote-6">5</footnote_reference> (<reference anonymous="1" name="a second reference" refuri="https://docutils.sourceforge.io/">a second reference</reference> <footnote_reference auto="1" ids="footnote-reference-15" refid="footnote-8">7</footnote_reference>), footnote references (manually
numbered <footnote_reference ids="footnote-reference-1" refid="footnote-1">1</footnote_reference>, anonymous auto-numbered <footnote_reference auto="1" ids="footnote-reference-2" refid="footnote-2">3</footnote_reference>, labeled auto-numbered
<footnote_reference auto="1" ids="footnote-reference-3" refid="label">2</footnote_reference>, or symbolic <footnote_reference auto="*" ids="footnote-reference-4" refid="footnote-3">*</footnote_reference>), citation references (see <citation_reference ids="citation-reference-1" refid="cit2002">CIT2002</citation_reference>),
substitution references (<image alt="EXAMPLE" uri="../../../docs/user/rst/images/biohazard.png"></image> &
@@ -751,7 +751,7 @@
<target refid="example"></target>
<paragraph ids="example" names="example">This paragraph is pointed to by the explicit "example" target. A
reference can be found under <reference name="Inline Markup" refid="inline-markup">Inline Markup</reference>, above. <reference name="Inline hyperlink targets" refid="inline-hyperlink-targets">Inline
- hyperlink targets</reference> are also possible.</paragraph>
+ hyperlink targets</reference> are also possible.</paragraph>
<paragraph>Section headers are implicit targets, referred to by name. See
<reference name="Targets" refid="targets">Targets</reference>, which is a subsection of <reference name="Body Elements" refid="body-elements">Body Elements</reference>.</paragraph>
<paragraph>Explicit external targets are interpolated into references such as
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|