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

milde--- via Docutils-checkins <[email protected]>
Newsgroups gmane.text.docutils.cvs
Message-ID <[email protected]>
Revision: 9546
          http://sourceforge.net/p/docutils/code/9546
Author:   milde
Date:     2024-02-17 10:38:06 +0000 (Sat, 17 Feb 2024)
Log Message:
-----------
Fix mismatch between Docutils DTD and actual behaviour.

The rST parser sets the "xml:space" attribute on the `<math_block>`
doctree element since support this element in Docutils 0.8.
The documentation of the new element in the DTD missed this fact.
Add "xml:space" to the !ATTLIST so that "Docutils XML" documents
containing math blocks validate.

The `<raw>` element may only contain text, no inline elements.

Modified Paths:
--------------
    trunk/docutils/HISTORY.txt
    trunk/docutils/docs/ref/docutils.dtd
    trunk/docutils/docutils/nodes.py

Modified: trunk/docutils/HISTORY.txt
===================================================================
--- trunk/docutils/HISTORY.txt	2024-02-17 10:37:56 UTC (rev 9545)
+++ trunk/docutils/HISTORY.txt	2024-02-17 10:38:06 UTC (rev 9546)
@@ -29,6 +29,9 @@
 * docs/ref/docutils.dtd
 
   - The <image> element accepts the new attribute "loading".
+  - The <math_block> element uses the attribute "xml:space"
+    (actually since Docutils 0.8).
+  - The <raw> element may contain text only (no inline elements).
 
 * docutils/frontend.py
 

Modified: trunk/docutils/docs/ref/docutils.dtd
===================================================================
--- trunk/docutils/docs/ref/docutils.dtd	2024-02-17 10:37:56 UTC (rev 9545)
+++ trunk/docutils/docs/ref/docutils.dtd	2024-02-17 10:38:06 UTC (rev 9546)
@@ -468,7 +468,9 @@
 that is typeset as mathematical notation (display formula).
 -->
 <!ELEMENT math_block (#PCDATA)>
-<!ATTLIST math_block %basic.atts;>
+<!ATTLIST math_block 
+    %basic.atts;
+    %fixedspace.att;>
 
 <!ELEMENT line_block (line | line_block)+>
 <!ATTLIST line_block %basic.atts;>
@@ -594,7 +596,7 @@
     type      NMTOKEN   #IMPLIED>
 
 <!-- Used to pass raw data through the system. Also inline. -->
-<!ELEMENT raw %text.model;>
+<!ELEMENT raw (#PCDATA)>
 <!ATTLIST raw
     %basic.atts;
     %fixedspace.att;

Modified: trunk/docutils/docutils/nodes.py
===================================================================
--- trunk/docutils/docutils/nodes.py	2024-02-17 10:37:56 UTC (rev 9545)
+++ trunk/docutils/docutils/nodes.py	2024-02-17 10:38:06 UTC (rev 9546)
@@ -1119,10 +1119,17 @@
     """An element which directly contains preformatted text."""
 
     def __init__(self, rawsource='', text='', *children, **attributes):
-        TextElement.__init__(self, rawsource, text, *children, **attributes)
+        super().__init__(rawsource, text, *children, **attributes)
         self.attributes['xml:space'] = 'preserve'
 
 
+# TODO: PureTextElement(TextElement):
+#   """An element which only contains text, no children."""
+#   For elements in the DTD that directly employ #PCDATA in their definition:
+#   citation_reference, comment, footnote_reference, label, math, math_block,
+#   option_argument, option_string, raw,
+
+
 # ========
 #  Mixins
 # ========

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.



_______________________________________________
Docutils-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/docutils-checkins
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.