(self, end)
| 212 | # and data to be processed by a subsequent call. If 'end' is |
| 213 | # true, force handling all data as if followed by EOF marker. |
| 214 | def goahead(self, end): |
| 215 | rawdata = self.rawdata |
| 216 | i = 0 |
| 217 | n = len(rawdata) |
| 218 | while i < n: |
| 219 | if self.convert_charrefs and not self.cdata_elem: |
| 220 | j = rawdata.find('<', i) |
| 221 | if j < 0: |
| 222 | # if we can't find the next <, either we are at the end |
| 223 | # or there's more text incoming. If the latter is True, |
| 224 | # we can't pass the text to handle_data in case we have |
| 225 | # a charref cut in half at end. Try to determine if |
| 226 | # this is the case before proceeding by looking for an |
| 227 | # & near the end and see if it's followed by a space or ;. |
| 228 | amppos = rawdata.rfind('&', max(i, n-34)) |
| 229 | if (amppos >= 0 and |
| 230 | not re.compile(r'[\t\n\r\f ;]').search(rawdata, amppos)): |
| 231 | break # wait till we get all the text |
| 232 | j = n |
| 233 | else: |
| 234 | match = self.interesting.search(rawdata, i) # < or & |
| 235 | if match: |
| 236 | j = match.start() |
| 237 | else: |
| 238 | if self.cdata_elem: |
| 239 | break |
| 240 | j = n |
| 241 | if i < j: |
| 242 | if self.convert_charrefs and self._escapable: |
| 243 | self.handle_data(unescape(rawdata[i:j])) |
| 244 | else: |
| 245 | self.handle_data(rawdata[i:j]) |
| 246 | i = self.updatepos(i, j) |
| 247 | if i == n: break |
| 248 | startswith = rawdata.startswith |
| 249 | if startswith('<', i): |
| 250 | if starttagopen.match(rawdata, i): # < + letter |
| 251 | k = self.parse_starttag(i) |
| 252 | elif startswith("</", i): |
| 253 | k = self.parse_endtag(i) |
| 254 | elif startswith("<!--", i): |
| 255 | k = self.parse_comment(i) |
| 256 | elif startswith("<?", i): |
| 257 | k = self.parse_pi(i) |
| 258 | elif startswith("<!", i): |
| 259 | k = self.parse_html_declaration(i) |
| 260 | elif (i + 1) < n or end: |
| 261 | self.handle_data("<") |
| 262 | k = i + 1 |
| 263 | else: |
| 264 | break |
| 265 | if k < 0: |
| 266 | if not end: |
| 267 | break |
| 268 | if starttagopen.match(rawdata, i): # < + letter |
| 269 | pass |
| 270 | elif startswith("</", i): |
| 271 | if i + 2 == n: |
no test coverage detected