Browse Source

Updated highlight.js usage info

- Ref #779
pull/783/head
Vitaly Puzrin 4 years ago
parent
commit
064d602c68
  1. 4
      README.md
  2. 24
      benchmark/samples/README.md
  3. 4
      lib/index.js
  4. 2
      package.json
  5. 4
      support/api_header.md
  6. 4
      support/demo_template/index.js

4
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 '<pre class="hljs"><code>' +
hljs.highlight(lang, str, true).value +
hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
'</code></pre>';
} catch (__) {}
}

24
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 (__) {}
}

4
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 '<pre class="hljs"><code>' +
* hljs.highlight(lang, str, true).value +
* hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
* '</code></pre>';
* } catch (__) {}
* }

2
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",

4
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 '<pre class="hljs"><code>' +
hljs.highlight(lang, str, true).value +
hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
'</code></pre>';
} catch (__) {}
}

4
support/demo_template/index.js

@ -91,7 +91,7 @@ defaults.highlight = function (str, lang) {
if (lang && lang !== 'auto' && hljs.getLanguage(lang)) {
return '<pre class="hljs language-' + esc(lang.toLowerCase()) + '"><code>' +
hljs.highlight(lang, str, true).value +
hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
'</code></pre>';
} 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);
}

Loading…
Cancel
Save