Scribble possible to render to custom output format (Anki)?

I am looking to create a set of tutorials and am considering including Anki notes (spaced-repetition flashcards) alongside them to give readers an additional resource and facility to remember the information. I'm considering using Scribble to write these tutorials and was wondering if it is possible to define a function/macro to handle this?

Wants:

  • Write/embed Anki notes into the Scribble document, e.g. @anki-basic["What is 2+2?" "4"], @anki-cloze{2+2 = {{c1::4}}}, etc.
  • Conditional output based on what format we are rendering to. When rendering to HTML (ideally would support PDF and any default Scribble output format), output a standard Scribble representation of the content. When "rendering" to Anki, eventually become comma-separated values or even Anki's custom note data format.

Example: When rendering to a visual format (not Anki data), @anki-basic["What is 2+2?" "4"] would become:

@itemlist[@item[@emph{What is 2 + 2?}]
                  @item{4}]

I've also looked at Pollen, and its Branching tag functions look perfect for my use case. However I quite like the scribble/manual look, so if possible I would rather add this feature on top of Scribble than do everything custom, which Pollen seems geared for.

1 Like

I think it's possible because you can write custom Scribble renderer. But I have no experience on it, hope the doc could help you: 6.4 Renderers

Where is the Anki file format documented?

My first priority was the Scribble side since worst case I can produce CSV or text for import into Anki. However, I found this for the Anki file format: https://github.com/SergioFacchini/anki-cards-web-browser/blob/master/documentation/Processing%20Anki's%20.apkg%20files.md. Seems to mostly be SQLite.


Thank you @yfzhe.

If anyone knows of tutorials or clear examples for writing a custom Scribble renderer, I would appreciate links. But in the meantime I'll try to figure out a simple renderer from the docs/source code.

The simplest renderer, must be the text one:

The next simplest is the markdown one.