Having an alternating style for odd or even pages #456
Answered
by
yhatt
PedroCavalheiro
asked this question in
Q&A
-
Hello, In print, it's usual for the page marker to alternate between the right and left side of the page. Is there a way to apply this in Marp? The expected section:nth-child solution doesn't work since each section is a standalone element. Thank you for your attention. |
Beta Was this translation helpful? Give feedback.
Answered by
yhatt
Jul 3, 2023
Replies: 1 comment
-
Marp is designed for PowerPoint style presentation slides, and is not supported the book style pagination. If necessary, you can write a Marp (Marpit) plugin to add // engine.mjs
const marpOddEvenSlidePlugin = (md) => {
md.core.ruler.after('marpit_slide', 'marp_odd_even_slide', (state) => {
if (state.inlineMode) return
for (const token of state.tokens) {
if (token.type === 'marpit_slide_open') {
const pageNumber = token.meta.marpitSlide + 1
token.attrJoin('class', pageNumber % 2 === 0 ? 'even' : 'odd')
}
}
})
}
export default ({ marp }) => marp.use(marpOddEvenSlidePlugin)
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
yhatt
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Marp is designed for PowerPoint style presentation slides, and is not supported the book style pagination.
If necessary, you can write a Marp (Marpit) plugin to add
odd
oreven
class to the<section>
element, and use it in Marp CLI.