Skip to content

Instantly share code, notes, and snippets.

@warriorg
Created March 25, 2021 03:02
Show Gist options
  • Save warriorg/d6261779e5a1a14fe36be990537c128a to your computer and use it in GitHub Desktop.
Save warriorg/d6261779e5a1a14fe36be990537c128a to your computer and use it in GitHub Desktop.
anki cloze template
<div class="card">
{{#Example}}
<div id="context">{{Example}}</div>
<div id="word">{{Word}}</div>
{{/Example}}
{{^Example}}
<div style="text-align: center">
<div>{{Word}}</div>
<div>{{IPA}}</div>
</div>
{{/Example}}
<div>{{Audio}}{{Sound_Example}}</div>
</div>
<script type="text/javascript">
//如果卡面变量是正面,就运行镂空帮助函数
if (window.cardside == "front"){
makeCloze();
}
</script>
<script type="text/javascript">
function makeCloze(){
var obj = document.getElementById('context');
var word = document.getElementById('word');
if (obj) {
var regExp = new RegExp(word.innerText, "gi");
obj.innerText = obj.innerText.replace(regExp, "___");
}
if (word) {
word.textContent = ''
}
}
window.cardside = "front"
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment