File tree Expand file tree Collapse file tree 4 files changed +22
-5
lines changed
src/components/widgets/Markdown Expand file tree Collapse file tree 4 files changed +22
-5
lines changed Original file line number Diff line number Diff line change 5656 "font-awesome-animation" : " ^0.2.1" ,
5757 "glob" : " ^7.1.2" ,
5858 "global" : " ^4.3.1" ,
59+ "highlight.js" : " ^9.16.2" ,
5960 "immutable" : " ^3.8.1" ,
6061 "isomorphic-fetch" : " ^2.2.1" ,
6162 "js-yaml" : " ^3.13.1" ,
Original file line number Diff line number Diff line change 11import React from 'react' ;
22import PropTypes from 'prop-types' ;
33
4- const md = require ( 'markdown-it' ) ( ) . use ( require ( '@iktakahiro/markdown-it-katex' ) ) ;
4+ const hljs = require ( 'highlight.js' ) ;
5+ const md = require ( 'markdown-it' ) ( {
6+ highlight : function ( str , lang ) {
7+ if ( lang && hljs . getLanguage ( lang ) ) {
8+ try {
9+ return hljs . highlight ( lang , str ) . value ;
10+ } catch ( error ) {
11+ /* just ignore the error */
12+ }
13+ }
14+
15+ return '' ; // use external default escaping
16+ } ,
17+ } ) . use ( require ( '@iktakahiro/markdown-it-katex' ) ) ;
518
619const Markdown = ( { source } ) => (
720 < div
Original file line number Diff line number Diff line change 1414 integrity =" sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
1515 crossorigin =" anonymous"
1616 />
17- <link
18- rel =" stylesheet"
19- href =" https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0/katex.min.css"
20- />
17+ <link rel =" stylesheet" href =" https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.9.0/katex.min.css" />
18+ <
link rel =
" stylesheet" href =
" https://cdn.jsdelivr.net/gh/highlightjs/[email protected] /build/styles/default.min.css" >
2119 <link
2220 rel =" stylesheet"
2321 href =" https://cdn.jsdelivr.net/github-markdown-css/2.2.1/github-markdown.css"
Original file line number Diff line number Diff line change 50755075 resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
50765076 integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
50775077
5078+ highlight.js@^9.16.2 :
5079+ version "9.16.2"
5080+ resolved "https://registry.yarnpkg.com/highlight.js/-/highlight.js-9.16.2.tgz#68368d039ffe1c6211bcc07e483daf95de3e403e"
5081+ integrity sha512-feMUrVLZvjy0oC7FVJQcSQRqbBq9kwqnYE4+Kj9ZjbHh3g+BisiPgF49NyQbVLNdrL/qqZr3Ca9yOKwgn2i/tw==
5082+
50785083history@^4.9.0 :
50795084 version "4.9.0"
50805085 resolved "https://registry.yarnpkg.com/history/-/history-4.9.0.tgz#84587c2068039ead8af769e9d6a6860a14fa1bca"
You can’t perform that action at this time.
0 commit comments