# highlightjs-glimmer

> Glimmer syntax highlighting with Highlight.JS

Latest version **2.2.2** (published 2024-10-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install highlightjs-glimmer
pnpm add highlightjs-glimmer
yarn add highlightjs-glimmer
bun add highlightjs-glimmer
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.2.2 |
| Published | 2024-10-06 |
| First published | 2021-04-06 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | ^14 \|\| ^16 \|\| ^18 \|\| >= 20 |
| Dependencies | 0 |
| Unpacked size | 43.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | NullVoxPopuli |
| Maintainers | nullvoxpopuli |

## Links

- npm: https://www.npmjs.com/package/highlightjs-glimmer
- Repository: https://github.com/NullVoxPopuli/highlightjs-glimmer
- Homepage: https://github.com/NullVoxPopuli/highlightjs-glimmer#readme
- Issues: https://github.com/NullVoxPopuli/highlightjs-glimmer/issues
- npm.io page: https://npm.io/package/highlightjs-glimmer

## Recent versions

- 2.2.2 (latest) — 2024-10-06
- 2.2.1 — 2023-11-13
- 2.2.0 — 2023-11-13
- 2.1.0 — 2023-06-24
- 2.0.1 — 2022-11-06
- 2.0.0 — 2022-11-05
- 1.4.1 — 2021-12-26
- 1.4.0 — 2021-05-01
- 1.3.4 — 2021-04-30
- 1.3.3 — 2021-04-13
- 1.3.2 — 2021-04-11
- 1.3.1 — 2021-04-11
- 1.3.0 — 2021-04-11
- 1.2.0 — 2021-04-11
- 1.1.1 — 2021-04-11
- … 3 more at https://npm.io/package/highlightjs-glimmer/versions

## README

# highlightjs-glimmer

[![npm version](https://badge.fury.io/js/highlightjs-glimmer.svg)](https://www.npmjs.com/package/highlightjs-glimmer)
[![code quality](https://badgen.net/lgtm/grade/github/NullVoxPopuli/highlightjs-glimmer/js?label=code+quality)](https://lgtm.com/projects/g/NullVoxPopuli/highlightjs-glimmer/)

glimmer syntax highlighting with [highlight.js](https://github.com/highlightjs/highlight.js)

## Install

```bash
yarn add highlightjs-glimmer
# or
npm install highlightjs-glimmer
```


## Compatibility

Requires: [highlight.js >= v11](https://github.com/highlightjs/highlight.js)

|     | [Remark][1] | [Rehype][2] | [MarkdownIt][3] |
| --  | ----------- | ----------- | --------------- |
| cjs | ✅          | ✅          | ✅              |
| esm | ❌[^1]      | ✅          | ✅              |

[1]: https://github.com/remarkjs/remark-highlight.js
[2]: https://github.com/rehypejs/rehype-highlight
[3]: https://github.com/markdown-it/markdown-it
[^1]: remark-highlight.js is deprecated and cjs only

## Usage

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

setup(hljs);

hljs.highlightAll();
```

 - the `javascript` language must be registered before `setup` is called.
 - `setup` _must_ be called before any highlighting occurs.

Supported language tags:

```html
<pre>
  <code class="language-{tag}">
```
where `{tag}` could be:
 - glimmer
 - hbs
 - html.hbs
 - html.handlebars
 - htmlbars

**NOTE** because highlightjs-glimmer overrides the same aliases as highlightjs' handlebars grammar,
to use the handlebars grammar align with the glimmer grammar, you'll need to use the full name in class
```html
<pre><code class="lang-glimmer">...</code></pre>
<pre><code class="lang-handlebars">...</code></pre>
```

## with `await import(...)`

When using ES Modules in browsers with a packager

```ts
let HIGHLIGHT;

async function getHighlighter() {
  if (HIGHLIGHT) return HIGHLIGHT;

  HIGHLIGHT = (await import('highlight.js')).default;

  let { setup } = await import('highlightjs-glimmer');

  setup(HIGHLIGHT);

  return HIGHLIGHT;
}


async highlight() {
  let hljs = await getHighlighter();

  let element = document.querySelector('...');

  hljs.highlightElement(element);
}

highlight();
```

## API

- `setup`

    The convenience method for configuring everything related to
    glimmer highlighting. This wraps `registerLanguage` and `registerInjections`.
    For most use cases, this should be the only method you need.

- `registerLanguage`

    Convenience method for registering the glimmer template syntax with
    highlight.js under the name "glimmer"

- `registerInjections`

    Registers the glimmer-javascript grammar, and installs `javascript`, `js`, `mjs` and `cjs`
    as aliases of it

- `glimmer`

    The highlight.js grammar function for glimmer templates. This can be used to register
    the glimmer grammar without using the provided setup methods.

- `glimmerJavascript`

    The highlight.js grammar function for glimmer-javascript (gjs) files. This can be used to register
    the glimmer-javascript grammar without using the provided setup methods.

## CDN Usage

### Traditional Script Tags

```html
<script type="text/javascript" src="/cdn/path/to/highlight.min.js"></script>
<script type="text/javascript" src="/cdn/path/to/highlightjs-glimmer/glimmer.js"></script>
<script type="text/javascript">hljs.highlightAll();</script>
```

### ES Modules

At this time, highlight.js does not ship ES Modules to CDNs

```html
<script type="text/javascript" src="/cdn/path/to/highlight.min.js"></script>
<script type="module">
  import { glimmer } from '/cdn/path/to/highlightjs-glimmer/glimmer.esm.js';

  hljs.registerLanguage('glimmer', glimmer);
  hljs.highlightAll();
</script>
```

## Node / cjs / `require`

```js
const hljs = require('highlight.js');
const { setup } = require('highlightjs-glimmer');

setup(hljs);

hljs.highlightAll();
```

Only Node 14 is supported

## Node ES Modules / `import`

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

setup(hljs);

hljs.highlightAll();
```

With Node 14, launch with

```bash
NODE_OPTIONS="--experimental-vm-modules" node your-module-script.js
```

## Contributing

Debug with `yarn debug -p 4201`
Visit `http://localhost:4201`

Run Tets with `yarn test` or `npm run test`

---
_Source: https://npm.io/package/highlightjs-glimmer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
