INNER CODE UNIT · Python
extract_text
OWASP/wstg · .github/ebooks/build-link-manifest.py:57
def extract_text(items):
for item in items:
if isinstance(item, dict):
if item.get("t") == "Str":
text_parts.append(item.get("c", ""))
elif item.get("t") in ("Emph", "Strong", "Code"):
extract_text(item.get("c", []))
elif item.get("t") == "Link":
c = item.get("c", [])
if len(c) >= 2:
extract_text(c[1])
extract_text(content)
if text_parts:
text = " ".join(text_parts)
slug = slugify(text)
if heading_id:
headings[slug] = heading_id