-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ae03065
commit 3f3447a
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |