Exemplo n.º 1
0
 def reset(self, query):
     #query is the list of keywords,eg:['yu','aoi']
     query = [escape(word) for word in query]
     words = '|'.join(query)
     self.Q_PATTERN = re.compile(r'(?P<query>' + words + r')', re.I)
     self.highlight = 0
     BaseHTMLProcessor.reset(self)
Exemplo n.º 2
0
	def reset(self,query):
		#query is the list of keywords,eg:['yu','aoi']
		query=[escape(word) for word in query]
		words='|'.join(query)
		self.Q_PATTERN=re.compile(r'(?P<query>' + words + r')',re.I)
		self.highlight=0
		BaseHTMLProcessor.reset(self)
Exemplo n.º 3
0
 def end_a(self):
     if self._start_a:
         method = getattr( self, self._start_a.__name__.replace('start','end'), None )
         if method:
             method()
     else:
         BaseHTMLProcessor.unknown_endtag(self,"a")
Exemplo n.º 4
0
    def reset(self):

        self._start_a = None
        self.methodQueue = []
        self.divClassStack = []
        self.articleRec = []
        BaseHTMLProcessor.reset(self)
Exemplo n.º 5
0
    def reset(self):

        self._start_a = None
        self.methodQueue = []
        self.divClassStack = []
        self.articleRec = []
        BaseHTMLProcessor.reset(self)
Exemplo n.º 6
0
 def end_a(self):
     if self._start_a:
         method = getattr(self,
                          self._start_a.__name__.replace('start', 'end'),
                          None)
         if method:
             method()
     else:
         BaseHTMLProcessor.unknown_endtag(self, "a")
Exemplo n.º 7
0
 def unknown_endtag(self, tag):
     self.flushcolor()
     BaseHTMLProcessor.unknown_endtag(self, tag)
     if self.needcolor:
         self.colorindex = len(self.pieces)
Exemplo n.º 8
0
 def unknown_starttag(self, tag, attrs):
     self.flushcolor()
     BaseHTMLProcessor.unknown_starttag(self, tag, attrs)
     if self.needcolor:
         self.colorindex = len(self.pieces)
Exemplo n.º 9
0
	def __init__(self, basedir):
		BaseHTMLProcessor.__init__(self)
		self.basedir = basedir
Exemplo n.º 10
0
 def reset(self):
     # extend (called from __init__ in ancestor)
     # Reset all data attributes
     self.verbatim = 0
     BaseHTMLProcessor.reset(self)
Exemplo n.º 11
0
 def reset(self):
   '''extend (called from __init__ in ancestor)'''
   self.verbatim = 0
   BaseHTMLProcessor.reset(self)
Exemplo n.º 12
0
	def unknown_starttag(self, tag, attrs):
		self.flushcolor()
		BaseHTMLProcessor.unknown_starttag(self, tag, attrs)
		if self.needcolor:
			self.colorindex = len(self.pieces)
Exemplo n.º 13
0
 def reset(self):
     self.meta = {'data': ''}
     self.div_stack = []  # keep track of div
     self.methodStack = []
     BaseHTMLProcessor.reset(self)
	def __init__(self, basedir):
		BaseHTMLProcessor.__init__(self)
		self.basedir = basedir
Exemplo n.º 15
0
 def start_a(self,attrs):
     if self._start_a:
         self._start_a(attrs)
     else:
         BaseHTMLProcessor.unknown_starttag(self,"a",attrs)
Exemplo n.º 16
0
 def start_a(self, attrs):
     if self._start_a:
         self._start_a(attrs)
     else:
         BaseHTMLProcessor.unknown_starttag(self, "a", attrs)
Exemplo n.º 17
0
 def reset(self):
     self.verbatim = 0
     BaseHTMLProcessor.reset(self)
Exemplo n.º 18
0
	def reset(self):
		BaseHTMLProcessor.reset(self)
		self.colorindex = 0
		self.needcolor = 0
Exemplo n.º 19
0
 def reset(self):
     self.meta = {'data':''}
     self.div_stack = [] # keep track of div
     self.methodStack = []
     BaseHTMLProcessor.reset(self)
Exemplo n.º 20
0
#!/usr/bin/python
'''
 htmlQuo.py
 @author ffmmx
 
'''

from BaseHTMLProcessor import BaseHTMLProcessor
if __name__=='__main__':
    htmlSource='''
    <html>
     <head>
     <title>Test page</title>
     </head>
     <body>
     <ul>
     <li><a href=index.html>Home</a></li>
     <li><a href=toc.html>Table of contents</a></li>
     <li><a href=history.html>Revision history</a></li>
     </body>
     </html>
    '''
    parser=BaseHTMLProcessor()
    print parser.feed(htmlSource)

Exemplo n.º 21
0
	def __init__(self, usefonts=0):
		BaseHTMLProcessor.__init__(self)
		self.usefonts = usefonts
Exemplo n.º 22
0
#! /usr/bin/python

htmlSource = """
<html>
<head>
<title>Test page</title>
</head>
<body>
<ul>
<li><a href=index.html>Home</a></li>
<li><a href=toc.html>Table of contents</a></li>
<li><a href=history.html>Revision history</a></li>
</body>
</html>
"""
import sys
sys.path.append("../..")
from BaseHTMLProcessor import BaseHTMLProcessor

parser = BaseHTMLProcessor()
parser.feed(htmlSource)

print parser.output()
Exemplo n.º 23
0
	def flushcolor(self):
		if self.colorindex:
			buffer = "".join(self.pieces[self.colorindex:])
			self.pieces = self.pieces[:self.colorindex]
			self.colorindex = 0
			BaseHTMLProcessor.handle_data(self, self.HTMLfontify(buffer))
Exemplo n.º 24
0
import urllib 
from BaseHTMLProcessor import BaseHTMLProcessor
                                      
sock = urllib.urlopen("../Programmer/html/examples.html") 
htmlSource = sock.read()                            
sock.close() 
parser = BaseHTMLProcessor()
parser.feed(htmlSource)    
f = open('../Programmer/html/examples1.html', 'w')
f.write(parser.output())                           
Exemplo n.º 25
0
	def unknown_endtag(self, tag):
		self.flushcolor()
		BaseHTMLProcessor.unknown_endtag(self, tag)
		if self.needcolor:
			self.colorindex = len(self.pieces)
Exemplo n.º 26
0
 def __init__(self, usefonts=0):
     BaseHTMLProcessor.__init__(self)
     self.usefonts = usefonts
Exemplo n.º 27
0
 def reset(self):
     BaseHTMLProcessor.reset(self)
     self.colorindex = 0
     self.needcolor = 0
Exemplo n.º 28
0
 def flushcolor(self):
     if self.colorindex:
         buffer = "".join(self.pieces[self.colorindex:])
         self.pieces = self.pieces[:self.colorindex]
         self.colorindex = 0
         BaseHTMLProcessor.handle_data(self, self.HTMLfontify(buffer))
Exemplo n.º 29
0
	def reset(self):
		# extend (called from __init__ in ancestor)
		# Reset all data attributes
		self.verbatim = 0
		BaseHTMLProcessor.reset(self)
Exemplo n.º 30
0
 def reset(self):
     '''extend (called from __init__ in ancestor)'''
     self.verbatim = 0
     BaseHTMLProcessor.reset(self)