From f47d3633c6a54f90acc92d7ccddbf508bf23cc75 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Thu, 29 Dec 2022 12:30:30 +0100 Subject: typo --- anki-card-temlate/.gitignore | 1 - anki-card-temlate/back-template.m4 | 11 ------ anki-card-temlate/card.css | 33 ----------------- anki-card-temlate/card.html | 22 ------------ anki-card-temlate/card.js | 70 ------------------------------------ anki-card-temlate/front-template.m4 | 7 ---- anki-card-temlate/makefile | 12 ------- anki-card-temlate/readme.md | 70 ------------------------------------ anki-card-template/.gitignore | 1 + anki-card-template/back-template.m4 | 11 ++++++ anki-card-template/card.css | 33 +++++++++++++++++ anki-card-template/card.html | 22 ++++++++++++ anki-card-template/card.js | 70 ++++++++++++++++++++++++++++++++++++ anki-card-template/front-template.m4 | 7 ++++ anki-card-template/makefile | 12 +++++++ anki-card-template/readme.md | 70 ++++++++++++++++++++++++++++++++++++ readme.md | 2 +- 17 files changed, 227 insertions(+), 227 deletions(-) delete mode 100644 anki-card-temlate/.gitignore delete mode 100644 anki-card-temlate/back-template.m4 delete mode 100644 anki-card-temlate/card.css delete mode 100644 anki-card-temlate/card.html delete mode 100644 anki-card-temlate/card.js delete mode 100644 anki-card-temlate/front-template.m4 delete mode 100644 anki-card-temlate/makefile delete mode 100644 anki-card-temlate/readme.md create mode 100644 anki-card-template/.gitignore create mode 100644 anki-card-template/back-template.m4 create mode 100644 anki-card-template/card.css create mode 100644 anki-card-template/card.html create mode 100644 anki-card-template/card.js create mode 100644 anki-card-template/front-template.m4 create mode 100644 anki-card-template/makefile create mode 100644 anki-card-template/readme.md diff --git a/anki-card-temlate/.gitignore b/anki-card-temlate/.gitignore deleted file mode 100644 index e49c5f5..0000000 --- a/anki-card-temlate/.gitignore +++ /dev/null @@ -1 +0,0 @@ -*-template.html diff --git a/anki-card-temlate/back-template.m4 b/anki-card-temlate/back-template.m4 deleted file mode 100644 index 1a0607d..0000000 --- a/anki-card-temlate/back-template.m4 +++ /dev/null @@ -1,11 +0,0 @@ -
-{{Complete sentence}} -
-{{Target word reading}} -{{Target word translation}} - -
- - - - diff --git a/anki-card-temlate/card.css b/anki-card-temlate/card.css deleted file mode 100644 index 8c2b0d0..0000000 --- a/anki-card-temlate/card.css +++ /dev/null @@ -1,33 +0,0 @@ -.mobile .card .foreign { font-size: 1.75rem; } -.mobile .card .native { font-size: 1.25rem; } - -.card .foreign { font-size: 1.5rem; } -.card .native { font-size: 1.0rem; } - -.card { text-align: center; } -.card span { display: block; } - -hr { - height: 10px; - border: none; - opacity: 20%; -} -hr { background-color: black; } -.nightMode hr { background-color: white; } - -.card.front #target-word-reading, -.card.front #target-word-translation, -.card.front #sentence-translation, -.card.front hr, -.card.front ruby rt.hidden { - display: none; -} - -#sentence-translation { margin-top: 1em; } - -.spoiler { - transition: filter 300ms; - cursor: pointer; -} -.spoiler.hidden { filter: blur(0.3rem); } -.spoiler.visible { filter: blur(0rem); } diff --git a/anki-card-temlate/card.html b/anki-card-temlate/card.html deleted file mode 100644 index 71ca300..0000000 --- a/anki-card-temlate/card.html +++ /dev/null @@ -1,22 +0,0 @@ - - - - - card template test - - - - - -
-[俺](おれ)の[目](め)の[前](まえ)に{全}(ぜん)[裸](はだか)のアリスが*[立](た)っていた*。\n\*escape\* (test) -
-立つ【た・つ】 -To stand - -
- - - - - diff --git a/anki-card-temlate/card.js b/anki-card-temlate/card.js deleted file mode 100644 index 0509c3e..0000000 --- a/anki-card-temlate/card.js +++ /dev/null @@ -1,70 +0,0 @@ -function parseSentence(input) { - var bold = false; // currently bold - var mode = "normal"; // normal, kanji, reading - var out = ""; // output html - - var alwaysvisisble = false; // if furigana is always visible (on front of card) - var kanji = ""; // current kanji - var reading = ""; // current kanji reading - - for (var i = 0; i < input.length; i++) { - // escape characters preceded by \ - if (input[i] == "\\") { - var escaped = input[i+1]; - if (escaped == "n") escaped = "
"; // newline - out += escaped; i++; continue; - } - // parse *test* into test - if (input[i] == "*") { bold = !bold; out += `<${bold ? "" : "/"}b>`; continue; } - - // parse [kanji](reading) into ruby text - // [kanji](reading) is only visible on card back - // {kanji}(reading) is always visible - if (mode == "normal" && input[i] == "[") // hidden reading kanji open - { kanji = ""; mode = "kanji"; alwaysvisisble = false; continue; } - if (mode == "normal" && input[i] == "{") // always visible reading kanji open - { kanji = ""; mode = "kanji"; alwaysvisisble = true; continue; } - if (mode == "kanji" && input[i] == "]") continue; // hidden reading kanji close - if (mode == "kanji" && input[i] == "}") continue; // always visible reading kanji close - if (mode == "kanji" && kanji.length > 0 && input[i] == "(") // reading open - { reading = ""; mode = "reading"; continue; } - if (mode == "reading" && input[i] == ")") { // reading close - mode = "normal"; - out += `${kanji}${reading}`; - continue; - } - - // add current character to selected mode buffer - if (mode == "normal") out += input[i]; - if (mode == "kanji") kanji += input[i]; - if (mode == "reading") reading += input[i]; - } - - return out; -} - -function run() { - // parse all elements with class parse - for (var el of document.getElementsByClassName("parse")) { - if (el.classList.contains("parsed")) continue; // ignore already parsed elements - el.innerHTML = parseSentence(el.innerHTML); // parse - el.classList.remove("parse"); // mark as parsed - el.classList.add("parsed"); - } - - // toggle spoiler by clicking - for (var el of document.getElementsByClassName("spoiler")) { - el.onclick = function () { - this.classList.toggle("hidden"); - this.classList.toggle("visible"); - }; - } - - // remove spoiler from sentence translation if word reading field is empty - if(document.getElementById("target-word-reading").innerText.length == 0) { - document.getElementById("sentence-translation").classList.remove("hidden"); - } -} - -run(); -window.onload = () => run(); diff --git a/anki-card-temlate/front-template.m4 b/anki-card-temlate/front-template.m4 deleted file mode 100644 index bb1fdb9..0000000 --- a/anki-card-temlate/front-template.m4 +++ /dev/null @@ -1,7 +0,0 @@ -
-{{Complete sentence}} -
- - - - diff --git a/anki-card-temlate/makefile b/anki-card-temlate/makefile deleted file mode 100644 index deb4c29..0000000 --- a/anki-card-temlate/makefile +++ /dev/null @@ -1,12 +0,0 @@ -all: back-template.html front-template.html - -.PRECIOUS: card.min.js card.min.css -.PHONY: clean - -include ../common.mk - -back-template.html: card.min.js card.min.css -front-template.html: card.min.js card.min.css - -clean: - $(RM) back-template.html front-template.html card.min.js card.min.css diff --git a/anki-card-temlate/readme.md b/anki-card-temlate/readme.md deleted file mode 100644 index 9de275d..0000000 --- a/anki-card-temlate/readme.md +++ /dev/null @@ -1,70 +0,0 @@ -# anki sentence mining template - -work in progress - -this is an anki card template for sentence mining. it has fields for a foreign -sentence, foreign word, translated word and an optional translated sentence. it -supports a markdown-like [syntax](#syntax) for adding furigana that is visible -on either both sides or only on the back side. - -## example - -### input - -|Field|Value| -|-|-| -|Complete sentence|`[家](うち)の{主}(あるじ)を*なめるなよ*…`| -|Target word reading|`舐める【なめる】`| -|Target word translation|`To underestimate`| -|Complete sentence translation|`Don't underestimate the master of the house...`| - -### front - -
-家のあるじなめるなよ -
- -### back - -
-あるじなめるなよ -
-舐める【なめる】
-To underestimate
-Don't underestimate the master of the house... -
- -## syntax - -html is passed through, so inline styling (should) still work. - -|input|html output|example| -|-|-|-| -|`[kanji](furigana)`|`kanjifurigana`
(furigana visible on back side only)|kanjifurigana| -|`{kanji}(furigana)`|`kanjifurigana`
(furigana visible on both sides)|kanjifurigana| -|`*text*`|`text` (bold)|text| -|`a\nb`|`a
b` (line break)|a
b| -|`\\`|`\` (backslash)|\\| -|`\[escaped](this)`|`[escaped](this)` (escaped furigana)|\[escaped](this)| - -## set-up - -i don't know how to create a teplate deck (if that's even a thing), so these -are instructions to apply to an empty deck. - -1. run `make` to generate files -2. Under Tools > Manage note types > (note type here) > Fields, make sure the - following fields exist (might be case-sensitive): - | |name|description| - |-|----|-----------| - |1|Complete sentence|Complete sentence with furigana and target word in bold| - |2|Target word reading|Dictionary reading of word (with word type)| - |3|Target word translation|(In context) translation of target word| - |4|Complete sentence translation|Complete sentence translation| -3. In the 'Browse' view, click on Cards... (you might need to create a - temporary card in a deck) and paste the contents of front-template.html and - back-template.html in the front template and back template of the card type. - Make sure the Styling tab doesn't contain any code as this will override the - built-in styles. -4. Profit - diff --git a/anki-card-template/.gitignore b/anki-card-template/.gitignore new file mode 100644 index 0000000..e49c5f5 --- /dev/null +++ b/anki-card-template/.gitignore @@ -0,0 +1 @@ +*-template.html diff --git a/anki-card-template/back-template.m4 b/anki-card-template/back-template.m4 new file mode 100644 index 0000000..1a0607d --- /dev/null +++ b/anki-card-template/back-template.m4 @@ -0,0 +1,11 @@ +
+{{Complete sentence}} +
+{{Target word reading}} +{{Target word translation}} + +
+ + + + diff --git a/anki-card-template/card.css b/anki-card-template/card.css new file mode 100644 index 0000000..8c2b0d0 --- /dev/null +++ b/anki-card-template/card.css @@ -0,0 +1,33 @@ +.mobile .card .foreign { font-size: 1.75rem; } +.mobile .card .native { font-size: 1.25rem; } + +.card .foreign { font-size: 1.5rem; } +.card .native { font-size: 1.0rem; } + +.card { text-align: center; } +.card span { display: block; } + +hr { + height: 10px; + border: none; + opacity: 20%; +} +hr { background-color: black; } +.nightMode hr { background-color: white; } + +.card.front #target-word-reading, +.card.front #target-word-translation, +.card.front #sentence-translation, +.card.front hr, +.card.front ruby rt.hidden { + display: none; +} + +#sentence-translation { margin-top: 1em; } + +.spoiler { + transition: filter 300ms; + cursor: pointer; +} +.spoiler.hidden { filter: blur(0.3rem); } +.spoiler.visible { filter: blur(0rem); } diff --git a/anki-card-template/card.html b/anki-card-template/card.html new file mode 100644 index 0000000..71ca300 --- /dev/null +++ b/anki-card-template/card.html @@ -0,0 +1,22 @@ + + + + + card template test + + + + + +
+[俺](おれ)の[目](め)の[前](まえ)に{全}(ぜん)[裸](はだか)のアリスが*[立](た)っていた*。\n\*escape\* (test) +
+立つ【た・つ】 +To stand + +
+ + + + + diff --git a/anki-card-template/card.js b/anki-card-template/card.js new file mode 100644 index 0000000..0509c3e --- /dev/null +++ b/anki-card-template/card.js @@ -0,0 +1,70 @@ +function parseSentence(input) { + var bold = false; // currently bold + var mode = "normal"; // normal, kanji, reading + var out = ""; // output html + + var alwaysvisisble = false; // if furigana is always visible (on front of card) + var kanji = ""; // current kanji + var reading = ""; // current kanji reading + + for (var i = 0; i < input.length; i++) { + // escape characters preceded by \ + if (input[i] == "\\") { + var escaped = input[i+1]; + if (escaped == "n") escaped = "
"; // newline + out += escaped; i++; continue; + } + // parse *test* into test + if (input[i] == "*") { bold = !bold; out += `<${bold ? "" : "/"}b>`; continue; } + + // parse [kanji](reading) into ruby text + // [kanji](reading) is only visible on card back + // {kanji}(reading) is always visible + if (mode == "normal" && input[i] == "[") // hidden reading kanji open + { kanji = ""; mode = "kanji"; alwaysvisisble = false; continue; } + if (mode == "normal" && input[i] == "{") // always visible reading kanji open + { kanji = ""; mode = "kanji"; alwaysvisisble = true; continue; } + if (mode == "kanji" && input[i] == "]") continue; // hidden reading kanji close + if (mode == "kanji" && input[i] == "}") continue; // always visible reading kanji close + if (mode == "kanji" && kanji.length > 0 && input[i] == "(") // reading open + { reading = ""; mode = "reading"; continue; } + if (mode == "reading" && input[i] == ")") { // reading close + mode = "normal"; + out += `${kanji}${reading}`; + continue; + } + + // add current character to selected mode buffer + if (mode == "normal") out += input[i]; + if (mode == "kanji") kanji += input[i]; + if (mode == "reading") reading += input[i]; + } + + return out; +} + +function run() { + // parse all elements with class parse + for (var el of document.getElementsByClassName("parse")) { + if (el.classList.contains("parsed")) continue; // ignore already parsed elements + el.innerHTML = parseSentence(el.innerHTML); // parse + el.classList.remove("parse"); // mark as parsed + el.classList.add("parsed"); + } + + // toggle spoiler by clicking + for (var el of document.getElementsByClassName("spoiler")) { + el.onclick = function () { + this.classList.toggle("hidden"); + this.classList.toggle("visible"); + }; + } + + // remove spoiler from sentence translation if word reading field is empty + if(document.getElementById("target-word-reading").innerText.length == 0) { + document.getElementById("sentence-translation").classList.remove("hidden"); + } +} + +run(); +window.onload = () => run(); diff --git a/anki-card-template/front-template.m4 b/anki-card-template/front-template.m4 new file mode 100644 index 0000000..bb1fdb9 --- /dev/null +++ b/anki-card-template/front-template.m4 @@ -0,0 +1,7 @@ +
+{{Complete sentence}} +
+ + + + diff --git a/anki-card-template/makefile b/anki-card-template/makefile new file mode 100644 index 0000000..deb4c29 --- /dev/null +++ b/anki-card-template/makefile @@ -0,0 +1,12 @@ +all: back-template.html front-template.html + +.PRECIOUS: card.min.js card.min.css +.PHONY: clean + +include ../common.mk + +back-template.html: card.min.js card.min.css +front-template.html: card.min.js card.min.css + +clean: + $(RM) back-template.html front-template.html card.min.js card.min.css diff --git a/anki-card-template/readme.md b/anki-card-template/readme.md new file mode 100644 index 0000000..9de275d --- /dev/null +++ b/anki-card-template/readme.md @@ -0,0 +1,70 @@ +# anki sentence mining template + +work in progress + +this is an anki card template for sentence mining. it has fields for a foreign +sentence, foreign word, translated word and an optional translated sentence. it +supports a markdown-like [syntax](#syntax) for adding furigana that is visible +on either both sides or only on the back side. + +## example + +### input + +|Field|Value| +|-|-| +|Complete sentence|`[家](うち)の{主}(あるじ)を*なめるなよ*…`| +|Target word reading|`舐める【なめる】`| +|Target word translation|`To underestimate`| +|Complete sentence translation|`Don't underestimate the master of the house...`| + +### front + +
+家のあるじなめるなよ +
+ +### back + +
+あるじなめるなよ +
+舐める【なめる】
+To underestimate
+Don't underestimate the master of the house... +
+ +## syntax + +html is passed through, so inline styling (should) still work. + +|input|html output|example| +|-|-|-| +|`[kanji](furigana)`|`kanjifurigana`
(furigana visible on back side only)|kanjifurigana| +|`{kanji}(furigana)`|`kanjifurigana`
(furigana visible on both sides)|kanjifurigana| +|`*text*`|`text` (bold)|text| +|`a\nb`|`a
b` (line break)|a
b| +|`\\`|`\` (backslash)|\\| +|`\[escaped](this)`|`[escaped](this)` (escaped furigana)|\[escaped](this)| + +## set-up + +i don't know how to create a teplate deck (if that's even a thing), so these +are instructions to apply to an empty deck. + +1. run `make` to generate files +2. Under Tools > Manage note types > (note type here) > Fields, make sure the + following fields exist (might be case-sensitive): + | |name|description| + |-|----|-----------| + |1|Complete sentence|Complete sentence with furigana and target word in bold| + |2|Target word reading|Dictionary reading of word (with word type)| + |3|Target word translation|(In context) translation of target word| + |4|Complete sentence translation|Complete sentence translation| +3. In the 'Browse' view, click on Cards... (you might need to create a + temporary card in a deck) and paste the contents of front-template.html and + back-template.html in the front template and back template of the card type. + Make sure the Styling tab doesn't contain any code as this will override the + built-in styles. +4. Profit + diff --git a/readme.md b/readme.md index ef78a39..060d5fa 100644 --- a/readme.md +++ b/readme.md @@ -2,6 +2,6 @@ this is a repo with language learning stuff: -- [anki sentence mining card template](anki-card-temlate) +- [anki sentence mining card template](anki-card-template) - [yomichan theme](yomichan) -- cgit v1.2.3