You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, Shiki uses a single regex matcher for notation transformers.
It resulted in a few problems:
Invalid syntax is included: JavaScript doesn't support # comment for adding comment, but notation transformers will still parse it as a normal comment.
Poor support of other formats: When using it with some formats, like the liquid template language, the current regex cannot match its comments.
Suggested solution
To solve the problem, we can use a specific matcher depending on the format/language, and allow people to customise it.
For example, when processing a JavaScript file, we only support JSX and JS style comments.
About the exact implementation, I think we can add a matchers map for different languages.
When cannot find a matcher for current format, it fallbacks to our current regex matcher which supports common comment syntaxes.
People can pass their own matchers object to customise it.
Alternative
For some notation transformers, we can use the corresponding meta transformer instead. like line/word highlight have their meta transformers, but this is not supported for all notation transformers.
Clear and concise description of the problem
Currently, Shiki uses a single regex matcher for notation transformers.
It resulted in a few problems:
# comment
for adding comment, but notation transformers will still parse it as a normal comment.liquid
template language, the current regex cannot match its comments.Suggested solution
To solve the problem, we can use a specific matcher depending on the format/language, and allow people to customise it.
For example, when processing a JavaScript file, we only support JSX and JS style comments.
About the exact implementation, I think we can add a
matchers
map for different languages.When cannot find a matcher for current format, it fallbacks to our current regex matcher which supports common comment syntaxes.
People can pass their own matchers object to customise it.
Alternative
For some notation transformers, we can use the corresponding meta transformer instead. like line/word highlight have their meta transformers, but this is not supported for all notation transformers.
Additional context
No response
Validations
Contributes
The text was updated successfully, but these errors were encountered: