Skip to content
Snippets Groups Projects
Commit c621887b authored by Henrik Askjer's avatar Henrik Askjer
Browse files

fix snippets

parent 2a9aaeb4
No related branches found
No related tags found
No related merge requests found
......@@ -42,6 +42,8 @@ import Header from './Header.vue'
import ArticleFooter from './ArticleFooter.vue'
import InflectionButton from './InflectionButton.vue'
import entities from '../utils/entities.js'
function find_sub_articles(definition) {
let sub_art_list = []
let sub_definitions = definition.elements.filter(el => el.type_ == 'definition')
......@@ -84,14 +86,8 @@ export default {
computed: {
snippet: function() {
let text = ""
this.article.body.definitions.forEach((definition) => {
//console.log(definition)
text+=definition.elements[0].content
})
return text
return this.parse_definitions(this.article.body.definitions)
},
collapsable: function() {
......@@ -129,6 +125,54 @@ export default {
InflectionButton
},
methods: {
parse_definitions: function(node) {
console.log(node)
//console.log(entities["nn"]["overf"])
let definitionTexts = []
node.forEach((definition) => {
if (definition.elements[0].content) {
let new_string = ""
let old_parts = definition.elements[0].content.split(/(\$)/)
let linkIndex = 0
old_parts.forEach((item) => {
if (item == '$') {
if (definition.elements[0].items[linkIndex].id) {
new_string += entities[this.dictionary][definition.elements[0].items[linkIndex].id].expansion
}
else {
new_string += definition.elements[0].items[linkIndex].lemmas[0].lemma
}
if (!definition.elements[0].items[linkIndex].id) {
console.log("NO", definition.elements[0].items[linkIndex])
}
linkIndex += 1
}
else {
console.log(item)
new_string += item
}
})
console.log("STRING", new_string)
console.log("LAST", new_string.substring(new_string.length, new_string.length - 1))
if (new_string.substring(new_string.length, new_string.length - 1) == ":") {
new_string = new_string.slice(0, -1)+"[...]"
}
definitionTexts.push(new_string)
}
else if (definition.elements[0].elements) {
definitionTexts.push(this.parse_definitions(definition.elements))
}
})
return definitionTexts.join(" [...] ")
},
expand: function() {
if (this.collapsed) {
this.collapsed = false
......
......@@ -22,7 +22,7 @@
</v-menu>)
</span>
<span v-if="$parent.collapsed && $parent.has_content" class="definition_snippet">
- {{$parent.snippet}}
| {{$parent.snippet}}
</span> <span v-if="$parent.collapsable" >
<v-btn class="expand_icon"
:title="$parent.collapsed? 'Vis mer' : 'Kollaps'"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment