From: Mischa POSLAWSKY Date: Mon, 6 Jun 2022 17:00:35 +0000 (+0200) Subject: word/finder: common method to format caption names X-Git-Tag: v1.14~67 X-Git-Url: http://git.shiar.nl/sheet.git/commitdiff_plain/5b70dd621e9a307e5c8ce9f0c816042038c4e666 word/finder: common method to format caption names --- diff --git a/word/finder.js b/word/finder.js index 5dcc9e3..9f56a2c 100644 --- a/word/finder.js +++ b/word/finder.js @@ -1,4 +1,15 @@ class WordFinder extends WordQuiz { + namehtml(name) { + //let wbr = new RegExp('\w{4} [^aoeuiyc\W] [rl]?+ \K (?= [^aoeuiy\W] [rl]? [aoeuiy] \w)', 'g'); + let aliases = name.split('/'); + let html = aliases.shift(); + html = html.replace(/\((.+)\)/, '$1'); + for (let alias of aliases) { + html += ` (${alias})`; + } + return html; + } + add(catitem, rows) { rows.forEach(ref => { const [title, level, imgid, subs] = this.data[ref]; @@ -8,9 +19,8 @@ class WordFinder extends WordQuiz { put(figitem, 'img[src=$]', `/data/word/32/${imgid}.jpg`); } if (title) { - let html = title.replace(/\/(.*)/, ' ($1)'); put(figitem, 'figcaption', { - innerHTML: html, + innerHTML: this.namehtml(title), }); } if (level <= 1 && subs.length >= 2) {