reveal.js 中文文档(持续翻译中)
使用HTML轻松创建漂亮的演示文稿的框架。查看演示.
reveal.js 具有多种功能,包括嵌套幻灯片, Markdown内容, PDF 导出, 演讲者备注 和 JavaScript API. 还有一个功能齐全的可视化编辑器和平台,可在以下位置共享reveal.js演示文稿 slides.com.
目录
- 在线编辑
- 安装
- Instructions
- Configuration
- Presentation Size
- Dependencies
- Ready Event
- Auto-sliding
- Keyboard Bindings
- Vertical Slide Navigation
- Touch Navigation
- Lazy Loading
- API
- PDF Export
- Theming
- Speaker Notes
- Plugins
- Multiplexing
- MathJax
- License
阅读更多
在线编辑
演示文稿是使用HTML或Markdown编写的,但是对于喜欢图形界面的人也有一个在线编辑器。 在 https://slides.com 尝试一下.
注意:国内使用在线编辑器可能需要科学上网
安装
基本设置仅用于编写演示文稿。 完全设置使您可以访问所有reveal.js功能和插件,例如演讲者注释以及对源进行更改所需的开发任务。
基本设置
Reveal.js的核心非常易于安装。 您只需要下载此存储库的副本,然后直接在浏览器中打开index.html文件。
1.从https://github.com/hakimel/reveal.js/releases下载最新版本的reveal.js。
2.解压缩并将index.html中的示例内容替换为您自己的内容
3.在浏览器中打开index.html进行查看
完全设置
某些诸如外部Markdown和演讲者注释之类的reveal.js功能要求演示文稿必须在本地Web服务器上运行。以下说明将设置这样的服务器以及对Reveal.js源代码进行编辑所需的所有开发任务。
安装 Node.js (4.0.0 or later)
克隆reveal.js存储库
1
$ git clone https://github.com/hakimel/reveal.js.git
导航到reveal.js文件夹
1
$ cd reveal.js
安装依赖项
1
$ npm install
提供演示并监视源文件的更改
1
$ npm start
打开 http://localhost:8000 查看您的演示文稿
您可以使用以下命令来更改端口
npm start -- --port=8001
.
文件夹结构
- css/ 核心样式,没有这些样式,项目就无法运行
- js/ 如上所述,但用于JavaScript
- plugin/ 为reveal.js开发的扩展的组件
- lib/ 所有其他第三方扩展 (JavaScript, CSS, fonts)
使用说明
标记
下面是一个完整的revael.js工作示例:
1 | <html> |
表示标记的层次结构必须为.reveal> .slides> section
,其中section
代表一张幻灯片,并且可以无限制重复。如果您将多个section
元素放在另一个section
内,它们将显示为垂直幻灯片。垂直幻灯片的第一张是其他幻灯片的“封面”(在顶部),将包含在水平序列中。 例如:
1 | <div class="reveal"> |
Markdown
可以使用Markdown编写幻灯片。 要启用Markdown,请在您的<section>
元素中添加data-markdown
属性,并将内容包装在<textarea data-template>
中,如下例所示。 您还需要(按顺序)将plugin/markdown/marked.js
和plugin/markdown/markdown.js
脚本添加到HTML文件中。
这是基于data-markdown从Paul Irish修改使用marked支持GitHub Flavored Markdown。对缩进(避免制表符和空格混合)和换行(避免连续换行)敏感。
1 | <section data-markdown> |
外部 Markdown
你可以把你的内容写成一个单独的文件,并在运行时加载它。注意separator参数,它决定了在外部文件中如何分隔幻灯片:data-separator
属性定义了水平幻灯片的正则表达式(默认为^\r?\n---\r?\n$
,这是一个以换行符为界的水平规则)。data-separator-vertical
属性定义垂直幻灯片(默认情况下处于禁用状态)。data-separator-notes
属性是一个正则表达式,用于指定当前幻灯片的演讲者注释的开头(默认为notes?:
,因此它将同时匹配note:
和 notes:
)。 data-charset
属性是可选的,它指定在加载外部文件时使用哪个字符集。
在本地使用时,这个功能需要reveal.js 从本地Web服务器运行。下面的例子指定了所有可用的选项:
1 | <section data-markdown="example.md" |
元素属性
特殊语法(通过HTML注释)可用于向Markdown元素添加属性。这对于片段非常有用。
1 | <section data-markdown> |
幻灯片属性
特殊语法(通过HTML注释)可用于将属性添加到Markdown生成的幻灯片<section>
元素中。
1 | <section data-markdown> |
配置标记
我们使用marked来解析Markdown。 要自定义标记的渲染,您可以在配置显示时传入选项
1 | Reveal.initialize({ |
配置
在页面的最后,您需要通过运行以下代码来初始化显示。 请注意,所有的配置都是可选的,并且将默认指定为以下值。
1 | Reveal.initialize({ |
可以在初始化后使用configure
方法:
1 | // Turn autoSlide off |
表示大小
所有演示文稿均具有正常大小,即创作时的分辨率。 框架将根据该大小自动统一缩放演示文稿,以确保所有内容都适合任何给定的显示或视口。
请参阅以下有关尺寸调整的配置选项列表,包括默认值:
1 | Reveal.initialize({ |
If you wish to disable this behavior and do your own scaling (e.g. using media queries), try these settings:
1 | Reveal.initialize({ |
依存关系
Reveal.js doesn’t rely on any third party scripts to work but a few optional libraries are included by default. These libraries are loaded as dependencies in the order they appear, for example:
1 | Reveal.initialize({ |
You can add your own extensions using the same syntax. The following properties are available for each dependency object:
- src: Path to the script to load
- async: [optional] Flags if the script should load after reveal.js has started, defaults to false
- callback: [optional] Function to execute when the script has loaded
- condition: [optional] Function which must return true for the script to be loaded
准备事件
A ready
event is fired when reveal.js has loaded all non-async dependencies and is ready to start navigating. To check if reveal.js is already ‘ready’ you can call Reveal.isReady()
.
1 | Reveal.addEventListener( 'ready', function( event ) { |
Note that we also add a .ready
class to the .reveal
element so that you can hook into this with CSS.
Auto-sliding
Presentations can be configured to progress through slides automatically, without any user input. To enable this you will need to tell the framework how many milliseconds it should wait between slides:
1 | // Slide every five seconds |
When this is turned on a control element will appear that enables users to pause and resume auto-sliding. Alternatively, sliding can be paused or resumed by pressing »A« on the keyboard. Sliding is paused automatically as soon as the user starts navigating. You can disable these controls by specifying autoSlideStoppable: false
in your reveal.js config.
You can also override the slide duration for individual slides and fragments by using the data-autoslide
attribute:
1 | <section data-autoslide="2000"> |
To override the method used for navigation when auto-sliding, you can specify the autoSlideMethod
setting. To only navigate along the top layer and ignore vertical slides, set this to Reveal.navigateRight
.
Whenever the auto-slide mode is resumed or paused the autoslideresumed
and autoslidepaused
events are fired.
Keyboard Bindings
If you’re unhappy with any of the default keyboard bindings you can override them using the keyboard
config option:
1 | Reveal.configure({ |
Vertical Slide Navigation
Slides can be nested within other slides to create vertical stacks (see Markup). When presenting, you use the left/right arrows to step through the main (horizontal) slides. When you arrive at a vertical stack you can optionally press the up/down arrows to view the vertical slides or skip past them by pressing the right arrow. Here’s an example showing a bird’s-eye view of what this looks like in action:
Navigation Mode
You can finetune the reveal.js navigation behavior by using the navigationMode
config option. Note that these options are only useful for presnetations that use a mix of horizontal and vertical slides. The following navigation modes are available:
Value | Description |
---|---|
default | Left/right arrow keys step between horizontal slides. Up/down arrow keys step between vertical slides. Space key steps through all slides (both horizontal and vertical). |
linear | Removes the up/down arrows. Left/right arrows step through all slides (both horizontal and vertical). |
grid | When this is enabled, stepping left/right from a vertical stack to an adjacent vertical stack will land you at the same vertical index. Consider a deck with six slides ordered in two vertical stacks: 1.1 2.1 1.2 2.2 1.3 2.3 If you’re on slide 1.3 and navigate right, you will normally move from 1.3 -> 2.1. With navigationMode set to “grid” the same navigation takes you from 1.3 -> 2.3. |
Touch Navigation
You can swipe to navigate through a presentation on any touch-enabled device. Horizontal swipes change between horizontal slides, vertical swipes change between vertical slides. If you wish to disable this you can set the touch
config option to false when initializing reveal.js.
If there’s some part of your content that needs to remain accessible to touch events you’ll need to highlight this by adding a data-prevent-swipe
attribute to the element. One common example where this is useful is elements that need to be scrolled.
Lazy Loading
When working on presentation with a lot of media or iframe content it’s important to load lazily. Lazy loading means that reveal.js will only load content for the few slides nearest to the current slide. The number of slides that are preloaded is determined by the viewDistance
configuration option.
To enable lazy loading all you need to do is change your src
attributes to data-src
as shown below. This is supported for image, video, audio and iframe elements.
1 | <section> |
Lazy Loading Iframes
Note that lazy loaded iframes ignore the viewDistance
configuration and will only load when their containing slide becomes visible. Iframes are also unloaded as soon as the slide is hidden.
When we lazy load a video or audio element, reveal.js won’t start playing that content until the slide becomes visible. However there is no way to control this for an iframe since that could contain any kind of content. That means if we loaded an iframe before the slide is visible on screen it could begin playing media and sound in the background.
You can override this behavior with the data-preload
attribute. The iframe below will be loaded
according to the viewDistance
.
1 | <section> |
You can also change the default globally with the preloadIframes
configuration option. If set totrue
ALL iframes with a data-src
attribute will be preloaded when within the viewDistance
regardless of individual data-preload
attributes. If set to false
, all iframes will only be
loaded when they become visible.
API
The Reveal
object exposes a JavaScript API for controlling navigation and reading state:
1 | // Navigation |
Custom Key Bindings
Custom key bindings can be added and removed using the following Javascript API. Custom key bindings will override the default keyboard bindings, but will in turn be overridden by the user defined bindings in the keyboard
config option.
1 | Reveal.addKeyBinding( binding, callback ); |
For example
1 | // The binding parameter provides the following properties |
This allows plugins to add key bindings directly to Reveal so they can
- make use of Reveal’s pre-processing logic for key handling (for example, ignoring key presses when paused); and
- be included in the help overlay (optional)
Slide Changed Event
A slidechanged
event is fired each time the slide is changed (regardless of state). The event object holds the index values of the current slide as well as a reference to the previous and current slide HTML nodes.
Some libraries, like MathJax (see #226), get confused by the transforms and display states of slides. Often times, this can be fixed by calling their update or render function from this callback.
1 | Reveal.addEventListener( 'slidechanged', function( event ) { |
Presentation State
The presentation’s current state can be fetched by using the getState
method. A state object contains all of the information required to put the presentation back as it was when getState
was first called. Sort of like a snapshot. It’s a simple object that can easily be stringified and persisted or sent over the wire.
1 | Reveal.slide( 1 ); |
Slide States
If you set data-state="somestate"
on a slide <section>
, “somestate” will be applied as a class on the document element when that slide is opened. This allows you to apply broad style changes to the page based on the active slide.
Furthermore you can also listen to these changes in state via JavaScript:
1 | Reveal.addEventListener( 'somestate', function() { |
Slide Backgrounds
Slides are contained within a limited portion of the screen by default to allow them to fit any display and scale uniformly. You can apply full page backgrounds outside of the slide area by adding a data-background
attribute to your <section>
elements. Four different types of backgrounds are supported: color, image, video and iframe.
Color Backgrounds
All CSS color formats are supported, including hex values, keywords, rgba()
or hsl()
.
1 | <section data-background-color="#ff0000"> |
Image Backgrounds
By default, background images are resized to cover the full page. Available options:
Attribute | Default | Description |
---|---|---|
data-background-image | URL of the image to show. GIFs restart when the slide opens. | |
data-background-size | cover | See background-size on MDN. |
data-background-position | center | See background-position on MDN. |
data-background-repeat | no-repeat | See background-repeat on MDN. |
data-background-opacity | 1 | Opacity of the background image on a 0-1 scale. 0 is transparent and 1 is fully opaque. |
1 | <section data-background-image="http://example.com/image.png"> |
Video Backgrounds
Automatically plays a full size video behind the slide.
Attribute | Default | Description |
---|---|---|
data-background-video | A single video source, or a comma separated list of video sources. | |
data-background-video-loop | false | Flags if the video should play repeatedly. |
data-background-video-muted | false | Flags if the audio should be muted. |
data-background-size | cover | Use cover for full screen and some cropping or contain for letterboxing. |
data-background-opacity | 1 | Opacity of the background video on a 0-1 scale. 0 is transparent and 1 is fully opaque. |
1 | <section data-background-video="https://s3.amazonaws.com/static.slid.es/site/homepage/v1/homepage-video-editor.mp4,https://s3.amazonaws.com/static.slid.es/site/homepage/v1/homepage-video-editor.webm" data-background-video-loop data-background-video-muted> |
Iframe Backgrounds
Embeds a web page as a slide background that covers 100% of the reveal.js width and height. The iframe is in the background layer, behind your slides, and as such it’s not possible to interact with it by default. To make your background interactive, you can add the data-background-interactive
attribute.
1 | <section data-background-iframe="https://slides.com" data-background-interactive> |
Background Transitions
Backgrounds transition using a fade animation by default. This can be changed to a linear sliding transition by passing backgroundTransition: 'slide'
to the Reveal.initialize()
call. Alternatively you can set data-background-transition
on any section with a background to override that specific transition.
Parallax Background
If you want to use a parallax scrolling background, set the first two properties below when initializing reveal.js (the other two are optional).
1 | Reveal.initialize({ |
Make sure that the background size is much bigger than screen size to allow for some scrolling. View example.
Slide Transitions
The global presentation transition is set using the transition
config value. You can override the global transition for a specific slide by using the data-transition
attribute:
1 | <section data-transition="zoom"> |
You can also use different in and out transitions for the same slide:
1 | <section data-transition="slide"> |
You can choose from none
, fade
, slide
, convex
, concave
and zoom
.
Internal links
It’s easy to link between slides. The first example below targets the index of another slide whereas the second targets a slide with an ID attribute (<section id="some-slide">
):
1 | <a href="#/2/2">Link</a> |
You can also add relative navigation links, similar to the built in reveal.js controls, by appending one of the following classes on any element. Note that each element is automatically given an enabled
class when it’s a valid navigation route based on the current slide.
1 | <a href="#" class="navigate-left"> |
Fragments
Fragments are used to highlight individual elements on a slide. Every element with the class fragment
will be stepped through before moving on to the next slide. Here’s an example: http://revealjs.com/#/fragments
The default fragment style is to start out invisible and fade in. This style can be changed by appending a different class to the fragment:
1 | <section> |
Multiple fragments can be applied to the same element sequentially by wrapping it, this will fade in the text on the first step and fade it back out on the second.
1 | <section> |
The display order of fragments can be controlled using the data-fragment-index
attribute.
1 | <section> |
Fragment events
When a slide fragment is either shown or hidden reveal.js will dispatch an event.
Some libraries, like MathJax (see #505), get confused by the initially hidden fragment elements. Often times this can be fixed by calling their update or render function from this callback.
1 | Reveal.addEventListener( 'fragmentshown', function( event ) { |
Code Syntax Highlighting
By default, Reveal is configured with highlight.js for code syntax highlighting. To enable syntax highlighting, you’ll have to load the highlight plugin (plugin/highlight/highlight.js) and a highlight.js CSS theme (Reveal comes packaged with the Monokai themes: lib/css/monokai.css).
1 | Reveal.initialize({ |
Below is an example with clojure code that will be syntax highlighted. When the data-trim
attribute is present, surrounding whitespace is automatically removed. HTML will be escaped by default. To avoid this, for example if you are using <mark>
to call out a line of code, add the data-noescape
attribute to the <code>
element.
1 | <section> |
Line Numbers & Highlights
To enable line numbers, add data-line-numbers
to your <code>
tags. If you want to highlight specific lines you can provide a comma separated list of line numbers using the same attribute. For example, in the following example lines 4 and 8-11 are highlighted:
1 | <pre><code class="hljs" data-line-numbers="4,8-11"> |
Slide number
If you would like to display the page number of the current slide you can do so using the slideNumber
and showSlideNumber
configuration values.
1 | // Shows the slide number using default formatting |
Overview mode
Press »ESC« or »O« keys to toggle the overview mode on and off. While you’re in this mode, you can still navigate between slides,
as if you were at 1,000 feet above your presentation. The overview mode comes with a few API hooks:
1 | Reveal.addEventListener( 'overviewshown', function( event ) { /* ... */ } ); |
Fullscreen mode
Just press »F« on your keyboard to show your presentation in fullscreen mode. Press the »ESC« key to exit fullscreen mode.
Embedded media
Add data-autoplay
to your media element if you want it to automatically start playing when the slide is shown:
1 | <video data-autoplay src="http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"></video> |
If you want to enable or disable autoplay globally, for all embedded media, you can use the autoPlayMedia
configuration option. If you set this to true
ALL media will autoplay regardless of individual data-autoplay
attributes. If you initialize with autoPlayMedia: false
NO media will autoplay.
Note that embedded HTML5 <video>
/<audio>
and YouTube/Vimeo iframes are automatically paused when you navigate away from a slide. This can be disabled by decorating your element with a data-ignore
attribute.
Embedded iframes
reveal.js automatically pushes two post messages to embedded iframes. slide:start
when the slide containing the iframe is made visible and slide:stop
when it is hidden.
Stretching elements
Sometimes it’s desirable to have an element, like an image or video, stretch to consume as much space as possible within a given slide. This can be done by adding the .stretch
class to an element as seen below:
1 | <section> |
Limitations:
- Only direct descendants of a slide section can be stretched
- Only one descendant per slide section can be stretched
Resize Event
When reveal.js changes the scale of the slides it fires a resize event. You can subscribe to the event to resize your elements accordingly.
1 | Reveal.addEventListener( 'resize', function( event ) { |
postMessage API
The framework has a built-in postMessage API that can be used when communicating with a presentation inside of another window. Here’s an example showing how you’d make a reveal.js instance in the given window proceed to slide 2:
1 | <window>.postMessage( JSON.stringify({ method: 'slide', args: [ 2 ] }), '*' ); |
When reveal.js runs inside of an iframe it can optionally bubble all of its events to the parent. Bubbled events are stringified JSON with three fields: namespace, eventName and state. Here’s how you subscribe to them from the parent window:
1 | window.addEventListener( 'message', function( event ) { |
This cross-window messaging can be toggled on or off using configuration flags.
1 | Reveal.initialize({ |
PDF Export
Presentations can be exported to PDF via a special print stylesheet. This feature requires that you use Google Chrome or Chromium and to be serving the presentation from a web server.
Here’s an example of an exported presentation that’s been uploaded to SlideShare: http://www.slideshare.net/hakimel/revealjs-300.
Separate pages for fragments
Fragments are printed on separate slides by default. Meaning if you have a slide with three fragment steps, it will generate three separate slides where the fragments appear incrementally.
If you prefer printing all fragments in their visible states on the same slide you can set the pdfSeparateFragments
config option to false.
Page size
Export dimensions are inferred from the configured presentation size. Slides that are too tall to fit within a single page will expand onto multiple pages. You can limit how many pages a slide may expand onto using the pdfMaxPagesPerSlide
config option, for example Reveal.configure({ pdfMaxPagesPerSlide: 1 })
ensures that no slide ever grows to more than one printed page.
Print stylesheet
To enable the PDF print capability in your presentation, the special print stylesheet at /css/print/pdf.css must be loaded. The default index.html file handles this for you when print-pdf
is included in the query string. If you’re using a different HTML template, you can add this to your HEAD:
1 | <script> |
Instructions
- Open your presentation with
print-pdf
included in the query string i.e. http://localhost:8000/?print-pdf. You can test this with revealjs.com?print-pdf.- If you want to include speaker notes in your export, you can append
showNotes=true
to the query string: http://localhost:8000/?print-pdf&showNotes=true
- If you want to include speaker notes in your export, you can append
- Open the in-browser print dialog (CTRL/CMD+P).
- Change the Destination setting to Save as PDF.
- Change the Layout to Landscape.
- Change the Margins to None.
- Enable the Background graphics option.
- Click Save.
Alternatively you can use the decktape project.
Theming
The framework comes with a few different themes included:
- black: Black background, white text, blue links (default theme)
- white: White background, black text, blue links
- league: Gray background, white text, blue links (default theme for reveal.js < 3.0.0)
- beige: Beige background, dark text, brown links
- sky: Blue background, thin dark text, blue links
- night: Black background, thick white text, orange links
- serif: Cappuccino background, gray text, brown links
- simple: White background, black text, blue links
- solarized: Cream-colored background, dark green text, blue links
Each theme is available as a separate stylesheet. To change theme you will need to replace black below with your desired theme name in index.html:
1 | <link rel="stylesheet" href="css/theme/black.css" id="theme"> |
If you want to add a theme of your own see the instructions here: /css/theme/README.md.
Speaker Notes
reveal.js comes with a speaker notes plugin which can be used to present per-slide notes in a separate browser window. The notes window also gives you a preview of the next upcoming slide so it may be helpful even if you haven’t written any notes. Press the »S« key on your keyboard to open the notes window.
A speaker timer starts as soon as the speaker view is opened. You can reset it to 00:00:00 at any time by simply clicking/tapping on it.
Notes are defined by appending an <aside>
element to a slide as seen below. You can add the data-markdown
attribute to the aside element if you prefer writing notes using Markdown.
Alternatively you can add your notes in a data-notes
attribute on the slide. Like <section data-notes="Something important"></section>
.
When used locally, this feature requires that reveal.js runs from a local web server.
1 | <section> |
If you’re using the external Markdown plugin, you can add notes with the help of a special delimiter:
1 | <section data-markdown="example.md" data-separator="^\n\n\n" data-separator-vertical="^\n\n" data-separator-notes="^Note:"></section> |
Share and Print Speaker Notes
Notes are only visible to the speaker inside of the speaker view. If you wish to share your notes with others you can initialize reveal.js with the showNotes
configuration value set to true
. Notes will appear along the bottom of the presentations.
When showNotes
is enabled notes are also included when you export to PDF. By default, notes are printed in a box on top of the slide. If you’d rather print them on a separate page, after the slide, set showNotes: "separate-page"
.
Speaker notes clock and timers
The speaker notes window will also show:
- Time elapsed since the beginning of the presentation. If you hover the mouse above this section, a timer reset button will appear.
- Current wall-clock time
- (Optionally) a pacing timer which indicates whether the current pace of the presentation is on track for the right timing (shown in green), and if not, whether the presenter should speed up (shown in red) or has the luxury of slowing down (blue).
The pacing timer can be enabled by configuring by the defaultTiming
parameter in the Reveal
configuration block, which specifies the number of seconds per slide. 120 can be a reasonable rule of thumb. Timings can also be given per slide <section>
by setting the data-timing
attribute. Both values are in numbers of seconds.
Server Side Speaker Notes
In some cases it can be desirable to run notes on a separate device from the one you’re presenting on. The Node.js-based notes plugin lets you do this using the same note definitions as its client side counterpart. Include the required scripts by adding the following dependencies:
1 | Reveal.initialize({ |
Then:
- Install Node.js (4.0.0 or later)
- Run
npm install
- Run
node plugin/notes-server
Plugins
Plugins should register themselves with reveal.js by calling Reveal.registerPlugin( 'myPluginID', MyPlugin )
. Registered plugin instances can optionally expose an “init” function that reveal.js will call to initialize them.
When reveal.js is booted up via Reveal.initialize()
, it will go through all registered plugins and invoke their “init” methods. If the “init” method returns a Promise, reveal.js will wait for that promise to be fullfilled before finshing the startup sequence and firing the ready event. Here’s an example of a plugin that does some asynchronous work before reveal.js can proceed:
1 | let MyPlugin = { |
If the init method does not return a Promise, the plugin is considered ready right away and will not hold up the reveal.js startup sequence.
Retrieving Plugins
If you want to check if a specific plugin is registered you can use the Reveal.hasPlugin
method and pass in a plugin ID, for example: Reveal.hasPlugin( 'myPlugin' )
. If you want to retrieve a plugin instance you can use Reveal.getPlugin( 'myPlugin' )
.
Multiplexing
The multiplex plugin allows your audience to view the slides of the presentation you are controlling on their own phone, tablet or laptop. As the master presentation navigates the slides, all client presentations will update in real time. See a demo at https://reveal-js-multiplex-ccjbegmaii.now.sh/.
The multiplex plugin needs the following 3 things to operate:
- Master presentation that has control
- Client presentations that follow the master
- Socket.io server to broadcast events from the master to the clients
Master presentation
Served from a static file server accessible (preferably) only to the presenter. This need only be on your (the presenter’s) computer. (It’s safer to run the master presentation from your own computer, so if the venue’s Internet goes down it doesn’t stop the show.) An example would be to execute the following commands in the directory of your master presentation:
npm install node-static
static
If you want to use the speaker notes plugin with your master presentation then make sure you have the speaker notes plugin configured correctly along with the configuration shown below, then execute node plugin/notes-server
in the directory of your master presentation. The configuration below will cause it to connect to the socket.io server as a master, as well as launch your speaker-notes/static-file server.
You can then access your master presentation at http://localhost:1947
Example configuration:
1 | Reveal.initialize({ |
Client presentation
Served from a publicly accessible static file server. Examples include: GitHub Pages, Amazon S3, Dreamhost, Akamai, etc. The more reliable, the better. Your audience can then access the client presentation via http://example.com/path/to/presentation/client/index.html
, with the configuration below causing them to connect to the socket.io server as clients.
Example configuration:
1 | Reveal.initialize({ |
Socket.io server
Server that receives the slideChanged
events from the master presentation and broadcasts them out to the connected client presentations. This needs to be publicly accessible. You can run your own socket.io server with the commands:
npm install
node plugin/multiplex
Or you can use the socket.io server at https://reveal-js-multiplex-ccjbegmaii.now.sh/.
You’ll need to generate a unique secret and token pair for your master and client presentations. To do so, visit http://example.com/token
, where http://example.com
is the location of your socket.io server. Or if you’re going to use the socket.io server at https://reveal-js-multiplex-ccjbegmaii.now.sh/, visit https://reveal-js-multiplex-ccjbegmaii.now.sh/token.
You are very welcome to point your presentations at the Socket.io server running at https://reveal-js-multiplex-ccjbegmaii.now.sh/, but availability and stability are not guaranteed.
For anything mission critical I recommend you run your own server. The easiest way to do this is by installing now. With that installed, deploying your own Multiplex server is as easy running the following command from the reveal.js folder: now plugin/multiplex
.
socket.io server as file static server
The socket.io server can play the role of static file server for your client presentation, as in the example at https://reveal-js-multiplex-ccjbegmaii.now.sh/. (Open https://reveal-js-multiplex-ccjbegmaii.now.sh/ in two browsers. Navigate through the slides on one, and the other will update to match.)
Example configuration:
1 | Reveal.initialize({ |
It can also play the role of static file server for your master presentation and client presentations at the same time (as long as you don’t want to use speaker notes). (Open https://reveal-js-multiplex-ccjbegmaii.now.sh/ in two browsers. Navigate through the slides on one, and the other will update to match. Navigate through the slides on the second, and the first will update to match.) This is probably not desirable, because you don’t want your audience to mess with your slides while you’re presenting. ;)
Example configuration:
1 | Reveal.initialize({ |
MathJax
If you want to display math equations in your presentation you can easily do so by including this plugin. The plugin is a very thin wrapper around the MathJax library. To use it you’ll need to include it as a reveal.js dependency, find our more about dependencies here.
The plugin defaults to using LaTeX but that can be adjusted through the math
configuration object. Note that MathJax is loaded from a remote server. If you want to use it offline you’ll need to download a copy of the library and adjust the mathjax
configuration value.
Below is an example of how the plugin can be configured. If you don’t intend to change these values you do not need to include the math
config object at all.
1 | Reveal.initialize({ |
Read MathJax’s documentation if you need HTTPS delivery or serving of specific versions for stability.
MathJax in Markdown
If you want to include math inside of a presentation written in Markdown you need to wrap the formula in backticks. This prevents syntax conflicts between LaTeX and Markdown. For example:
1 | `$$ J(\theta_0,\theta_1) = \sum_{i=0} $$` |
License
MIT licensed
Copyright (C) 2019 Hakim El Hattab, http://hakim.se