From 8bb978debe0dbb4d311c710ce2e04c6b4d516744 Mon Sep 17 00:00:00 2001
From: Amour1688 <31695475+Amour1688@users.noreply.github.com>
Date: Thu, 12 Mar 2020 22:49:03 +0800
Subject: [PATCH] Perf: highlight.js --> prism (#1865)

* perf: highlight.js --> prism

* fix: wrong mentions route
---
 build/dev.js               | 1 -
 build/webpack.base.conf.js | 6 +++---
 package.json               | 3 ++-
 site/demoRoutes.js         | 2 +-
 site/index.js              | 1 -
 5 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/build/dev.js b/build/dev.js
index a5ffaa67d..b1e8a4b86 100644
--- a/build/dev.js
+++ b/build/dev.js
@@ -28,7 +28,6 @@ let { componentName } = require('./config').dev;
 const componentsInPrototype = ['Modal', 'message', 'notification'];
 
 const MAIN_TEMPLATE = `import 'babel-polyfill';
-import 'highlight.js/styles/solarized-light.css';
 import Vue from 'vue';
 import Vuex from 'vuex';
 import VueI18n from 'vue-i18n';
diff --git a/build/webpack.base.conf.js b/build/webpack.base.conf.js
index 2b2673363..0292ba864 100644
--- a/build/webpack.base.conf.js
+++ b/build/webpack.base.conf.js
@@ -1,5 +1,5 @@
 const path = require('path');
-const hljs = require('highlight.js');
+const Prism = require('prismjs');
 const Token = require('markdown-it/lib/token');
 const cheerio = require('cheerio');
 const WebpackBar = require('webpackbar');
@@ -43,12 +43,12 @@ const replaceDelimiters = function(str) {
  */
 
 const renderHighlight = function(str, lang) {
-  if (!(lang && hljs.getLanguage(lang))) {
+  if (!(lang && Prism.languages[lang])) {
     return '';
   }
 
   try {
-    return replaceDelimiters(hljs.highlight(lang, str, true).value);
+    return replaceDelimiters(Prism.highlight(str, Prism.languages[lang], lang));
   } catch (err) {}
 };
 
diff --git a/package.json b/package.json
index a1723c660..be7c42bc7 100644
--- a/package.json
+++ b/package.json
@@ -139,6 +139,7 @@
         "postcss-loader": "^3.0.0",
         "prettier": "^1.18.2",
         "pretty-quick": "^2.0.0",
+        "prismjs": "^1.19.0",
         "querystring": "^0.2.0",
         "raw-loader": "^4.0.0",
         "reqwest": "^2.0.5",
@@ -216,4 +217,4 @@
         "lib/**/style/*",
         "*.less"
     ]
-}
\ No newline at end of file
+}
diff --git a/site/demoRoutes.js b/site/demoRoutes.js
index bfd4800e9..766721d80 100644
--- a/site/demoRoutes.js
+++ b/site/demoRoutes.js
@@ -80,7 +80,7 @@ export default [
     component: () => import('../antdv-demo/input/demo/index.vue'),
   },
   {
-    path: 'mentions-cn',
+    path: 'mentions',
     component: () => import('../antdv-demo/mentions/demo/index.vue'),
   },
   {
diff --git a/site/index.js b/site/index.js
index f68098456..3393a09b2 100644
--- a/site/index.js
+++ b/site/index.js
@@ -2,7 +2,6 @@ import 'babel-polyfill';
 import '../components/style.js';
 import './index.less';
 import 'nprogress/nprogress.css';
-import 'highlight.js/styles/solarized-light.css';
 import Vue from 'vue';
 import Vuex from 'vuex';
 import VueI18n from 'vue-i18n';