README.adoc

Asciidoctor

Asciidoctor is a fast, open source text processor and publishing toolchain for converting AsciiDoc content to HTML5, DocBook, PDF, and other formats.
Asciidoctor is written in Ruby and runs on all major operation systems.
To simplify installation, Asciidoctor is packaged and distributed as a gem to RubyGems.org and is packaged for popular Linux distributions and macOS.
Asciidoctor can also be run in a JVM using AsciidoctorJ or in any JavaScript environment using Asciidoctor.js.
The Asciidoctor project is hosted on GitHub.

This document is also available in the following languages:汉语
|
Français
|
日本語

The Big Picture

Asciidoctor reads content written in plain text, as shown in the panel on the left in the image below, and converts it to HTML5, as shown rendered in the right panel.
Asciidoctor applies a default stylesheet to the HTML5 document to provide a pleasant out-of-the-box experience.

AsciiDoc Processing

Asciidoctor reads and parses text written in the AsciiDoc syntax, then feeds the parse tree to a set of built-in converters to produce HTML5, DocBook 5, and man(ual) page output.
You have the option of using your own converter or loading Tilt-supported templates to customize the generated output or produce additional formats.

Asciidoctor is a drop-in replacement for the original AsciiDoc Python processor (asciidoc.py).
The Asciidoctor test suite has > 2,000 tests to ensure compatibility with the AsciiDoc syntax.

In addition to the classic AsciiDoc syntax, Asciidoctor recognizes additional markup and formatting options, such as font-based icons (e.g., icon:fire[]) and UI elements (e.g., button:[Save]).
Asciidoctor also offers a modern, responsive theme based on Foundation to style the HTML5 output.

Where Ruby goes, Asciidoctor follows

You can run Asciidoctor on the JVM using JRuby.
To invoke the Asciidoctor API directly from Java and other JVM languages, use AsciidoctorJ.
There are plugins available, based on AsciidoctorJ, that integrate the Asciidoctor processor into Apache Maven, Gradle or Javadoc builds.

Asciidoctor also runs in JavaScript.
Opal is used to transcompile the Ruby source to JavaScript to produce Asciidoctor.js.
Asciidoctor.js is a fully-functional version of Asciidoctor that works in any JavaScript environment, such as a web browser or Node.js.
It’s used to power the AsciiDoc preview extensions for Chrome, Atom, Brackets and other web-based tooling.

Requirements

Asciidoctor works on Linux, macOS and Windows and requires one of the following implementations of Ruby:

Ruby (MRI/CRuby 1.8.7 - 2.5)

JRuby (1.7 in Ruby 1.8 and 1.9 modes, 9000)

Rubinius 2.2.x

Opal (JavaScript)

🔥

If you’re using a non-English Windows environment, you may bump into an Encoding::UndefinedConversionError when invoking Asciidoctor.
To solve this issue, we recommend changing the active code page in your console to UTF-8:

chcp 65001

Once you make this change, all your Unicode headaches will be behind you.
If you’re using an IDE like Eclipse, make sure you set the encoding to UTF-8 there as well.
Asciidoctor works best when you use UTF-8 everywhere.

Installation

Asciidoctor can be installed using (a) package managers for popular Linux distributions, (b) Homebrew for macOS, (c) the gem install command (recommended for Windows users), (d) the Asciidoctor Docker image, or (e) Bundler.

The benefit of using your operating system’s package manager to install the gem is that it handles installing Ruby and the RubyGems library if those packages are not already installed on your machine.

(a) Linux package managers

The version of Asciidoctor installed by the package manager may not match the latest release of Asciidoctor.
Consult the package repository for your distribution to find out which version is packaged per distribution release.

apk (Alpine Linux)

pacman (Arch Linux)

To install the gem on Arch-based distributions, open a terminal and type:

$ sudo pacman -S asciidoctor

APT

On Debian and Debian-based distributions such as Ubuntu, use APT to install Asciidoctor.
To install the package, open a terminal and type:

$ sudo apt-get install -y asciidoctor

DNF

On RPM-based Linux distributions, such as Fedora, CentOS, and RHEL, use the DNF package manager to install Asciidoctor.
To install the package, open a terminal and type:

$ sudo dnf install -y asciidoctor

(b) Homebrew (macOS)

You can use Homebrew, the macOS package manager, to install Asciidoctor.
If you don’t have Homebrew on your computer, complete the installation instructions at brew.sh first.
Once Homebrew is installed, you’re ready to install the asciidoctor gem.
Open a terminal and type:

