docs: highlight code
This commit is contained in:
parent
e4b72cde9b
commit
2de077d39f
|
@ -27,13 +27,14 @@
|
||||||
"verror": "^1.8.1"
|
"verror": "^1.8.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"eslint": "^7.14.0",
|
"eslint": "^7.20.0",
|
||||||
"eslint-config-standard": "^16.0.2",
|
"eslint-config-standard": "^16.0.2",
|
||||||
"eslint-plugin-import": "^2.22.1",
|
"eslint-plugin-import": "^2.22.1",
|
||||||
"eslint-plugin-node": "^11.1.0",
|
"eslint-plugin-node": "^11.1.0",
|
||||||
"eslint-plugin-promise": "^4.2.1",
|
"eslint-plugin-promise": "^4.3.1",
|
||||||
"front-matter": "^4.0.2",
|
"front-matter": "^4.0.2",
|
||||||
"get-port": "^5.1.1",
|
"get-port": "^5.1.1",
|
||||||
|
"highlight.js": "^10.6.0",
|
||||||
"husky": "^4.2.5",
|
"husky": "^4.2.5",
|
||||||
"marked": "^2.0.0",
|
"marked": "^2.0.0",
|
||||||
"tap": "14.11.0"
|
"tap": "14.11.0"
|
||||||
|
|
|
@ -2,6 +2,16 @@ const fs = require('fs/promises')
|
||||||
const path = require('path')
|
const path = require('path')
|
||||||
const marked = require('marked')
|
const marked = require('marked')
|
||||||
const fm = require('front-matter')
|
const fm = require('front-matter')
|
||||||
|
const { highlight, highlightAuto } = require('highlight.js')
|
||||||
|
|
||||||
|
marked.use({
|
||||||
|
highlight: (code, lang) => {
|
||||||
|
if (!lang) {
|
||||||
|
return highlightAuto(code).value
|
||||||
|
}
|
||||||
|
return highlight(lang, code).value
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
function tocHTML (toc) {
|
function tocHTML (toc) {
|
||||||
let html = '<ul>\n'
|
let html = '<ul>\n'
|
||||||
|
|
Loading…
Reference in New Issue