Markdown features

August 3, 2026 ยท View on GitHub

This guide covers Markdown features available to authors writing slides with Marp Core.

Note

For basic slide syntax, directives, and image syntax inherited from Marpit framework, see the Marpit documentation.


Built-in features

Marp Markdown

Marp Markdown is based on Marpit Markdown and CommonMark. Marp Core changes the defaults as follows:

  • Changes from CommonMark
    • Supports GitHub Flavored Markdown tables and strikethrough.
    • Line breaks in paragraph will convert to <br> tag.
    • Generates GitHub-like IDs for headings (slugifications).
    • Allows only known-safe HTML elements and attributes by default.

Applications can change these defaults through constructor options.

Themes

Marp Core includes 3 built-in themes:

Default Gaia Uncover
Default theme Gaia theme Uncover theme
<!-- theme: default --> <!-- theme: gaia --> <!-- theme: uncover -->

See themes documentation for details.

Emoji

Emoji shortcodes such as :smile: and Unicode emoji such as ๐Ÿ˜„ are converted to SVG images provided by Twemoji. This keeps emoji rendering sharp and consistent across output formats.

Applications can change shortcode, Unicode, and Twemoji behavior through the emoji constructor option.

Slide size

Use the size global directive to select a size preset defined by the current theme:

---
theme: gaia
size: 4:3
---

# A traditional 4:3 slide

Every built-in theme provides 16:9$** (1280 \times 720: \text{default}) \text{and} **$4:3 (960ร—720) presets.

Theme authors can define custom presets.

Auto-scaling

The auto-scaling feature helps block content fit seamlessly into your slides.

While this feature depends on theme support, it is natively supported by all built-in themes. Theme authors should see how to enable auto scaling by setting @auto-scaling metadata.

Fitting header

