SF.net SVN: docutils:[10151] trunk/docutils
milde--- via Docutils-checkins <[email protected]> Sun, 01 Jun 2025 15:39:35 +0000
| Newsgroups | gmane.text.docutils.cvs |
|---|---|
| Message-ID | <[email protected]> |
Revision: 10151
http://sourceforge.net/p/docutils/code/10151
Author: milde
Date: 2025-06-01 15:39:34 +0000 (Sun, 01 Jun 2025)
Log Message:
-----------
Warn about duplicate name in references with embedded internal targets.
Named references with embedded internal targets like
```this <that_>`_`` did not check for duplicate names when generating
the target `<target ids="this" names="this" refid="that">`.
(References with embedded URI did check.)
Modified Paths:
--------------
trunk/docutils/HISTORY.rst
trunk/docutils/docutils/parsers/rst/states.py
trunk/docutils/test/test_parsers/test_rst/test_inline_markup.py
trunk/docutils/test/test_transforms/test_hyperlinks.py
Modified: trunk/docutils/HISTORY.rst
===================================================================
--- trunk/docutils/HISTORY.rst 2025-06-01 08:34:07 UTC (rev 10150)
+++ trunk/docutils/HISTORY.rst 2025-06-01 15:39:34 UTC (rev 10151)
@@ -26,7 +26,15 @@
- New transform `CitationReferences`. Marks citation_references
as resolved if BibTeX is used by the backend (LaTeX).
+* docutils/parsers/rst/states.py
+ - Warn about duplicate name in references with embedded internal targets.
+
+* docutils/writers/manpage.py
+
+ - Do not drop text of internal targets.
+
+
Release 0.22rc2 (2025-05-22)
============================
@@ -256,7 +264,6 @@
- Print Docutils version in header comment (feature-request #105).
- Stop converting text to full capitals (bug #481).
- Fix reference output (bug #497).
- - Do not drop text of internal targets.
- Use macros .UR/.UE for hyperlink references unless the new
configuration setting text_references_ is True.
The current default is True (text references), it will change
Modified: trunk/docutils/docutils/parsers/rst/states.py
===================================================================
--- trunk/docutils/docutils/parsers/rst/states.py 2025-06-01 08:34:07 UTC (rev 10150)
+++ trunk/docutils/docutils/parsers/rst/states.py 2025-06-01 15:39:34 UTC (rev 10151)
@@ -857,8 +857,8 @@
self.document.note_refname(reference)
else:
reference['refuri'] = alias
- self.document.note_explicit_target(target, self.parent)
# target.note_referenced_by(name=refname)
+ self.document.note_explicit_target(target, self.parent)
node_list.append(target)
else:
reference['refname'] = refname
Modified: trunk/docutils/test/test_parsers/test_rst/test_inline_markup.py
===================================================================
--- trunk/docutils/test/test_parsers/test_rst/test_inline_markup.py 2025-06-01 08:34:07 UTC (rev 10150)
+++ trunk/docutils/test/test_parsers/test_rst/test_inline_markup.py 2025-06-01 15:39:34 UTC (rev 10151)
@@ -23,6 +23,8 @@
class ParserTestCase(unittest.TestCase):
+ maxDiff = None
+
def test_parser(self):
parser = Parser()
settings = get_default_settings(Parser)
@@ -1152,6 +1154,33 @@
<reference name="anonymouscall" refuri="anonymouscall">
anonymouscall
"""],
+["""\
+Report duplicate refnames. First use: _`named.txt` vs. _`anonymous.html`.
+
+Embedded targets: `<named.txt>`_, `<anonymous.html>`__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Report duplicate refnames. First use: \n\
+ <target dupnames="named.txt" ids="named-txt">
+ named.txt
+ vs. \n\
+ <target ids="anonymous-html" names="anonymous.html">
+ anonymous.html
+ .
+ <system_message backrefs="named-txt-1" level="2" line="4" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "named.txt".
+ <paragraph>
+ Embedded targets: \n\
+ <reference name="named.txt" refuri="named.txt">
+ named.txt
+ <target dupnames="named.txt" ids="named-txt-1" refuri="named.txt">
+ , \n\
+ <reference name="anonymous.html" refuri="anonymous.html">
+ anonymous.html
+"""],
]
totest['embedded_aliases'] = [
@@ -1163,7 +1192,7 @@
<paragraph>
<reference name="phrase reference" refname="alias">
phrase reference
- <target names="phrase\\ reference" refname="alias">
+ <target ids="phrase-reference" names="phrase\\ reference" refname="alias">
"""],
["""\
`anonymous reference <alias_>`__
@@ -1245,6 +1274,33 @@
<reference name="anonymous reference" refname="aliaswith\\ escaped :characters">
anonymous reference
"""],
+["""\
+Report duplicate refnames: First use: _`named` vs. _`anonymous`.
+
+Embedded alias: `named <anonymous_>`_, `ano <anonymous_>`__
+""",
+"""\
+<document source="test data">
+ <paragraph>
+ Report duplicate refnames: First use: \n\
+ <target dupnames="named" ids="named">
+ named
+ vs. \n\
+ <target ids="anonymous" names="anonymous">
+ anonymous
+ .
+ <system_message backrefs="named-1" level="2" line="4" source="test data" type="WARNING">
+ <paragraph>
+ Duplicate explicit target name: "named".
+ <paragraph>
+ Embedded alias: \n\
+ <reference name="named" refname="anonymous">
+ named
+ <target dupnames="named" ids="named-1" refname="anonymous">
+ , \n\
+ <reference name="ano" refname="anonymous">
+ ano
+"""],
]
totest['inline_targets'] = [
Modified: trunk/docutils/test/test_transforms/test_hyperlinks.py
===================================================================
--- trunk/docutils/test/test_transforms/test_hyperlinks.py 2025-06-01 08:34:07 UTC (rev 10150)
+++ trunk/docutils/test/test_transforms/test_hyperlinks.py 2025-06-01 15:39:34 UTC (rev 10151)
@@ -27,6 +27,8 @@
class TransformTestCase(unittest.TestCase):
+ maxDiff = None
+
def test_transforms(self):
parser = Parser()
settings = get_default_settings(Parser)
@@ -373,7 +375,7 @@
An \n\
<reference name="embedded alias" refuri="ham.py">
embedded alias
- <target names="embedded\\ alias" refuri="ham.py">
+ <target ids="embedded-alias" names="embedded\\ alias" refuri="ham.py">
.
<paragraph>
Another reference to the same \n\
@@ -405,11 +407,11 @@
An \n\
<problematic ids="problematic-1" refid="system-message-2">
`embedded alias <alias_>`_
- <target names="embedded\\ alias" refname="alias">
+ <target ids="embedded-alias" names="embedded\\ alias" refname="alias">
with unknown reference.
<system_message ids="system-message-1" level="3" line="1" source="test data" type="ERROR">
<paragraph>
- Indirect hyperlink target "embedded alias" refers to target "alias", which does not exist.
+ Indirect hyperlink target "embedded alias" (id="embedded-alias") refers to target "alias", which does not exist.
<system_message backrefs="problematic-1" ids="system-message-2" level="3" line="1" source="test data" type="ERROR">
<paragraph>
Unknown target name: "alias".
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.