craft-letter/scripts/format.py
Pascal Le Merrer a1181a3eb2 Add formater
2026-02-28 11:22:42 +01:00

23 lines
559 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import argparse
from pathlib import Path
REPLACEMENTS = {
" :": " :",
" ;": " :",
" !": " :",
" ?": " :",
"'": "",
}
parser = argparse.ArgumentParser()
parser.add_argument("-n", "--number", required=True, type=int, help="Newsletter number")
args = parser.parse_args()
file = Path(f"./content/newsletter/craft-letter-{args.number}.md")
with open(file) as f:
content = f.read()
for value, replacement in REPLACEMENTS.items():
content = content.replace(value, replacement)
file.write_text(content)