diff --git a/indent_begin_end.py b/indent_begin_end.py new file mode 100755 index 0000000..cb17761 --- /dev/null +++ b/indent_begin_end.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python + +import sys + +indent = b"" + +with open(sys.argv[1], 'rb') as fin: + with open(sys.argv[2], 'wb') as fout: + for line in fin: + if line.endswith(b"end\r\n"): + indent = indent[:-2] + fout.write(indent) + fout.write(line) + if line.endswith(b"begin\r\n"): + indent = indent + b" "