Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc176913

Browse files
authored
Merge pull requestcoderoad#181 from ShMcK/remove-markdown-it-prism
remove markdown-it-prism
2 parents745d4cc +d3bc4f0 commitc176913

File tree

2 files changed

+16
-7
lines changed

2 files changed

+16
-7
lines changed

‎web-app/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
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",

‎web-app/src/components/Markdown/index.tsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
importMarkdownItfrom'markdown-it'
22
//@ts-ignore no types for package
3-
importmarkdownEmojifrom'markdown-it-emoji'
3+
4+
importPrismfrom'prismjs'
5+
46
//@ts-ignore no types for package
5-
importprismfrom'markdown-it-prism'
7+
importmarkdownEmojifrom'markdown-it-emoji'
68
import*asReactfrom'react'
79
importonErrorfrom'../../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+
lethl
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',

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp