Browse Source

conditional inclusion of catsoop source...kind of

pull/67/head
adam j hartz 1 month ago
parent
commit
c28348b5dc
Signed by: hz <hartz@mit.edu> GPG Key ID: 5FDD2840E179AD62
1 changed files with 9 additions and 0 deletions
  1. +9
    -0
      catsoop/language.py

+ 9
- 0
catsoop/language.py View File

@@ -819,6 +819,15 @@ def handle_custom_tags(context, text):

tree = BeautifulSoup(text, "html.parser")

# remove conditional includes that aren't falsy
FALSY = {"0", "false", "", "[]", "()", "set()"}
for t in tree.find_all(["div", "span", "p"]):
if (
t.get("cs-hide-if", "false").lower() not in FALSY
or t.get("cs-show-if", "true").lower() in FALSY
):
t.extract()

# handle sections, etc.

labels = {}


Loading…
Cancel
Save