Support specifying content path in arguments
This commit is contained in:
parent
358e68c8db
commit
72fbcb42d6
|
@ -116,7 +116,7 @@
|
|||
let content_fn = if args.no_content {
|
||||
_ => []
|
||||
} else {
|
||||
import "content/content.typ"
|
||||
import "cache/content/content.typ"
|
||||
content.content
|
||||
}
|
||||
|
||||
|
|
19
format.py
19
format.py
|
@ -5,6 +5,7 @@ import csv
|
|||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import string
|
||||
import typing
|
||||
import urllib.parse
|
||||
|
@ -160,6 +161,14 @@ parser.add_argument(
|
|||
help="CSV file containing addresses",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-i",
|
||||
"--content-path",
|
||||
default="content",
|
||||
type=str,
|
||||
help="Directory containing content files",
|
||||
)
|
||||
|
||||
parser.add_argument(
|
||||
"-n",
|
||||
"--no-content",
|
||||
|
@ -216,6 +225,14 @@ for row in rows:
|
|||
}
|
||||
]
|
||||
|
||||
# Typst can't access files outside the project root, except through a symlink
|
||||
# Create one in cache to use here
|
||||
if not os.path.exists("cache"):
|
||||
os.mkdir("cache")
|
||||
p = pathlib.Path("cache/content")
|
||||
p.unlink(missing_ok=True)
|
||||
p.symlink_to(args.content_path)
|
||||
|
||||
cards = cards * args.count
|
||||
|
||||
serial = imb.get_first_serial()
|
||||
|
@ -246,7 +263,7 @@ os.execlp(
|
|||
"typst",
|
||||
"watch" if args.watch else "compile",
|
||||
"--font-path",
|
||||
"content",
|
||||
args.content_path,
|
||||
"--font-path",
|
||||
os.getenv("TYPST_FONT_PATHS"),
|
||||
args.template,
|
||||
|
|
Loading…
Reference in a new issue