Replace Make with Just

This commit is contained in:
Pascal Le Merrer 2026-01-16 17:19:41 +01:00
parent af4c2d7241
commit d04d523bdf
3 changed files with 59 additions and 79 deletions

37
scripts/prepare_email.py Executable file
View file

@ -0,0 +1,37 @@
#!python
# Copies the given input file, removing the parts specific to the Web,
# so it can be converted to an email
import subprocess
import argparse
import re
from pathlib import Path
MAIL_GENERATOR = "/opt/homebrew/bin/mdtosendy"
parser = argparse.ArgumentParser()
parser.add_argument("source")
args = parser.parse_args()
root = Path.cwd()
print(f"Root: {root}")
source = Path(root / args.source)
if not source.is_file():
print(f"ERROR: file not found {source}")
exit(1)
print(f"Processing {source}")
input = source.read_text()
regex = re.compile(r"Title.*svg\">", re.S)
output = re.sub(regex, "", input)
destination = Path.cwd() / "mail" / source.name
print(f"Writing {destination}")
destination.write_text(output)
subprocess.run([MAIL_GENERATOR, "--preview", str(destination)])