$ brew install asciidoctor

Homebrew installs the asciidoctor gem into an exclusive prefix that’s independent of system gems.

(c) gem install

Before installing Asciidoctor using gem install, you should use RVM to install Ruby in your home directory (i.e., user space).
Then, you can safely use the gem command to install or update the Asciidoctor gem.
When using RVM, gems are installed in a location isolated from the system.

Open a terminal and type:

$ gem install asciidoctor

If you want to install a pre-release version (e.g., a release candidate), use:

To upgrade the gem, specify the new version in the Gemfile and run bundle again.
Using bundle update (without specifying a gem) is not recommended as it will also update other gems, which may not be the desired result.

Upgrade

If you installed Asciidoctor using a package manager, your operating system is probably configured to automatically update packages, in which case you don’t need to update the gem manually.

apk (Alpine Linux)

To upgrade the gem, use:

$ sudo apk add -u asciidoctor

APT

To upgrade the gem, use:

$ sudo apt-get upgrade -y asciidoctor

DNF

To upgrade the gem, use:

$ sudo dnf update -y asciidoctor

Homebrew (macOS)

To upgrade the gem, use:

$ brew update
$ brew upgrade asciidoctor

gem install

If you previously installed Asciidoctor using the gem command, you’ll need to manually upgrade Asciidoctor when a new version is released.
You can upgrade the gem by typing:

$ gem install asciidoctor

When you install a new version of the gem using gem install, you end up with multiple versions installed.
Use the following command to remove the old versions:

$ gem cleanup asciidoctor

Usage

If the Asciidoctor gem installed successfully, the asciidoctor command line interface (CLI) will be available on your PATH.
To verify it’s available, run the following in your terminal:

$ asciidoctor --version

You should see information about the Asciidoctor version and your Ruby environment printed in the terminal.

Asciidoctor also provides an API.
The API is intended for integration with other Ruby software, such as Rails, Sinatra and GitHub, and other languages, such as Java (via AsciidoctorJ) and JavaScript (via Asciidoctor.js).

Command line interface (CLI)

The asciidoctor command allows you to invoke Asciidoctor from the command line (i.e., a terminal).

The following command converts the file README.adoc to HTML and saves the result to the file README.html in the same directory.
The name of the generated HTML file is derived from the source file by changing its file extension to .html.

$ asciidoctor README.adoc

You can control the Asciidoctor processor by adding various flags and switches, which you can learn about using:

$ asciidoctor --help

For instance, to write the file to a different directory, use:

$ asciidoctor -D output README.adoc

The asciidoctorman page provides a complete reference of the command line interface.

Refer to the following resources to learn more about how to use the asciidoctor command.

Ruby API

To use Asciidoctor in your application, you first need to require the gem:

require'asciidoctor'

You can then convert an AsciiDoc source file to an HTML file using:

Asciidoctor.convert_file 'README.adoc', to_file:true, safe::safe

⚠️

When using Asciidoctor via the API, the default safe mode is :secure.
In secure mode, several core features are disabled, including the include directive.
If you want to enable these features, you’ll need to explicitly set the safe mode to :server (recommended) or :safe.

You can also convert an AsciiDoc string to embeddable HTML (for inserting in an HTML page) using:

content ='_Zen_ in the art of writing https://asciidoctor.org[AsciiDoc].'Asciidoctor.convert content, safe::safe

If you want the full HTML document, enable the header_footer option as follows:

Keep in mind that if you don’t like the output Asciidoctor produces, you can change it!
Asciidoctor supports custom converters that can handle converting from the parsed document to the generated output.

One easy way to customize the output piecemeal is by using the template converter.
The template converter allows you to supply a Tilt-supported template file to handle converting any node in the document.

However you go about it, you can have 100% control over the output.
For more information about how to use the API or to customize the output, refer to the user manual.

Contributing

New contributors are always welcome!
If you discover errors or omissions in the source code, documentation, or website content, please don’t hesitate to submit an issue or open a pull request with a fix.

The Contributing guide provides information on how to create, style, and submit issues, feature requests, code, and documentation to the Asciidoctor Project.

Getting Help

Asciidoctor is developed to help you easily write and publish your content.
But we can’t do it without your feedback!
We encourage you to ask questions and discuss any aspects of the project on the discussion list, on Twitter or in the chat room.