#!/usr/bin/env python3 # Import local files from whitespace import * from panflute import * ifs = ["dog"] def transform(e: Element): """Transform the AST, making format-agnostic changes.""" if isinstance(e, Whitespace) and bavlna(e): e.parent.content[e.index] = NBSP() if hasattr(e, "attributes"): if "if" in e.attributes: if not e.attributes["if"] in ifs: del e.parent.content[e.index] if hasattr(e, "content"): for c in e.content: transform(c) doc = load() print(stringify(doc)) transform(doc) print("---------------------") print(stringify(doc)) print(vars(doc))