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

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
ShMcK merged 1 commit intomasterfromremove-markdown-it-prism
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes fromall 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 deletionweb-app/package.json
View file
Open in desktop
Original file line numberDiff line numberDiff 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 deletionsweb-app/src/components/Markdown/index.tsx
View file
Open in desktop
Original file line numberDiff line numberDiff 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
importprism from 'markdown-it-prism'
importmarkdownEmoji 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

[8]ページ先頭

©2009-2025 Movatter.jp