marp-cli async rules #466
-
In order to run some rendering, in my case However References:
It states:
I've tried to make my own engine: class PostprocessMarpitEngine extends Marpit {
constructor(options, postprocess) {
super(options)
this.postprocess = postprocess
}
withPostprocess(postprocess) {
this.postprocess = postprocess
return this
}
async render(markdown, env = {}) {
const { html, css, comments } = super.render(markdown, env)
if (this.postprocess) {
return await this.postprocess(markdown, env, html, css, comments)
}
return { html, css, comments }
}
} which I hope to use like so export default {
engine: async (constructorOptions) =>
new PostprocessMarpitEngine(constructorOptions)
.use(marpMermaidPlugin)
.withPostprocess(async (markdown, env, html, css, comments) => {
// do async things
return { html, css, comments }
}),
} However the current implementation does not support an async render method. I'm wondering if changing this line like so would be enough - const ret = engine.render(stripBOM(markdown))
+ const ret = await engine.render(stripBOM(markdown)) I don't see any blocker, since the wrapping function is already async Would this change be possible? EDIT: I went ahead and proposed the change. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Shipped as Marp CLI v3.2.1. However, keep in mind returning |
Beta Was this translation helpful? Give feedback.
Shipped as Marp CLI v3.2.1. However, keep in mind returning
Promise
inMarpit.prototype.render
is still out of the spec of current Marpit framework. The custom engine withPromise
will not become working on other Marp/Marpit tools that are strictly following API interface of the framework.