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

**URL:** <https://racket.discourse.group/t/scribble-possible-to-render-to-custom-output-format-anki/2463>\
**Category:** Questions & Answers\
**Tags:** pollen, scribble\
**Created:** [November 5, 2023, 3:30pm UTC](https://racket.discourse.group/t/scribble-possible-to-render-to-custom-output-format-anki/2463 "2023-11-05T15:30:20Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jegfish](https://avatars.discourse-cdn.com/v4/letter/j/df705f/32.png) [@jegfish](https://racket.discourse.group/u/jegfish)\
**Post date:** [November 5, 2023, 3:30pm UTC](https://racket.discourse.group/t/scribble-possible-to-render-to-custom-output-format-anki/2463/1 "2023-11-05T15:30:20Z")

</div>

I am looking to create a set of tutorials and am considering including [Anki](https://apps.ankiweb.net/) 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:

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

```

I've also looked at Pollen, and its [Branching tag functions](https://docs.racket-lang.org/pollen/fourth-tutorial.html#%28part._.Branching_tag_functions%29) 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.

---

<div class="post-metadata">

**Author:** ![yfzhe](https://avatars.discourse-cdn.com/v4/letter/y/f05b48/32.png) [@yfzhe](https://racket.discourse.group/u/yfzhe)\
**Post date:** [November 7, 2023, 8:59am UTC](https://racket.discourse.group/t/scribble-possible-to-render-to-custom-output-format-anki/2463/2 "2023-11-07T08:59:48Z")

</div>

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&nbsp;Renderers](https://docs.racket-lang.org/scribble/renderer.html)

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [November 7, 2023, 1:51pm UTC](https://racket.discourse.group/t/scribble-possible-to-render-to-custom-output-format-anki/2463/3 "2023-11-07T13:51:47Z")

</div>

Where is the Anki file format documented?

---

<div class="post-metadata">

**Author:** ![jegfish](https://avatars.discourse-cdn.com/v4/letter/j/df705f/32.png) [@jegfish](https://racket.discourse.group/u/jegfish)\
**Post date:** [November 7, 2023, 2:45pm UTC](https://racket.discourse.group/t/scribble-possible-to-render-to-custom-output-format-anki/2463/4 "2023-11-07T14:45:13Z")

</div>

My first priority was the Scribble side since worst case I can produce [CSV or text for import into Anki](https://docs.ankiweb.net/importing/text-files.html). 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](https://github.com/SergioFacchini/anki-cards-web-browser/blob/master/documentation/Processing%20Anki%27s%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.

---

<div class="post-metadata">

**Author:** ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)\
**Post date:** [November 7, 2023, 3:06pm UTC](https://racket.discourse.group/t/scribble-possible-to-render-to-custom-output-format-anki/2463/5 "2023-11-07T15:06:27Z")

</div>

The simplest renderer, must be the text one:

> <https://github.com/racket/scribble/blob/master/scribble-lib/scribble/text-render.rkt>

The next simplest is the markdown one.
