Skip to content
Snippets Groups Projects
Commit 1901f4f4 authored by robinwilliam.hundt's avatar robinwilliam.hundt
Browse files

Frontend Java Syntax highlight support

parent 9a60d63d
No related branches found
No related tags found
1 merge request!84Java syntax highlight support
Pipeline #
......@@ -20,7 +20,7 @@
<v-flex v-else-if="item.title === 'Solution'">
<pre
class="elevation-2 solution-code pl-2"
:class="language"
:class="programming_language"
><span v-html="highlightedSolution"></span></pre>
</v-flex>
</v-expansion-panel-content>
......@@ -51,7 +51,7 @@
type: Number,
required: true
},
language: {
programming_language: {
type: String,
default: 'c'
},
......@@ -88,7 +88,7 @@
}
},
highlightedSolution () {
return highlight(this.language, this.solution, true).value
return highlight(this.programming_language, this.solution, true).value
}
}
}
......
......@@ -76,7 +76,7 @@
return this.currentAssignment.submission
},
submissionType () {
return this.$store.state.submissionTypes[this.submission['type_pk']]
return this.$store.state.submissionTypes[this.submission['type']]
}
},
beforeRouteEnter (to, from, next) {
......
......@@ -22,7 +22,8 @@ function initialState () {
return {
assignment: '',
submission: {
text: ''
text: '',
pk: ''
},
ui: {
showEditorOnLine: {},
......@@ -46,11 +47,18 @@ const submissionNotes = {
namespaced: true,
state: initialState(),
getters: {
// reduce the string submission.text into an object where the keys are the
submissionType: (state, getters, rootState) => {
return rootState.submissionTypes[state.submission.type]
},
// highlight the submission the reduce the string
// submission.text into an object where the keys are the
// line indexes starting at one and the values the corresponding submission line
// this makes iterating over the submission much more pleasant
submission: state => {
const highlighted = hljs.highlight('c', state.submission.text, true).value
submission: (state, getters) => {
const language = getters.submissionType
? getters.submissionType.programming_language
: 'c'
const highlighted = hljs.highlight(language, state.submission.text, true).value
return highlighted.split('\n').reduce((acc, cur, index) => {
acc[index + 1] = cur
return acc
......
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