forked from ScoDoc/ScoDoc
removed unused html2txt
This commit is contained in:
parent
a565fffe2f
commit
2bc3dc66a3
@ -717,44 +717,6 @@ if WITH_PYDOT:
|
||||
return g.get_node(name)
|
||||
|
||||
|
||||
from sgmllib import SGMLParser
|
||||
|
||||
|
||||
class html2txt_parser(SGMLParser):
|
||||
"""html2txt()"""
|
||||
|
||||
def reset(self):
|
||||
"""reset() --> initialize the parser"""
|
||||
SGMLParser.reset(self)
|
||||
self.pieces = []
|
||||
|
||||
def handle_data(self, text):
|
||||
"""handle_data(text) --> appends the pieces to self.pieces
|
||||
handles all normal data not between brackets "<>"
|
||||
"""
|
||||
self.pieces.append(text)
|
||||
|
||||
def handle_entityref(self, ref):
|
||||
"""called for each entity reference, e.g. for "©", ref will be
|
||||
"copy"
|
||||
Reconstruct the original entity reference.
|
||||
"""
|
||||
if ref == "amp":
|
||||
self.pieces.append("&")
|
||||
|
||||
def output(self):
|
||||
"""Return processed HTML as a single string"""
|
||||
return " ".join(self.pieces)
|
||||
|
||||
|
||||
def scodoc_html2txt(html):
|
||||
parser = html2txt_parser()
|
||||
parser.reset()
|
||||
parser.feed(html)
|
||||
parser.close()
|
||||
return parser.output()
|
||||
|
||||
|
||||
def is_valid_mail(email):
|
||||
"""True if well-formed email address"""
|
||||
return re.match(r"^.+@.+\..{2,3}$", email)
|
||||
|
Loading…
Reference in New Issue
Block a user