Restore support for older BeautifulSoup4 versions

This commit is contained in:
Marius Gedminas 2020-03-30 14:49:29 +03:00
parent ccc0ee0464
commit af0f50efa8
2 changed files with 4 additions and 4 deletions

View file

@ -8,9 +8,6 @@ jobs:
include:
- python: "3.5"
env: TOXENV=oldbs4
allow_failures:
- python: "3.5"
env: TOXENV=oldbs4
# command to install dependencies
addons:
apt:

View file

@ -93,7 +93,10 @@ class Parser(object):
self.handler.comment(comment)
elif isinstance(content, Doctype):
if hasattr(self.handler, 'doctype'):
self.handler.doctype(content)
self.handler.doctype(
content[len('DOCTYPE '):]
if content.upper().startswith('DOCTYPE ')
else content)
elif isinstance(content, Comment):
if hasattr(self.handler, 'comment'):
self.handler.comment(content.strip())