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

[FEATURE] Sync version #29

Open
amatiasq opened this issue Jul 4, 2022 · 2 comments
Open

[FEATURE] Sync version #29

amatiasq opened this issue Jul 4, 2022 · 2 comments
Labels
enhancement New feature or request

Comments

@amatiasq
Copy link

amatiasq commented Jul 4, 2022

Is your feature request related to a problem? Please describe.
Trying to use this with Deno's Markdown. It doesn't work because this library is asynchronous and that library doesn't accept an asynchronous syntax highlighter.

Describe the solution you'd like
Expose highlightTextSync for example?

Describe alternatives you've considered
Not much I can do, this library always returns a promise and the markdown library doesn't know how to handle it.

Reproduction script

import { Marked } from 'https://deno.land/x/markdown@v2.0.0/mod.ts';
import { highlightText } from 'https://deno.land/x/speed_highlight_js@1.1.7/src/index.js';

Marked.setOptions({
  // prints `[object Promise]`
  highlight: (code, lang) => highlightText(code, lang),
});

I saw the only reason this is asynchronous is because tokenize imports the language if not loaded yet. Maybe I can import the languages in advance and pass them down to tokenizeSync?

@amatiasq amatiasq added the enhancement New feature or request label Jul 4, 2022
@nvlled
Copy link

nvlled commented Mar 9, 2023

Weirdly enough, I encountered the same exact problem you have and thought of the same solution you had. Is this being actively worked on? I can start working on this if not.

@matubu
Copy link
Member

matubu commented Mar 9, 2023

Thank you for your interest in this project! Unfortunately, a sync version of the highlighting functions is not currently under active development. However, you're welcome to fork the project and develop your own version. If you have any questions or need help getting started, let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants