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

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9738
          http://sourceforge.net/p/docutils/code/9738
Author:   milde
Date:     2024-06-06 14:02:18 +0000 (Thu, 06 Jun 2024)
Log Message:
-----------
Let `transforms.universal.Messages` handle parser messages.

Include system messages generated by the parser in the list of
messages handled by the `universal.Messages` transform
(attach to "System Messages" section).

Helps parsers when a problem occurs but it is not clear
where to attach a system message (see "xml" parser for examples).

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

Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt	2024-06-06 14:02:08 UTC (rev 9737)
+++ trunk/docutils/HISTORY.txt	2024-06-06 14:02:18 UTC (rev 9738)
@@ -55,6 +55,10 @@
     follows a <meta> or <decoration> element as this is invalid
     according to ``docutils.dtd``.
 
+* docutils/transforms/universal.py
+
+  - `Messages` also handles "loose" system messages generated by the parser.
+
 * docutils/writers/manpage.py
 
   - Remove code for unused emdash bullets.

Modified: trunk/docutils/docutils/transforms/universal.py
===================================================================
--- trunk/docutils/docutils/transforms/universal.py	2024-06-06 14:02:08 UTC (rev 9737)
+++ trunk/docutils/docutils/transforms/universal.py	2024-06-06 14:02:18 UTC (rev 9738)
@@ -113,15 +113,17 @@
 
 class Messages(Transform):
 
+    """Handle "loose" messages.
+
+    Place system messages generated by parsing or transforms that are not
+    attached to the document tree into a dedicated section of the document.
     """
-    Place any system messages generated after parsing into a dedicated section
-    of the document.
-    """
 
     default_priority = 860
 
     def apply(self):
-        messages = self.document.transform_messages
+        messages = [*self.document.parse_messages,
+                    *self.document.transform_messages]
         loose_messages = [msg for msg in messages if not msg.parent]
         if loose_messages:
             section = nodes.section(classes=['system-messages'])

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.