1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
|
= Asciidoctor
Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>
v2.0.22, 2024-03-08
// settings:
:idprefix:
:idseparator: -
:source-language: ruby
:language: {source-language}
ifndef::env-github[:icons: font]
ifdef::env-github[]
:status:
:caution-caption: :fire:
:important-caption: :exclamation:
:note-caption: :paperclip:
:tip-caption: :bulb:
:warning-caption: :warning:
endif::[]
// Variables:
:release-version: 2.0.22
// URLs:
:url-org: https://github.com/asciidoctor
:url-repo: {url-org}/asciidoctor
:url-asciidoctorj: {url-org}/asciidoctorj
:url-asciidoctorjs: {url-org}/asciidoctor.js
:url-gradle-plugin: {url-org}/asciidoctor-gradle-plugin
:url-maven-plugin: {url-org}/asciidoctor-maven-plugin
:url-asciidoclet: {url-org}/asciidoclet
:url-project: https://asciidoctor.org
ifdef::env-site[:url-project: link:]
:url-docs: https://docs.asciidoctor.org
:url-news: {url-project}/news
:url-manpage: {url-project}/man/asciidoctor
:url-issues: {url-repo}/issues
:url-contributors: {url-repo}/graphs/contributors
:url-rel-file-base: link:
:url-rel-tree-base: link:
ifdef::env-site,env-yard[]
:url-rel-file-base: {url-repo}/blob/HEAD/
:url-rel-tree-base: {url-repo}/tree/HEAD/
endif::[]
:url-changelog: {url-rel-file-base}CHANGELOG.adoc
:url-contribute: {url-rel-file-base}CONTRIBUTING.adoc
:url-license: {url-rel-file-base}LICENSE
:url-tests: {url-rel-tree-base}test
:url-discuss: https://discuss.asciidoctor.org
:url-chat: https://asciidoctor.zulipchat.com
:url-rubygem: https://rubygems.org/gems/asciidoctor
:url-what-is-asciidoc: {url-docs}/asciidoctor/latest/#relationship-to-asciidoc
:url-install-docker: https://github.com/asciidoctor/docker-asciidoctor
:url-opal: https://opalrb.com
:url-tilt: https://github.com/rtomayko/tilt
:url-ruby: https://www.ruby-lang.org
// images:
:image-url-screenshot: https://cdn.jsdelivr.net/gh/asciidoctor/asciidoctor/screenshot.png
{url-project}[Asciidoctor] is a fast, open source, Ruby-based text processor for parsing AsciiDoc(R) into a document model and converting it to output formats such as HTML 5, DocBook 5, manual pages, PDF, EPUB 3, and other formats.
Asciidoctor also has an ecosystem of extensions, converters, build plugins, and tools to help you author and publish content written in {url-what-is-asciidoc}[AsciiDoc].
You can find the documentation for these projects at {url-docs}.
In addition to running on Ruby, Asciidoctor can be executed on a JVM using {url-asciidoctorj}[AsciidoctorJ] or in any JavaScript environment using {url-asciidoctorjs}[Asciidoctor.js].
ifndef::env-site,env-yard[]
This document is also available in the following languages: +
{url-rel-file-base}README-zh_CN.adoc[汉语]
|
{url-rel-file-base}README-de.adoc[Deutsch]
|
{url-rel-file-base}README-fr.adoc[Français]
|
{url-rel-file-base}README-jp.adoc[日本語]
endif::[]
.Key documentation
[.compact]
* {url-docs}/asciidoctor/latest/[Asciidoctor Documentation]
* {url-docs}/asciidoc/latest/[AsciiDoc Language Documentation]
* {url-docs}/asciidoc/latest/syntax-quick-reference/[AsciiDoc Syntax Quick Reference]
ifdef::status[]
image:https://img.shields.io/gem/v/asciidoctor.svg[Latest Release, link={url-rubygem}]
image:https://img.shields.io/badge/rubydoc.info-{release-version}-blue.svg[library (API) docs,link=https://www.rubydoc.info/gems/asciidoctor/{release-version}]
image:https://github.com/asciidoctor/asciidoctor/workflows/CI/badge.svg[Build Status (GitHub Actions),link={url-repo}/actions]
image:https://img.shields.io/badge/zulip-join_chat-brightgreen.svg[Project Chat (Zulip),link={url-chat}]
endif::[]
== Sponsors
We want to recognize our {url-project}/supporters[sponsors] for their commitment to improving the state of technical documentation by supporting this project.
Thank you sponsors!
Without your generous support, Asciidoctor would not be possible.
You can support this project by becoming a sponsor through https://opencollective.com/asciidoctor[OpenCollective].
== AsciiDoc Processing and Built-in Converters
AsciiDoc is the language. +
Asciidoctor is the processor.
Asciidoctor reads the AsciiDoc source, as shown in the panel on the left in the image below, and converts it to publishable formats, such as HTML 5, as shown rendered in the panel on the right.
image::{image-url-screenshot}[Preview of AsciiDoc source and corresponding rendered HTML]
Asciidoctor provides built-in {url-docs}/asciidoctor/latest/converters/[converters] for three output formats by default: {url-docs}/asciidoctor/latest/html-backend/[HTML 5], {url-docs}/asciidoctor/latest/docbook-backend/[DocBook 5], and {url-docs}/asciidoctor/latest/manpage-backend/[man page] (short for manual page).
Additional converters, such as PDF and EPUB 3, are provided by separate gems.
Asciidoctor also provides an out-of-the-box HTML experience complete with a {url-docs}/asciidoctor/latest/html-backend/default-stylesheet/[default stylesheet] and built-in integrations like Font Awesome (for icons), highlight.js, Rouge, and Pygments (for source highlighting), and MathJax (for STEM processing).
== Asciidoctor Ecosystem
Although Asciidoctor is written in Ruby, it does not mean you need Ruby to use it.
Asciidoctor can be executed on a JVM using {url-docs}/asciidoctorj/latest/[AsciidoctorJ] or in any JavaScript environment (including the browser) using {url-docs}/asciidoctor.js/latest/[Asciidoctor.js].
Installing an Asciidoctor processor is just the beginning of your publishing experience.
Asciidoctor gives you access to a ecosystem of extensions and tools, ranging from add-on converters, to extended syntax, to build plugins, to integrated writing and preview environments:
* {url-docs}/diagram-extension/latest/[Asciidoctor Diagram]
* {url-docs}/maven-tools/latest/[Maven plugin and site module]
* {url-gradle-plugin}[Gradle plugin]
* {url-docs}/asciidoclet/latest/[Asciidoclet]
* {url-docs}/reveal.js-converter/latest/[reveal.js converter]
* {url-docs}/epub3-converter/latest/[EPUB 3 converter]
* https://intellij-asciidoc-plugin.ahus1.de/docs[IntelliJ plugin]
* {url-docs}/asciidoctor/latest/tooling/#web-browser-add-ons-preview-only[web browser extensions]
* {url-org}[and more]
Asciidoctor is the successor to AsciiDoc.py.
If you're using AsciiDoc.py, see {url-docs}/asciidoctor/latest/migrate/asciidoc-py/[Migrate from AsciiDoc.py] to learn how to upgrade to Asciidoctor.
== Requirements
Asciidoctor works on Linux, macOS and Windows and requires one of the following implementations of {url-ruby}[Ruby]:
* CRuby (aka MRI) 2.3 - 3.3
* JRuby 9.1 - 9.4
* TruffleRuby (GraalVM)
[CAUTION]
====
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 overriding the default external and internal character encodings to `utf-8`.
You can do so by setting the `RUBYOPT` environment variable as follows:
RUBYOPT="-E utf-8:utf-8"
Once you make this change, all your Unicode headaches should be behind you.
If you're using an IDE like Eclipse, make sure you set the encoding to UTF-8 there as well.
Asciidoctor is optimized to work with UTF-8 as the default encoding.
====
== Installation
Asciidoctor is packaged and distributed to RubyGems.org as a RubyGem (aka gem) named {url-rubygem}[asciidoctor^].
The asciidoctor gem can be installed on all major operating systems using Ruby packaging tools (gem or bundle).
Asciidoctor is also distributed as a Docker image, as a package for numerous Linux distributions, and as a package for macOS (via Homebrew and MacPorts).
=== 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.
* https://pkgs.alpinelinux.org/packages?name=asciidoctor[Alpine Linux (asciidoctor)]
* https://www.archlinux.org/packages/?name=asciidoctor[Arch Linux (asciidoctor)]
* https://packages.debian.org/sid/asciidoctor[Debian (asciidoctor)]
* https://apps.fedoraproject.org/packages/rubygem-asciidoctor[Fedora (asciidoctor)]
* https://software.opensuse.org/package/rubygem-asciidoctor[OpenSUSE (rubygem-asciidoctor)]
* https://packages.ubuntu.com/search?keywords=asciidoctor[Ubuntu (asciidoctor)]
If you want to use a version of Asciidoctor that's newer than what is installed by the package manager, see the <<gem-install,gem installation instructions>>.
==== apk (Alpine Linux)
To install the gem on Alpine Linux, open a terminal and type:
$ sudo apk add asciidoctor
==== 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
=== macOS
==== Homebrew
You can use https://brew.sh[Homebrew], the macOS package manager, to install Asciidoctor.
If you don't have Homebrew on your computer, complete the https://brew.sh[installation instructions] 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.
==== MacPorts
You can also use https://www.macports.org[MacPorts], another package manager for macOS, to install Asciidoctor.
If you don't have MacPorts on your computer, complete the https://www.macports.org/install.php[installation instructions] first.
Once MacPorts is installed, you're ready to install the `asciidoctor` gem via the https://ports.macports.org/port/asciidoctor/[Asciidoctor port].
Open a terminal and type:
$ sudo port install asciidoctor
=== Windows
To use Asciidoctor with Windows, you have two options.
==== Chocolatey
When you already use https://chocolatey.org[chocolatey] on your machine, you can use:
[source]
----
choco install ruby
----
Then follow <<gem-install,gem installation instructions>>.
==== Rubyinstaller
Or you use the https://rubyinstaller.org/downloads/[Rubyinstaller], download the package for your Windows Version and after the installation go ahead with <<gem-install,gem installation instructions>>.
[#gem-install]
=== gem install
Before installing Asciidoctor using `gem install`, you should set up https://rvm.io[RVM] (or similar) 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, or any other gem for that matter.
When using RVM, gems are installed in a location isolated from the system.
(You should never use the gem command to install system-wide gems).
Once you've installed Ruby using RVM, and you have activated it using `rvm use 3.0`, open a terminal and type:
$ gem install asciidoctor
If you want to install a pre-release version (e.g., a release candidate), use:
$ gem install asciidoctor --pre
=== Docker
See {url-install-docker}[Installing Asciidoctor using Docker].
=== Bundler
. Create a Gemfile in the root folder of your project (or the current directory)
. Add the `asciidoctor` gem to your Gemfile as follows:
+
[source,subs=attributes+]
----
source 'https://rubygems.org'
gem 'asciidoctor'
# or specify the version explicitly
# gem 'asciidoctor', '{release-version}'
----
. Save the Gemfile
. Open a terminal and install the gem using:
$ bundle
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
=== MacPorts (macOS)
To upgrade the gem, use:
$ sudo port selfupdate
$ sudo port 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.
[.output,subs=attributes+]
....
Asciidoctor {release-version} [https://asciidoctor.org]
Runtime Environment (ruby 3.0.1p64 [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:UTF-8 ex:UTF-8)
....
=== 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 `asciidoctor` {url-manpage}[man 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.
* {url-docs}/asciidoctor/latest/cli/[Process AsciiDoc using the CLI]
* {url-docs}/asciidoctor/latest/cli/options/[CLI options]
=== Ruby API
Asciidoctor also provides an API.
The API is intended for integration with other Ruby software, such as Rails, GitHub, and GitLab, as well as other languages, such as Java (via AsciidoctorJ) and JavaScript (via Asciidoctor.js).
To use Asciidoctor in your application, you first need to require the gem:
[source]
require 'asciidoctor'
You can then convert an AsciiDoc source file to an HTML file using:
[source]
Asciidoctor.convert_file 'README.adoc', to_file: true, safe: :safe
WARNING: 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:
[source]
----
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:
[source]
----
content = '_Zen_ in the art of writing https://asciidoctor.org[AsciiDoc].'
html = Asciidoctor.convert content, header_footer: true, safe: :safe
----
If you need access to the parsed document, you can split the conversion into discrete steps:
[source]
----
content = '_Zen_ in the art of writing https://asciidoctor.org[AsciiDoc].'
document = Asciidoctor.load content, header_footer: true, safe: :safe
puts document.doctitle
html = document.convert
----
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 {url-tilt}[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, see:
* {url-docs}/asciidoctor/latest/api/[Process AsciiDoc using the API]
* {url-docs}/asciidoctor/latest/api/options/[API options]
* {url-docs}/asciidoctor/latest/safe-modes/[Safe modes]
== 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.
Here are some ways *you* can contribute:
* by using prerelease (alpha, beta or preview) versions
* by reporting bugs
* by suggesting new features
* by writing or editing documentation
* by writing code with tests -- _No patch is too small._
** fix typos
** add comments
** clean up inconsistent whitespace
** write tests!
* by refactoring code
* by fixing {url-issues}[issues]
* by reviewing patches
The {url-contribute}[Contributing] guide provides information on how to create, style, and submit issues, feature requests, code, and documentation to Asciidoctor.
== 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.
Chat (Zulip):: {url-chat}
Discussion list (Nabble):: {url-discuss}
Twitter:: Follow https://twitter.com/asciidoctor[@asciidoctor] or search for the https://twitter.com/search?f=tweets&q=%23asciidoctor[#asciidoctor] hashtag
ifdef::env-github[]
Further information and documentation about Asciidoctor can be found on the project's website.
{url-project}[Home] | {url-news}[News] | {url-docs}[Docs]
endif::[]
The Asciidoctor organization on GitHub hosts the project's source code, issue tracker, and sub-projects.
Source repository (git):: {url-repo}
Issue tracker:: {url-issues}
Asciidoctor organization on GitHub:: {url-org}
== Code of Conduct
The core Asciidoctor project is governed by the https://github.com/asciidoctor/.github/blob/HEAD/CODE-OF-CONDUCT.md[Code of Conduct] for the Asciidoctor community of projects.
By participating, you're agreeing to honor this code.
Let's work together to make this a welcoming, professional, inclusive, and safe environment for everyone.
== Versioning and Release Policy
This project adheres to semantic versioning (*major.minor.patch*).
Typically, patch releases are only made for the current minor release.
However, exceptions are made on a case-by-case basis to address security vulnerabilities and other high-priority issues.
== Copyright and License
Copyright (C) 2012-present Dan Allen, Sarah White, Ryan Waldron, and the individual contributors to Asciidoctor.
Use of this software is granted under the terms of the MIT License.
See the {url-license}[LICENSE] for the full license text.
== Authors
*Asciidoctor* is led by https://github.com/mojavelinux[Dan Allen] and https://github.com/graphitefriction[Sarah White] and has received contributions from {url-contributors}[many individuals] in Asciidoctor's awesome community.
The project was initiated in 2012 by https://github.com/erebor[Ryan Waldron] based on a prototype written by https://github.com/nickh[Nick Hengeveld] for the Git website.
*AsciiDoc.py* was started and maintained by Stuart Rackham from https://github.com/asciidoc-py/asciidoc-py2/blob/HEAD/CHANGELOG.txt[2002 to 2013] and has received contributions from many individuals in the https://github.com/asciidoc-py/asciidoc-py2/graphs/contributors[AsciiDoc.py community].
== Trademarks
AsciiDoc(R) and AsciiDoc Language(TM) are trademarks of the Eclipse Foundation, Inc.
ifndef::env-site[]
== Changelog
ifeval::[{safe-mode-level} < 20]
include::CHANGELOG.adoc[tag=compact,leveloffset=+1]
endif::[]
Refer to the {url-changelog}[CHANGELOG] for a complete list of changes in older releases.
endif::[]
|