diff --git a/docs/docusaurus.md b/docs/docusaurus.md index 97487e4000..b7bf133d9c 100644 --- a/docs/docusaurus.md +++ b/docs/docusaurus.md @@ -5,7 +5,7 @@ title: docusaurus
Docusaurus
-
+
diff --git a/docs/hello.md b/docs/hello.md
index a392b2ca54..299d48f962 100644
--- a/docs/hello.md
+++ b/docs/hello.md
@@ -5,6 +5,15 @@ title: Hello, World !
Hi, Endilie here :)
+```py
+import hello
+def hi(name):
+ hello(name)
+
+print('Welcome to my repos!')
+```
+
+
## Blockquotes
> Blockquotes can also be nested...
diff --git a/lib/core/App.js b/lib/core/App.js
index dd1ca50162..c0b92a8b44 100644
--- a/lib/core/App.js
+++ b/lib/core/App.js
@@ -3,6 +3,6 @@ import {renderRoutes} from 'react-router-config';
import routes from '@generated/routes'; // eslint-disable-line
import docsData from '@generated/docsData'; // eslint-disable-line
import pagesData from '@generated/pagesData'; // eslint-disable-line
-import config from '@site/siteConfig.js'; //eslint-disable-line
+import siteConfig from '@site/siteConfig'; //eslint-disable-line
-export default () => renderRoutes(routes, {docsData, pagesData, config});
+export default () => renderRoutes(routes, {docsData, pagesData, siteConfig});
diff --git a/lib/core/components/Markdown/highlight.js b/lib/core/components/Markdown/highlight.js
new file mode 100644
index 0000000000..2b2c4f815d
--- /dev/null
+++ b/lib/core/components/Markdown/highlight.js
@@ -0,0 +1,22 @@
+const hljs = require('highlight.js');
+const chalk = require('chalk');
+const escapeHtml = require('escape-html');
+
+export default (str, rawLang) => {
+ if (rawLang === 'text') {
+ return escapeHtml(str);
+ }
+ const lang = rawLang.toLowerCase();
+ try {
+ if (hljs.getLanguage(lang)) {
+ return hljs.highlight(lang, str).value;
+ }
+ } catch (e) {
+ console.error(
+ chalk.yellow(
+ `Highlight.js syntax highlighting for language "${lang}" is not supported.`
+ )
+ );
+ }
+ return hljs.highlightAuto(str).value;
+};
diff --git a/lib/core/components/Markdown/index.js b/lib/core/components/Markdown/index.js
index e2ca07cffb..c9412efc8d 100644
--- a/lib/core/components/Markdown/index.js
+++ b/lib/core/components/Markdown/index.js
@@ -1,9 +1,8 @@
-/* eslint-disable react/no-danger */
+/* eslint-disable */
import React from 'react';
import Markdown from 'remarkable';
-import hljs from 'highlight.js';
-import prismjs from 'prismjs';
+import highlight from './highlight';
import anchors from './anchors';
class MarkdownBlock extends React.Component {
@@ -36,46 +35,7 @@ class MarkdownBlock extends React.Component {
const {siteConfig} = this.props;
const md = new Markdown({
langPrefix: 'hljs css language-',
- highlight(str, reqLang) {
- const lang =
- reqLang || (siteConfig.highlight && siteConfig.highlight.defaultLang);
- if (lang === 'text') {
- return str;
- }
- if (lang) {
- try {
- if (
- siteConfig.usePrism === true ||
- (siteConfig.usePrism &&
- siteConfig.usePrism.length > 0 &&
- siteConfig.usePrism.indexOf(lang) !== -1)
- ) {
- try {
- const language = alias[lang] || lang;
- // 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`); // eslint-disable-line
- return prismjs.highlight(str, prismjs.languages[language]);
- } catch (err) {
- console.error(err);
- }
- }
- if (hljs.getLanguage(lang)) {
- return hljs.highlight(lang, str).value;
- }
- } catch (err) {
- console.error(err);
- }
- }
-
- try {
- return hljs.highlightAuto(str).value;
- } catch (err) {
- console.error(err);
- }
-
- return '';
- },
+ highlight: highlight,
html: true,
linkify: true
});
diff --git a/lib/theme/Docs/index.js b/lib/theme/Docs/index.js
index 5a6ff22aa4..e4e1d0862f 100644
--- a/lib/theme/Docs/index.js
+++ b/lib/theme/Docs/index.js
@@ -6,8 +6,8 @@ import Layout from '@theme/Layout'; // eslint-disable-line
export default class Docs extends React.Component {
render() {
- const {location, docsData, config} = this.props;
- const currentDoc = docsData.find(data => data.path === location.pathname);
+ const {route, docsData, siteConfig} = this.props;
+ const currentDoc = docsData.find(data => data.path === route.path);
const highlight = Object.assign(
{},
@@ -15,21 +15,21 @@ export default class Docs extends React.Component {
version: '9.12.0',
theme: 'default'
},
- config.highlight
+ siteConfig.highlight
);
// Use user-provided themeUrl if it exists, else construct one from version and theme.
const highlightThemeURL = highlight.themeUrl
? highlight.themeUrl
- : `//cdnjs.cloudflare.com/ajax/libs/highlight.js/${
+ : `https://cdnjs.cloudflare.com/ajax/libs/highlight.js/${
highlight.version
}/styles/${highlight.theme}.min.css`;
return (