#anki cards beside typst

98 messages · Page 1 of 1 (latest)

somber valve
#

followup from #discussions message

The format looks something like this:

id;front side; backside; deck-name/id
id;front side; backside; deck-name/id
id;front side; backside; deck-name/id
id;front side; backside; deck-name/id
id;front side; backside; deck-name/id
id;front side; backside; deck-name/id

The fron side and back side fields can accept html. Thats what currently gets attached to my pdf.

How/What kind of logic is allowed after the query?

mild oxide
somber valve
mild oxide
#

How/What kind of logic is allowed after the query?
anything supported by the typst language

#

query() just returns an array

#

do whatever with it

#

e.g. "i want to query all notes related to this table" => when creating the notes you attach a field "related-to: "table 123"" and then the-output-of-query.filter(n => n.value.related-to == "table 123") will give you all of those notes

somber valve
clear gorge
#

let's imagine you have a metadata element or something with all the information (all the columns) from that example format. Then you can filter the elements from the query based on any of that - id, deck name, search text in front/back and so on.

mild oxide
#

cuz in principle you dont have to "copy paste" the script, it is part of your document

#

so you just need your document

somber valve
clear gorge
#

I kind of wanted to check that the discussion still makes sense - if Zocky710 needs to write a csv format, that has some HTML style tags embedded. That's not something typst HTML export will ever be able to do.

So first check that typst can output a file that anki import can actually use.

mild oxide
#

if vs code / tinymist has an export html button you can use that, if it has export svg that also works

mild oxide
#

you will inevitably have to massage the output a bit, e.g. remove the <html> surrounding it

#

but otherwise i dont see why you cant output abc;something;def into your document

somber valve
mild oxide
#

it's the code i sent in #discussions

#

it goes at the top of your document

#

you export your document like normal, but if you set a certain input, it will replace your whole document with just anki notes and exports them instead

#

but of course you would export to html instead of pdf

#

you can still export your document to pdf by not setting the input

#

now, its worth mentioning here that im assuming your goal is explicitly to avoid using some auxiliary script... i think that would make your job much easier, but still, here we are

somber valve
# mild oxide but otherwise i dont see why you cant output abc;something;def into your documen...

I think I get what you mean.

But it feels very user unfriendly. I might work, but at a cost:

  • no more ready to import files emedded into the pdf (which is nice if I share the doc)
  • more work to the user/me -> I have to manually go in the html and fish out the file that should be importable
  • escaping issues -> If I manually (in typst itself) convert the content, I can easily escape to the csv
  • more difficult for people that do not know html or want to do manual work for exporting the anki deck
mild oxide
#

yep. thats why you use a little script instead

#

regarding the embedding, thats no problem, you can export it once and embed later.

somber valve
somber valve
mild oxide
#

disagree... the only step is to run the script.

somber valve
#

Although thinking about, when I use a script, I also need a scripting language installed besides the script and typst.

mild oxide
#

here's what it would do:

  1. invoke typst query to retrieve the list of notes.
  2. for each note, export just that note and create one csv line.
  3. generate a file result.csv (for example) by joining the lines.
  4. in your document, have pdf.embed(read("result.csv")) (for example), and as soon as you export it it's already embedded.
mild oxide
#

assuming you wanna use that of course, haha

#

not that much of a problem for such a small script though

somber valve
mild oxide
#

yeah

somber valve
# mild oxide yeah

Like maintaining two scripts, one in bash and one in cmd because I have a windows and a linux machine? Sure not.

mild oxide
#

🤔

#

i mean, you only have to write it once

somber valve
mild oxide
#

sure

#

but i'd prefer my solution as i can give it to someone who doesnt know what wasm is, and they can do what they want with it

somber valve
#

The only downside I can find the the already existing solution is: plugin size, a bit of perfomance and that it is a bit... hacky (?)

mild oxide
#

still, you can always use what works for you of course

#

but personally i wouldnt be too fond of doing 5x more work and making it harder to adapt in the future..

somber valve
mild oxide
#

im ok with that

#

but it all depends on your end goal

#

i guess, if youre gonna install on a machine that only has typst, then maybe you dont have much of an option

#

e.g. on the web app

#

or some university pc which blocks the shell or smth

somber valve
somber valve
mild oxide
#

it gets worse if you release more than one version for example, and then you can have multiple copies

#

or if some other package vendors it, but i consider that unlikely

somber valve
mild oxide
#

one .wasm for v0.1, one .wasm for 0.2

#

both can be used at the same time, by different packages depending on yours

somber valve
mild oxide
#

total size, cuz the size of previous releases might still count.

mild oxide
#

cuz multiple releases can be installed at a given time due to dependencies

#

maybe if you find a way to decrease the size, that might be ideal

somber valve
#

And I find that already very slim for such a programm. Looking at MikeTex download archives with over 100MB.

somber valve
#

With a lot of playing around I got the size down to 4.01MB.

somber valve
#

@mild oxide I want to thank you for your enthusiastic discussion before.
After a short walk, and a few thoughs I want to make a small cli/script.

somber valve
#

But I am having a hard time exporting notes.

#

When I do something like this:

#context query(<anki>)

#show: it => []

above
#anki.basic([test], "test") <anki>
below

The basic note at the bottom gets obvisously not rendered. But I dont know how else I could only render one note, and not the content above or below.

Hiding seems not to work on html.

mild oxide
#

and you can just insert what you queried

#

unless im misunderstanding the question

#

though, i should remark that you shouldnt feel guilty for using your solution - if thats what worked for you then feel free to use it, i was simply suggesting what i would do instead, but that doesnt mean you have to do what i would do haha

#

so if you arent successful here then you dont have to follow through

somber valve
somber valve
mild oxide
#

ah i see
i think thats gonna be a bit annoying to solve

#

i think you will need to just do it separately then, should be easy since you will be using a script

#

in the script you can run typst query <lbl> doc.typ and that should give you all of the anki notes

somber valve
#

?render

#let a() = [This is a test #text("text", size: 20pt)]

#a() <test>

#context query(<test>)
mild oxide
#

i was thinking now that you could try to export the whole thing but use specific html elements that you can isolate as needed

#

theres probably a way to do the one note thing but i couldnt think right away of a way to do it without causing layout to diverge

somber valve
somber valve
somber valve
mild oxide
#

#show: it => html.elem("ignore", it)

#

something of the sort

#

then you can just delete everything after the line with <ignore>

#

sounds easy enough