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

@shikijs/rehype: support for inline code #660

Open
3 of 4 tasks
jeremt opened this issue Apr 21, 2024 · 2 comments
Open
3 of 4 tasks

@shikijs/rehype: support for inline code #660

jeremt opened this issue Apr 21, 2024 · 2 comments

Comments

@jeremt
Copy link

jeremt commented Apr 21, 2024

Clear and concise description of the problem

There is no support for highlighting inline code (similarly to rehype-pretty-code). It would be nice to be able to highlight something like console.log('coucou').

Suggested solution

Apply highlighting when there is something like `console.log('coucou'){:js}`

Alternative

No response

Additional context

No response

Validations

Contributes

  • If this feature request is accepted, I am willing to submit a PR to fix this issue
@antfu
Copy link
Member

antfu commented Apr 22, 2024

It would be a good feature to have - however I don't know what syntax we should follow as there is not standard right now. I see people doing

  • `code`{lang=js}
  • `code`{js}
  • `code`{.js}
  • `code{:js}`

@souporserious
Copy link

In my own parser, I parse a prefix that works similar to normal triple slash code blocks:
`js const a = 'a'`

And similarly these can be tagged with a filename:
`filename.js const a = 'a'`

The presence of the space is used to determine if it needs highlighting, so this wouldn't be highlighted for example:
`js`

The idea was to bring familiarity with how it's already done in code blocks. However, this does unfortunately look weird in raw markdown since it's embedded in the code snippet.

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