Skip to content

Commit 2cf00d0

Browse files
authored
Merge pull request #1597 from ehuss/update-hightlight.js
Update to highlight.js 11.0.
2 parents 8c7af3c + 6dd785e commit 2cf00d0

File tree

4 files changed

+1350
-7
lines changed

4 files changed

+1350
-7
lines changed

CONTRIBUTING.md

+13
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,16 @@ If possible, do your best to avoid breaking older browser releases.
115115
116116
Any change to the HTML or styling is encouraged to manually check on as many browsers and platforms that you can.
117117
Unfortunately at this time we don't have any automated UI or browser testing, so your assistance in testing is appreciated.
118+
119+
## Updating higlight.js
120+
121+
The following are instructions for updating [highlight.js](https://highlightjs.org/).
122+
123+
1. Clone the repository at <https://github.com/highlightjs/highlight.js>
124+
1. Check out a tagged release (like `11.0.0`).
125+
1. Run `npm install`
126+
1. Run `node tools/build.js :common apache armasm coffeescript d handlebars haskell http julia nginx properties r scala x86asm yaml`
127+
1. Compare the language list that it spits out to the one in [`syntax-highlighting.md`](https://github.com/camelid/mdBook/blob/master/guide/src/format/theme/syntax-highlighting.md). If any are missing, add them to the list and rebuild (and update these docs). If any are added to the common set, add them to `syntax-highlighting.md`.
128+
1. Copy `build/highlight.min.js` to mdbook's directory [`highlight.js`](https://github.com/rust-lang/mdBook/blob/master/src/theme/highlight.js).
129+
1. Be sure to check the highlight.js [CHANGES](https://github.com/highlightjs/highlight.js/blob/main/CHANGES.md) for any breaking changes. Breaking changes that would affect users will need to wait until the next major release.
130+
1. Build mdbook with the new file and build some books with the new version and compare the output with a variety of languages to see if anything changes. (TODO: It would be nice to have a demo file in the repo to help with this.)

guide/src/format/theme/syntax-highlighting.md

+3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@ your own `highlight.js` file:
4747
- objectivec
4848
- perl
4949
- php
50+
- php-template
5051
- plaintext
5152
- properties
5253
- python
54+
- python-repl
5355
- r
5456
- ruby
5557
- rust
@@ -59,6 +61,7 @@ your own `highlight.js` file:
5961
- sql
6062
- swift
6163
- typescript
64+
- vbnet
6265
- x86asm
6366
- xml
6467
- yaml

src/theme/book.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ function playground_text(playground) {
169169
Array
170170
code_nodes
171171
.filter(function (node) {return !node.classList.contains("editable"); })
172-
.forEach(function (block) { hljs.highlightBlock(block); });
172+
.forEach(function (block) { hljs.highlightElement(block); });
173173
} else {
174-
code_nodes.forEach(function (block) { hljs.highlightBlock(block); });
174+
code_nodes.forEach(function (block) { hljs.highlightElement(block); });
175175
}
176176

177177
// Adding the hljs class gives code blocks the color css

src/theme/highlight.js

+1,332-5
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)