This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
Zaimki/components/Abbreviation.vue

36 lines
846 B
Vue
Raw Normal View History

2022-02-13 06:20:14 -08:00
<template>
<span>
<template v-for="(meaning, abbr) in abbrs"><abbr v-if="meaning" :title="meaning">{{abbr}}</abbr><span v-else>{{abbr}}</span>&nbsp;</template><slot v-bind:abbrs="abbrs" v-bind:word="word"></slot>
2022-02-13 06:20:14 -08:00
</span>
</template>
<script>
import { abbreviations } from '../src/data';
export default {
props: {
v: {required: true},
},
data() {
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();
2022-02-13 06:20:14 -08:00
}
return { abbrs, word };
2022-02-13 06:20:14 -08:00
},
}
</script>
<style lang="scss" scoped>
@import "assets/variables";
abbr {
text-decoration-color: $text-muted;
}
</style>