File tree Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Expand file tree Collapse file tree 2 files changed +16
-7
lines changed Original file line number Diff line number Diff line change 3232 "@sentry/browser" : " ^5.15.4" ,
3333 "markdown-it" : " ^10.0.0" ,
3434 "markdown-it-emoji" : " ^1.4.0" ,
35- "markdown-it-prism" : " ^2.0.5" ,
3635 "moment" : " ^2.24.0" ,
3736 "prismjs" : " ^1.19.0" ,
3837 "react" : " ^16.13.1" ,
Original file line number Diff line number Diff line change 11import MarkdownIt from 'markdown-it'
22// @ts -ignore no types for package
3- import markdownEmoji from 'markdown-it-emoji'
3+
4+ import Prism from 'prismjs'
5+
46// @ts -ignore no types for package
5- import prism from 'markdown-it-prism '
7+ import markdownEmoji from 'markdown-it-emoji '
68import * as React from 'react'
79import onError from '../../services/sentry/onError'
810// load prism styles & language support
@@ -13,13 +15,21 @@ const md: MarkdownIt = new MarkdownIt({
1315 breaks : true ,
1416 html : true ,
1517 linkify : true ,
18+ highlight ( str , lang ) {
19+ let hl
20+
21+ try {
22+ hl = Prism . highlight ( str , Prism . languages [ lang ] , lang )
23+ } catch ( error ) {
24+ console . error ( error )
25+ hl = md . utils . escapeHtml ( str )
26+ }
27+
28+ return `<pre class="language-${ lang } "><code class="language-${ lang } ">${ hl } </code></pre>`
29+ } ,
1630} )
1731 // add emoji: https://github.com/markdown-it/markdown-it-emoji
1832 . use ( markdownEmoji )
19- // add syntax highlighting through prism
20- . use ( prism , {
21- defaultLanguage : 'js' ,
22- } )
2333
2434// const mdFeatures = [
2535// 'table',
You can’t perform that action at this time.
0 commit comments