INNER CODE UNIT · Python

esc_slash

OWASP/wstg · .github/ebooks/fix-typst-body.py:29

    def esc_slash(m: re.Match[str]) -> str:
        indent, rest = m.group(1), m.group(2)
        if rest.startswith("/"):
            return m.group(0)  # // comment
        return f"{indent}\\/{rest}"

    text = re.sub(r"(?m)^([ \t]*)/(.*)$", esc_slash, text)

    # extract-media paths → root-absolute
    text = text.replace('#image("build-ebooks/media/', f'#image("{args.media_prefix}')
    text = text.replace('#image("media/', f'#image("{args.media_prefix}')

    # Convert ID tables to styled badges
    # Matches: #align(center)[#table(...[ID]...[WSTG-…]...)]
    def replace_id_table(m: re.Match[str]) -> str:
        id_val = m.group(1)
        return f'''#block(
  fill: rgb("#0080BD"),

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…