-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
1 changed file
with
81 additions
and
2 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 |
---|---|---|
@@ -1,2 +1,81 @@ | ||
# shiki-transformers | ||
Shiki transformers used by Typlog | ||
# @typlog/shiki-transformers | ||
|
||
Shiki transformers by Typlog. | ||
|
||
## Install | ||
|
||
Install via npm: | ||
|
||
``` | ||
npm i @typlog/shiki-transformers | ||
``` | ||
|
||
Import from CDN: | ||
|
||
```html | ||
<script type="module"> | ||
import { transformerLineHighlight } from 'https://esm.sh/@typlog/shiki-transformers' | ||
</script> | ||
``` | ||
|
||
## Usage | ||
|
||
```ts | ||
import { codeToHtml } from 'shiki' | ||
import { transformerLineHighlight } from '@typlog/shiki-transformers' | ||
|
||
const code = `console.log('a') | ||
console.log('b') | ||
console.log('c') | ||
console.log('e') | ||
console.log('f') | ||
console.log('g') | ||
console.log('h') | ||
` | ||
const html = await codeToHtml(code, { | ||
lang: 'ts', | ||
theme: 'nord', | ||
transformers: [ | ||
transformerLineHighlight({ | ||
highlight: '1,3-5', | ||
showLines: true, | ||
}), | ||
], | ||
}) | ||
``` | ||
|
||
## Options | ||
|
||
```ts | ||
export interface TransformerHighlightOptions { | ||
/** | ||
* Lines to be highlighted | ||
*/ | ||
highlight?: string; | ||
|
||
/** | ||
* Class for highlighted lines | ||
* | ||
* @default 'highlighted' | ||
*/ | ||
className?: string; | ||
|
||
/** | ||
* Line numbers starts from | ||
* | ||
* @default 1 | ||
*/ | ||
lineStart?: number; | ||
|
||
/** | ||
* Display line numbers | ||
* | ||
* @default false | ||
*/ | ||
showLines?: boolean; | ||
} | ||
``` | ||
|
||
## License | ||
|
||
MIT License |