27 lines
617 B
Python
Executable file
27 lines
617 B
Python
Executable file
#!/bin/env python
|
|
|
|
import textwrap
|
|
import sys
|
|
|
|
with open(sys.argv[1], 'r') as f:
|
|
lines = f.read().splitlines()
|
|
|
|
|
|
skipping = False
|
|
for line in lines:
|
|
if line.startswith(">"):
|
|
# ignore quoted line
|
|
print(line)
|
|
elif line.startswith("```"):
|
|
# ignore code block
|
|
skipping = not skipping
|
|
elif line.startswith("--"):
|
|
skipping = True
|
|
else:
|
|
# wrap the line
|
|
if not skipping:
|
|
wrapped = textwrap.wrap(line, width=74, break_long_words=False, replace_whitespace=True)
|
|
|
|
print("\n".join(wrapped))
|
|
else:
|
|
print(line)
|