Add formater
This commit is contained in:
parent
7456c24200
commit
a1181a3eb2
2 changed files with 27 additions and 1 deletions
5
justfile
5
justfile
|
|
@ -54,6 +54,9 @@ new number:
|
|||
|
||||
# generate HTML email
|
||||
mail file:
|
||||
echo {{file}}
|
||||
PYTHONPATH=PWD venv/bin/python ./scripts/prepare_email.py {{file}}
|
||||
|
||||
# Format the content of a given newsletter
|
||||
format number:
|
||||
PYTHONPATH=PWD venv/bin/python ./scripts/format.py --number={{number}}
|
||||
|
||||
|
|
|
|||
23
scripts/format.py
Normal file
23
scripts/format.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue