Skip to content
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

fix: Support tsx with prism syntax highlighter #1391

Merged
merged 2 commits into from
Apr 25, 2019
Merged
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
3 changes: 2 additions & 1 deletion packages/docusaurus-1.x/lib/core/renderMarkdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
const hljs = require('highlight.js');
const Markdown = require('remarkable');
const prismjs = require('prismjs');
const loadLanguages = require('prismjs/components/index');
const deepmerge = require('deepmerge');
const chalk = require('chalk');
const anchors = require('./anchors.js');
Expand Down Expand Up @@ -51,7 +52,7 @@ class MarkdownRenderer {
try {
// Currently people using prismjs on Node have to individually require()
// every single language (https://github.com/PrismJS/prism/issues/593)
require(`prismjs/components/prism-${language}.min`);
loadLanguages([language]);
return prismjs.highlight(str, prismjs.languages[language]);
} catch (err) {
if (err.code === 'MODULE_NOT_FOUND') {
Expand Down