#!/usr/bin/env python3 # Import local files from whitespace import * from panflute import * from mj_show import show 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(show(doc)) transform(doc) print("---------------------") print(show(doc)) print(vars(doc))