[Zope-Checkins] CVS: Zope2 - __init__.py:1.6

Andreas Jung andreas@dhcp165.digicool.com
Wed, 2 May 2001 12:29:54 -0400


Update of /cvs-repository/Zope2/lib/python/Products/ZopeTutorial
In directory yetix:/work/sandboxes/Zope2/lib/python/Products/ZopeTutorial

Modified Files:
	__init__.py 
Log Message:
Workaround to get Tutorial working with STXNG



--- Updated File __init__.py in package Zope2 --
--- __init__.py	2001/04/27 20:27:50	1.5
+++ __init__.py	2001/05/02 16:28:38	1.6
@@ -139,7 +139,7 @@
                 topic_id = 'topic_%02d' % id
                 text=string.join(lines[1:], '')
                 text=term_pat.sub(glossaryTerm, text)
-                topic=TutorialTopic.TutorialTopic(topic_id, string.strip(lines[0]), text)
+                topic=TutorialTopic.TutorialTopic(topic_id, string.strip(lines[0]), spacestrip(text))
                 context.registerHelpTopic(topic_id, topic)            
             lines=[line]
         else:
@@ -148,6 +148,21 @@
             break
     f.close()
 
+
+def spacestrip(txt):
+    """ dedent text by 2 spaces !
+
+    We need this to workaround a nasty bug in STXNG. 
+    STXNG creates empty <pre>..</pre> when then text start
+    if a level > 1
+    """
+    
+    l = []
+    for x in string.split(txt,"\n"):
+        if len(x)>2 and x[:2]=='  ':
+            l.append(x[2:])
+
+    return string.join(l,'\n')
 
 
 # Glossary functions