INNER CODE UNIT · Python
slugify
OWASP/wstg · .github/ebooks/build-link-manifest.py:24
def slugify(text: str) -> str:
"""Match links.lua's slugify exactly."""
text = text.lower()
text = re.sub(r"[\s_]+", "-", text)
text = re.sub(r"[^\w-]", "", text)
text = re.sub(r"-+", "-", text).strip("-")
return text
def extract_headings_from_json(json_data: dict) -> dict[str, str]:
"""Extract heading id -> heading text from pandoc JSON AST.
Returns: {slug-of-heading-text -> pandoc-assigned-id}
"""
headings = {}
def walk(blocks):
if not blocks: