aboutsummaryrefslogtreecommitdiff
path: root/anki-card-template
diff options
context:
space:
mode:
Diffstat (limited to 'anki-card-template')
-rw-r--r--anki-card-template/card.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/anki-card-template/card.js b/anki-card-template/card.js
index a98e2fe..18d5eda 100644
--- a/anki-card-template/card.js
+++ b/anki-card-template/card.js
@@ -235,7 +235,13 @@ function parseReading(nodes) {
function parseTags(nodes) {
var out = "";
- for (var tag of nodes.map(n => n.data).join("").split(" "))
+ var tags = nodes.map(n => n.data).join(""); // original field content
+ tags = tags.replaceAll("::", " "); // treat subtags as normal tags
+ tags = tags.split(" "); // split on space (tags may not contain spaces)
+ tags = Array.from(new Set(tags)); // remove duplicates
+ tags = tags.sort(); // sort the tags
+ tags = tags.map(text => text.replaceAll("_", " ")); // display underscore as space
+ for (var tag of tags)
out += `<span class="tag" style="--tag-hue: ${calculateTagHue(tag)};"><span class="inner">${tag}</span></span>`;
return HTMLtoParseArr(out);
}