INNER CODE UNIT · Python

extract_headings_from_json

OWASP/wstg · .github/ebooks/build-link-manifest.py:33

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:
            return
        for block in blocks:
            if not isinstance(block, dict):
                continue

            if block.get("t") == "Header":
                c = block.get("c", [])
                if len(c) >= 3:
                    content = c[1]  # inline content

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…