Skip to content

Commit

Permalink
Add changeset
Browse files Browse the repository at this point in the history
  • Loading branch information
NullVoxPopuli committed Nov 13, 2023
1 parent ae03065 commit 3f3447a
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .changeset/proud-pigs-know.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
'highlightjs-glimmer': minor
---

Previously, this package enabled glimmer-js support by patching into the official highlightjs javascript grammar. This is problematic if you want to support both gjs and js(/jsx) syntax highlighting alongside each other.

This change refactors things so that glimmer-javascript is defined and exported as a standalone grammar. Instead of patching the standard javascript grammar, it uses the `subLanguage` feature to extend it cleanly. hbs-literal and template-tag support are added via additional 'contains' rules.

To maintain the existing 'override javascript grammar' behavior for existing consumers of this package, the setup APIs will register `javascript`, `js`, `mjs` and `cjs` as aliases of the new `glimmer-javascript` grammar. Consumers who want to take advantage of the standalone grammar can import it and register using the standard `hljs.registerLanguage` technique.

For example:

```js
import hljs from 'highlight.js';
import { glimmerJavascript } from 'highlightjs-glimmer';

hljs.registerLanguage('glimmer-javascript', (hljs) => {
const definition = glimmerJavascript(hljs, 'glimmer-javascript');

return definition;
});
```

The old usage, `setup` and other methods,

```js
import hljs from 'highlight.js';
import { setup } from 'highlightjs-glimmer';

setup(hljs);

hljs.highlightAll();
```

Has been unchanged in this release, but is likely to change in a major so that the default / recommended APIs don't take away from the possibility of using other languages in the same document.

0 comments on commit 3f3447a

Please sign in to comment.