Skip to content

feat(rules): support async markdown-it rules #6

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ronny1020
Copy link

Description

support async markdown-it rules, and add test and doc

Linked Issues

Additional context

@@ -76,7 +133,7 @@ export class MarkdownItAsync extends MarkdownIt {
async renderAsync(src: string, env?: any): Promise<string> {
this.options.highlight = wrapHightlight(this.options.highlight, this.placeholderMap)
this.disableWarn = true
const result = this.render(src, env)
const result = await this.renderer.renderAsync(this.parse(src, env), this.options, env)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We couldn't do this as some plugins rely on replacing the md.render function.

Copy link
Author

@ronny1020 ronny1020 Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reply. I apologize for not reviewing too many plugin examples. Could you recommend some examples to help me improve? I'm confused that if multiple plugins are used, isn't there a risk that earlier plugins might be overridden by later ones? If there is some way to avoid that, maybe, we can use a similar approach.

Copy link
Owner

@antfu antfu Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ronny1020 i think we exactly have this hen egg thing here:
there are plugins out there that do the overwriting.
and yeah - that would mean that they are eventually overwritting each other..

maybe they just doing something first and then calling the original?
in this case i think that maybe they are working all one after each other..
????
would need a testcase for this to exactly pin-point it..

maybe one of my test-setups can help as a starting point:
for a complex test-setup you can have a look at

i am happy if you have the motivation to test and setup things..
for my personal use-case for now i switched to a sync-only approach... (so i am in no need currently)

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants