SF.net SVN: docutils:[9741 ] trunk/docutils

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9741
          http://sourceforge.net/p/docutils/code/9741
Author:   milde
Date:     2024-06-06 14:03:03 +0000 (Thu, 06 Jun 2024)
Log Message:
-----------
Make `references.AnonymousHyperlinks` transform idempotent.

Don't try to resolve already resolved anonymous hyperlinks again.

Fixes XML round-trip.

Modified Paths:
--------------
    trunk/docutils/HISTORY.txt
    trunk/docutils/docutils/transforms/references.py

Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt	2024-06-06 14:02:54 UTC (rev 9740)
+++ trunk/docutils/HISTORY.txt	2024-06-06 14:03:03 UTC (rev 9741)
@@ -55,6 +55,10 @@
     follows a <meta> or <decoration> element as this is invalid
     according to ``docutils.dtd``.
 
+* docutils/transforms/references.py
+
+  - Make `AnonymousHyperlinks` transform idempotent.
+
 * docutils/transforms/universal.py
 
   - `Messages` also handles "loose" system messages generated by the parser.
@@ -72,7 +76,6 @@
     when formatting with `indents`_.
 
 
-
 Release 0.21.2 (2024-04-23)
 ===========================
 

Modified: trunk/docutils/docutils/transforms/references.py
===================================================================
--- trunk/docutils/docutils/transforms/references.py	2024-06-06 14:02:54 UTC (rev 9740)
+++ trunk/docutils/docutils/transforms/references.py	2024-06-06 14:03:03 UTC (rev 9741)
@@ -135,11 +135,13 @@
                 ref.replace_self(prb)
             return
         for ref, target in zip(anonymous_refs, anonymous_targets):
-            target.referenced = 1
+            if ref.hasattr('refid') or ref.hasattr('refuri'):
+                continue
+            target.referenced = True
             while True:
                 if target.hasattr('refuri'):
                     ref['refuri'] = target['refuri']
-                    ref.resolved = 1
+                    ref.resolved = True
                     break
                 else:
                     if not target['ids']:

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.