Skip to content

Instantly share code, notes, and snippets.

@mmcclimon
Created August 3, 2023 01:50
Show Gist options
  • Save mmcclimon/8cec3f1fae581a1cfed449df2af92df7 to your computer and use it in GitHub Desktop.
Save mmcclimon/8cec3f1fae581a1cfed449df2af92df7 to your computer and use it in GitHub Desktop.
goofy program: fold-headers
#!/usr/bin/env python
import fileinput
import re
in_headers = True
header_start = re.compile(r"[-A-Za-z0-9]+:\s")
for line in fileinput.input():
if line.isspace():
in_headers = False
if not in_headers or header_start.match(line):
print(line, end="")
else:
print(" " + line, end="")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment