# shikix-transformers

> Collective of common transformers transformers for Shikix

Latest version **0.0.3** (published 2023-11-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install shikix-transformers
pnpm add shikix-transformers
yarn add shikix-transformers
bun add shikix-transformers
```

## Health

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

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2023-11-29 |
| First published | 2023-11-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 19 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Dennis Ollhoff |
| Maintainers | dennisollhoff |
| Keywords | shiki, shikix-transformers |

## Links

- npm: https://www.npmjs.com/package/shikix-transformers
- Repository: https://github.com/nyxb/shikix
- Homepage: https://github.com/nyxb/shikix#readme
- Issues: https://github.com/nyxb/shikix/issues
- npm.io page: https://npm.io/package/shikix-transformers

## Dependencies (1)

- [shikix](https://npm.io/package/shikix.md) 0.0.3

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2023-11-29

## README

# shikix-transformers

Collective of common transformers for [shikix](https://github.com/nyxb/shikix), inspired by [shiki-processor](https://github.com/innocenzi/shiki-processor).

## Install

```bash
npm i -D shikix-transformers
```

```ts
import {
   codeToHtml,
} from 'shikix'
import {
   transformerNotationDiff,
   // ...
} from 'shikix-transformers'

const html = codeToHtml(code, {
   lang: 'ts',
   transformers: [
      transformerNotationDiff(),
      // ...
   ],
})
```

## Transformers

### `transformerNotationDiff`

Use `[!code ++]` and `[!code --]` to mark added and removed lines.

For example, the following code

```ts
export function foo() {
   console.log('hewwo') // [!code --]
   console.log('hello') // [!code ++]
}
```

will be transformed to

```html
<!-- Output (stripped of `style` attributes for clarity) -->
<pre class="shiki has-diff"> <!-- Notice `has-diff` -->
  <code>
    <span class="line"></span>
    <span class="line"><span>function</span><span>()</span><span></span><span>{</span></span>
    <span class="line diff remove">  <!-- Notice `diff` and `remove` -->
      <span></span><span>console</span><span>.</span><span>log</span><span>(</span><span>&#39;</span><span>hewwo</span><span>&#39;</span><span>) </span>
    </span>
    <span class="line diff add">  <!-- Notice `diff` and `add` -->
      <span></span><span>console</span><span>.</span><span>log</span><span>(</span><span>&#39;</span><span>hello</span><span>&#39;</span><span>) </span>
    </span>
    <span class="line"><span></span><span>}</span></span>
    <span class="line"><span></span></span>
  </code>
</pre>
```

With some CSS, you can make it look like this:

<img width="362" alt="image" src="https://github.com/nyxb/shikix/assets/11247099/c1b6d2b2-686c-4d36-87b1-f01877071cde">

### `transformerNotationHighlight`

Use `[!code highlight]` to highlight a line (adding `highlighted` class).

### `transformerNotationFocus`

Use `[!code focus]` to focus a line (adding `focused` class).

### `transformerNotationErrorLevel`

Use `[!code error]`, `[!code warning]`, to mark a line with an error level (adding `highlighted error`, `highlighted warning` class).

### `transformerRenderWhitespace`

Render whitespaces (tabs and spaces) as individual spans, with classes `tab` and `space`.

With some CSS, you can make it look like this:

<img width="293" alt="image" src="https://github.com/nyxb/shikix/assets/11247099/01b7c4ba-6d63-4e74-8fd7-68a9f901f3de">

### `transformerCompactLineOptions`

Support for `shiki`'s `lineOptions` that is removed in `shikix`.

### `transformerRemoveLineBreak`

Remove line breaks between `<span class="line">`. Useful when you set `display: block` to `.line` in CSS.

## License

MIT

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