Skip to content

Instantly share code, notes, and snippets.

@yhatt
Last active January 30, 2024 18:43
Show Gist options
  • Save yhatt/54a1b07ff41485920d370e864860b8a8 to your computer and use it in GitHub Desktop.
Save yhatt/54a1b07ff41485920d370e864860b8a8 to your computer and use it in GitHub Desktop.
Convert paragraphs on top level of the slide page into presenter notes, and hide from the slide.

Regular text is only visible to you. Headlines go on the slide.

iA Presenter (https://ia.net/presenter)

Unlike popular Markdown slide tools, iA Presenter has a unique approach to displaying written content in Markdown.

Are you looking at its innovative approach with longing eyes? No need to wait with your fingers crossed; the same feature can be achieved in Marp using a plugin.

git clone https://gist.github.com/54a1b07ff41485920d370e864860b8a8.git ia_presenter_style_notes
cd ia_presenter_style_notes
npx @marp-team/marp-cli@latest -c ./marp.config.js slide.md

Presenter view screen shot

module.exports = {
engine: ({ marp }) =>
marp.use(require('./paragraphs-as-presenter-notes-plugin')),
}
/**
* Marpit / Marp plugin to make regular texts turn into presenter notes.
*
* Convert texts in the paragraphs on top level of the slide page into presenter
* notes, and hide from the slide. Texts inside nested elements, such as
* blockquotes and lists, will not convert into presenter notes.
*
* It brings a key feature of iA Presenter to Marp and Marpit.
*/
module.exports = function marpitParagraphsAsPresenterNotesPlugin(md) {
md.core.ruler.after(
'marpit_sweep_paragraph',
'marpit_paragraphs_as_notes',
(state) => {
if (state.inlineMode) return
const ctx = { slide: false, p: false, nest: 0 }
for (const token of state.tokens) {
if (token.hidden) continue
const { type } = token
if (!ctx.slide) {
if (type === 'marpit_slide_open') {
ctx.slide = true
ctx.nest = 0
}
} else {
if (type === 'marpit_slide_close') {
ctx.slide = false
} else if (ctx.nest === 0 && !ctx.p && type === 'paragraph_open') {
ctx.p = true
token.hidden = true
} else if (ctx.p && type === 'paragraph_close') {
ctx.p = false
token.hidden = true
} else if (ctx.p && type === 'inline') {
token.type = 'marpit_comment'
token.hidden = true
}
ctx.nest += token.nesting
}
}
}
)
}
theme class backgroundColor
uncover
invert

iA Presenter style notes ✨

This Marp plugin achieves iA Presenter style notes.


How to write slides

Unlike popular Markdown slide tools, regular text paragraphs in Markdown are only visible to you. Otherwise go on the slide.

Use headings or indented texts to present.

Focus on the your story 🎯

bg right

The Markdown slide document tends to be text-intensive. This design is somewhat reasonable for making clean slides in a conscious way.

https://twitter.com/iAPresenter/status/1585930315314274304

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment