Skip to content

Commit

Permalink
Add diagnostic logging
Browse files Browse the repository at this point in the history
  • Loading branch information
bensteinberg committed Mar 22, 2024
1 parent ab56c04 commit 3d5b51a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion web/main/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,13 @@ def replace_in_parent(style, el):
original_html = el.parent().html(method="html")
src = el.outer_html()
replacement = f"</p><div data-custom-style='{style}'>{el.outer_html()}</div><p>"
el.parent().html(original_html.replace(src, replacement))
try:
el.parent().html(original_html.replace(src, replacement))
except AttributeError:
# 'NoneType' object has no attribute 'replace'
logger.info(
f"original_html.replace failed; src is '{src}', replacement is '{replacement}', parent is '{el.parent()}'"
)

def attach_id_to_style(el):
el.attrib["data-custom-style"] += f"-{id_prefix}"
Expand Down

0 comments on commit 3d5b51a

Please sign in to comment.