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

Code highlight in JSX #807

Closed
Yonom opened this issue Sep 5, 2024 · 2 comments
Closed

Code highlight in JSX #807

Yonom opened this issue Sep 5, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Yonom
Copy link
Contributor

Yonom commented Sep 5, 2024

To Reproduce

I wanted to add a code highlight as such:

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

The highlighting works, but this gets rendered as:

<div> {}
  <div />
</div>

Omitting the {} works, but is not valid JSX and thus breaks my editor highlighting

Current vs. Expected behavior

I expected the [!code highlight] to capture JSX {/* */} blocks as this is the usual way to add comments in JSX

Provide environment information

Node.js v20.15.0

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 23.6.0: Mon Jul 29 21:14:30 PDT 2024; root:xnu-10063.141.2~1/RELEASE_ARM64_T6000
  Available memory (MB): 32768
  Available CPU cores: 10
Binaries:
  Node: 20.15.0
  npm: 10.7.0
  Yarn: N/A
  pnpm: 9.9.0
Relevant Packages:
  next: 14.2.7 // There is a newer version (14.2.8) available, upgrade recommended! 
  eslint-config-next: 14.2.7
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.5.4
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Additional context

No response

@Yonom Yonom added the bug Something isn't working label Sep 5, 2024
@fuma-nama
Copy link
Owner

fuma-nama commented Sep 5, 2024

Use // comment on the top of element instead. For further issues, you can open an issue on Shiki.

@fuma-nama fuma-nama closed this as not planned Won't fix, can't repro, duplicate, stale Sep 5, 2024
@Yonom
Copy link
Contributor Author

Yonom commented Sep 5, 2024

adding // [!code highlight:2] above works as a workaround, but only for the outermost JSX element

Opened an issue on shiki, thanks for pointing me to the right place
shikijs/shiki#770

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants