A small rust crate to convert Obsidian callouts notes to formats that can be imported by the Obsidian_to_Anki Obsidian plugin or to interact with AnkiConnect directly.
To install the md2anki binary:
cargo install --path .To see help instructions just run:
md2anki --helpOr without installing:
cargo run -- --helpmd2anki markdown input [output_file]To demo how the project works, run the following command:
cargo run markdown demoThis will generate the following file: markdown_to_anki/Anki cards.md
This file can be parsed using the ObsidianToAnki plugin from inside of obsidian, or using the associated Python scripts.
Make sure Anki desktop is installed.
Install the AnkiConnect plugin by:
- Tools > Add-ons
- Click on
Get Add-ons - Type in
2055492159 - Click
Ok - Restart Anki
To demo how the project works, run the following command:
cargo run -- sync --css cards_style.css demoThis will create a deck called md2anki with cards created from the markdown notes in demo/.
Markdown to Anki looks for callout blocks to convert into flashcards.
It only converts callouts that have a CalloutType that is Word or Rule.
Currently the following text is recognized as these types:
Word:word,단어Rule:rule,규칙
It can handle nested callouts. The top-level/most outer callout will be the base content for the flashcard. All nested callouts will be embedded in the flashcard as callouts.
Markdown to Anki creates a simple Note Type with 3 fields:
- MarkdownID: uses the last block ID found in the callout.
- Front: the word text in the callout block header.
- Back: everything inside the callout that is not the header or MarkdownID.
> [!CalloutType](+|-)? (Front)
> (Back)
> ^(MarkdownID)> [!word]- 단어
> word
> ^daneoThis would be parsed as:
- MarkdownID: daneo
- Front: 단어
- Back: word
> [!규칙] VS + 자
> [[반말]] Let's do V
>
> > [!예]
> > 가자
> ---
> > [!예문]
> > 집에 가자.
> > Let's go home.
> > ---
> > 자! 밥먹자!
> > Hey! Let's eat!
> ---
> > [!인용]
> > [[KMS2 Chapter 12 Let's]]
>
> ^y6d5vj487mThis would be parsed as:
- MarkdownID: y6d5vj487m
- Front: VS + 자
- Back:
[[반말]] Let's do V
> [!예]
> 가자
---
> [!예문]
> 집에 가자.
> Let's go home.
> ---
> 자! 밥먹자!
> Hey! Let's eat!
---
> [!인용]
> [[KMS2 Chapter 12 Let's]]
Which in the Anki HTML format would be:
<p>[[반말|C]] Let's do V</p>
<details data-callout="example" class="callout"><summary class="callout-title"><div class="callout-icon"></div>Example</summary><p>가자</p></details>
<hr>
<details data-callout="example-sentence" class="callout"><summary class="callout-title"><div class="callout-icon"></div>Example Sentence</summary><p>집에 가자.</p>
<p>Let's go home.</p>
<hr>
<p>자! 밥먹자!.</p>
<p>Hey! Let's eat!</p></details>
<hr>
<details data-callout="cite" class="callout"><summary class="callout-title"><div class="callout-icon"></div>Cite</summary><p>[[KMS2 Chapter 12]]</p></details>