-
-
Notifications
You must be signed in to change notification settings - Fork 4
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Clear and concise description of the problem
kind of allow async plugins
this is supported if you do the parsing and rendering yourself.
more information can be found in this topic:
markdown-it/markdown-it#256 (comment)
Suggested solution
this would be easily possible if we split the parse and render functions / make the renderer.render someway available:
something in the like of
async renderAsync(src: string, env?: any): Promise<string> {
return this.rendererRenderAsync(
this.parse(src, env),
this.options,
env,
)
}
async rendererRenderAsync(tokens: Array, options: any, env: any): Promise<string> {
this.options.highlight = wrapHightlight(this.options.highlight, this.placeholderMap)
this.disableWarn = true
const result = this.renderer.render(tokens, this.options, env)
this.disableWarn = false
return replaceAsync(result, placeholderRe, async (match, id) => {
if (!this.placeholderMap.has(id))
throw new Error(`Unknown highlight placeholder id: ${id}`)
const [promise, _str, lang, _attrs] = this.placeholderMap.get(id)!
const result = await promise || ''
this.placeholderMap.delete(id)
if (result.startsWith('<pre'))
return result
else
return `<pre><code class="language-${lang}">${result}</code></pre>`
})
}
Alternative
No response
Additional context
this is needed for unplugin/unplugin-vue-markdown#62
i will create a pr for this..
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.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request