[Zope-CVS] CVS: Packages/HTMLStructure - Parser.py:1.2
   
    Evan Simpson
     
    evan@zope.com
       
    Wed, 23 Jan 2002 17:08:28 -0500
    
    
  
Update of /cvs-repository/Packages/HTMLStructure
In directory cvs.zope.org:/tmp/cvs-serv18614
Modified Files:
	Parser.py 
Log Message:
Add posOfChar utility method.
=== Packages/HTMLStructure/Parser.py 1.1 => 1.2 ===
         self.linemap = getLines(text)
 
+    def posOfChar(self, index):
+        '''Convert a character index into a line number and line position.'''
+        line = self.lineOfChar(index)
+        if line > 0:
+            index -= self.linemap[line - 1]
+        return line, index
+
     def lineOfChar(self, index):
         '''Convert a character index into a line number.'''
         return bisect(self.linemap, index)