Skip to content

Marp: Markdown Presentation Ecosystem

What is Marp?

Quote

Marp (also known as the Markdown Presentation Ecosystem) provides an intuitive experience for creating beautiful slide decks. You only have to focus on writing your story in a Markdown document.

Here you find a few good references if you wish to get started using Marp:

How to build a cool presentation

Marp is a really powerful tool to build an HTML presentation using Markdown. It can be developed inside VS Code (see e.g. https://www.youtube.com/watch?v=EzQ-p41wNEE) and the HTML can be directly exported there.

Let me give you an example presentation that shows how easy it is:

Marp Example Presenation

Example:

---
paginate: true
marp: true
theme: uncover
class: invert
style: |
  .small-red-text {
    font-size: 0.75rem;
    color: red;
  }

  h1 {
    font-size: 60px;
  }

  h2 {
    font-size: 50px;
  } 

  h3 {
    font-size: 40px;
  }

  h4 {
    font-size: 30px;
  }

  h5,h6,p,li,code,table {
    font-size: 25px;
  }
headingDivider: 1
math: mathjax
---


# **Marp**


![bg left:40% 80%](https://marp.app/assets/marp.svg)

Markdown Presentation Ecosystem

https://marp.app/


# How to write slides

Split pages by horizontal ruler (`---`). It's very simple! :satisfied:

```markdown
# Slide 1

foobar


# Slide 2

foobar
```

Alternatively, set the **directive** [headingDivider](https://marpit.marp.app/directives?id=heading-divider). To automatically split at `h1` headers add to the document metadata:
```md
headingDivider: 1
```


# Markdown !!!

*Just* **write** `Markdown` ==here==!!!

- Bullet 1
- Bullet 2

### Subtitle

[Marp Link](https://marpit.marp.app/)

**Emojies**: :joy: :wink: :smile: :rocket:


# Markdown !!!
#### Use automatic syntax highlighting
```python
def foo(bar: str) -> str:
    return bar.strip()

if __name__ == "__main__":
    main()

```


# Markdown !!!

### Tables

| Syntax      | Description | Test Text     |
| :---        |    :----:   |          ---: |
| Header      | Title       | Here's this   |
| Paragraph   | Text        | And more      |


# Markdown !!!

## Crazy Math
<!-- _footer: You have to add **math: mathjax** to the document metadata -->
$$ 
f(a) = \frac{1}{2 \pi i} \oint_\gamma \frac{f(z)}{z-a} dz
$$


# Custom Backgrounds

![bg](https://patrikhlobil.github.io/Blog/blogs/images/background.png)

Use **Image Directives** (local or web-resource):

```md
![bg](https://patrikhlobil.github.io/Blog/blogs/images/background.png)
```


# Custom Backgrounds

![bg](https://patrikhlobil.github.io/Blog/blogs/images/cats.jpg)

![bg](https://patrikhlobil.github.io/Blog/blogs/images/sea.jpg)
**Multiple Backgrounds!!!**

```md
![bg](https://patrikhlobil.github.io/Blog/blogs/images/cats.jpg)

![bg](https://patrikhlobil.github.io/Blog/blogs/images/sea.jpg)
```


# Images

Put Images to the left

![bg left](https://patrikhlobil.github.io/Blog/blogs/images/cats.jpg)
```md
![bg left](https://patrikhlobil.github.io/Blog/blogs/images/cats.jpg)
```

# Images

... or to the right

![bg right](https://patrikhlobil.github.io/Blog/blogs/images/cats.jpg)
```md
![bg right](https://patrikhlobil.github.io/Blog/blogs/images/cats.jpg)
```

# Images

... or adjust the width ...

![bg left:25%](https://patrikhlobil.github.io/Blog/blogs/images/cats.jpg)
```md
![bg left:25%](https://patrikhlobil.github.io/Blog/blogs/images/cats.jpg)
```


# Images

... or apply filters:

![bg left sepia](https://patrikhlobil.github.io/Blog/blogs/images/sea.jpg)
![bg right blur](https://patrikhlobil.github.io/Blog/blogs/images/sea.jpg)
```md
![bg left sepia](https://patrikhlobil.github.io/Blog/blogs/images/sea.jpg)
![bg right blur](https://patrikhlobil.github.io/Blog/blogs/images/sea.jpg)
```


# GIFS !!!
```
![bg right](https://media0.giphy.com/media/SbtWGvMSmJIaV8faS8/200w.webp?
cid=ecf05e47i5eyozrdt5aytc41m0o7ea6uxu6ck2088uxo4ojz&ep=v1_gifs_search&rid=200w.webp&ct=g)
```
![bg](https://media0.giphy.com/media/SbtWGvMSmJIaV8faS8/200w.webp?cid=ecf05e47i5eyozrdt5aytc41m0o7ea6uxu6ck2088uxo4ojz&ep=v1_gifs_search&rid=200w.webp&ct=g)


# Mermaid Support

<!-- Add this anywhere in your Markdown file -->
<script type="module">
  import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
  mermaid.initialize({ startOnLoad: true });
</script>

<div class="mermaid">
journey
    title My working day
    section Go to work
      Make tea: 5: Me
      Go upstairs: 3: Me
      Do work: 1: Me, Cat
    section Go home
      Go downstairs: 5: Me
      Sit down: 3: Me
</div>

# HTML Support

Add custom CSS to document metadata
```
---
marp: true
style: |
  .small-red-text {
    font-size: 0.75rem;
    color: red;
  }
---
# Title
<div class="small-red-text"> Small Red Text</div>
```


<div class="small-red-text"> Small Red Text</div>

# HTML Support

<div id="myDiv"> </div>
<script src='https://cdn.plot.ly/plotly-2.24.1.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.17/d3.min.js'></script>

<script>
d3.json('https://raw.githubusercontent.com/plotly/plotly.js/master/test/image/mocks/sankey_energy.json', function(fig){

var data = {
  type: "sankey",
  domain: {
    x: [0,1],
    y: [0,1]
  },
  orientation: "h",
  valueformat: ".0f",
  valuesuffix: "TWh",
  node: {
    pad: 15,
    thickness: 15,
    line: {
      color: "black",
      width: 0.5
    },
   label: fig.data[0].node.label,
   color: fig.data[0].node.color
      },

  link: {
    source: fig.data[0].link.source,
    target: fig.data[0].link.target,
    value: fig.data[0].link.value,
    label: fig.data[0].link.label
  }
}

var data = [data]

var layout = {
  title: "Energy forecast for 2050<br>Source: Department of Energy & Climate Change, Tom Counsell via <a href='https://bost.ocks.org/mike/sankey/'>Mike Bostock</a>",
  width: 1000,
  height: 500,
  font: {
    size: 10
  }
}

Plotly.newPlot('myDiv', data, layout)
});

</script>


# Fragmented lists

Use `*` to get a fragmented list, where each item appears one after each other and `-` to directly display all items.

### Non-Fragmented

- non-frag 1
- non-frag 2

### Fragmented

* frag 1
* frag 2


# Speaker Notes

Just add **Speaker Notes** via:
```html
<!-- 
Some notes here that might be useful.
-->
```


<!-- 
Some notes here that might be useful.
-->

# Directives

<!-- _backgroundColor: #180f61 -->

With `Directives`, it is easy to modify the behaviour of **Marp** for a single slide or the whole presentation.

#### Local Directives

Using local directives (prepend with `_`), one can modify a single page, e.g.
```html
<!-- _backgroundColor: #180f61 -->
```

#### Global Directives

Using global directives, one can modify the bejaviour of the slides from the current slide on
```html
<!-- backgroundColor: aqua -->
```