antfu / shikiji

A syntax highlighter based on TextMate grammars. ESM rewrite of shiki, with more features and capabilities.
https://shikiji.netlify.app/
MIT License
1.47k stars 38 forks source link

Support for inline code #111

Closed fuma-nama closed 8 months ago

fuma-nama commented 8 months ago

Clear and concise description of the problem

For now, shikiji is not intended to support inline code blocks, as transformers, integrations, and many others are not supposed to process inline code.

I want to highlight an inline code block, for example: console.log("Hello World").

Suggested solution

Allow us to specify language via {js} console.log("Hello World"), and enable inline code processing for each integration.

Alternative

No response

Additional context

No response

Validations

antfu commented 8 months ago

Shikiji itself is focused on highlighting, while you can see quite many highlighter integrations built on top of Shikiji does support inline highlights. For example,

Basically, you just treat the inline code as a 1-line code and get the first line element from the HAST.

If you mean the official markdown-it / rehype plugins, I am happy to have it as an optional feature. But to do that, we need to research existing syntaxes and find one that makes sense, as it's not a standard markdown syntax and might conflict with other integrations.

fuma-nama commented 8 months ago

Thanks! That makes sense