highlight.js
AGENTS.md25k starsChanged 3 months agoBSD-3-ClauseView on GitHub
Project policy: docs/ai-contributions.md. For this repo, when work was substantially tool-assisted, include an Assisted-by trailer on the commit and/or PR body (eat our own dogfood): Omit unknown pieces rather than guessing (Assisted-by: Copilot is fine). Do not claim assistance on commits that were fully human. className is deprecated. Use scope (string) for the mode’s overall CSS scope in new or edited grammar code. relevance on modes is deprecated. Do not add new relevance fields. When a PR touches a mode…
We split this AGENTS.md into the rules it gives an agent
8 rules. About 0 are common, 1 is distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 27
Do not claim assistance on commits that were fully human.
- Very specific: line 47
When a PR touches a mode that still sets relevance, remove relevance from that mode (or ask the author to remove it) as part of the …
- Very specific: line 51
When a rule is really “match this, except these cases,” prefer pure regex (especially negative lookahead/lookbehind) over "on:begin" / …
- Very specific: line 84
Use beginScope when the mode continues after the begin (e.g.
- Very specific: line 109
When a rule is really “keyword/punctuation, then whitespace, then an identifier (or similar)” with different scopes per piece, prefer …
- Very specific: line 152
Prefer regex literals or template strings.
- Very specific: line 153
Prefer regex.concat(...) when joining lookarounds and IDENT_RE-style fragments.
- Very specific: line 186
Do not commit build/ artifacts from local rebuilds unless the project explicitly expects it (normally CI builds).
≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent notes (highlight.js)
AI policy (dogfood)
Project policy: docs/ai-contributions.md. For this repo, when work was
substantially tool-assisted, include an Assisted-by trailer on the commit
and/or PR body (eat our own dogfood):
Assisted-by: <model> (<effort>)| Piece | Meaning | Examples |
| model | Product / model id | Grok 4.5, Claude Sonnet 4 |
| effort | Reasoning / effort setting if any | low, medium, high, max |
Examples:
Assisted-by: Grok 4.5 (low)
Assisted-by: Claude Opus 4 (high)
Assisted-by: CopilotOmit unknown pieces rather than guessing (Assisted-by: Copilot is fine).
Do not claim assistance on commits that were fully human.
Grammar API preferences
Prefer scope over className
className is deprecated. Use scope (string) for the mode’s overall CSS scope in new or edited grammar code.
// good
{ match: /\bfoo\b/, scope: "keyword" }
// avoid in new code
{ match: /\bfoo\b/, className: "keyword" }Drop relevance when touching a mode
relevance on modes is deprecated. Do not add new relevance fields.
When a PR touches a mode that still sets relevance, remove relevance from that mode (or ask the author to remove it) as part of the change—same “touch it, modernize it” rule as className → scope.
Prefer lookarounds over on:begin / on:end callbacks
When a rule is really “match this, except these cases,” prefer pure regex (especially negative lookahead/lookbehind) over "on:begin" / "on:end" callbacks that call ignoreMatch().
Callbacks run in JS on every candidate match and are harder to optimize; lookarounds stay in the regex engine.
// preferred — exclude statement keywords that look like calls
{
match: /\b(?!(?:if|for|while|switch)\b)[a-z_][A-Za-z0-9_]*(?=\()/,
scope: "title.function"
}
// avoid when a lookahead suffices
{
match: /\b[a-z_][A-Za-z0-9_]*(?=\()/,
scope: "title.function",
"on:begin": (m, resp) => {
if (/^(?:if|for|while|switch)$/.test(m[0])) resp.ignoreMatch();
}
}Callbacks are still fine when the decision needs sets, multi-match state, paired begin/end checks, or other logic regex cannot express cleanly.
scope vs beginScope / endScope
These are not interchangeable (see docs/mode-reference.rst):
| Field | What it scopes |
scope (string) | The whole mode (content between begin and end, as one region). |
beginScope | Only the begin match (string = wrap entire begin; object = per multi-match piece). |
endScope | Only the end match (same shapes as beginScope). |
Use beginScope when the mode continues after the begin (e.g. end: /$/, contains: […]) and only the opening lexeme(s) should be keyword/punctuation—not the rest of the line.
// begin pieces only; body stays unscoped (except contains)
{
begin: [/^[ \t]*/, /\bFeature\b/, /:/],
beginScope: { 2: "keyword", 3: "punctuation" },
end: /$/,
contains: [VARIABLE]
}
// wrong here: would treat the entire mode/line as keyword
{
begin: [/^[ \t]*/, /\bFeature\b/, /:/],
scope: { 2: "keyword", 3: "punctuation" },
end: /$/
}Sugar: for match: [ … ] only (no end), an object scope: { 1: "…", 3: "…" } is compiled into beginScope (src/lib/ext/multi_class.js scopeSugar). That form is fine for match-only multi-class rules. Prefer explicit beginScope when the mode has a real begin/end pair so intent stays obvious.
String beginScope: "keyword" wraps the entire begin lexeme (not multi-index).
Prefer multi-match for keyword + following token
When a rule is really “keyword/punctuation, then whitespace, then an identifier (or similar)” with different scopes per piece, prefer multi-match over begin + excludeBegin / end: /\W/ dances.
// preferred — match-only: object `scope` → beginScope sugar
{
match: [/\bnew\b/, /\s+/, hljs.IDENT_RE],
scope: {
1: "keyword",
3: "type"
}
}
// preferred — mode with body after begin: use beginScope
{
begin: [/\bnew\b/, /\s+/, hljs.IDENT_RE],
beginScope: {
1: "keyword",
3: "type"
},
end: /$/,
contains: [/* ... */]
}
// older style — avoid for new work when multi-match fits
{
className: "type",
beginKeywords: "new", // or begin: /new\s+/, excludeBegin: true
end: /\W/,
excludeBegin: true,
excludeEnd: true
}Multi-match:
- Uses
begin: [ ... ]ormatch: [ ... ](array of consecutive patterns). - Per-piece scopes are 1-based indexes into that array (
beginScope/endScope, or objectscopesugar onmatch). - Avoids empty spans and makes keyword vs type/title boundaries explicit.
Same idea applies to “after : type” rules, class/enum titles, etc. See existing usage in java.js, scala.js, rust.js, and test/api/multiClassMatch.js.
Building patterns
- Prefer regex literals or template strings; hljs accepts string patterns without
new RegExp(...). - Prefer
regex.concat(...)when joining lookarounds andIDENT_RE-style fragments. - Mirror style in nearby grammars (e.g.
src/languages/lib/java.jsnumber variants use template strings, notnew RegExp).
Running tests
Markup and most mocha suites load the compiler output from build/, not
src/ directly. After editing a grammar under src/languages/, rebuild before
testing or you get Cannot find module '../build' / stale results.
# rebuild one language (fast) then run its markup tests
node tools/build.js -t node rust
ONLY_LANGUAGES=rust npm run test-markup
# full node build (all languages)
node tools/build.js -t node
# full test suite (also needs a prior build)
npm test
# other targeted scripts (see package.json)
npm run test-markup
npm run test-detectNotes:
ONLY_LANGUAGESis a space-separated list of markup folder names (e.g.rust,bash), matchingtest/markup/<lang>/.- Mocha
--grepoften matches poorly here because language suites are nested under dynamicdescribes; preferONLY_LANGUAGESfor markup. - Markup cases live as pairs:
test/markup/<lang>/<name>.txtand<name>.expect.txt. Expect files comparehljs.highlight(...).value(trimmed). - Do not commit
build/artifacts from local rebuilds unless the project explicitly expects it (normally CI builds).
Style / hygiene
Trailing whitespace
Ignore trailing whitespace (and minor EOF newline nits from git diff --check)
unless you are already editing that exact line for a real change. Do not open
cleanup-only commits or block reviews on trailing spaces. Prefer leaving
historical noise alone over drive-by whitespace diffs.
Trending
Less talk lately.about the whole repository
Who's talking about highlightjs/highlight.js
- dcode“How to Add Syntax Highlighting to Code on Your Website”YouTube · Dec 13, 2022 · 36k views
- Raul Terhes“Awesome Code Snippet Showcase | HTML, CSS, JavaScript + Highlight.js & Clipboard API”YouTube · Jan 10, 2021 · 9.9k views
- Unleashed Design“Einfach Markdown-Text zu HTML parsen mit MARKED!! [TUTORIAL]”YouTube · Jun 14, 2021 · 3.2k views
- Alex“Adding a language to Highlight.js 1- developement environment”YouTube · Jul 28, 2021 · 361 views
- Seboss666“Je construis mes images "Docker" dans mon cluster k3s avec Kaniko (le tout piloté par Drone)”YouTube · Feb 25, 2024 · 103 views
The biggest 5 of 59 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 59
Talked about on GitHub, Stack Overflow, YouTube and the web (59 times).
On GitHub · 44
- Jul 26, 2021Dynamic imports don't work when `exports` specified in package.json and aliases — webpack/webpack33 reactions · 22 comments
- Dec 7, 2020highlight.js 9.x is obsolete and leads to warnings when used — alanshaw/markdown-pdf15 reactions · 2 comments
- Nov 19, 2020Upgrade highlight.js dependency to v10 — helpers/helper-markdown11 reactions · 8 comments
- Nov 19, 2020The highlight.js Is the 9. X version prompt:`Version 9 of Highlight.js has reached EOL and is no longer supported. Please upgrade to version 10.` — typeorm/typeorm8 reactions · 7 comments
- Mar 23, 2021highlight.js 10.7.0 Deprecated issue - typeorm@0.2.31, cli-highlight@^2.1.10 — typeorm/typeorm5 reactions · 4 comments
39 more on GitHub
- Nov 19, 2020Verion 9 of Highlight.js has reached EOL. — vuejs/vue-cli5 reactions · 1 comment
- Feb 23, 2022Upgrade Highlight.js — nubank/workspaces4 reactions · 1 comment
- Dec 18, 2020Deps: react-highlight.js with a sub dependency to outdated highlight.js — day8/re-frame-10x4 reactions · 1 comment
- Jan 10, 2026Prefer newlines over `<br>` when emitting code blocks in HTML export — typst/typst3 reactions · 6 comments
- Aug 9, 2022Can't play custom sound in 5.0.1-5.0.3 version [Error: Exception while invoking method uploadCustomSound] — RocketChat/Rocket.Chat3 reactions · 3 comments
- Feb 20, 2022Codeblock syntax highlighting — cinnyapp/cinny3 reactions · 4 comments
- Mar 21, 2021Upgrade Highlight JS 10.x — asciidoctor/asciidoctor3 reactions · 23 comments
- Oct 10, 2020Load only languages needed support — valeriangalliat/markdown-it-highlightjs3 reactions · 7 comments
- Aug 17, 2026chore(deps): bump the npm group with 3 updates — chainguard-dev/edu2 reactions · 3 comments
- Aug 14, 2026chore(deps): bump the npm group across 1 directory with 3 updates — chainguard-dev/edu2 reactions · 1 comment
- Aug 8, 2026Switching away from `scrivo/highlight.php` in the code element — contao/contao2 reactions · 6 comments
- Oct 15, 2021Update highlight.js library with HLSL support and other improvements — discord/highlight.js2 reactions · 1 comment
- Jul 6, 2021Update to highlight.js 11.0. — rust-lang/mdBook2 reactions
- Jun 8, 2021tools: update doctool dependencies, migrate to ESM — nodejs/node2 reactions · 25 comments
- Mar 23, 2021fix: prevent deprecation warnings with highlight.js v10.7 — felixfbecker/cli-highlight2 reactions · 3 comments
- Feb 8, 2021Install Warning — solo-io/proxy-runtime2 reactions · 1 comment
- Oct 5, 2026chore(deps): bump the frontend-runtime group across 1 directory with 8 updates — kevenhu001-cyber/Socrates1 reaction · 1 comment
- Oct 2, 2026chore(deps): bump the frontend-runtime group across 1 directory with 9 updates — kevenhu001-cyber/Socrates1 reaction · 2 comments
- Sep 26, 2026build(deps): bump the frontend-runtime group across 1 directory with 10 updates — kevenhu001-cyber/Socrates1 reaction · 2 comments
- Sep 4, 2026[Snyk] Upgrade highlight.js from 11.11.2 to 11.12.0 — sickn33/agentic-awesome-skills1 reaction · 3 comments
- Sep 2, 2026[Snyk] Upgrade highlight.js from 11.11.1 to 11.11.2 — sickn33/agentic-awesome-skills1 reaction · 2 comments
- Aug 24, 2026chore: bump the npm-non-major group across 1 directory with 27 updates — CloudHub-Social/Charm1 reaction · 4 comments
- Aug 23, 2026build(deps): bump the bun group with 8 updates — moq-dev/moq1 reaction
- Aug 17, 2026chore: bump the npm-non-major group with 19 updates — CloudHub-Social/Charm1 reaction · 4 comments
- Aug 17, 2026chore(deps): bump the minor-and-patch group across 1 directory with 19 updates — abelxmendoza/Lore-Book1 reaction · 2 comments
- Aug 16, 2026chore(deps): bump highlight.js from 11.11.1 to 11.12.0 in /frontend — Anchit-AI-Hustle/The-Third-Eye1 reaction
- Aug 16, 2026chore(deps): bump highlight.js from 11.11.1 to 11.12.0 in /frontend — Anchit-AI-Hustle/The-Third-Eye1 reaction
- Aug 16, 2026Build(deps): bump the minor-update group with 3 updates — WakuwakuP/miyulab-officialsite1 reaction · 3 comments
- Jan 12, 2026deps(web): bump the production-dependencies group across 1 directory with 10 updates — comppolicylab/pingpong1 reaction
- Jan 12, 2026deps(web): bump the production-dependencies group in /web/pingpong with 12 updates — comppolicylab/pingpong1 reaction · 2 comments
- Jan 10, 2026Bump the npm_and_yarn group across 1 directory with 32 updates — ParryQiu/mapbox-gl-geocoder1 reaction
- Jun 8, 2025Fix styles in shadow DOM — noraj/cybertopia-highlightjs1 reaction
- May 24, 2025chore(deps): bump highlight.js and react-syntax-highlighter — wkylin/pro-react-admin1 reaction · 4 comments
- May 14, 2025feat: SQL Editor - Syntax Coloring — azerothcore/Keira31 reaction · 1 comment
- Jan 27, 2025Render callouts in code block — elastic/docs-builder1 reaction
- Nov 30, 2024[Snyk] Upgrade highlight.js from 10.7.3 to 11.10.0 — lloydchang/allure-framework-allure21 reaction · 2 comments
- Sep 20, 2023(fix) highlighted-line emphasis on codeblock — php-debugbar/php-debugbar1 reaction
- Dec 4, 2020Bump highlight.js from 9.12.0 to 10.4.1 — bvaughn/react-highlight.js1 reaction · 1 comment
- Nov 24, 2020Bump highlight.js from 7.3.0 to 10.1.2 — jsfiddle/togetherjs1 reaction · 1 comment
On Stack Overflow · 8
- Oct 1, 2018How to highlight bash/shell commands in Markdown?102 votes
- Nov 12, 2021Angular 13 Cannot find module '@angular/common/locales/fr.js'6 votes · 3 answers
- Jan 28, 2020How to dynamically change the theme using highlight.js?5 votes
- Oct 18, 2020How can I correctly highlight a line by line code, using highlight.js (React)?3 votes
- Dec 1, 2020Verion 9 of Highlight.js has reached EOL. It will no longer be supported2 votes
3 more on Stack Overflow
- May 11, 2020Angular 6 target es5 IE Syntax error (arrow function)2 votes
- Sep 3, 2024Style Code with highlightJS inside a web component1 vote
- Oct 3, 2023Check if a program exists from a Makefile1 vote
On YouTube · 6
- Dec 13, 2022How to Add Syntax Highlighting to Code on Your Website — dcode36k views · 28 comments
- Jan 10, 2021Awesome Code Snippet Showcase | HTML, CSS, JavaScript + Highlight.js & Clipboard API — Raul Terhes9.9k views · 15 comments
- Jun 14, 2021Einfach Markdown-Text zu HTML parsen mit MARKED!! [TUTORIAL] — Unleashed Design3.2k views · 13 comments
- Jul 28, 2021Adding a language to Highlight.js 1- developement environment — Alex361 views · 3 comments
- Feb 25, 2024Je construis mes images "Docker" dans mon cluster k3s avec Kaniko (le tout piloté par Drone) — Seboss666103 views
1 more on YouTube
- Dec 10, 2024How to Install Code Syntax Highlighter.js on PhpBB (Tutorial 2024) — Tibers60 views
On the web · 1
- Jan 19, 2021highlight.js 9.x is no longer supported #74 — google.com
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 28,693 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

