From 3ad8194ee0c51e02e9ef33806c97561c9e538090 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 16 Apr 2023 13:05:09 +0200 Subject: add support for japanese definitions, no hard-coded css colors and make indicator stamp square if too small --- anki-card-template/card.css | 19 ++++++++++++------- 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 += ``; continue; } // definition separator - if (input[i] == "," && !subtile && !parenthesis) { - out += `
  • `; - continue; + if (!subtile && !parenthesis) { + if (input[i] == ",") { + out += `
  • `; + continue; + } else if (input[i] == "\u3002") { + out += `${input[i]}
  • `; + if (input.substr(i+1).trim().length > 0) + out += `
  • `; + 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 += ``; else if (script != lastScript) out += ``; -- cgit v1.2.3