craft-letter/scripts/format.py
Pascal Le Merrer 3165d050a1 Improve tooling
2026-03-02 09:13:04 +01:00

22 lines
534 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")
content = file.read_text()
for value, replacement in REPLACEMENTS.items():
content = content.replace(value, replacement)
file.write_text(content)