Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change @shikijs/transformers range by + 1 #619

Open
5 tasks done
richardgill opened this issue Mar 9, 2024 · 2 comments
Open
5 tasks done

Change @shikijs/transformers range by + 1 #619

richardgill opened this issue Mar 9, 2024 · 2 comments

Comments

@richardgill
Copy link
Contributor

Validations

Describe the bug

// [!code highlight:2]
console.log('highlighted')
console.log('not highlighted')

Ranges on transformations include the current line, to me this was very uninuitive.

Instead it could be:

// [!code highlight:2]
console.log('highlighted')
console.log('highlighted')

Currently: // [!code highlight] is effectively // [!code highlight:1]
Becomes: // [!code highlight:0]

I guess this is a breaking change, and it is slightly arbitary - so no worries if you disagree :)

Reproduction

Included in comment

Contributes

  • I am willing to submit a PR to fix this issue
  • I am willing to submit a PR with failing tests
@fuma-nama
Copy link
Contributor

Noticed this problem too, it's because the notation highlighter was initially designed as:

console.log('highlighted') // [!code highlight:2]
console.log('not highlighted')

See https://shiki.style/packages/transformers#transformernotationhighlight

So when the comment was added to an empty line, it still start counting from the current line.
The exact problem is that we need to consider the case of empty lines, we still need the approval from maintainers since it should be a breaking change (impacts normal usages).

@antfu
Copy link
Member

antfu commented Aug 22, 2024

I am up to it, feel free to bring up a PR and then we could discuss how we enroll it with the minimal impact to the existing users

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants