diff --git a/src/app/markdown/markdown.service.spec.ts b/src/app/markdown/markdown.service.spec.ts index 9d91a51a..d2746c6d 100644 --- a/src/app/markdown/markdown.service.spec.ts +++ b/src/app/markdown/markdown.service.spec.ts @@ -168,14 +168,14 @@ describe('MarkdowService', () => { it('should not call Prism when not available', () => { - Prism = undefined; + global['Prism'] = undefined; markdownService.highlight(); }); it('should call Prism when available', () => { - Prism = { highlightAll: () => {} }; + global['Prism'] = { highlightAll: () => {} }; spyOn(Prism, 'highlightAll'); diff --git a/src/app/markdown/markdown.service.ts b/src/app/markdown/markdown.service.ts index 9248ea3d..4c3d00fe 100644 --- a/src/app/markdown/markdown.service.ts +++ b/src/app/markdown/markdown.service.ts @@ -46,10 +46,9 @@ export class MarkdownService { } highlight() { - if (!Prism) { - return; + if (typeof Prism !== 'undefined') { + Prism.highlightAll(false); } - Prism.highlightAll(false); } private extractData(response: Response) {