Helper function for html validation
This commit is contained in:
parent
9c78a9d95c
commit
bdb1d1998a
17 changed files with 76 additions and 338 deletions
20
bookwyrm/tests/validate_html.py
Normal file
20
bookwyrm/tests/validate_html.py
Normal file
|
@ -0,0 +1,20 @@
|
|||
""" html validation on rendered templates """
|
||||
from tidylib import tidy_document
|
||||
|
||||
def validate_html(html):
|
||||
""" run tidy on html """
|
||||
_, errors = tidy_document(
|
||||
html.content,
|
||||
options={
|
||||
"drop-empty-elements": False,
|
||||
"warn-proprietary-attributes": False,
|
||||
},
|
||||
)
|
||||
# idk how else to filter out these unescape amp errs
|
||||
errors = "\n".join(
|
||||
e
|
||||
for e in errors.split("\n")
|
||||
if "&book" not in e and "id and name attribute" not in e
|
||||
)
|
||||
if errors:
|
||||
raise Exception(errors)
|
Loading…
Add table
Add a link
Reference in a new issue