diff --git a/components/Abbreviation.vue b/components/Abbreviation.vue index 98a4e97e..f343fb49 100644 --- a/components/Abbreviation.vue +++ b/components/Abbreviation.vue @@ -1,6 +1,6 @@ @@ -12,21 +12,16 @@ export default { v: {required: true}, }, data() { - for (let abbr in abbreviations) { - if (!abbreviations.hasOwnProperty(abbr)) { continue; } - if (this.v.startsWith(abbr + ' ')) { - return { - abbr, - meaning: abbreviations[abbr], - word: this.v.substring(abbr.length + 1), - }; - } - } - return { - abbr: null, - meaning: null, - word: this.v, + const abbrs = {}; + let word = this.v.trim(); + let m = null; + while ((m = word.match(/^(\w+\.?) /)) !== null) { + const abbr = m[1]; + abbrs[abbr] = abbreviations[abbr] || null; + word = word.substring(abbr.length + 1).trim(); } + + return { abbrs, word }; }, }