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

Amos Latteier amos@digiciool.com
Tue, 13 Mar 2001 15:11:17 -0500 (EST)


Update of /cvs-repository/Zope2/lib/python/StructuredText
In directory korak:/tmp/cvs-serv30459

Modified Files:
	DocumentClass.py 
Log Message:
Fixed a bug in how examples were handled.

Before this failed::

  line one

    line two

Now this example is handled correctly.



--- Updated File DocumentClass.py in package Zope2 --
--- DocumentClass.py	2001/03/12 20:05:49	1.9
+++ DocumentClass.py	2001/03/13 20:11:17	1.10
@@ -89,15 +89,25 @@
 StringType=type('')
 ListType=type([])
 
+def flatten(obj, append):
+   if obj.getNodeType()==STDOM.TEXT_NODE:
+      append(obj.getNodeValue())
+   else:
+      for child in obj.getChildNodes():
+         flatten(child, append)
+
+
 class StructuredTextExample(ST.StructuredTextParagraph):
     """Represents a section of document with literal text, as for examples"""
 
     def __init__(self, subs, **kw):
-       t=[]; a=t.append
-       for s in subs: a(s.getNodeValue())
-       apply(ST.StructuredTextParagraph.__init__,
-             (self, join(t,'\n\n'), ()),
-             kw)
+        t=[]
+        a=t.append
+        for s in subs:
+            flatten(s, a)
+        apply(ST.StructuredTextParagraph.__init__,
+              (self, join(t,'\n\n'), ()),
+              kw)
 
     def getColorizableTexts(self): return ()
     def setColorizableTexts(self, src): pass # never color examples