• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ashlinchak/mdanki: Markdown to Anki converter

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称(OpenSource Name):

ashlinchak/mdanki

开源软件地址(OpenSource Url):

https://github.com/ashlinchak/mdanki

开源编程语言(OpenSource Language):

JavaScript 90.0%

开源软件介绍(OpenSource Introduction):

MDAnki

Converts Markdown file(s) to the Anki cards.

Requirements

Node.js v10.0+

Install

npm install -g mdanki

Usage

Convert a single markdown file:

mdanki library.md anki.apkg

Convert files from directory recursively:

mdanki ./documents/library ./documents/anki.apkg

Using all available options:

mdanki library.md anki.apkg --deck Library --config config.json

Import just generated .apkg file to Anki ("File" - "Import").

Overriding default settings

To override default settings use --config option:

mdanki library.md anki.apkg --config faworite-settings.json

The JSON file, for example, would look like the following if you were to change the mdanki card template to the default that Anki has:

{
"template": {
    "formats": {
        "question": "{{Front}}",
        "answer"  : "{{FrontSide}}\n\n<hr id=\"answer\">\n\n{{Back}}",
         "css"     : ".card {\n font-family: arial;\n font-size: 20px;\n text-align: center;\n color: black;\n background-color: white;\n}"
               }
            }
}

Supported files

MDAnki supports .md and .markdown files.

Cards

By default, MDAnki splits cards by ## headline. For example, below markdown will generate 2 cards where headlines will be on the front side and its description - on the back.

## What's the Markdown?

Markdown is a lightweight markup language with plain-text-formatting syntax.
Its design allows it to be converted to many output formats,
but the original tool by the same name only supports HTML.

## Who created Markdown?

John Gruber created the Markdown language in 2004 in collaboration with
Aaron Swartz on the syntax.

If you want to have multiple lines on the card's front side - use % symbol for splitting front and back sides:

## YAGNI

Describe this acronym and why it's so important.

%

"You aren't gonna need it" (YAGNI) is a principle of extreme programming
(XP) that states a programmer should not add functionality until deemed
necessary.

When parsing only one markdown file, the title of the deck could be generated based on the top-level headline (# ).

Tags

Cards can have tags in their markdown sources. For adding tags to cart it should follow some rules:

  • tags start from a new line
  • only one line with tags per card
  • a tag should be written in the link format
  • tag (link text) should start from # symbol

MDAnki uses '^\\[#(.*)\\]' pattern for searching tags. This pattern could be overwritten by specifying custom settings. The source file in the tag link is optional.

The below example will generate a card with 3 tags: algorithms, OOP, and binary_tree.

## Binary tree

In computer science, a binary tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child.

[#algorithms](./algorityms.md) [#OOP]() [#binary tree]()

Code and syntax highlighting

Code blocks can be written with and without specifying a language name:

```java
public static void main(String[] args) {
  System.out.println("Hello, World!");
}
```
```
echo "Hello, World!"
```

The last code block will be treated by MDAnki as Bash code. The default language can be configured by specifying --config with an appropriate defaultLanguage setting.

Note! Creating a block without language name is not fully supported and should be eliminated in usage. Take a look at this:

echo "Code block with language name"
echo "Code block without language name"

Supported languages

MDAnki supports code highlighting for these languages:

actionscript, applescript, aspnet, bash, basic, batch, c, coffeescript, cpp, csharp, d, dart, erlang, fsharp, go, graphql, groovy, handlebars, java, json, latex, less, livescript, lua, makefile, markdown, markup-templating, nginx, objectivec, pascal, perl, php, powershell, python, r, ruby, rust, sass, scheme, smalltalk, smarty, sql, stylus, swift, typescript, vim, yaml.

Images

You can use links to image files inside markdown, MDAnki will parse them and add those images to the import collection. It's allowed to use two styles for writing images:

  1. Inline: alt text

  2. Reference: alt text

LaTeX

MDAnki and Anki can support LaTeX. Install LaTeX for your OS and use the [latex] attribute within Markdown files.

[latex]\\[e^x -1 = 3\\][/latex]

Memory limit

Converting a big Markdown file you can get a memory limit error like this:

Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value 16777216...

For overcoming this error, replace sql.js:

cp node_modules/sql.js/js/sql-memory-growth.js node_modules/sql.js/js/sql.js

More info here.

License

MIT License, Copyright (c) 2020, Oleksandr Shlinchak.

Changelog

Changelog




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap