Skip to content
Snippets Groups Projects

Resolve "Incorrect syntax highlighting for block comments"

All threads resolved!
Files
2
@@ -4,6 +4,7 @@ import * as api from '@/api'
import { Feedback, FeedbackComment, SubmissionNoType } from '@/models'
import { RootState } from '@/store/store'
import { getStoreBuilder, BareActionContext } from 'vuex-typex'
import { syntaxPostProcess } from '@/util/helpers';
export interface SubmissionNotesState {
submission: SubmissionNoType
@@ -63,15 +64,12 @@ const submissionGetter = mb.read(function submission (state, getters) {
? getters.submissionType.programmingLanguage
: 'c'
const highlighted = hljs.highlight(language, state.submission.text || '', true).value
let commentFlag = false
return highlighted.split('\n').reduce((acc: {[k: number]: string}, cur, index) => {
if (cur.includes("/*")) commentFlag = true
cur = commentFlag ? '<span class="hljs-comment">' + cur + '</span>' : cur
if (cur.includes("*/")) commentFlag = false // so that the ending line will also be greyed out
const postProcessed = syntaxPostProcess(highlighted);
const splitted = postProcessed.split('\n').reduce((acc: {[k: number]: string}, cur, index) => {
acc[index + 1] = cur
return acc
}, {})
return splitted;
})
const scoreGetter = mb.read(function score (state) {
return state.updatedFeedback.score !== undefined ? state.updatedFeedback.score : state.origFeedback.score
Loading