add svg output mode

This commit is contained in:
Artemis Tosini 2024-01-20 07:14:20 +00:00
parent 880a521607
commit 821358ac1a
Signed by: artemist
GPG key ID: EE5227935FE3FF18
2 changed files with 14 additions and 1 deletions

1
.gitignore vendored
View file

@ -6,6 +6,7 @@ result
addresses.csv addresses.csv
addresses.*.csv addresses.*.csv
/content /content
/output
cache/ cache/
*.pyc *.pyc

View file

@ -213,11 +213,16 @@ parser.add_argument(
) )
parser.add_argument( parser.add_argument(
"-N",
"--no-nixowos", "--no-nixowos",
action="store_true", action="store_true",
help="Don't print nixowos (e.g. if it would go over stamp)", help="Don't print nixowos (e.g. if it would go over stamp)",
) )
parser.add_argument(
"-g", "--svg", action="store_true", help="Output SVG files instead of PDF"
)
parser.add_argument("-w", "--watch", action="store_true", help="Watch input files") parser.add_argument("-w", "--watch", action="store_true", help="Watch input files")
@ -381,6 +386,13 @@ if args.dont_compile:
font_paths = os.getenv("TYPST_FONT_PATHS") font_paths = os.getenv("TYPST_FONT_PATHS")
assert font_paths is not None assert font_paths is not None
if args.svg:
if os.path.exists(root_dir() / "output"):
for f in (root_dir() / "output").glob("*.svg"):
os.remove(f)
else:
os.mkdir(root_dir() / "output")
typst_args = [ typst_args = [
"typst", "typst",
"watch" if args.watch else "compile", "watch" if args.watch else "compile",
@ -391,7 +403,7 @@ typst_args = [
"--font-path", "--font-path",
font_paths, font_paths,
args.template, args.template,
"output.pdf", root_dir() / "output" / "{n}.svg" if args.svg else "output.pdf",
] ]
# print(*typst_args) # print(*typst_args)