INNER CODE UNIT · Python
is_nav_readme
OWASP/wstg · .github/ebooks/list-chapters.py:48
def is_nav_readme(path: str) -> bool:
with open(path, encoding="utf-8") as f:
lines = f.readlines()
return bool(lines) and all(_is_nav_line(line) for line in lines)
def slugify(text: str) -> str:
text = text.lower()
text = re.sub(r"[\s_]+", "-", text)
text = re.sub(r"[^\w-]", "", text)
text = re.sub(r"-+", "-", text).strip("-")
return text
def synthesize_heading(dirpath: str, root: str) -> tuple[str, str]:
"""Return (display title, anchor id) for a directory's chapter heading.
The id is derived the same way links.lua derives a link target from a