I am trying to generate many flashcards from one document.
I have a perfectly fine way to generate one interactive html flashcard (with collapsible answer, I use single side anki cards that auto flip/answer to the grading screen, making the collapsible html element act as the answering action) per file for importing into anki (I copy the generated html to clipboard with a vscode task triggered by a keybinding).
The problem is that this forces a one-to-one mapping of files to export targets/flashcards.
I’d prefer to generate one html document per #card[...] invocation.
Is there ongoing work for that?
I was thinking about a hack like having some kind of counter that counts the cards and having them be elements in the html with style rules with an integer
let index = {
let index = sys.inputs.at("index", default: none)
if not (type(index) == int and index >= 0) {
panic("Invalid index")
}
index
}
and then invoking the compiler for each index up to the first failure:
for index in {0..10000}; do
if ! typst compile \
--features html \
--format html \
--input "index=${index}" \
./cards.typ \
"./card_${index}.typ";
then
break
fi
done
This seems related to a question I asked about creating multiple PDF outputs from one call. It is possible to generate multiple PNG files from a single call to Typst, but it appears it’s not yet possible for PDF or HTML.