[pl][nouns] allow multiple abbreviations
This commit is contained in:
parent
ebb408ae8d
commit
42c5f270b3
|
@ -1,6 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<span>
|
<span>
|
||||||
<abbr v-if="abbr" :title="meaning">{{abbr}}</abbr><template v-if="abbr"> </template><slot v-bind:abbr="abbr" v-bind:meaning="meaning" v-bind:word="word"></slot>
|
<template v-for="(meaning, abbr) in abbrs"><abbr v-if="meaning" :title="meaning">{{abbr}}</abbr><span v-else>{{abbr}}</span> </template><slot v-bind:abbrs="abbrs" v-bind:word="word"></slot>
|
||||||
</span>
|
</span>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -12,21 +12,16 @@ export default {
|
||||||
v: {required: true},
|
v: {required: true},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
for (let abbr in abbreviations) {
|
const abbrs = {};
|
||||||
if (!abbreviations.hasOwnProperty(abbr)) { continue; }
|
let word = this.v.trim();
|
||||||
if (this.v.startsWith(abbr + ' ')) {
|
let m = null;
|
||||||
return {
|
while ((m = word.match(/^(\w+\.?) /)) !== null) {
|
||||||
abbr,
|
const abbr = m[1];
|
||||||
meaning: abbreviations[abbr],
|
abbrs[abbr] = abbreviations[abbr] || null;
|
||||||
word: this.v.substring(abbr.length + 1),
|
word = word.substring(abbr.length + 1).trim();
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
abbr: null,
|
|
||||||
meaning: null,
|
|
||||||
word: this.v,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return { abbrs, word };
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Reference in New Issue