Skip to content

Commit

Permalink
Merge pull request #1597 from ehuss/update-hightlight.js
Browse files Browse the repository at this point in the history
Update to highlight.js 11.0.
  • Loading branch information
ehuss authored Jul 26, 2021
2 parents 8c7af3c + 6dd785e commit 2cf00d0
Show file tree
Hide file tree
Showing 4 changed files with 1,350 additions and 7 deletions.
13 changes: 13 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,16 @@ If possible, do your best to avoid breaking older browser releases.
Any change to the HTML or styling is encouraged to manually check on as many browsers and platforms that you can.
Unfortunately at this time we don't have any automated UI or browser testing, so your assistance in testing is appreciated.
## Updating higlight.js
The following are instructions for updating [highlight.js](https://highlightjs.org/).
1. Clone the repository at <https://github.com/highlightjs/highlight.js>
1. Check out a tagged release (like `11.0.0`).
1. Run `npm install`
1. Run `node tools/build.js :common apache armasm coffeescript d handlebars haskell http julia nginx properties r scala x86asm yaml`
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`.
1. Copy `build/highlight.min.js` to mdbook's directory [`highlight.js`](https://github.com/rust-lang/mdBook/blob/master/src/theme/highlight.js).
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.
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.)
3 changes: 3 additions & 0 deletions guide/src/format/theme/syntax-highlighting.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,11 @@ your own `highlight.js` file:
- objectivec
- perl
- php
- php-template
- plaintext
- properties
- python
- python-repl
- r
- ruby
- rust
Expand All @@ -59,6 +61,7 @@ your own `highlight.js` file:
- sql
- swift
- typescript
- vbnet
- x86asm
- xml
- yaml
Expand Down
4 changes: 2 additions & 2 deletions src/theme/book.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ function playground_text(playground) {
Array
code_nodes
.filter(function (node) {return !node.classList.contains("editable"); })
.forEach(function (block) { hljs.highlightBlock(block); });
.forEach(function (block) { hljs.highlightElement(block); });
} else {
code_nodes.forEach(function (block) { hljs.highlightBlock(block); });
code_nodes.forEach(function (block) { hljs.highlightElement(block); });
}

// Adding the hljs class gives code blocks the color css
Expand Down
1,337 changes: 1,332 additions & 5 deletions src/theme/highlight.js

Large diffs are not rendered by default.

0 comments on commit 2cf00d0

Please sign in to comment.