You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

35 lines
601 B

#!/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))