diff --git a/src/app/components/tasks/task-body/task-body.component.ts b/src/app/components/tasks/task-body/task-body.component.ts index c66e195..bfbe5b0 100644 --- a/src/app/components/tasks/task-body/task-body.component.ts +++ b/src/app/components/tasks/task-body/task-body.component.ts @@ -16,6 +16,31 @@ import { DomSanitizer, SafeHtml } from '@angular/platform-browser'; import { TaskTipComponent } from './task-tip/task-tip.component'; import { TaskPanel, TaskTipData } from '../../../models'; +// https://stackoverflow.com/questions/64280814/how-can-i-correctly-highlight-a-line-by-line-code-using-highlight-js-react +highlight.addPlugin({ + 'after:highlight': (params: { value: string }) => { + const openTags: string[] = []; + + params.value = params.value + .split('\n') + .map((line) => { + line = line.replace(/(]+>)|(<\/span>)/g, (match) => { + if (match === '') { + openTags.pop(); + } else { + openTags.push(match); + } + return match; + }); + + return `