AutoYADM commit: 2025-03-25 01:30:07
This commit is contained in:
parent
46c4cf25ad
commit
e5c0898f10
1 changed files with 22 additions and 5 deletions
|
@ -3,20 +3,37 @@
|
||||||
import textwrap
|
import textwrap
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
with open(sys.argv[1], 'r') as f:
|
# with open(sys.argv[1], 'r') as f:
|
||||||
lines = f.read().splitlines()
|
# lines = f.read().splitlines()
|
||||||
|
# print(lines)
|
||||||
|
|
||||||
|
# first pass: reflow paragraphs
|
||||||
|
# paragraph = []
|
||||||
|
# lines = []
|
||||||
|
# for line in sys.stdin:
|
||||||
|
# line = line.rstrip()
|
||||||
|
# if line:
|
||||||
|
# paragraph.append(line)
|
||||||
|
# else:
|
||||||
|
# if paragraph:
|
||||||
|
# lines.append(' '.join(paragraph))
|
||||||
|
# lines.append("\n")
|
||||||
|
# if paragraph:
|
||||||
|
# lines.append(' '.join(paragraph))
|
||||||
|
|
||||||
|
|
||||||
skipping = False
|
skipping = False
|
||||||
for line in lines:
|
for line in sys.stdin:
|
||||||
if line.startswith(">"):
|
if line.startswith(">"):
|
||||||
# ignore quoted line
|
# ignore quoted line
|
||||||
print(line)
|
print(line, end = "")
|
||||||
elif line.startswith("```"):
|
elif line.startswith("```"):
|
||||||
# ignore code block
|
# ignore code block
|
||||||
skipping = not skipping
|
skipping = not skipping
|
||||||
|
print(line, end = "")
|
||||||
elif line.startswith("--"):
|
elif line.startswith("--"):
|
||||||
skipping = True
|
skipping = True
|
||||||
|
print(line, end = "")
|
||||||
else:
|
else:
|
||||||
# wrap the line
|
# wrap the line
|
||||||
if not skipping:
|
if not skipping:
|
||||||
|
@ -24,4 +41,4 @@ for line in lines:
|
||||||
|
|
||||||
print("\n".join(wrapped))
|
print("\n".join(wrapped))
|
||||||
else:
|
else:
|
||||||
print(line)
|
print(line, end = "")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue