Skip to content

gxr404/md-to-anki

Repository files navigation

md-to-anki

markdown转为anki卡片

fork自mdanki, 结合anki-prettify优化卡片样式

安装

npm i -g md-to-anki

使用

$ md-to-anki --help

  Usage:
    $ md-to-anki <mdFile>

  Commands:
    <mdFile>  markdown文件

  For more info, run any command with the `--help` flag:
    $ md-to-anki --help

  Options:
    -t, --target <targetFile>  输出的anki文件名 eg: "-d targe.apkg"
    -c, --config <configFile>  配置文件 eg: "-c ./config.json"
    -s, --theme <theme>        样式主题可选 nord/minimal/dracula (default: nord)
    -d, --deckName <deckName>  卡片组名 eg: "-d Test", Default: 取md文件中的"# xx"
    -h, --help                 Display this message
    -v, --version              Display version number

Example

默认采用## xxx..分割卡片

simple.md

# Test

## Card1
Test

## Card2
Test2

### Card3
Test3
$ md-to-anki ./simple.md -s minimal

>"Test"含卡片3张: /xxx/simple.apkg

默认采用 % 来分割卡片的正反面

simple.md

# Test

## Media stored in file system

There is ability to write media files in 2 styles: inline and reference.

%

Node.js is an open-source, cross-platform, JavaScript runtime environment that executes JavaScript code outside of a browser.
$ md-to-anki ./simple.md

>"Test"含卡片1张: /xxx/simple.apkg

卡片正面

example1

卡片反面

example1_2

如果没有%则,则默认标题为正面其余内容会反面

simple.md

# Test

## Media stored in file system

There is ability to write media files in 2 styles: inline and reference.

Node.js is an open-source, cross-platform, JavaScript runtime environment that executes JavaScript code outside of a browser.
$ md-to-anki ./simple.md -s minimal

>"Test"含卡片1张: /xxx/simple.apkg

卡片正面

example2

卡片反面

example2_2

可通过传入配置文件自行定义使用什么符号来分割卡片正反面

config.json

{
  "card": {
    // 卡片分割的正则: ##.. xxx
    "separator": "(?=^#{2,}\\s)",
    // 卡片正反面分割用什么字符串区分 从默认的 % 改为 &&&&
    "frontBackSeparator": "&&&&"
  }
}

ps: 配置文件json不能带有注释,上面仅是为了说明

simple.md

# Test

## Media stored in file system

There is ability to write media files in 2 styles: inline and reference.

&&&&

Node.js is an open-source, cross-platform, JavaScript runtime environment that executes JavaScript code outside of a browser.
$ md-to-anki ./simple.md -c ./config.json -s dracula

>"Test"含卡片1张: /xxx/simple.apkg

卡片正面

example3

卡片反面

example3_2

可以含有代码块、图片等资源会一并打包进apkg文件

example

TODO

  • 添加loading
  • 更多模板主题选择