Skip to content
This repository was archived by the owner on May 14, 2024. It is now read-only.

Commit 2de077d

Browse files
committed
docs: highlight code
1 parent e4b72cd commit 2de077d

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,14 @@
2727
"verror": "^1.8.1"
2828
},
2929
"devDependencies": {
30-
"eslint": "^7.14.0",
30+
"eslint": "^7.20.0",
3131
"eslint-config-standard": "^16.0.2",
3232
"eslint-plugin-import": "^2.22.1",
3333
"eslint-plugin-node": "^11.1.0",
34-
"eslint-plugin-promise": "^4.2.1",
34+
"eslint-plugin-promise": "^4.3.1",
3535
"front-matter": "^4.0.2",
3636
"get-port": "^5.1.1",
37+
"highlight.js": "^10.6.0",
3738
"husky": "^4.2.5",
3839
"marked": "^2.0.0",
3940
"tap": "14.11.0"

scripts/build-docs.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@ const fs = require('fs/promises')
22
const path = require('path')
33
const marked = require('marked')
44
const fm = require('front-matter')
5+
const { highlight, highlightAuto } = require('highlight.js')
6+
7+
marked.use({
8+
highlight: (code, lang) => {
9+
if (!lang) {
10+
return highlightAuto(code).value
11+
}
12+
return highlight(lang, code).value
13+
}
14+
})
515

616
function tocHTML (toc) {
717
let html = '<ul>\n'

0 commit comments

Comments
 (0)