Add <!-- fit --> inside a heading (# ~ ######) to scale it to the slide width:

# <!-- fit --> Fitting header

Auto-shrink blocks

Some wide blocks are automatically shrunk when the theme enables their corresponding auto scaling features.

Note

  • Auto scaling is only horizontal. Content may still overflow the bottom of a slide.
  • If inlineSVG option was disabled, auto scaling will not be applied.

Optional features by core plugins

Syntax highlighting

Requirements: @marp-team/marp-core/plugins/shiki plugin and shiki dependency (npm install --save shiki)

A code fence is highlighted when its info string contains a supported language identifier.

```js
import { Marp } from '@marp-team/marp-core'
import shiki from '@marp-team/marp-core/plugins/shiki'

const marp = new Marp().use(shiki())
const { html, css } = marp.render('# Hello, Marp!')
```

Syntax highlighting

Refer to Shiki's language list for supported identifiers.

Colors for syntax highlighting can be customized with CSS variables.

Line highlighting

Add a space-separated {} attribute after the language.

```js {2,4-5}
import { Marp } from '@marp-team/marp-core'
import shiki from '@marp-team/marp-core/plugins/shiki'

const marp = new Marp().use(shiki())
const { html, css } = marp.render('# Hello, Marp!')
```

Highlighted lines in a code block

Mermaid diagrams

Requirements: @marp-team/marp-core/plugins/mermaid plugin and beautiful-mermaid dependency (npm install --save beautiful-mermaid)

Use a mermaid code fence to render mermaid diagrams.

```mermaid
graph LR
  M[Marpit framework] --> C{Marp Core}
  C --> CLI[Marp CLI]
  C --> VS[Marp for VS Code]
  C --> O[[Your own app]]
```

A Mermaid flowchart rendered by Marp Core

Marp Core uses beautiful-mermaid for deterministic server-side output. It supports the following diagram types:

Flowchart
```mermaid
graph LR
  M[Marpit framework] --> C{Marp Core}
  C --> CLI[Marp CLI]
  C --> VS[Marp for VS Code]
  C --> O[[Your own app]]
```

A Mermaid flowchart rendered by Marp Core

Sequence Diagram
```mermaid
sequenceDiagram
  actor U as User
  participant M as Marp
  participant P as Markdown parser
  U->>+M: Request render
  M->>P: Parse Markdown
  P-->>M: Parsed result
  M-->>-U: Output
```

A Mermaid sequence diagram rendered by Marp Core

State Diagram
```mermaid
stateDiagram
  direction LR
  [*]-->Draft
  Draft-->FeedbackLoop
  state FeedbackLoop {
    Edit-->Preview
    Preview-->Edit
  }
  FeedbackLoop-->Export
  Export-->[*]: Present
```

A Mermaid state diagram rendered by Marp Core

Class Diagram
```mermaid
classDiagram
  class Marp {
    +constructor(options: MarpOptions)
  }
  class Marpit {
    +constructor(options: Marpit.Options)
    +render(markdown: string, env?: object) RenderResult
  }
  Marp <|-- Marpit
```

A Mermaid class diagram rendered by Marp Core

Entity Relationship Diagram (ERD)
```mermaid
erDiagram
  User ||--o{ MarpDocument : owns
  User ||--o{ Theme : owns
  User ||--o{ Asset : owns
  MarpDocument o{--o| Theme : uses
  MarpDocument o{..o{ Asset : uses
  User {
    int id
    string name
  }
  MarpDocument {
    int id
    string markdown
  }
  Theme {
    int id
    string css
  }
  Asset {
    int id
    string url
  }
```

A Mermaid entity relationship diagram rendered by Marp Core

XY Chart: Bar chart
```mermaid
xychart
  title "npm Downloads (2025-08 to 2026-07)"
  x-axis [Aug, Sep, Oct, Nov, Dec, Jan, Feb, Mar, Apr, May, Jun, Jul]
  y-axis "Downloads" 0 --> 500000
  bar [30958, 40546, 46111, 52399, 59409, 67686, 120845, 270062, 390907, 477828, 298524, 298974]
```

A Mermaid bar chart rendered by Marp Core

XY Chart: Line chart
```mermaid
xychart
  title "npm Downloads (2025-08 to 2026-07)"
  x-axis [Aug, Sep, Oct, Nov, Dec, Jan, Feb, Mar, Apr, May, Jun, Jul]
  y-axis "Downloads" 0 --> 500000
  line [30958, 40546, 46111, 52399, 59409, 67686, 120845, 270062, 390907, 477828, 298524, 298974]
```

A Mermaid line chart rendered by Marp Core

Interactive diagrams

Add interactive after the info string to enable beautiful-mermaid's interactive mode. For example, charts show a tooltip when hovering over a bar or line.

```mermaid interactive
xychart
  x-axis [Jan, Feb, Mar]
  bar [10, 15, 12]
```

Note

  • Some Mermaid syntax may not be supported by beautiful-mermaid renderer. You can see the full list of supported diagrams in https://agents.craft.do/mermaid.
  • To display source code instead of rendering a diagram, use mermaid-raw or mmd as the info string.
  • Diagram colors follow the current theme of syntax highlighting. Theme authors can override them with CSS variables.

Math typesetting

Requirements (At least one):

  • @marp-team/marp-core/plugins/katex plugin and katex dependency (npm install --save katex)
  • @marp-team/marp-core/plugins/mathjax plugin and MathJax dependencies (npm install --save @mathjax/src @mathjax/mathjax-bbm-font-extension @mathjax/mathjax-bboldx-font-extension @mathjax/mathjax-dsfont-font-extension @mathjax/mathjax-mhchem-font-extension)

Marp Core supports Pandoc-style math typesetting, powered by MathJax and KaTeX:

Math typesetting support
Render inline math such as $ax^2+bx+c$.

$$
f(x) = \int_{-\infty}^\infty
    \hat f(\xi)\,e^{2 \pi i \xi x}
    \,d\xi
$$

Choose a math library

Use the math global directive to select the library for the current Markdown document:

---
math: katex
---

$$
\begin{align}
x &= 1+1 \tag{1} \\
  &= 2
\end{align}
$$

For deterministic rendering, we recommend to declare math: mathjax or math: katex whenever a document uses math.

Note

  • The math library of first registered plugin will be used as the default. In the full build @marp-team/marp-core/full, MathJax is the default library.
  • In general, MathJax has better rendering and syntax support, but KaTeX is faster rendering if you had a lot of formulas.
  • See Math configuration for the application-side settings. If the application has disabled math, the math directive will be ignored.