From 72fbcb42d60bd0131628160a8c4a40384bd09b38 Mon Sep 17 00:00:00 2001 From: Artemis Tosini Date: Fri, 1 Dec 2023 02:40:44 +0000 Subject: [PATCH] Support specifying content path in arguments --- common.typ | 2 +- format.py | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/common.typ b/common.typ index 5d30551..e25fa22 100644 --- a/common.typ +++ b/common.typ @@ -116,7 +116,7 @@ let content_fn = if args.no_content { _ => [] } else { - import "content/content.typ" + import "cache/content/content.typ" content.content } diff --git a/format.py b/format.py index 639b66f..4e543c4 100755 --- a/format.py +++ b/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,