Asciidoctor reveal.js is a converter for Asciidoctor and Asciidoctor.js that transforms an AsciiDoc document into an HTML5 presentation designed to be executed by the reveal.js presentation framework.
There are two main technology stacks that can transform AsciiDoc into HTML5 / reveal.js:
-
Asciidoctor / Ruby / Bundler (See Ruby Setup)
-
Asciidoctor.js / JavaScript (Node.js) / NPM (See Node / JavaScript Setup)
Right now the Asciidoctor / Ruby stack is the better tested one but with the changes in v1.1.0 they have feature parity.
📎
|
You’re viewing the documentation for an upcoming release.
If you’re looking for the documentation for the current release or an older one, please click on the appropriate link below: 2.0.0 (latest release) ⁃ 1.1.3 (latest from 1.1 series) ⁃ 1.0.x ⁃ Unversioned pre-release (compatible with RevealJS 2.x) |
- Ruby Setup
- Node / JavaScript Setup
- Syntax Examples
- Basic presentation with speaker notes
- Slides without titles
- Background Colors
- Background images
- Background videos
- Background iframes
- Slide Transitions
- Fragments
- Stretch class attribute
- Videos
- Syntax highlighting
- Vertical slides
- Asciidoctor-reveal.js specific roles
- Title slide customization
- Content meant for multiple converters
- CSS override
- Slide state
- Admonitions
- Reveal.js Options
- Minimum Requirements
- Contributing
- Copyright and Licensing
📎
|
asciidoctor-reveal.js is now a Ruby Gem. To ensure repeatability, we recommend that you manage your presentation projects using bundler. |
For a quick start clone our starter repository and follow instructions there.
For more complete instructions, read on.
-
Install bundler (if not already installed) using your system’s package manager or with:
$ gem install bundler
-
If you’re using RVM, make sure you switch away from any gemset:
$ rvm use default
or
$ rvm use system
📎
|
These instructions should be repeated for every presentation project. |
-
Create project directory
$ mkdir my-awesome-presentation $ cd my-awesome-presentation
-
Create a file named
Gemfile
with the following content:source 'https://rubygems.org' gem 'asciidoctor-revealjs' # latest released version
📎For some reason, when you use the system Ruby on Fedora, you also have to add the json gem to the Gemfile. -
Install the gems into the project
$ bundle config --local github.https true $ bundle --path=.bundle/gems --binstubs=.bundle/.bin
-
Optional: Copy or clone reveal.js presentation framework. Allows you to modify themes or view slides offline.
$ git clone -b 3.7.0 --depth 1 https://github.com/hakimel/reveal.js.git
-
Create content in a file (*.adoc, *.ad, etc.). See examples in Syntax Examples section to get started.
-
Generate HTML presentation from the AsciiDoc source
$ bundle exec asciidoctor-revealjs \ -a revealjsdir=https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.7.0 CONTENT_FILE.adoc
-
If you did the optional step of having a local reveal.js clone you can convert AsciiDoc source with
$ bundle exec asciidoctor-revealjs CONTENT_FILE.adoc
💡
|
If you are using GitHub Pages, plan ahead by keeping your source files on master branch and all output files on the gh-pages branch.
|
First you must install and configure Node.js on your machine.
Using npm:
Create a directory to place slides. Initialize the directory to store npm packages within that directory.
$ echo {} > package.json # eliminates warnings, use `npm init` if you prefer $ npm i --save asciidoctor-reveal.js
Once the package is installed, you can convert AsciiDoc files using reveal.js converter.
Here we are converting a file named presentation.adoc
into a reveal.js presentation using Node.js:
// Load asciidoctor.js and asciidoctor-reveal.js
var asciidoctor = require('asciidoctor.js')();
var asciidoctorRevealjs = require('asciidoctor-reveal.js');
asciidoctorRevealjs.register()
// Convert the document 'presentation.adoc' using the reveal.js converter
var options = {safe: 'safe', backend: 'revealjs'};
asciidoctor.convertFile('presentation.adoc', options); // (1)
-
Creates a file named
presentation.html
(in the directory where command is run)
= Title Slide
== Slide One
* Foo
* Bar
* World
To render the slides, run:
node asciidoctor-revealjs.js
You can open the presentation.html
file in your browser and enjoy!
Let’s see some examples of revealjs
backend features.
Additional examples can be found in the AsciiDoc files (.adoc) in examples/
.
= Title Slide
== Slide One
* Foo
* Bar
* World
== Slide Two
A Great Story
[.notes]
--
* tell anecdote
* make a point
--
In previous snippet we are creating a slide titled Slide One with bullets and another one titled Slide Two with centered text (reveal.js’ default behavior) with speaker notes.
Other syntax exists to create speaker notes, see examples/speaker-notes.adoc
.
Speaker notes are opened by pressing s
.
With Reveal.js 3.5 they require a webserver to work.
This limitation is not present in 3.6.
You can get a Web server running quickly with:
ruby -run -e httpd . -p 5000 -b 127.0.0.1
Then use your browser to navigate to the URL http://localhost:5000.
There are a few ways to have no titles on slides.
-
Setting your title to
!
-
Adding the
notitle
option to your slide -
Adding the
conceal
option to your slide
📎
|
conceal and notitle have the advantage that the slide still has an id so it can be linked to.
|
❗
|
Like the first page of an AsciiDoc document, the first slide is handled differently.
To hide the whole slide use the :notitle: document attribute.
To achieve the effect of hiding only the first slide’s title, combine the :notitle: attribute on the first slide and use [%notitle] on the second slide which will, in effect, be your first slide now.
|
Background colors for slides can be specified by two means: a classic one and one using AsciiDoc roles. See background-color.adoc for more examples.
Using roles respects the AsciiDoc philosophy of separation of content and presentation.
Colors are to be defined by CSS and the :customcss:
attribute need to be used to specify the CSS file to load.
To avoid clashing with existing reveal.js themes or CSS, a specific CSS class called background
is expected to be present.
Here is an example:
= Title
:customcss: my-css.css
[.red.background]
== Slide One
Is very red
section.red.background {
background-color: red;
}
📎
|
The canvas keyword can be used instead of background for the same effect.
|
[background-color="yellow"]
== Slide Three
Is very yellow
Slide Three applies the attribute data-background-color to the reveal.js
<section> tag.
Anything accepted by CSS color formats works.
[%notitle]
== Grand Announcement
image::cover.jpg[background, size=cover]
This will put cover.jpg
as the slide’s background image.
It sets reveal.js’ data-background-image
attribute.
The size
attribute is also supported.
See the relevant reveal.js documentation for details.
📎
|
Background images file names are now relative to the :imagesdir: attribute if set.
|
📎
|
The canvas keyword can be used instead of background for the same effect.
|
[%notitle]
== The Great Goat
image::https://upload.wikimedia.org/wikipedia/commons/b/b2/Hausziege_04.jpg[canvas,size=contain]
As you can see, you can use a URL to specify your image resource too.
A background video for a slide can be specified using the background-video
element attribute.
[background-video="https://my.video/file.mp4",background-video-loop=true,background-video-muted=true]
== Nice background!
For convenience background-video-loop
and background-video-muted
attributes are mapped to loop
and muted
options which can be specified with options="loop,muted"
.
For example:
[background-video="https://my.video/file.mp4",options="loop,muted"]
== Nice background!
See the relevant reveal.js documentation for details.
Note that the data-
prefix is not required in asciidoc files.
The background can be replaced with anything a browser can render in an iframe using the background-iframe
reveal.js feature.
[%notitle,background-iframe="https://www.youtube.com/embed/LaApqL4QjH8?rel=0&start=3&enablejsapi=1&autoplay=1&loop=1&controls=0&modestbranding=1"]
== a youtube video
See the relevant reveal.js documentation for details.
[transition=zoom, %notitle]
== Zoom zoom
This slide will override the presentation transition and zoom!
[transition-speed=fast, %notitle]
== Speed
Choose from three transition speeds: default, fast or slow!
See the relevant reveal.js documentation for details.
== Slide Four
[%step]
* this
* is
* revealed
* gradually
Slide Four has bullets that are revealed one after the other.
This is what reveal.js
calls fragments.
Applying the step option or role on a list ([%step]
or [.step]
) will do the trick.
Here is the relevant reveal.js
documentation on the topic.
Note that only fade-in
is supported for lists at the moment.
Reveal.js supports a special class that will give all available screen space to an HTML node.
This class element is named stretch
.
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.
To apply that class to block simply use asciidoctor’s class assignment:
[.stretch]
In addition to background videos, videos can be inserted directly into slides. The syntax is the standard asciidoc video block macro syntax.
== Trains, we love trains!
video::kZH9JtPBq7k[youtube, start=34, options=autoplay]
By default videos are given as much space as possible.
To override that behavior use the width
and height
named attributes.
Reveal.js is well integrated with highlight.js for syntax highlighting.
Asciidoctor-reveal.js supports that.
You can activate highlight.js syntax highlighting (disabled by default) by setting the source-highlighter
document attribute as follows:
= Presentation Title
// [...] other document attributes
:source-highlighter: highlightjs
Once enabled you can write code blocks as usual:
== Slide Five
Uses highlighted code
[source, python]
----
print "Hello World"
----
By default [source]
blocks and blocks delimited by ----
will be highlighted.
An explicit [listing]
block will not be highlighted.
highlight.js
does language auto-detection but using the language="…"
attribute will hint the highlighter.
For example this will highlight this source code as Perl:
== Slide Five
[source,perl]
----
print "$0: hello world\n"
----
📎
|
Alternatively, you can use Coderay or Pygments as syntax highlighters if you are using the Asciidoctor/Ruby/Bundler toolchain (not Asciidoctor.js/Javascript/NPM).
Check the examples/ directory for examples and notes about what needs to be done for them to work.
They are considered unsupported by the asciidoctor-reveal.js project.
|
== Slide Six
Top slide
=== Slide Six.One
This is a vertical subslide
Slide Six uses the vertical slide feature of reveal.js
.
Slide Six.One will be rendered vertically below Slide Six.
Here is the relevant reveal.js
documentation on that topic.
Roles are usually applied with the following syntax where the important-text
CSS class would be applied to the slide title in the generated HTML:
[.important-text]
== Slide Title
* Some
* Information
Or
[role="important-text"]
== Slide Title
* Some
* Information
See Asciidoctor’s documentation for more details.
In addition to the existing attributes to position images, roles can be used as well. However, the shorthand syntax (.) doesn’t work in the image macro arguments but must be used above with the angle bracket syntax. See images.adoc for examples.
Here is a list of supported roles:
- right
-
Will apply a
float: right
style to the affected block
The title slide is customized via Asciidoc attributes.
These are the global variable assigned at the top of a document under the lead
title that look like this: :name: value
.
This converter supports changing the color, image, video, iframe and transitions of the title slide.
Read the relevant reveal.js documentation to understand what attributes need to be set.
Keep in mind that for title slides you must replace data-
with title-slide-
.
The title slide is also added a title
CSS class to help with template customization.
Some content can be created with both slides and book in mind.
To mark slides split points you can use preprocessor conditionals combined
with a backend declaration.
Breaking points are set using slides with no title === !
wrapped in a
conditional: ifdef::backend-revealjs[=== !]
.
In the end, the whole document has to be compiled with the backend option:
-b revealjs
For example:
== Main section
=== Sub Section
Small +
Multiline +
intro
. very
. long
. list
. of
. items
ifdef::backend-revealjs[=== !]
Some overview diagram
ifdef::backend-revealjs[=== !]
Detailed view diagram
If you use the :customcss:
document attribute, a CSS file of the name given in the attribute is added to the list of CSS resources loaded by the rendered HTML.
Doing so, you can then easily override specific elements of your theme per presentation.
For example, to do proper position-independent text placement of a title slide with a specific background you can use:
.reveal section.title h1 {
margin-top: 2.3em;
}
.reveal section.title small {
margin-top: 15.3em;
font-weight: bold;
color: white;
}
If the :customcss:
attribute value is empty then asciidoctor-revealjs.css
is the CSS resource that the presentation is linked to.
Reveal.js supports a data-state tag that can be added on slides which gets rendered into <section>
tags.
In AsciiDoc the data-state
can be applied to a slide by adding a state attribute to a section like this:
[state=topic]
== Epic Topic
That state can be queried from Javascript or used in CSS to apply further customization to your slide deck. For example, by combining this feature with the CSS override one, you can alter fonts for specific pages with this CSS:
@import 'https://fonts.googleapis.com/css?family=Baloo+Bhai';
section[data-state="topic"] h2 {
font-family: 'Baloo Bhai', cursive;
font-size: 4em;
}
Asciidoctor font-based admonitions are supported. Make sure to add the following attribute to your document:
:icons: font
Here is an example slide:
== But first
WARNING: This presentation is dangerous!
Here are details about Asciidoctor’s Admonition icons support.
There are some attributes that can be set at the top of the document which they are specific of revealjs
converter.
📎
|
Default settings are based on reveal.js default settings.
|
Attribute | Value(s) | Description |
---|---|---|
|
beige, black, league, night, serif, simple, sky, solarized, white |
Chooses one of reveal.js’ built-in themes. |
|
<file|URL> |
Overrides CSS with given file or URL. Default is disabled. |
|
<file|URL> |
Overrides highlight.js CSS style with given file or URL. Default is built-in lib/css/zenburn.css. |
|
<file|URL> |
Overrides reveal.js directory.
Example: ../reveal.js or
https://cdnjs.cloudflare.com/ajax/libs/reveal.js/3.7.0.
Default is |
|
true, false |
Display presentation control arrows |
|
true, false |
Help the user learn the controls by providing hints, for example by bouncing the down arrow when they first encounter a vertical slide |
|
edges, bottom-right |
Determines where controls appear, "edges" or "bottom-right" |
|
faded, hidden, visible |
Visibility rule for backwards navigation arrows; "faded", "hidden" or "visible" |
|
true, false |
Display a presentation progress bar. |
|
true, false, h.v, h/v, c, c/t |
Display the page number of the current slide. true will display the slide number with default formatting. Additional formatting is available:
|
|
all, speaker, print |
Control which views the slide number displays on using the "showSlideNumber" value:
|
|
true, false |
Push each slide change to the browser history. |
|
true, false |
Enable keyboard shortcuts for navigation. |
|
true, false |
Enable the slide overview mode. |
|
true, false |
Enables touch navigation on devices with touch input. |
|
true, false |
Vertical centering of slides. |
|
true, false |
Loop the presentation. |
|
true, false |
Change the presentation direction to be RTL. |
|
true, false |
Turns fragments on and off globally. |
|
true, false |
Flags whether to include the current fragment in the URL, so that reloading brings you to the same fragment position |
|
true, false |
Flags if the presentation is running in an embedded mode (i.e., contained within a limited portion of the screen). |
|
true, false |
Flags if we should show a help overlay when the questionmark key is pressed |
|
true, false |
Flags if speaker notes should be visible to all viewers |
|
null, true, false |
Global override for autolaying embedded media (video/audio/iframe)
|
|
<integer> |
Delay in milliseconds between automatically proceeding to the next slide.
Disabled when set to 0 (the default).
This value can be overwritten by using a |
|
true, false |
Stop auto-sliding after user input. |
|
Reveal.navigateNext |
Use this method for navigation when auto-sliding |
|
<integer> |
Specify the average time in seconds that you think you will spend presenting each slide. This is used to show a pacing timer in the speaker view. Defaults to 120 |
|
true, false |
Enable slide navigation via mouse wheel. |
|
true, false |
Hides the address bar on mobile devices. |
|
true, false |
Opens links in an iframe preview overlay.
Add |
|
none, fade, slide, convex, concave, zoom |
Transition style. |
|
default, fast, slow |
Transition speed. |
|
none, fade, slide, convex, concave, zoom |
Transition style for full page slide backgrounds. |
|
<integer> |
Number of slides away from the current that are visible. Default: 3 |
|
<file|URL> |
Parallax background image. Defaults to none |
|
<CSS size syntax> |
Parallax background size (accepts any CSS syntax). Defaults to none |
|
<Number of pixels> |
Number of pixels to move the parallax background per slide
|
|
<Number of pixels> |
Number of pixels to move the parallax background per slide
|
|
<a valid CSS display mode> |
The display mode that will be used to show slides. Defaults to block |
If you want to build a custom theme or customize an existing one you should
look at the
reveal.js
theme documentation and use the revealjs_customtheme
AsciiDoc attribute to
activate it.
By default, generated presentations will have the following reveal.js plugins enabled:
-
plugin/zoom-js/zoom.js
-
plugin/notes/notes.js
All these plugins are part of the reveal.js distribution.
To enable or disable a built-in plugin, it is possible to set the revealjs_plugin_[plugin name]
attribute to enable
or disable
.
For example, to disable all the default plugins set the following document attributes:
:revealjs_plugin_zoom: disabled :revealjs_plugin_notes: disabled
reveal.js ships with a plugin that allows to create a PDF from a slide deck.
To enable this plugin, set the revealjs_plugin_pdf
attribute.
:revealjs_plugin_pdf: enabled
When the plugin is enabled and you run your presentation in a browser with ?print-pdf
at the end of the URL, you can then use the default print function to print the slide deck into a PDF document.
💡
|
To work properly, this plugin requires a Chrome-based browser. |
Additional reveal.js plugins can be installed and activated using AsciiDoc attributes and external javascript files.
-
Extract the plugin files in a directory
-
Create a Javascript file that will contain the Javascript statements to load the plugin (only one required even if you are using several plugins)
-
Add a
:revealjs_plugins:
attribute to point to that Javascript file -
(Optional) Add a
:revealjs_plugins_configuration:
attribute to point to a Javascript file that configures the plugins you use
Looking at the example provided in the repository will provide guidance: AsciiDoc source, Plugin Loader, Plugin Configuration.
Read the relevant reveal.js documentation to understand more about reveal.js plugins. A list of existing reveal.js plugins is also maintained upstream.
Our requirements are expressed in our packages and by our dependencies. Basically, all you need is the package manager of the flavor of Asciidoctor-Reveal.js you are interested to run:
-
With Ruby / Bundler: A recent Ruby and Bundler
-
With Javascript (Node.js) / NPM: a recent Node.js environment
If you need more details about our dependencies check out Asciidoctor dependencies:
-
With Ruby / Bundler: Asciidoctor 1.5.6
-
With Javascript (Node.js) / NPM: Asciidoctor.js 1.5.6
Interested in contributing? We are interested! Developer-focused documentation is over here.
Copyright © 2012-2019 Olivier Bilodeau, Guillaume Grossetie, Dan Allen, Rahman Usta, Charles Moulliard and the Asciidoctor Project. Free use of this software is granted under the terms of the MIT License.
See the LICENSE file for details.