shikijs / shiki

A beautiful yet powerful syntax highlighter

Home Page:http://shiki.style/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Misleading documentation in `@shikijs/transformers`

YieldRay opened this issue · comments

Additional context

Also tested on @shikijs/transformers v1.2.1.

transformerNotationErrorLevel

The outer <pre> tag is actually <pre class="has-highlighted">

has-error-levels

Relevant code:

/**
* Allow using `[!code error]` `[!code warning]` notation in code to mark highlighted lines.
*/
export function transformerNotationErrorLevel(
options: TransformerNotationErrorLevelOptions = {},
): ShikiTransformer {
const {
classMap = {
error: ['highlighted', 'error'],
warning: ['highlighted', 'warning'],
},
classActivePre = 'has-highlighted',
} = options

transformerNotationFocus

In Vitepress, the documentation, the outer class is has-focused-lines and the inner class is has-focus
image

This differs from what I tested on @shikijs/transformers v1.2.1.
image

Relevant code:

/**
* Allow using `[!code focus]` notation in code to mark focused lines.
*/
export function transformerNotationFocus(
options: TransformerNotationFocusOptions = {},
): ShikiTransformer {
const {
classActiveLine = 'focused',
classActivePre = 'has-focused',
} = options

PR welcome! Thanks

PR welcome! Thanks

But I don' t known which one is correct, the docs or the source code?

The code. There were some mistakes in the docs.

ok, will try to do it.