Skip to content

Don't crash when there are styles that don't apply to any element #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion pynliner/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,11 @@ def _apply_styles(self):
# build up a property list for every styled element
for rule in rules:
for selector in rule.selectorList:
for element in select(self.soup, selector.selectorText):
try:
elements = select(self.soup, selector.selectorText)
except:
pass
for element in elements:
element_tuple = (element, id(element))
if element_tuple not in elem_prop_map:
elem_prop_map[element_tuple] = []
Expand Down