From 363f1f6561cf09965cbdd0e94225960a9c8ed81e Mon Sep 17 00:00:00 2001 From: lonkaars Date: Sun, 18 Feb 2024 16:41:53 +0100 Subject: update tag parsing in Anki card template --- anki-card-template/card.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 += `${tag}`; return HTMLtoParseArr(out); } -- cgit v1.2.3