shikijs / shiki

A beautiful yet powerful syntax highlighter
http://shiki.style/
MIT License
9.74k stars 356 forks source link

Using transformerNotationHighlight in JSX code #770

Open Yonom opened 1 week ago

Yonom commented 1 week ago

Validations

Describe the bug

```ts
const Test: React.FC = () => {
  return (
    <div>
      <div /> {/* [!code highlight] */}
    </div>
  );
};

gets converted to

```ts
const Test: React.FC = () => {
  return (
    <div>
      <div /> {}
    </div>
  );
};

I expected no empty brackets {} to remain. I believe {/* comment */} is the only valid syntax for comments inside JSX.

Reproduction

-

Contributes

Yonom commented 1 week ago

I believe the regex here would have to be adjusted to also capture the curly brackets {}

https://github.com/shikijs/shiki/blob/eae73919d4a9c65722acb7455668e3a8f1c31fac/packages/transformers/src/transformers/notation-map.ts#L27