Produce valid JSON (escape \n), add indent filter

This commit is contained in:
Kegan Dougal 2015-05-20 11:49:10 +01:00
parent 2e5809a68e
commit 8f448a1764
13 changed files with 17 additions and 69 deletions

View file

@ -78,12 +78,16 @@ def main(file_stream=None, out_dir=None):
return code
def indent(input, indent):
return input.replace("\n", ("\n" + " "*indent))
# make Jinja aware of the templates and filters
env = Environment(
loader=FileSystemLoader("templates"),
undefined=StrictUndefined
)
env.filters["jsonify"] = jsonify
env.filters["indent"] = indent
# load up and parse the lowest single units possible: we don't know or care
# which spec section will use it, we just need it there in memory for when