Skip to content

Instantly share code, notes, and snippets.

@koyo922
Last active July 10, 2018 04:37
Show Gist options
  • Save koyo922/928e7f858a2300fcf39f4c9b29e5926e to your computer and use it in GitHub Desktop.
Save koyo922/928e7f858a2300fcf39f4c9b29e5926e to your computer and use it in GitHub Desktop.
Anki_config
<!-- Add this to Front/Back or both, to support CodeHighlight -->
<!-- http://note.qidong.name/2017/06/24/hugo-highlight/ -->
<link href="https://cdn.bootcss.com/highlight.js/9.12.0/styles/monokai.min.css" rel="stylesheet">
<script src="https://cdn.bootcss.com/highlight.js/9.12.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>
# ankitxt` ;直接写到文本文件,手动 cmd+I导入;这样可以避免 全集上传
pbpaste | ankdown -u -i /dev/stdin -o /dev/stdout | tee @@anki.txt@@ | head
# ankifew` ; for only a few lines
pbpaste | ankdown -u -i /dev/stdin -o /dev/stdout | tee >(pbcopy)
# anki` ;create&load into deck_name; need to manually change card_type
pbpaste | (export PKG_NAME=bash.apkg; ankdown -u -i /dev/stdin -p $PKG_NAME -d @@deck_name@@ && open $PKG_NAME)
# cloze` ; replace %%xx%% into {{c1::xx}}
%s/%%(.{1,50}?)%%/{{c1::$1}}/g
# rcloze` ;revert {{c1::xx}} into %%xx%%
%s/{{c1::(.+?)}}/%%$1%%/g
# noimg` ; 把马克飞象中的所有<img>注释起来(否则无法同步)
%s/!\[\](\(\S+\)(?!-))/<!--$1-->/g
# rnoimg` ; 把注释起来的<img>都放开
%s/<!--(\(\S+\))-->/![]$1/g
<!-- Anki自带的LaTeX功能也可以了;无需这个脚本 -->
<!-- Add this to Front/Back or both, to support MathJax -->
<!-- https://www.reddit.com/r/Anki/comments/54c967/how_to_use_mathjax_in_anki_ankidroid_online_and/ -->
<!-- http://www.bootcdn.cn/mathjax/ -->
<script type="text/x-mathjax-config">
MathJax.Hub.processSectionDelay = 0;
MathJax.Hub.Config({
messageStyle:"none",
showProcessingMessages:false,
tex2jax:{
inlineMath: [['$','$']],
displayMath:[['$$','$$']],
processEscapes:true
}
});
</script>
<script type="text/javascript" src="https://cdn.bootcss.com/mathjax/2.7.4/MathJax.js?config=TeX-AMS_SVG-full"></script>
.mobile, .card { // 注意加上 .mobile 否则在手机上不生效
font-family: 'Crimson Text', arial;
font-size: 20px;
//text-align: center;
color: black;
background-color: white;
}
em { // 默认的<em>只是斜体,不够醒目
background-color: yellow;
font-style: normal;
}
.cloze {
font-weight: bold;
color: blue;
}
.nightMode .cloze {
color: lightblue;
}
/* Add this to stylesheet of card_types, to support rendering <kbd> tags */
/* https://ankiweb.net/shared/info/162313389 */
kbd {
box-shadow: inset 0px 1px 0px 0px #ffffff;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #f9f9f9), color-stop(1, #e9e9e9) );
background-color: #f9f9f9;
border-radius: 5px;
border: 1px solid #dcdcdc;
display: inline-block;
font-size: 0.8em;
height: 30px;
line-height: 30px;
padding: 0px 10px;
text-align: center;
text-shadow: 1px 1px 0px #ffffff;
}
# 1. 安装
# active py3
pip install git+https://github.com/koyo922/ankdown.git
# 2. 本地临时测试
pbpaste | ankdown -u -i /dev/stdin -o /dev/stdout | cat -n
# 3. 导出到文本文件(注意字段数,导入时的分隔符)
ankitxt`
# # 3. 导入
# use Dash_snippet "anki`", typing in deck_name
# equivlent to: pbpaste | (export PKG_NAME=bash.apkg; ankdown -u -i /dev/stdin -p $PKG_NAME -d deck_name && open $PKG_NAME)
# # 4. 在Anki中改变 card_type
# choose is:new in browser
# select all
# cmd+shift+M to change card_type
# upload to AnkiWeb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment