Skip to content

remove markdown-it-prism #181

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion web-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@sentry/browser": "^5.15.4",
"markdown-it": "^10.0.0",
"markdown-it-emoji": "^1.4.0",
"markdown-it-prism": "^2.0.5",
"moment": "^2.24.0",
"prismjs": "^1.19.0",
"react": "^16.13.1",
Expand Down
22 changes: 16 additions & 6 deletions web-app/src/components/Markdown/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import MarkdownIt from 'markdown-it'
// @ts-ignore no types for package
import markdownEmoji from 'markdown-it-emoji'

import Prism from 'prismjs'

// @ts-ignore no types for package
import prism from 'markdown-it-prism'
import markdownEmoji from 'markdown-it-emoji'
import * as React from 'react'
import onError from '../../services/sentry/onError'
// load prism styles & language support
Expand All @@ -13,13 +15,21 @@ const md: MarkdownIt = new MarkdownIt({
breaks: true,
html: true,
linkify: true,
highlight(str, lang) {
let hl

try {
hl = Prism.highlight(str, Prism.languages[lang], lang)
} catch (error) {
console.error(error)
hl = md.utils.escapeHtml(str)
}

return `<pre class="language-${lang}"><code class="language-${lang}">${hl}</code></pre>`
},
})
// add emoji: https://github.com/markdown-it/markdown-it-emoji
.use(markdownEmoji)
// add syntax highlighting through prism
.use(prism, {
defaultLanguage: 'js',
})

// const mdFeatures = [
// 'table',
Expand Down