Add HTML email generator
This commit is contained in:
parent
35b999c8c6
commit
f1864d8841
14 changed files with 1748 additions and 16 deletions
37
prepare_email.py
Executable file
37
prepare_email.py
Executable 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)])
|
||||
Loading…
Add table
Add a link
Reference in a new issue