Skip to content

Commit f958a0e

Browse files
committed
Add a syntax-highlighting GUI test
This adds a test specific to highlight.js syntax highlighting.
1 parent dbad189 commit f958a0e

File tree

9 files changed

+58
-53
lines changed

9 files changed

+58
-53
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ The following are instructions for updating [highlight.js](https://highlightjs.o
213213
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`.
214214
1. Copy `build/highlight.min.js` to mdbook's directory [`highlight.js`](https://github.com/rust-lang/mdBook/blob/master/src/theme/highlight.js).
215215
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.
216-
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. The [test_book](https://github.com/rust-lang/mdBook/tree/master/test_book) contains a chapter with many languages to examine.
216+
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. The [syntax GUI test](https://github.com/rust-lang/mdBook/tree/master/tests/gui/books/highlighting) contains a chapter with many languages to examine. Update the test (`highlighting.goml`) to add any new languages.
217217

218218
## Publishing new releases
219219

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Syntax Highlighting
2+
3+
This GUI test book is used for testing syntax highlighting.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[book]
2+
title = "Syntax Highlighting"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Summary
2+
3+
- [Languages](./languages.md)
File renamed without changes.

tests/gui/books/test_book/src/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ This contains dummy examples of various markdown elements and code languages, so
66
This rough outline is :
77

88
- individual : contains basic markdown elements such as headings, paragraphs, links etc.
9-
- languages : contains a `hello world` in each of supported language to see changes in syntax highlighting
109
- rust : contains language examples specific to rust, such as play pen, runnable examples etc.
1110

1211
This is more for checking and fixing style, rather than verifying that correct code is generated for given markdown, that is better handled in tests.

tests/gui/books/test_book/src/SUMMARY.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
- [Strikethrough](individual/strikethrough.md)
2525
- [MathJax](individual/mathjax.md)
2626
- [Mixed](individual/mixed.md)
27-
- [Languages](languages/README.md)
28-
- [Syntax Highlight](languages/highlight.md)
2927
- [Rust Specific](rust/README.md)
3028
- [Rust Codeblocks](rust/rust_codeblock.md)
3129
- [Last numbered chapter](last.md)

tests/gui/books/test_book/src/languages/README.md

Lines changed: 0 additions & 49 deletions
This file was deleted.

tests/gui/highlighting.goml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// This tests syntax highlighting.
2+
3+
go-to: |DOC_PATH| + "highlighting/index.html"
4+
5+
assert: "#apache ~ pre > code > span.hljs-comment"
6+
assert: "#armasm ~ pre > code > span.hljs-symbol"
7+
assert: "#bash ~ pre > code > span.hljs-meta"
8+
assert: "#c ~ pre > code > span.hljs-meta"
9+
assert: "#coffeescript ~ pre > code > span.hljs-title"
10+
assert: "#cpp ~ pre > code > span.hljs-meta"
11+
assert: "#csharp ~ pre > code > span.hljs-keyword"
12+
assert: "#css ~ pre > code > span.hljs-keyword"
13+
assert: "#d ~ pre > code > span.hljs-comment"
14+
assert: "#diff ~ pre > code > span.hljs-comment"
15+
assert: "#go ~ pre > code > span.hljs-keyword"
16+
// Not clear why this doesn't have the hljs- prefix.
17+
assert: "#handlebars ~ pre > code > span.xml"
18+
assert: "#haskell ~ pre > code > span.hljs-title"
19+
assert: "#http ~ pre > code > span.hljs-keyword"
20+
assert: "#ini ~ pre > code > span.hljs-comment"
21+
assert: "#java ~ pre > code > span.hljs-class"
22+
assert: "#javascript ~ pre > code > span.hljs-function"
23+
assert: "#json ~ pre > code > span.hljs-attr"
24+
assert: "#julia ~ pre > code > span.hljs-comment"
25+
assert: "#kotlin ~ pre > code > span.hljs-keyword"
26+
assert: "#less ~ pre > code > span.hljs-keyword"
27+
assert: "#lua ~ pre > code > span.hljs-comment"
28+
assert: "#makefile ~ pre > code > span.hljs-comment"
29+
assert: "#markdown ~ pre > code > span.hljs-section"
30+
assert: "#nginx ~ pre > code > span.hljs-attribute"
31+
assert: "#nim ~ pre > code > span.hljs-keyword"
32+
assert: "#objectivec ~ pre > code > span.hljs-meta"
33+
assert: "#nix ~ pre > code > span.hljs-keyword"
34+
assert: "#perl ~ pre > code > span.hljs-keyword"
35+
assert: "#php ~ pre > code > span.hljs-meta"
36+
assert: "#properties ~ pre > code > span.hljs-comment"
37+
assert: "#python ~ pre > code > span.hljs-meta"
38+
assert: "#r ~ pre > code > span.hljs-keyword"
39+
assert: "#ruby ~ pre > code > span.hljs-comment"
40+
assert: "#rust ~ pre > code > span.hljs-function"
41+
assert: "#scala ~ pre > code > span.hljs-comment"
42+
assert: "#scss ~ pre > code > span.hljs-comment"
43+
assert: "#shell ~ pre > code > span.hljs-meta"
44+
assert: "#sql ~ pre > code > span.hljs-keyword"
45+
assert: "#swift ~ pre > code > span.hljs-keyword"
46+
assert: "#typescript ~ pre > code > span.hljs-keyword"
47+
assert: "#x86asm ~ pre > code > span.hljs-meta"
48+
assert: "#xml ~ pre > code > span.hljs-meta"
49+
assert: "#yaml ~ pre > code > span.hljs-meta"

0 commit comments

Comments
 (0)