Is it possible to highlight code synchronously without top-level await being available?
xsjcTony opened this issue · comments
Clear and concise description of the problem
I'm using React, hence I need to synchronously highlight the code and use dangerouslySetInnerHTML
to inject the content.
However, using async
in React environment is a bit hard.
I tried to create a highlighter instance to highlight code synchronously in my local and it worked well, however it's not supported in the production environment, due to the browser version as required:
Any way I can use the synchronous way without top-level await being available?
I need to use it fully synchronously, but seems either shorthand needs to be async, or getHighlighter needs to be async. I know we are dynamically loading modules, but I wonder whether we have any solution to this.
Suggested solution
This is a Question as no discussion is available
Alternative
No response
Additional context
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guide.
- Check that there isn't already an issue that request the same feature to avoid creating a duplicate.
Contributes
- If this feature request is accepted, I am willing to submit a PR to fix this issue
I'd wish to, but no. It's how JS works, you can't workaround it.