diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-04-16 13:05:09 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-04-16 13:05:09 +0200 |
commit | 3ad8194ee0c51e02e9ef33806c97561c9e538090 (patch) | |
tree | eea231d2a39ed67b44a82e541eab77ae001a428c | |
parent | ddf052841eb87aabed6b901ae0dffe18ccc1bbea (diff) |
add support for japanese definitions, no hard-coded css colors and make indicator stamp square if too small
-rw-r--r-- | anki-card-template/card.css | 19 | ||||
-rw-r--r-- | anki-card-template/card.js | 20 |
2 files changed, 26 insertions, 13 deletions
diff --git a/anki-card-template/card.css b/anki-card-template/card.css index aed5f7b..bc82186 100644 --- a/anki-card-template/card.css +++ b/anki-card-template/card.css @@ -253,8 +253,7 @@ rt { user-select: none; } } #card #back #tags .tag { background-color: var(--tag-color-light); } .night_mode #card #back #tags .tag { background-color: var(--tag-color-dark); } -#card #back #tags .tag .inner { color: white; } -.night_mode #card #back #tags .tag .inner { color: black; } +#card #back #tags .tag .inner { color: canvas; } #card #back #tags .tag { --tag-hue: 0; padding: 4px; @@ -339,7 +338,7 @@ rt { user-select: none; } display: inline; } -#card #target-word-translation .definitions .definition-separator::after { content: ", "; } +#card #target-word-translation .definitions:has(.script-latin) .definition-separator::after { content: ", "; } /* mobile definitions style */ .mobile #card.vertical-layout #target-word-translation .definitions { @@ -378,6 +377,7 @@ rt { user-select: none; } .indicator .content { margin: 1px 4px; } .indicator .stamp { position: relative; + min-width: calc(1lh - 4px); padding: 2px 4px; margin: 1px; font-weight: bold; @@ -418,13 +418,15 @@ rt { user-select: none; } } /* theme colors */ -#target-word-reading .indicator, -.indicator .stamp { color: white; } +#target-word-reading .indicator .content, +.indicator .stamp span { color: canvas; } +.night_mode #target-word-reading .indicator .content, +.night_mode .indicator .stamp span { color: currentColor; } .indicator .stamp::before, -#target-word-reading .indicator::before { background-color: black; } +#target-word-reading .indicator::before { background-color: currentColor; } .night_mode #target-word-translation .indicator .stamp::before, .night_mode #target-word-reading .indicator::before { - background-color: white; opacity: calc(0.45 * var(--pitch-accent-opacity)); + opacity: calc(0.45 * var(--pitch-accent-opacity)); } /* grey color in definitions */ @@ -557,3 +559,6 @@ rt { user-select: none; } } .mobile #card #sentence-translation .outer:active { box-shadow: 0 0 0 2px currentColor; } +#card { color-scheme: light; } +.night_mode #card { color-scheme: dark; } + diff --git a/anki-card-template/card.js b/anki-card-template/card.js index 7d1742e..53e2625 100644 --- a/anki-card-template/card.js +++ b/anki-card-template/card.js @@ -214,7 +214,6 @@ function parseReading(nodes) { else out += input[i]; } flush_writings(); // kana only word fix - console.log(out); return out; }); } @@ -255,9 +254,16 @@ function parseDefinitions(nodes) { if (input[i] == "}" && subtile) { subtile = false; out += `</span>`; continue; } // definition separator - if (input[i] == "," && !subtile && !parenthesis) { - out += `</li><li class="definition-separator"></li><li class="definition">`; - continue; + if (!subtile && !parenthesis) { + if (input[i] == ",") { + out += `</li><li class="definition-separator"></li><li class="definition">`; + continue; + } else if (input[i] == "\u3002") { + out += `${input[i]}</li>`; + if (input.substr(i+1).trim().length > 0) + out += `<li class="definition-separator"></li><li class="definition">`; + continue; + } } // ignore comma's starting new definition in parenthesis @@ -280,8 +286,10 @@ function parseScript(nodes) { var out = ""; for (var i = 0; i < input.length; i++) { var script = "unknown"; - if (!charNotJapanese(input[i])) script = "japanese"; - if (!charNotLatin(input[i])) script = "latin"; + if (input[i] != " ") { + if (!charNotJapanese(input[i])) script = "japanese"; + if (!charNotLatin(input[i])) script = "latin"; + } if (i == 0) out += `<span class="script-${script}">`; else if (script != lastScript) out += `</span><span class="script-${script}">`; |