一、简介

Marp是一个用Markdown语法来制作幻灯片的跨平台文本编辑工具。

marp-introduce

二、特性

  • 使用markdown编写幻灯片
  • 跨平台,支持Windows,Mac,and Linux
  • 3种实时预览模式
  • 幻灯片主题(default,gaia)和自定义背景图片
  • 支持表情显示❤️
  • 可以显示数学公式
  • 将幻灯片导出为PDF

三、特殊语法

1、幻类片分页

使用`---`符号分隔每页幻灯片

# Slide 1

foobar 

---

# Slide 2

foobar

Notice: Ruler (<hr>) is not displayed in Marp.

2、指令

marp使用扩展指令影响幻灯片,指令通过插入HTML注释实现,如下:

<!-- {directive_name}: {value} -->

或

<!--
   {first_directive_name}: {value}
   {second_directive_name}: {value}
-->
  • 全局指令

    全局指令在整个文档中都有效,如果设置了多个相同的全局指令,只有最后一个会生效。

(1)、$theme

可以通过菜单中的View -> Theme 菜单修改所有幻灯片的主题。

<!-- $theme: gaia -->
 Theme name   Value   Directive 
Default default <!-- $theme: default -->
Gaia gaia <!-- $theme: gaia -->
 
(2)、$width $height

修改所有幻灯片的宽度和高度,可以使用以下单位:px(默认),cm,mm,in,pt和pc。

<!-- $width: 12in -->
(3)、$size

修改大小使用预先设置的值: 4:3, 16:9, A0-A8, B0-B8

<!-- $size: 16:9 -->
  • 页面指令

    页面指令将会在当前页面和之后页面生效。

(1)、page_number

设置为true时,右下角会显示页码。

<!-- page_number: true -->
(2)、template

template指令仅用在支持模板的主题中。

Example: Set "invert" template of Gaia theme.

<!--
$theme: gaia
template: invert
-->
(3)、footer

添加页脚给当前和之后的幻灯片。

<!-- footer: This is a footer -->
(4)、prerender

预渲染幻灯片,可以防止背景图片过大带来的问题。

<!-- prerender: true -->

3、背景图片

![bg](images/mybackground.png)

bg之后有一些可选配置,例如: ![bg original](path).

  • original: 只是引入背景图,不作任何处理(默认有类似设置透明度的效果)

  • x%:设置图片相对于幻灯片大小的百分比

  • 预览:

marp-background

4、数学公式

可以使用$formula$实现行内显示的公式,例如:$ax^2+bc+c$;使用$$formula$$实现块级显示的公式,例如: $$I_{xx}=\int\int_Ry^2f(x,y)\cdot{}dydx$$。

  • 预览:

marp-mathematics

5、Emojo表情

在两个冒号间添加表情代码(:emojo-code:)可以创建表情,例如:

:+1: :-1: :smile: :heart: :cry: :sob: :a: :b: :angry: :grin: :tongue: :ru: :us: :cn:

  • 预览效果:

marp-emojos

  • 其他表情代码(部分):
  英文     中文  
smile 微笑
grimace 撇嘴
drool 色
scowl 发呆
coolGuy 得意
sob 流泪
shy 害羞
frown 难过
ruthless 酷
blush 冷汗
scream 抓狂
puke 吐
silent 闭嘴
sleep 睡
cry 大哭
awkward 尴尬
angry 发怒
tongue 调皮
grin 呲牙
surprise 惊讶
… …
参考资料

Marp官网