add link and logging

This commit is contained in:
2026-04-23 08:25:52 +02:00
parent bd935c62f5
commit e5cf74245a
2 changed files with 15 additions and 0 deletions
+2
View File
@@ -89,6 +89,7 @@ def build_profiles_from_cfg(cfg: Optional[Dict[str, Any]] = None) -> Dict[str, D
"table": ["summary", "class"], "table": ["summary", "class"],
"th": ["scope", "colspan", "rowspan"], "th": ["scope", "colspan", "rowspan"],
"td": ["colspan", "rowspan"], "td": ["colspan", "rowspan"],
"link": ["href", "rel"],
"time": ["datetime"], "time": ["datetime"],
"meta": ["charset", "name", "content"], "meta": ["charset", "name", "content"],
"html": ["lang"], "html": ["lang"],
@@ -129,6 +130,7 @@ def build_profiles_from_cfg(cfg: Optional[Dict[str, Any]] = None) -> Dict[str, D
"span": ["class", "id", "style"], "span": ["class", "id", "style"],
"pre": ["class"], "pre": ["class"],
"code": ["class"], "code": ["class"],
"link" : ["href", "rel"],
"meta": ["charset", "name", "content"], "meta": ["charset", "name", "content"],
"html": ["lang"], "html": ["lang"],
"*": ["class", "id", "style"] "*": ["class", "id", "style"]
+13
View File
@@ -59,6 +59,19 @@ def sanitize(html: str, mode: str, profiles: dict) -> str:
pretty_body = BeautifulSoup(cleaned_body_content, "html.parser").prettify() pretty_body = BeautifulSoup(cleaned_body_content, "html.parser").prettify()
pretty_head = BeautifulSoup(cleaned_head_content, "html.parser").prettify() pretty_head = BeautifulSoup(cleaned_head_content, "html.parser").prettify()
logger.log_debug(
# very ugly string concationation for logging
"parser args: " + str(
"Tags: " + str(config.get("tags")) + "\n" +
"Attributes: " + str(config.get("attributes")) + "\n" +
"Protocols: " + str(config.get("protocols")) + "\n" +
"Strip: " + str(config.get("strip")) + "\n"
) +
"input html: " + str(html) +
"clean head: " + str(pretty_head) +
"clean body: " + str(pretty_body)
)
return f""" return f"""
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>