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

await mdlib.render #3614

Closed
wants to merge 1 commit into from
Closed

await mdlib.render #3614

wants to merge 1 commit into from

Conversation

boehs
Copy link

@boehs boehs commented Jan 8, 2025

Hi Zach, I'm over here again with my incredibly-overengineered-11ty-fuzzing-how-tf-does-this-monstrosity-work-website-called-boehs.org, and this is a tiny patch.

Markdown-it does not support async, but you can implement your own markdown renderer by { render: (fileContents,data) => string }, and you may wish for this renderer to be asynchronous because you commit coding horrors

Javascript spec says

[rv] = await expression;
expression: A Promise or any value to wait for.
rv: Returns the fulfilled value of the promise, or the value itself if it's not a Promise.

so you can kinda just chuck an await on there and pray for the best. A good way to make #2827 a problem for an another day!

@boehs boehs requested a review from zachleat as a code owner January 8, 2025 02:15
@zachleat
Copy link
Member

zachleat commented Jan 8, 2025

HMM! If the function there is already async isn't it returning a promise or no? Shouldn't this already work?

@Ryuno-Ki
Copy link
Contributor

Ryuno-Ki commented Jan 8, 2025

You can directly return the mdlib.render call here.

Yes, it is always returning a Promise.
Using an additional async here should add another entry to the microtask queue.

(I was expecting to find a link on What Color is Your Function here 😅 )

@boehs
Copy link
Author

boehs commented Jan 8, 2025

HMM! If the function there is already async isn't it returning a promise or no? Shouldn't this already work?

i'm so silly

@boehs boehs closed this Jan 8, 2025
@zachleat
Copy link
Member

zachleat commented Jan 8, 2025

@boehs don't you dare! Everyone makes mistakes (especially me) and that's what code review is for! Keep those PRs coming!

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

Successfully merging this pull request may close these issues.

3 participants