How to define a "global" div automatically appears on every slide? #342
Answered
by
yhatt
ChiMaoShuPhy
asked this question in
Q&A
-
I really enjoy building slide with marp! I am wondering is there any way to define something like a "global" thanks for this fabulous tool! |
Beta Was this translation helpful? Give feedback.
Answered by
yhatt
Aug 25, 2022
Replies: 1 comment 1 reply
-
Generally you have to use Marp CLI, with a customized Marp engine by a plugin. This is a simple example to use the plugin for appending custom HTML snippet into every slides. // marp.config.js
const appendDivPlugin = (md) => {
const html = '<div>Your custom HTML is here</div>'
// Override marpit_slide_close renderer rule to append a specific HTML tag before closing a slide
const { marpit_slide_close } = md.renderer.rules
md.renderer.rules.marpit_slide_close = (tokens, idx, opts, env, self) => {
const renderer = marpit_slide_close || self.renderToken
const original = renderer.call(self, tokens, idx, opts, env, self)
return html + original
}
}
module.exports = {
engine: ({ marp }) => marp.use(appendDivPlugin),
} marp -c ./marp.config.js ./slide.md |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
ChiMaoShuPhy
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Generally you have to use Marp CLI, with a customized Marp engine by a plugin. This is a simple example to use the plugin for appending custom HTML snippet into every slides.