Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../lib64/python3..../html
File: parser.py
"""A parser for HTML and XHTML."""
[0] Fix | Delete
[1] Fix | Delete
# This file is based on sgmllib.py, but the API is slightly different.
[2] Fix | Delete
[3] Fix | Delete
# XXX There should be a way to distinguish between PCDATA (parsed
[4] Fix | Delete
# character data -- the normal case), RCDATA (replaceable character
[5] Fix | Delete
# data -- only char and entity references and end tags are special)
[6] Fix | Delete
# and CDATA (character data -- only end tags are special).
[7] Fix | Delete
[8] Fix | Delete
[9] Fix | Delete
import re
[10] Fix | Delete
import warnings
[11] Fix | Delete
import _markupbase
[12] Fix | Delete
[13] Fix | Delete
from html import unescape
[14] Fix | Delete
[15] Fix | Delete
[16] Fix | Delete
__all__ = ['HTMLParser']
[17] Fix | Delete
[18] Fix | Delete
# Regular expressions used for parsing
[19] Fix | Delete
[20] Fix | Delete
interesting_normal = re.compile('[&<]')
[21] Fix | Delete
incomplete = re.compile('&[a-zA-Z#]')
[22] Fix | Delete
[23] Fix | Delete
entityref = re.compile('&([a-zA-Z][-.a-zA-Z0-9]*)[^a-zA-Z0-9]')
[24] Fix | Delete
charref = re.compile('&#(?:[0-9]+|[xX][0-9a-fA-F]+)[^0-9a-fA-F]')
[25] Fix | Delete
[26] Fix | Delete
starttagopen = re.compile('<[a-zA-Z]')
[27] Fix | Delete
piclose = re.compile('>')
[28] Fix | Delete
commentclose = re.compile(r'--\s*>')
[29] Fix | Delete
# Note:
[30] Fix | Delete
# 1) if you change tagfind/attrfind remember to update locatestarttagend too;
[31] Fix | Delete
# 2) if you change tagfind/attrfind and/or locatestarttagend the parser will
[32] Fix | Delete
# explode, so don't do it.
[33] Fix | Delete
# see http://www.w3.org/TR/html5/tokenization.html#tag-open-state
[34] Fix | Delete
# and http://www.w3.org/TR/html5/tokenization.html#tag-name-state
[35] Fix | Delete
tagfind_tolerant = re.compile(r'([a-zA-Z][^\t\n\r\f />\x00]*)(?:\s|/(?!>))*')
[36] Fix | Delete
attrfind_tolerant = re.compile(
[37] Fix | Delete
r'((?<=[\'"\s/])[^\s/>][^\s/=>]*)(\s*=+\s*'
[38] Fix | Delete
r'(\'[^\']*\'|"[^"]*"|(?![\'"])[^>\s]*))?(?:\s|/(?!>))*')
[39] Fix | Delete
locatestarttagend_tolerant = re.compile(r"""
[40] Fix | Delete
<[a-zA-Z][^\t\n\r\f />\x00]* # tag name
[41] Fix | Delete
(?:[\s/]* # optional whitespace before attribute name
[42] Fix | Delete
(?:(?<=['"\s/])[^\s/>][^\s/=>]* # attribute name
[43] Fix | Delete
(?:\s*=+\s* # value indicator
[44] Fix | Delete
(?:'[^']*' # LITA-enclosed value
[45] Fix | Delete
|"[^"]*" # LIT-enclosed value
[46] Fix | Delete
|(?!['"])[^>\s]* # bare value
[47] Fix | Delete
)
[48] Fix | Delete
(?:\s*,)* # possibly followed by a comma
[49] Fix | Delete
)?(?:\s|/(?!>))*
[50] Fix | Delete
)*
[51] Fix | Delete
)?
[52] Fix | Delete
\s* # trailing whitespace
[53] Fix | Delete
""", re.VERBOSE)
[54] Fix | Delete
endendtag = re.compile('>')
[55] Fix | Delete
# the HTML 5 spec, section 8.1.2.2, doesn't allow spaces between
[56] Fix | Delete
# </ and the tag name, so maybe this should be fixed
[57] Fix | Delete
endtagfind = re.compile(r'</\s*([a-zA-Z][-.a-zA-Z0-9:_]*)\s*>')
[58] Fix | Delete
[59] Fix | Delete
[60] Fix | Delete
[61] Fix | Delete
class HTMLParser(_markupbase.ParserBase):
[62] Fix | Delete
"""Find tags and other markup and call handler functions.
[63] Fix | Delete
[64] Fix | Delete
Usage:
[65] Fix | Delete
p = HTMLParser()
[66] Fix | Delete
p.feed(data)
[67] Fix | Delete
...
[68] Fix | Delete
p.close()
[69] Fix | Delete
[70] Fix | Delete
Start tags are handled by calling self.handle_starttag() or
[71] Fix | Delete
self.handle_startendtag(); end tags by self.handle_endtag(). The
[72] Fix | Delete
data between tags is passed from the parser to the derived class
[73] Fix | Delete
by calling self.handle_data() with the data as argument (the data
[74] Fix | Delete
may be split up in arbitrary chunks). If convert_charrefs is
[75] Fix | Delete
True the character references are converted automatically to the
[76] Fix | Delete
corresponding Unicode character (and self.handle_data() is no
[77] Fix | Delete
longer split in chunks), otherwise they are passed by calling
[78] Fix | Delete
self.handle_entityref() or self.handle_charref() with the string
[79] Fix | Delete
containing respectively the named or numeric reference as the
[80] Fix | Delete
argument.
[81] Fix | Delete
"""
[82] Fix | Delete
[83] Fix | Delete
CDATA_CONTENT_ELEMENTS = ("script", "style")
[84] Fix | Delete
[85] Fix | Delete
def __init__(self, *, convert_charrefs=True):
[86] Fix | Delete
"""Initialize and reset this instance.
[87] Fix | Delete
[88] Fix | Delete
If convert_charrefs is True (the default), all character references
[89] Fix | Delete
are automatically converted to the corresponding Unicode characters.
[90] Fix | Delete
"""
[91] Fix | Delete
self.convert_charrefs = convert_charrefs
[92] Fix | Delete
self.reset()
[93] Fix | Delete
[94] Fix | Delete
def reset(self):
[95] Fix | Delete
"""Reset this instance. Loses all unprocessed data."""
[96] Fix | Delete
self.rawdata = ''
[97] Fix | Delete
self.lasttag = '???'
[98] Fix | Delete
self.interesting = interesting_normal
[99] Fix | Delete
self.cdata_elem = None
[100] Fix | Delete
_markupbase.ParserBase.reset(self)
[101] Fix | Delete
[102] Fix | Delete
def feed(self, data):
[103] Fix | Delete
r"""Feed data to the parser.
[104] Fix | Delete
[105] Fix | Delete
Call this as often as you want, with as little or as much text
[106] Fix | Delete
as you want (may include '\n').
[107] Fix | Delete
"""
[108] Fix | Delete
self.rawdata = self.rawdata + data
[109] Fix | Delete
self.goahead(0)
[110] Fix | Delete
[111] Fix | Delete
def close(self):
[112] Fix | Delete
"""Handle any buffered data."""
[113] Fix | Delete
self.goahead(1)
[114] Fix | Delete
[115] Fix | Delete
__starttag_text = None
[116] Fix | Delete
[117] Fix | Delete
def get_starttag_text(self):
[118] Fix | Delete
"""Return full source of start tag: '<...>'."""
[119] Fix | Delete
return self.__starttag_text
[120] Fix | Delete
[121] Fix | Delete
def set_cdata_mode(self, elem):
[122] Fix | Delete
self.cdata_elem = elem.lower()
[123] Fix | Delete
self.interesting = re.compile(r'</\s*%s\s*>' % self.cdata_elem, re.I)
[124] Fix | Delete
[125] Fix | Delete
def clear_cdata_mode(self):
[126] Fix | Delete
self.interesting = interesting_normal
[127] Fix | Delete
self.cdata_elem = None
[128] Fix | Delete
[129] Fix | Delete
# Internal -- handle data as far as reasonable. May leave state
[130] Fix | Delete
# and data to be processed by a subsequent call. If 'end' is
[131] Fix | Delete
# true, force handling all data as if followed by EOF marker.
[132] Fix | Delete
def goahead(self, end):
[133] Fix | Delete
rawdata = self.rawdata
[134] Fix | Delete
i = 0
[135] Fix | Delete
n = len(rawdata)
[136] Fix | Delete
while i < n:
[137] Fix | Delete
if self.convert_charrefs and not self.cdata_elem:
[138] Fix | Delete
j = rawdata.find('<', i)
[139] Fix | Delete
if j < 0:
[140] Fix | Delete
# if we can't find the next <, either we are at the end
[141] Fix | Delete
# or there's more text incoming. If the latter is True,
[142] Fix | Delete
# we can't pass the text to handle_data in case we have
[143] Fix | Delete
# a charref cut in half at end. Try to determine if
[144] Fix | Delete
# this is the case before proceeding by looking for an
[145] Fix | Delete
# & near the end and see if it's followed by a space or ;.
[146] Fix | Delete
amppos = rawdata.rfind('&', max(i, n-34))
[147] Fix | Delete
if (amppos >= 0 and
[148] Fix | Delete
not re.compile(r'[\s;]').search(rawdata, amppos)):
[149] Fix | Delete
break # wait till we get all the text
[150] Fix | Delete
j = n
[151] Fix | Delete
else:
[152] Fix | Delete
match = self.interesting.search(rawdata, i) # < or &
[153] Fix | Delete
if match:
[154] Fix | Delete
j = match.start()
[155] Fix | Delete
else:
[156] Fix | Delete
if self.cdata_elem:
[157] Fix | Delete
break
[158] Fix | Delete
j = n
[159] Fix | Delete
if i < j:
[160] Fix | Delete
if self.convert_charrefs and not self.cdata_elem:
[161] Fix | Delete
self.handle_data(unescape(rawdata[i:j]))
[162] Fix | Delete
else:
[163] Fix | Delete
self.handle_data(rawdata[i:j])
[164] Fix | Delete
i = self.updatepos(i, j)
[165] Fix | Delete
if i == n: break
[166] Fix | Delete
startswith = rawdata.startswith
[167] Fix | Delete
if startswith('<', i):
[168] Fix | Delete
if starttagopen.match(rawdata, i): # < + letter
[169] Fix | Delete
k = self.parse_starttag(i)
[170] Fix | Delete
elif startswith("</", i):
[171] Fix | Delete
k = self.parse_endtag(i)
[172] Fix | Delete
elif startswith("<!--", i):
[173] Fix | Delete
k = self.parse_comment(i)
[174] Fix | Delete
elif startswith("<?", i):
[175] Fix | Delete
k = self.parse_pi(i)
[176] Fix | Delete
elif startswith("<!", i):
[177] Fix | Delete
k = self.parse_html_declaration(i)
[178] Fix | Delete
elif (i + 1) < n:
[179] Fix | Delete
self.handle_data("<")
[180] Fix | Delete
k = i + 1
[181] Fix | Delete
else:
[182] Fix | Delete
break
[183] Fix | Delete
if k < 0:
[184] Fix | Delete
if not end:
[185] Fix | Delete
break
[186] Fix | Delete
k = rawdata.find('>', i + 1)
[187] Fix | Delete
if k < 0:
[188] Fix | Delete
k = rawdata.find('<', i + 1)
[189] Fix | Delete
if k < 0:
[190] Fix | Delete
k = i + 1
[191] Fix | Delete
else:
[192] Fix | Delete
k += 1
[193] Fix | Delete
if self.convert_charrefs and not self.cdata_elem:
[194] Fix | Delete
self.handle_data(unescape(rawdata[i:k]))
[195] Fix | Delete
else:
[196] Fix | Delete
self.handle_data(rawdata[i:k])
[197] Fix | Delete
i = self.updatepos(i, k)
[198] Fix | Delete
elif startswith("&#", i):
[199] Fix | Delete
match = charref.match(rawdata, i)
[200] Fix | Delete
if match:
[201] Fix | Delete
name = match.group()[2:-1]
[202] Fix | Delete
self.handle_charref(name)
[203] Fix | Delete
k = match.end()
[204] Fix | Delete
if not startswith(';', k-1):
[205] Fix | Delete
k = k - 1
[206] Fix | Delete
i = self.updatepos(i, k)
[207] Fix | Delete
continue
[208] Fix | Delete
else:
[209] Fix | Delete
if ";" in rawdata[i:]: # bail by consuming &#
[210] Fix | Delete
self.handle_data(rawdata[i:i+2])
[211] Fix | Delete
i = self.updatepos(i, i+2)
[212] Fix | Delete
break
[213] Fix | Delete
elif startswith('&', i):
[214] Fix | Delete
match = entityref.match(rawdata, i)
[215] Fix | Delete
if match:
[216] Fix | Delete
name = match.group(1)
[217] Fix | Delete
self.handle_entityref(name)
[218] Fix | Delete
k = match.end()
[219] Fix | Delete
if not startswith(';', k-1):
[220] Fix | Delete
k = k - 1
[221] Fix | Delete
i = self.updatepos(i, k)
[222] Fix | Delete
continue
[223] Fix | Delete
match = incomplete.match(rawdata, i)
[224] Fix | Delete
if match:
[225] Fix | Delete
# match.group() will contain at least 2 chars
[226] Fix | Delete
if end and match.group() == rawdata[i:]:
[227] Fix | Delete
k = match.end()
[228] Fix | Delete
if k <= i:
[229] Fix | Delete
k = n
[230] Fix | Delete
i = self.updatepos(i, i + 1)
[231] Fix | Delete
# incomplete
[232] Fix | Delete
break
[233] Fix | Delete
elif (i + 1) < n:
[234] Fix | Delete
# not the end of the buffer, and can't be confused
[235] Fix | Delete
# with some other construct
[236] Fix | Delete
self.handle_data("&")
[237] Fix | Delete
i = self.updatepos(i, i + 1)
[238] Fix | Delete
else:
[239] Fix | Delete
break
[240] Fix | Delete
else:
[241] Fix | Delete
assert 0, "interesting.search() lied"
[242] Fix | Delete
# end while
[243] Fix | Delete
if end and i < n and not self.cdata_elem:
[244] Fix | Delete
if self.convert_charrefs and not self.cdata_elem:
[245] Fix | Delete
self.handle_data(unescape(rawdata[i:n]))
[246] Fix | Delete
else:
[247] Fix | Delete
self.handle_data(rawdata[i:n])
[248] Fix | Delete
i = self.updatepos(i, n)
[249] Fix | Delete
self.rawdata = rawdata[i:]
[250] Fix | Delete
[251] Fix | Delete
# Internal -- parse html declarations, return length or -1 if not terminated
[252] Fix | Delete
# See w3.org/TR/html5/tokenization.html#markup-declaration-open-state
[253] Fix | Delete
# See also parse_declaration in _markupbase
[254] Fix | Delete
def parse_html_declaration(self, i):
[255] Fix | Delete
rawdata = self.rawdata
[256] Fix | Delete
assert rawdata[i:i+2] == '<!', ('unexpected call to '
[257] Fix | Delete
'parse_html_declaration()')
[258] Fix | Delete
if rawdata[i:i+4] == '<!--':
[259] Fix | Delete
# this case is actually already handled in goahead()
[260] Fix | Delete
return self.parse_comment(i)
[261] Fix | Delete
elif rawdata[i:i+3] == '<![':
[262] Fix | Delete
return self.parse_marked_section(i)
[263] Fix | Delete
elif rawdata[i:i+9].lower() == '<!doctype':
[264] Fix | Delete
# find the closing >
[265] Fix | Delete
gtpos = rawdata.find('>', i+9)
[266] Fix | Delete
if gtpos == -1:
[267] Fix | Delete
return -1
[268] Fix | Delete
self.handle_decl(rawdata[i+2:gtpos])
[269] Fix | Delete
return gtpos+1
[270] Fix | Delete
else:
[271] Fix | Delete
return self.parse_bogus_comment(i)
[272] Fix | Delete
[273] Fix | Delete
# Internal -- parse bogus comment, return length or -1 if not terminated
[274] Fix | Delete
# see http://www.w3.org/TR/html5/tokenization.html#bogus-comment-state
[275] Fix | Delete
def parse_bogus_comment(self, i, report=1):
[276] Fix | Delete
rawdata = self.rawdata
[277] Fix | Delete
assert rawdata[i:i+2] in ('<!', '</'), ('unexpected call to '
[278] Fix | Delete
'parse_comment()')
[279] Fix | Delete
pos = rawdata.find('>', i+2)
[280] Fix | Delete
if pos == -1:
[281] Fix | Delete
return -1
[282] Fix | Delete
if report:
[283] Fix | Delete
self.handle_comment(rawdata[i+2:pos])
[284] Fix | Delete
return pos + 1
[285] Fix | Delete
[286] Fix | Delete
# Internal -- parse processing instr, return end or -1 if not terminated
[287] Fix | Delete
def parse_pi(self, i):
[288] Fix | Delete
rawdata = self.rawdata
[289] Fix | Delete
assert rawdata[i:i+2] == '<?', 'unexpected call to parse_pi()'
[290] Fix | Delete
match = piclose.search(rawdata, i+2) # >
[291] Fix | Delete
if not match:
[292] Fix | Delete
return -1
[293] Fix | Delete
j = match.start()
[294] Fix | Delete
self.handle_pi(rawdata[i+2: j])
[295] Fix | Delete
j = match.end()
[296] Fix | Delete
return j
[297] Fix | Delete
[298] Fix | Delete
# Internal -- handle starttag, return end or -1 if not terminated
[299] Fix | Delete
def parse_starttag(self, i):
[300] Fix | Delete
self.__starttag_text = None
[301] Fix | Delete
endpos = self.check_for_whole_start_tag(i)
[302] Fix | Delete
if endpos < 0:
[303] Fix | Delete
return endpos
[304] Fix | Delete
rawdata = self.rawdata
[305] Fix | Delete
self.__starttag_text = rawdata[i:endpos]
[306] Fix | Delete
[307] Fix | Delete
# Now parse the data between i+1 and j into a tag and attrs
[308] Fix | Delete
attrs = []
[309] Fix | Delete
match = tagfind_tolerant.match(rawdata, i+1)
[310] Fix | Delete
assert match, 'unexpected call to parse_starttag()'
[311] Fix | Delete
k = match.end()
[312] Fix | Delete
self.lasttag = tag = match.group(1).lower()
[313] Fix | Delete
while k < endpos:
[314] Fix | Delete
m = attrfind_tolerant.match(rawdata, k)
[315] Fix | Delete
if not m:
[316] Fix | Delete
break
[317] Fix | Delete
attrname, rest, attrvalue = m.group(1, 2, 3)
[318] Fix | Delete
if not rest:
[319] Fix | Delete
attrvalue = None
[320] Fix | Delete
elif attrvalue[:1] == '\'' == attrvalue[-1:] or \
[321] Fix | Delete
attrvalue[:1] == '"' == attrvalue[-1:]:
[322] Fix | Delete
attrvalue = attrvalue[1:-1]
[323] Fix | Delete
if attrvalue:
[324] Fix | Delete
attrvalue = unescape(attrvalue)
[325] Fix | Delete
attrs.append((attrname.lower(), attrvalue))
[326] Fix | Delete
k = m.end()
[327] Fix | Delete
[328] Fix | Delete
end = rawdata[k:endpos].strip()
[329] Fix | Delete
if end not in (">", "/>"):
[330] Fix | Delete
lineno, offset = self.getpos()
[331] Fix | Delete
if "\n" in self.__starttag_text:
[332] Fix | Delete
lineno = lineno + self.__starttag_text.count("\n")
[333] Fix | Delete
offset = len(self.__starttag_text) \
[334] Fix | Delete
- self.__starttag_text.rfind("\n")
[335] Fix | Delete
else:
[336] Fix | Delete
offset = offset + len(self.__starttag_text)
[337] Fix | Delete
self.handle_data(rawdata[i:endpos])
[338] Fix | Delete
return endpos
[339] Fix | Delete
if end.endswith('/>'):
[340] Fix | Delete
# XHTML-style empty tag: <span attr="value" />
[341] Fix | Delete
self.handle_startendtag(tag, attrs)
[342] Fix | Delete
else:
[343] Fix | Delete
self.handle_starttag(tag, attrs)
[344] Fix | Delete
if tag in self.CDATA_CONTENT_ELEMENTS:
[345] Fix | Delete
self.set_cdata_mode(tag)
[346] Fix | Delete
return endpos
[347] Fix | Delete
[348] Fix | Delete
# Internal -- check to see if we have a complete starttag; return end
[349] Fix | Delete
# or -1 if incomplete.
[350] Fix | Delete
def check_for_whole_start_tag(self, i):
[351] Fix | Delete
rawdata = self.rawdata
[352] Fix | Delete
m = locatestarttagend_tolerant.match(rawdata, i)
[353] Fix | Delete
if m:
[354] Fix | Delete
j = m.end()
[355] Fix | Delete
next = rawdata[j:j+1]
[356] Fix | Delete
if next == ">":
[357] Fix | Delete
return j + 1
[358] Fix | Delete
if next == "/":
[359] Fix | Delete
if rawdata.startswith("/>", j):
[360] Fix | Delete
return j + 2
[361] Fix | Delete
if rawdata.startswith("/", j):
[362] Fix | Delete
# buffer boundary
[363] Fix | Delete
return -1
[364] Fix | Delete
# else bogus input
[365] Fix | Delete
if j > i:
[366] Fix | Delete
return j
[367] Fix | Delete
else:
[368] Fix | Delete
return i + 1
[369] Fix | Delete
if next == "":
[370] Fix | Delete
# end of input
[371] Fix | Delete
return -1
[372] Fix | Delete
if next in ("abcdefghijklmnopqrstuvwxyz=/"
[373] Fix | Delete
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
[374] Fix | Delete
# end of input in or before attribute value, or we have the
[375] Fix | Delete
# '/' from a '/>' ending
[376] Fix | Delete
return -1
[377] Fix | Delete
if j > i:
[378] Fix | Delete
return j
[379] Fix | Delete
else:
[380] Fix | Delete
return i + 1
[381] Fix | Delete
raise AssertionError("we should not get here!")
[382] Fix | Delete
[383] Fix | Delete
# Internal -- parse endtag, return end or -1 if incomplete
[384] Fix | Delete
def parse_endtag(self, i):
[385] Fix | Delete
rawdata = self.rawdata
[386] Fix | Delete
assert rawdata[i:i+2] == "</", "unexpected call to parse_endtag"
[387] Fix | Delete
match = endendtag.search(rawdata, i+1) # >
[388] Fix | Delete
if not match:
[389] Fix | Delete
return -1
[390] Fix | Delete
gtpos = match.end()
[391] Fix | Delete
match = endtagfind.match(rawdata, i) # </ + tag + >
[392] Fix | Delete
if not match:
[393] Fix | Delete
if self.cdata_elem is not None:
[394] Fix | Delete
self.handle_data(rawdata[i:gtpos])
[395] Fix | Delete
return gtpos
[396] Fix | Delete
# find the name: w3.org/TR/html5/tokenization.html#tag-name-state
[397] Fix | Delete
namematch = tagfind_tolerant.match(rawdata, i+2)
[398] Fix | Delete
if not namematch:
[399] Fix | Delete
# w3.org/TR/html5/tokenization.html#end-tag-open-state
[400] Fix | Delete
if rawdata[i:i+3] == '</>':
[401] Fix | Delete
return i+3
[402] Fix | Delete
else:
[403] Fix | Delete
return self.parse_bogus_comment(i)
[404] Fix | Delete
tagname = namematch.group(1).lower()
[405] Fix | Delete
# consume and ignore other stuff between the name and the >
[406] Fix | Delete
# Note: this is not 100% correct, since we might have things like
[407] Fix | Delete
# </tag attr=">">, but looking for > after tha name should cover
[408] Fix | Delete
# most of the cases and is much simpler
[409] Fix | Delete
gtpos = rawdata.find('>', namematch.end())
[410] Fix | Delete
self.handle_endtag(tagname)
[411] Fix | Delete
return gtpos+1
[412] Fix | Delete
[413] Fix | Delete
elem = match.group(1).lower() # script or style
[414] Fix | Delete
if self.cdata_elem is not None:
[415] Fix | Delete
if elem != self.cdata_elem:
[416] Fix | Delete
self.handle_data(rawdata[i:gtpos])
[417] Fix | Delete
return gtpos
[418] Fix | Delete
[419] Fix | Delete
self.handle_endtag(elem.lower())
[420] Fix | Delete
self.clear_cdata_mode()
[421] Fix | Delete
return gtpos
[422] Fix | Delete
[423] Fix | Delete
# Overridable -- finish processing of start+end tag: <tag.../>
[424] Fix | Delete
def handle_startendtag(self, tag, attrs):
[425] Fix | Delete
self.handle_starttag(tag, attrs)
[426] Fix | Delete
self.handle_endtag(tag)
[427] Fix | Delete
[428] Fix | Delete
# Overridable -- handle start tag
[429] Fix | Delete
def handle_starttag(self, tag, attrs):
[430] Fix | Delete
pass
[431] Fix | Delete
[432] Fix | Delete
# Overridable -- handle end tag
[433] Fix | Delete
def handle_endtag(self, tag):
[434] Fix | Delete
pass
[435] Fix | Delete
[436] Fix | Delete
# Overridable -- handle character reference
[437] Fix | Delete
def handle_charref(self, name):
[438] Fix | Delete
pass
[439] Fix | Delete
[440] Fix | Delete
# Overridable -- handle entity reference
[441] Fix | Delete
def handle_entityref(self, name):
[442] Fix | Delete
pass
[443] Fix | Delete
[444] Fix | Delete
# Overridable -- handle data
[445] Fix | Delete
def handle_data(self, data):
[446] Fix | Delete
pass
[447] Fix | Delete
[448] Fix | Delete
# Overridable -- handle comment
[449] Fix | Delete
def handle_comment(self, data):
[450] Fix | Delete
pass
[451] Fix | Delete
[452] Fix | Delete
# Overridable -- handle declaration
[453] Fix | Delete
def handle_decl(self, decl):
[454] Fix | Delete
pass
[455] Fix | Delete
[456] Fix | Delete
# Overridable -- handle processing instruction
[457] Fix | Delete
def handle_pi(self, data):
[458] Fix | Delete
pass
[459] Fix | Delete
[460] Fix | Delete
def unknown_decl(self, data):
[461] Fix | Delete
pass
[462] Fix | Delete
[463] Fix | Delete
# Internal -- helper to remove special character quoting
[464] Fix | Delete
def unescape(self, s):
[465] Fix | Delete
warnings.warn('The unescape method is deprecated and will be removed '
[466] Fix | Delete
'in 3.5, use html.unescape() instead.',
[467] Fix | Delete
DeprecationWarning, stacklevel=2)
[468] Fix | Delete
return unescape(s)
[469] Fix | Delete
[470] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function