[Zope-Checkins] CVS: Zope2 - DocumentClass.py:1.21

chrism@serenade.digicool.com chrism@serenade.digicool.com
Sat, 16 Jun 2001 11:27:48 -0400


Update of /cvs-repository/Zope2/lib/python/StructuredText
In directory serenade:/home/chrism/BackTalk/lib/python/StructuredText

Modified Files:
	DocumentClass.py 
Log Message:
The color_paragraphs method of DocumentClass attempts to iterate through all the defined paragraph_type methods for each paragraph.  If a paragraph_type method returns anything but None, the colorization has been completed by the paragraph_type method, and we move on.  However, when a paragraph_type cannot be found to colorize a paragraph, we make a copy of the paragraph, and attempt to colorize its children with the color_paragraphs function.  In this case, the DOM-style attributes attached to the original paragraph were lost.  I modified the color_paragraphs method to retain the original paragraph's DOM-style attributes when a colorizer for the paragraph was not found.



--- Updated File DocumentClass.py in package Zope2 --
--- DocumentClass.py	2001/05/31 20:12:37	1.20
+++ DocumentClass.py	2001/06/16 15:27:48	1.21
@@ -487,12 +487,17 @@
                     r=r,
                 new_paragraphs=r
                 for paragraph in new_paragraphs:
-                    paragraph.setSubparagraphs(self.color_paragraphs(paragraph.getSubparagraphs()))
+                    subs = self.color_paragraphs(paragraph.getSubparagraphs())
+                    paragraph.setSubparagraphs(subs)
                 break
           else:
-             new_paragraphs=ST.StructuredTextParagraph(paragraph.getColorizableTexts()[0],
-                                                       self.color_paragraphs(paragraph.getSubparagraphs()),
-                                                       indent=paragraph.indent),
+             # copy, retain attributes
+             kw = {}
+             atts = getattr(paragraph, '_attributes', [])
+             for att in atts: kw[att] = getattr(paragraph, att)
+             subs = self.color_paragraphs(paragraph.getSubparagraphs())
+             new_paragraphs=apply(ST.StructuredTextParagraph,
+                (paragraph.getColorizableTexts()[0], subs), kw),
         
           # color the inline StructuredText types
           # for each StructuredTextParagraph