Marp Markdown Presentation Ecosystem
repository·main·Indexed 11 days ago
https://github.com/marp-team/marpA Markdown-based presentation ecosystem for creating professional slide decks. The ecosystem includes Marpit (a lightweight framework), Marp Core (the core converter with built-in themes), Marp CLI (a command-line tool for exporting to HTML, PDF, PPTX, and images), and an extension for VS Code. Key features include support for MathJax and KaTeX, custom CSS transitions via the View Transitions API in Marp CLI v2, and theme customization.
What's inside Marp
- Marp is a Markdown Presentation Ecosystem that allows you to create slide decks using plain Markdown. The ecosystem is divided into several specialized components including core frameworks, command-line tools, and editor integrations.
Marp Web (PWA)
mainMarp Web is a web-based interface for writing Marp presentations. It is designed as a Progressive Web App (PWA), meaning:
- Offline Support: Once accessed, resources are cached in your browser, allowing you to use the interface without an internet connection.
- Cross-Device Compatibility: Works on desktop browsers, mobile devices (Android/iOS), tablets (iPad), and Chrome OS.
- Live Preview: Provides a high-performance live preview that updates as you type without blocking the UI, even for large documents.
Handle backward navigation in custom transitions
mainWhen creating custom transitions, animations might behave incorrectly during backward navigation (e.g., sliding in the wrong direction). You can solve this using two methods:
- Use the
--marp-transition-directionCSS variable: This variable is available within@keyframes. It evaluates to1for forward navigation and-1for backward navigation. Usecalc()to adjust positions based on this value. - Declare specific backward keyframes: Use the
backward-prefix in your@keyframesname (e.g.,marp-incoming-transition-backward-name). Marp will prioritize these keyframes during backward navigation and fall back to the standard ones if the backward version is not defined. To prevent unintended fallback, you can declare an empty@keyframesfor the backward version.
/* Method 1: Using the direction variable */ @keyframes marp-outgoing-transition-slide-up { from { transform: translateY(0%); } to { transform: translateY(calc(var(--marp-transition-direction, 1) * -100%)); } } /* Method 2: Using the backward prefix */ @keyframes marp-incoming-transition-triangle { from { clip-path: polygon(0% 0%, 0% 0%, 0% 0%); } to { clip-path: polygon(0% 0%, 200% 0%, 0% 200%); } } @keyframes marp-incoming-transition-backward-triangle { from { clip-path: polygon(100% 100%, 100% 100%, 100% 100%); } to { clip-path: polygon(-100% 100%, 100% -100%, 100% 100%); } }- Use the
Create custom transitions using CSS @keyframes
mainCustom transitions can be defined by adding
@keyframesat-rules within an inline<style>element or a custom theme's CSS.To create a custom transition named
my-custom-name, you must define the corresponding Marp-specific keyframe names:marp-incoming-transition-my-custom-name(for the entrance animation)marp-outgoing-transition-my-custom-name(for the exit animation, optional)marp-incoming-transition-backward-my-custom-name(for backward navigation, optional)marp-outgoing-transition-backward-my-custom-name(for backward navigation, optional)
This allows for complex, creative CSS animations to be used as slide transitions.
/* Simple definition: "dissolve" custom transition */ @keyframes marp-transition-dissolve { from { opacity: 1; } to { opacity: 0; } } /* Splitted definitions: "triangle" custom transition */ @keyframes marp-incoming-transition-triangle { from { clip-path: polygon(0% 0%, 0% 0%, 0% 0%); } to { clip-path: polygon(0% 0%, 200% 0%, 0% 200%); } } @keyframes marp-incoming-transition-backward-triangle { from { clip-path: polygon(100% 100%, 100% 100%, 100% 100%); } to { clip-path: polygon(-100% 100%, 100% -100%, 100% 100%); } }How fragmented lists work in Marp
mainFragmented lists (also known as incremental lists or builds) allow list content to appear incrementally during a presentation.
Key Behaviors:
- Export Dependency: Fragmented lists only function when exporting to HTML. In PDF and PPTX exports, they render as normal, fully visible lists.
- Rendering Implementation: The syntax merely indicates that a list should be fragmented. The actual animation depends on the tool used. In the official Marp toolset, the Marp CLI's default HTML template
bespokeis required to reproduce the fragmented list as a build animation. - Usage Warning: While they can help focus attention, they can also cause confusion regarding hidden items. Use them judiciously.
Understand the Marp ecosystem concepts
mainMarp (Markdown Presentation Ecosystem) is a system for creating presentations using Markdown. It is built on several core principles:
- Markdown-based: Uses CommonMark for maximum compatibility. You focus on logical structure rather than presentation code.
- Theme CSS: Uses standard HTML and CSS for styling. It follows the principle of separation of content and style, allowing you to apply community themes to your content easily.
- Multi-format Export: Supports conversion to PDF, PPTX, and HTML. Marp prioritizes reproducible rendering so that layouts remain consistent across these formats.
- Pluggable Architecture: Built on the Marpit framework, which allows developers to extend functionality via plugins (e.g., adding new Markdown syntax via
markdown-itplugins, custom directives, or custom theme sets).
Identify the right Marp component for your needs
mainThe Marp ecosystem is split into different packages depending on whether you need a framework, a CLI, or an editor extension:
Framework / Core
- Marpit: A lightweight framework for creating slide decks from Markdown.
- Marp Core: The core converter featuring practical features and built-in themes.
Apps
- Marp CLI: A command-line interface for Marp Core/Marpit that converts Markdown into HTML, PDF, PPTX, or images.
Integrations
- Marp for VS Code: A Visual Studio Code extension that provides a live preview of your Marp Markdown slide decks.
Understand Workspace Trust restrictions in Marp for VS Code
mainMarp for VS Code supports VS Code's Workspace Trust security model. If you are working in an untrusted workspace, only basic Marp features are available (Markdown preview and IntelliSense).
To use advanced features, you must trust the workspace. The following features are restricted in untrusted workspaces:
- The Export command (to PDF/PPTX).
- Using custom themes configured via the
markdown.marp.themessetting. - Enabling HTML tags in Markdown via the
markdown.marp.enableHtmlsetting.
Understand Marp's extended Markdown syntax
mainMarp is based on CommonMark but includes several extensions and specific behaviors:
Line Breaks
- Line breaks within a paragraph are automatically converted to
<br />tags. - You can manually use the
<br />tag for explicit line breaks (e.g., inside a fitting header).
GitHub Flavored Markdown (GFM) Features
- Automatic linking: URLs are automatically converted to links.
- Emoji shortcodes: Supported via
markdown-it-emojiandtwemoji. - Strikethrough: Use
~~text~~to strike through text. - Syntax highlighting: Supported in code blocks via
highlight.js. - Tables: GFM table syntax is enabled.
List Markers
- Certain uncommon list markers like
*and1)have special meanings for creating fragmented lists.
- Line breaks within a paragraph are automatically converted to
How custom slide transitions work in Marp
mainMarp implements slide transitions by treating the current slide and the next slide as two separate layers presented simultaneously. To create a smooth effect, you must follow two principles:
- The Outgoing Slide: The slide being navigated away from must have an animation to hide it.
- The Incoming Slide: The new slide appearing must have an animation to show it.
When navigating, Marp's
bespokeHTML template creates these two layers and applies the appropriate CSS animation keyframes to each.Define global macros in KaTeX
mainWhen using KaTeX, standard
\defmacros are local to the specific math environment (the current block). To define a macro that persists and can be used in subsequent math environments throughout the Markdown document, use\gdef(\global\def).$$ % macroA is local to this block \def\macroA{{\color{red}A}} % macroB is global \gdef\macroB{{\color{blue}B}} \macroA + \macroB $$ --- $$ % macroA will not work here, but macroB will \macroA + \macroB $$Configure HTML tag usage in Marp
mainBy default, most HTML tags are disabled for security reasons. Marp only allows two specific tags out of the box:
<style>: Used for tweaking the current theme.<br />: Used for line breaks.
If you need to use other HTML tags, you must explicitly opt-in via the specific Marp tool or CLI configuration you are using.