Skip to content

How to define a "global" div automatically appears on every slide? #342

Answered by yhatt
ChiMaoShuPhy asked this question in Q&A
Discussion options

You must be logged in to vote

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 = {
  e…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ChiMaoShuPhy
Comment options

Answer selected by ChiMaoShuPhy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants