diff --git a/README.md b/README.md index a6f8396ec..0e866de2f 100644 --- a/README.md +++ b/README.md @@ -152,7 +152,7 @@ var md = require('markdown-it')({ highlight: function (str, lang) { if (lang && hljs.getLanguage(lang)) { try { - return hljs.highlight(lang, str).value; + return hljs.highlight(str, { language: lang }).value; } catch (__) {} } @@ -172,7 +172,7 @@ var md = require('markdown-it')({ if (lang && hljs.getLanguage(lang)) { try { return '
' +
- hljs.highlight(lang, str, true).value +
+ hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
'
';
} catch (__) {}
}
diff --git a/benchmark/samples/README.md b/benchmark/samples/README.md
index 27dc9a6eb..bc4f98ad7 100644
--- a/benchmark/samples/README.md
+++ b/benchmark/samples/README.md
@@ -18,14 +18,20 @@ __v4.+ changed internals! Plugins need update. See [migration details](https://g
__Table of content__
-- [Install](#install)
-- [Usage examples](#usage-examples)
-- [API](#api)
-- [Syntax extensions](#syntax-extensions)
-- [Benchmark](#benchmark)
-- [Authors](#authors)
-- [References / Thanks](#references--thanks)
-- [License](#license)
+- [markdown-it](#markdown-it)
+ - [Install](#install)
+ - [Usage examples](#usage-examples)
+ - [Simple](#simple)
+ - [Init with presets and options](#init-with-presets-and-options)
+ - [Plugins load](#plugins-load)
+ - [Syntax highlighting](#syntax-highlighting)
+ - [API](#api)
+ - [Syntax extensions](#syntax-extensions)
+ - [Manage rules](#manage-rules)
+ - [Benchmark](#benchmark)
+ - [Authors](#authors)
+ - [References / Thanks](#references--thanks)
+ - [License](#license)
## Install
@@ -142,7 +148,7 @@ var md = require('markdown-it')({
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
- return hljs.highlight(lang, str).value;
+ return hljs.highlight(str, { language: lang }).value;
} catch (__) {}
}
diff --git a/lib/index.js b/lib/index.js
index 7e1f7e4ec..afec8d8de 100644
--- a/lib/index.js
+++ b/lib/index.js
@@ -188,7 +188,7 @@ function normalizeLinkText(url) {
* highlight: function (str, lang) {
* if (lang && hljs.getLanguage(lang)) {
* try {
- * return hljs.highlight(lang, str, true).value;
+ * return hljs.highlight(str, { language: lang, ignoreIllegals: true }).value;
* } catch (__) {}
* }
*
@@ -208,7 +208,7 @@ function normalizeLinkText(url) {
* if (lang && hljs.getLanguage(lang)) {
* try {
* return '' +
- * hljs.highlight(lang, str, true).value +
+ * hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
* '
';
* } catch (__) {}
* }
diff --git a/package.json b/package.json
index 5c5a58bf9..86ce7ff09 100644
--- a/package.json
+++ b/package.json
@@ -55,7 +55,7 @@
"eslint": "^7.0.0",
"express": "^4.14.0",
"gh-pages": "^3.1.0",
- "highlight.js": "^10.0.3",
+ "highlight.js": "^10.7.2",
"jest-worker": "^26.6.2",
"markdown-it-abbr": "^1.0.4",
"markdown-it-container": "^3.0.0",
diff --git a/support/api_header.md b/support/api_header.md
index 9e762ce63..6e1fb732e 100644
--- a/support/api_header.md
+++ b/support/api_header.md
@@ -117,7 +117,7 @@ var md = require('markdown-it')({
highlight: function (str, lang) {
if (lang && hljs.getLanguage(lang)) {
try {
- return hljs.highlight(lang, str).value;
+ return hljs.highlight(str, { language: lang }).value;
} catch (__) {}
}
@@ -137,7 +137,7 @@ var md = require('markdown-it')({
if (lang && hljs.getLanguage(lang)) {
try {
return '' +
- hljs.highlight(lang, str, true).value +
+ hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
'
';
} catch (__) {}
}
diff --git a/support/demo_template/index.js b/support/demo_template/index.js
index 8414c9ae6..8ecc764d8 100644
--- a/support/demo_template/index.js
+++ b/support/demo_template/index.js
@@ -91,7 +91,7 @@ defaults.highlight = function (str, lang) {
if (lang && lang !== 'auto' && hljs.getLanguage(lang)) {
return '' +
- hljs.highlight(lang, str, true).value +
+ hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
'
';
} else if (lang === 'auto') {
@@ -183,7 +183,7 @@ function mdInit() {
function setHighlightedlContent(selector, content, lang) {
if (window.hljs) {
- $(selector).html(window.hljs.highlight(lang, content).value);
+ $(selector).html(window.hljs.highlight(content, { language: lang }).value);
} else {
$(selector).text(content);
}