Skip to content

Commit 49558e0

Browse files
authored
Add test suite for highlight.js Djot grammar (#100)
* Add test suite for highlight.js Djot grammar - Add docs/tests/ with Node.js test suite using highlight.js - 50 test cases covering all Djot syntax elements - Add GitHub workflow to run tests on PRs affecting hljs-djot.js * Expand hljs test suite to 118 comprehensive tests Cover all Djot syntax elements: - Headings (levels 1-6) - Emphasis/strong variations - Code (inline, double/triple backtick, fences) - Links (inline, reference, shortcut, autolink, email) - Images (with titles, attributes) - Lists (all markers, numbered, task, indented) - Blockquotes, divs (with 4+ colons) - Tables (rows, separators, alignment) - Comments (inline, fenced) - Highlight, insert, delete - Super/subscript (shorthand and braced) - Math (inline, display) - Definitions (reference, footnote, abbreviation) - Attributes (class, id, key-value, complex) - Horizontal rules, symbols, smart punctuation - Escapes, raw format, captions, line blocks - Frontmatter, hard line breaks - Edge cases with multiple elements
1 parent 9b944a0 commit 49558e0

5 files changed

Lines changed: 785 additions & 0 deletions

File tree

.github/workflows/test-hljs.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Test Highlight.js Grammar
2+
3+
on:
4+
push:
5+
branches: [master]
6+
paths:
7+
- 'docs/public/assets/hljs-djot.js'
8+
- 'docs/tests/**'
9+
pull_request:
10+
paths:
11+
- 'docs/public/assets/hljs-djot.js'
12+
- 'docs/tests/**'
13+
workflow_dispatch:
14+
15+
jobs:
16+
test:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v4
21+
22+
- name: Setup Node.js
23+
uses: actions/setup-node@v4
24+
with:
25+
node-version: 20
26+
cache: npm
27+
cache-dependency-path: docs/tests/package-lock.json
28+
29+
- name: Install dependencies
30+
run: npm ci
31+
working-directory: docs/tests
32+
33+
- name: Run highlight.js grammar tests
34+
run: npm test
35+
working-directory: docs/tests

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
# Documentation
2121
/docs/node_modules/
22+
/docs/tests/node_modules/
2223
/docs/.vitepress/cache/
2324
/docs/.vitepress/dist/
2425
/docs/.vitepress/grammars/

docs/tests/package-lock.json

Lines changed: 24 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/tests/package.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "djot-hljs-tests",
3+
"version": "1.0.0",
4+
"description": "Tests for Djot highlight.js grammar",
5+
"type": "module",
6+
"scripts": {
7+
"test": "node test-hljs.mjs"
8+
},
9+
"devDependencies": {
10+
"highlight.js": "^11.9.0"
11+
}
12+
}

0 commit comments

Comments
 (0)