[ZPT] CVS: Packages/TAL - HTMLParser.py:1.20

Fred L. Drake" <fdrake@acm.org> Fred L. Drake" <fdrake@acm.org>
Thu, 27 Sep 2001 01:22:47 -0400


Update of /cvs-repository/Packages/TAL
In directory cvs.zope.org:/tmp/cvs-serv668

Modified Files:
	HTMLParser.py 
Log Message:
Quick fix for Python 2.x dependency.

=== Packages/TAL/HTMLParser.py 1.19 => 1.20 ===
 
 
+def _contains_at(s, sub, pos):
+    return s[pos:pos+len(sub)] == sub
+
+
 class HTMLParser(markupbase.ParserBase):
     """Find tags and other markup and call handler functions.
 
@@ -152,11 +156,11 @@
                     k = self.parse_endtag(i)
                     if k >= 0:
                         self.clear_cdata_mode()
-                elif rawdata.startswith("<!--", i): # <!--
+                elif _contains_at(rawdata, "<!--", i): # <!--
                     k = self.parse_comment(i)
-                elif rawdata.startswith("<?", i): # <?
+                elif _contains_at(rawdata, "<?", i): # <?
                     k = self.parse_pi(i)
-                elif rawdata.startswith("<!", i): # <!
+                elif _contains_at(rawdata, "<?", i): # <!
                     k = self.parse_declaration(i)
                 elif (i + 1) < n:
                     self.handle_data("<")