asciidoctor 1.5.6.2 → 1.5.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of asciidoctor might be problematic. Click here for more details.

Files changed (112) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.adoc +330 -143
  3. data/README-fr.adoc +441 -0
  4. data/README-jp.adoc +418 -0
  5. data/README-zh_CN.adoc +430 -0
  6. data/README.adoc +454 -0
  7. data/Rakefile +57 -0
  8. data/asciidoctor.gemspec +7 -1
  9. data/data/locale/attributes-ar.adoc +22 -0
  10. data/data/locale/attributes-bg.adoc +22 -0
  11. data/data/locale/attributes-ca.adoc +22 -0
  12. data/data/locale/attributes-cs.adoc +22 -0
  13. data/data/locale/attributes-da.adoc +22 -0
  14. data/data/locale/attributes-de.adoc +22 -0
  15. data/data/locale/attributes-en.adoc +23 -0
  16. data/data/locale/attributes-es.adoc +22 -0
  17. data/data/locale/attributes-fa.adoc +22 -0
  18. data/data/locale/attributes-fi.adoc +22 -0
  19. data/data/locale/attributes-fr.adoc +22 -0
  20. data/data/locale/attributes-hu.adoc +22 -0
  21. data/data/locale/attributes-id.adoc +22 -0
  22. data/data/locale/attributes-it.adoc +22 -0
  23. data/data/locale/attributes-ja.adoc +22 -0
  24. data/data/locale/attributes-kr.adoc +22 -0
  25. data/data/locale/attributes-nb.adoc +22 -0
  26. data/data/locale/attributes-nl.adoc +22 -0
  27. data/data/locale/attributes-nn.adoc +22 -0
  28. data/data/locale/attributes-pl.adoc +22 -0
  29. data/data/locale/attributes-pt.adoc +22 -0
  30. data/data/locale/attributes-pt_BR.adoc +22 -0
  31. data/data/locale/attributes-ro.adoc +22 -0
  32. data/data/locale/attributes-ru.adoc +22 -0
  33. data/data/locale/attributes-sr.adoc +22 -0
  34. data/data/locale/attributes-sr_Latn.adoc +22 -0
  35. data/data/locale/attributes-tr.adoc +22 -0
  36. data/data/locale/attributes-uk.adoc +22 -0
  37. data/data/locale/attributes-zh_CN.adoc +22 -0
  38. data/data/locale/attributes-zh_TW.adoc +22 -0
  39. data/data/locale/attributes.adoc +8 -649
  40. data/data/stylesheets/asciidoctor-default.css +77 -72
  41. data/features/xref.feature +366 -7
  42. data/lib/asciidoctor.rb +107 -93
  43. data/lib/asciidoctor/abstract_block.rb +247 -239
  44. data/lib/asciidoctor/abstract_node.rb +56 -58
  45. data/lib/asciidoctor/block.rb +3 -3
  46. data/lib/asciidoctor/callouts.rb +1 -1
  47. data/lib/asciidoctor/cli/invoker.rb +36 -9
  48. data/lib/asciidoctor/cli/options.rb +63 -25
  49. data/lib/asciidoctor/converter.rb +23 -13
  50. data/lib/asciidoctor/converter/base.rb +4 -0
  51. data/lib/asciidoctor/converter/docbook45.rb +16 -9
  52. data/lib/asciidoctor/converter/docbook5.rb +115 -97
  53. data/lib/asciidoctor/converter/factory.rb +29 -31
  54. data/lib/asciidoctor/converter/html5.rb +229 -192
  55. data/lib/asciidoctor/converter/manpage.rb +72 -50
  56. data/lib/asciidoctor/converter/template.rb +12 -12
  57. data/lib/asciidoctor/core_ext.rb +5 -1
  58. data/lib/asciidoctor/core_ext/1.8.7/base64/strict_encode64.rb +6 -0
  59. data/lib/asciidoctor/document.rb +168 -77
  60. data/lib/asciidoctor/extensions.rb +79 -47
  61. data/lib/asciidoctor/helpers.rb +33 -11
  62. data/lib/asciidoctor/inline.rb +3 -2
  63. data/lib/asciidoctor/list.rb +2 -1
  64. data/lib/asciidoctor/logging.rb +122 -0
  65. data/lib/asciidoctor/parser.rb +406 -382
  66. data/lib/asciidoctor/path_resolver.rb +169 -162
  67. data/lib/asciidoctor/reader.rb +166 -121
  68. data/lib/asciidoctor/section.rb +45 -28
  69. data/lib/asciidoctor/stylesheets.rb +13 -5
  70. data/lib/asciidoctor/substitutors.rb +328 -254
  71. data/lib/asciidoctor/table.rb +105 -48
  72. data/lib/asciidoctor/timings.rb +34 -6
  73. data/lib/asciidoctor/version.rb +1 -1
  74. data/man/asciidoctor.1 +41 -23
  75. data/man/asciidoctor.adoc +14 -8
  76. data/test/api_test.rb +1004 -0
  77. data/test/attributes_test.rb +241 -50
  78. data/test/blocks_test.rb +549 -124
  79. data/test/converter_test.rb +170 -78
  80. data/test/document_test.rb +208 -767
  81. data/test/extensions_test.rb +188 -53
  82. data/test/fixtures/custom-backends/slim/html5/block_paragraph.html.slim +1 -1
  83. data/test/fixtures/custom-backends/slim/html5/block_sidebar.html.slim +1 -1
  84. data/test/fixtures/file-with-missing-include.adoc +1 -0
  85. data/test/fixtures/include-file.jsx +8 -0
  86. data/test/fixtures/lists.adoc +96 -0
  87. data/test/fixtures/other-chapters.adoc +11 -0
  88. data/test/fixtures/outer-include.adoc +5 -0
  89. data/test/fixtures/sample.asciidoc +5 -1
  90. data/test/fixtures/subdir/index.adoc +3 -0
  91. data/test/fixtures/subdir/inner-include.adoc +3 -0
  92. data/test/fixtures/subdir/middle-include.adoc +5 -0
  93. data/test/fixtures/tagged-class-enclosed.rb +0 -1
  94. data/test/fixtures/unclosed-tag.adoc +3 -0
  95. data/test/fixtures/unexpected-end-tag.adoc +4 -0
  96. data/test/invoker_test.rb +101 -40
  97. data/test/links_test.rb +266 -72
  98. data/test/lists_test.rb +243 -45
  99. data/test/logger_test.rb +211 -0
  100. data/test/manpage_test.rb +124 -6
  101. data/test/options_test.rb +46 -1
  102. data/test/paragraphs_test.rb +23 -10
  103. data/test/parser_test.rb +30 -1
  104. data/test/paths_test.rb +115 -33
  105. data/test/preamble_test.rb +1 -1
  106. data/test/reader_test.rb +337 -81
  107. data/test/sections_test.rb +656 -72
  108. data/test/substitutions_test.rb +182 -57
  109. data/test/tables_test.rb +324 -57
  110. data/test/test_helper.rb +77 -32
  111. data/test/text_test.rb +7 -7
  112. metadata +67 -3
@@ -0,0 +1,430 @@
1
+ = Asciidoctor
2
+ Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>; Ryan Waldron <https://github.com/erebor[@erebor]>
3
+ v1.5.7, 2018-05-02
4
+ // settings:
5
+ :page-layout: base
6
+ :idprefix:
7
+ :idseparator: -
8
+ :source-language: ruby
9
+ :language: {source-language}
10
+ ifndef::env-github[:icons: font]
11
+ ifdef::env-github[]
12
+ :status:
13
+ :outfilesuffix: .adoc
14
+ :caution-caption: :fire:
15
+ :important-caption: :exclamation:
16
+ :note-caption: :paperclip:
17
+ :tip-caption: :bulb:
18
+ :warning-caption: :warning:
19
+ endif::[]
20
+ // Variables:
21
+ :release-version: 1.5.7
22
+ // URIs:
23
+ :uri-org: https://github.com/asciidoctor
24
+ :uri-repo: {uri-org}/asciidoctor
25
+ :uri-asciidoctorj: {uri-org}/asciidoctorj
26
+ :uri-asciidoctorjs: {uri-org}/asciidoctor.js
27
+ :uri-project: http://asciidoctor.org
28
+ ifdef::env-site[:uri-project: link:]
29
+ :uri-docs: {uri-project}/docs
30
+ :uri-news: {uri-project}/news
31
+ :uri-manpage: {uri-project}/man/asciidoctor
32
+ :uri-issues: {uri-repo}/issues
33
+ :uri-contributors: {uri-repo}/graphs/contributors
34
+ :uri-rel-file-base: link:
35
+ :uri-rel-tree-base: link:
36
+ ifdef::env-site[]
37
+ :uri-rel-file-base: {uri-repo}/blob/master/
38
+ :uri-rel-tree-base: {uri-repo}/tree/master/
39
+ endif::[]
40
+ :uri-changelog: {uri-rel-file-base}CHANGELOG.adoc
41
+ :uri-contribute: {uri-rel-file-base}CONTRIBUTING.adoc
42
+ :uri-license: {uri-rel-file-base}LICENSE
43
+ :uri-tests: {uri-rel-tree-base}test
44
+ :uri-discuss: http://discuss.asciidoctor.org
45
+ :uri-irc: irc://irc.freenode.org/#asciidoctor
46
+ :uri-rubygem: https://rubygems.org/gems/asciidoctor
47
+ :uri-what-is-asciidoc: {uri-docs}/what-is-asciidoc
48
+ :uri-user-manual: {uri-docs}/user-manual
49
+ :uri-install-docker: https://github.com/asciidoctor/docker-asciidoctor
50
+ //:uri-install-doc: {uri-docs}/install-toolchain
51
+ :uri-install-osx-doc: {uri-docs}/install-asciidoctor-macosx
52
+ :uri-render-doc: {uri-docs}/render-documents
53
+ :uri-themes-doc: {uri-docs}/produce-custom-themes-using-asciidoctor-stylesheet-factory
54
+ :uri-gitscm-repo: https://github.com/git/git-scm.com
55
+ :uri-prototype: {uri-gitscm-repo}/commits/master/lib/asciidoc.rb
56
+ :uri-freesoftware: https://www.gnu.org/philosophy/free-sw.html
57
+ :uri-foundation: http://foundation.zurb.com
58
+ :uri-tilt: https://github.com/rtomayko/tilt
59
+ :uri-ruby: https://ruby-lang.org
60
+ // images:
61
+ :image-uri-screenshot: https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/screenshot.png
62
+
63
+ {uri-project}/[Asciidoctor] 是一个 _快速_ 文本处理器和发布工具链,它可以将 {uri-what-is-asciidoc}[AsciiDoc] 文档转化成 HTML5、 DocBook 5 (或 4.5) 以及其他格式。
64
+ Asciidoctor 由 Ruby 编写,打包成 RubyGem,然后发布到 {uri-rubygem}[RubyGems.org] 上。
65
+ 这个 gem 还被包含道几个 Linux 发行版中,其中包括 Fedora、Debian 和 Ubuntu。
66
+ Asciidoctor 是开源的,{uri-repo}[代码]托管在 GitHub,遵从 {uri-license}[MIT] 协议。
67
+
68
+ 该文档有如下语言的翻译版:
69
+
70
+ * {uri-rel-file-base}README.adoc[English]
71
+ * {uri-rel-file-base}README-fr.adoc[Français]
72
+ * {uri-rel-file-base}README-jp.adoc[日本語]
73
+
74
+ .关键文档
75
+ [.compact]
76
+ * {uri-docs}/what-is-asciidoc[Asciidoctor 是什么?]
77
+ * {uri-docs}/asciidoc-writers-guide[AsciiDoc 写作指南]
78
+ * {uri-docs}/asciidoc-syntax-quick-reference[AsciiDoc 语法快速参考]
79
+ * {uri-docs}/user-manual[Asciidoctor 用户手册]
80
+
81
+ .Ruby 所至, Asciidoctor 相随
82
+ ****
83
+ 使用 JRuby 让 Asciidoctor 运行在 Java 虚拟机上。
84
+ 使用 {uri-asciidoctorj}[AsciidoctorJ] 直接调用 Asciidoctor 的 API 运行在 Java 或者其他 Java 虚拟机中。
85
+ 基于 AsciidoctorJ 有好多插件可用,这些插件可以将 Asciidoctor 整合到 Apache Maven,Gradle 或 Javadoc 构建中。
86
+
87
+ Asciidoctor 也可以运行在 JavaScript 上。
88
+ 我们可以使用 http://opalrb.org[Opal] 将 Ruby 源码编译成 JavaScript 生成 {uri-asciidoctorjs}[Asciidoctor.js] 文件,这是一个全功能版的 Asciidoctor,可以运行在任意的 JavaScript 环境中,比如 Web 浏览器 或 Node.js。
89
+ Asciidoctor.js 被用于预览 AsciiDoc,支持 Chrome 扩展,Atom,Brackets 或其他基于 Web 的工具。
90
+ ****
91
+
92
+ ifdef::status[]
93
+ .*Project health*
94
+ image:https://img.shields.io/travis/asciidoctor/asciidoctor/master.svg[Build Status (Travis CI), link=https://travis-ci.org/asciidoctor/asciidoctor]
95
+ image:https://ci.appveyor.com/api/projects/status/ifplu67oxvgn6ceq/branch/master?svg=true&amp;passingText=green%20bar&amp;failingText=%23fail&amp;pendingText=building%2E%2E%2E[Build Status (AppVeyor), link=https://ci.appveyor.com/project/asciidoctor/asciidoctor]
96
+ //image:https://img.shields.io/coveralls/asciidoctor/asciidoctor/master.svg[Coverage Status, link=https://coveralls.io/r/asciidoctor/asciidoctor]
97
+ //image:https://codeclimate.com/github/asciidoctor/asciidoctor/badges/gpa.svg[Code Climate, link="https://codeclimate.com/github/asciidoctor/asciidoctor"]
98
+ image:https://inch-ci.org/github/asciidoctor/asciidoctor.svg?branch=master[Inline docs, link="https://inch-ci.org/github/asciidoctor/asciidoctor"]
99
+ endif::[]
100
+
101
+ [#the-big-picture]
102
+ == 整体概况
103
+
104
+ Asciidoctor 以纯文本格式读取内容,见下图左边的面板,并将它转换成 HTML5 呈现在右侧面板中。
105
+ Asciidoctor 将默认的样式表应用到 HTML5 文档上,提供一个愉快的开箱即用的体验。
106
+
107
+ image::{image-uri-screenshot}[AsciiDoc 源文预览和相应的 HTML 渲染]
108
+
109
+ [#asciidoc-processing]
110
+ == AsciiDoc Processing
111
+
112
+ Asciidoctor 会读取并处理用 AsciiDoc 语法写的文件,然后将解析出来的解析树参数交给内置的转化器去生成 HTML5,DocBook 5 (或 4.5) 或帮助手册页面输出。
113
+ 你可以选择使用你自己的转化器或者加载 {uri-tilt}[Tilt] - 支持通过模板来自定义输出或产生附加的格式。
114
+
115
+ NOTE: Asciidoctor是为了直接替换原 AsciiDoc Python 处理器(`asciidoc.py`)。
116
+ Asciidoctor 测试套件含有 {uri-tests}[> 1,600 测试示例] 来确保和 AsciiDoc 语法的兼容性。
117
+
118
+ 除了传统的 AsciiDoc 语法,Asciidoctor 还添加额外的标记和格式设置选项,例如 font-based 图标(例如: `+icon:fire[]+`)和 UI 元素(例如: `+button:[Save]+`)。
119
+ Asciidoctor 还提供了一个基于 {uri-foundation}[Foundation] 的现代化的、响应式主题来美化 HTML5 输出。
120
+
121
+ [#requirements]
122
+ == 要求
123
+
124
+ Asciidoctor 可以运行在 Linux,OSX (Mac) 和 Windows 系统,但需要安装下面任意一个 {uri-ruby}[Ruby] 环境去实现:
125
+
126
+ * MRI (Ruby 1.8.7, 1.9.3, 2.0, 2.1, 2.2 & 2.3)
127
+ * JRuby (1.7 in Ruby 1.8 and 1.9 modes, 9000)
128
+ * Rubinius 2.2.x
129
+ * Opal (JavaScript)
130
+
131
+ 我们欢迎你来帮助在这些以及其他平台测试 Asciidoctor。
132
+
133
+ 请参考 <<{idprefix}contributing,Contributing>> 来了解如何参与。
134
+
135
+ [CAUTION]
136
+ ====
137
+ 如果在非英语的 Windows 环境,当你去调用 Asciidoctor 时,可能会碰到 `Encoding::UndefinedConversionError` 的错误提示。
138
+ 为了解决这个问题,我们建议将控制台的编码更改为 UTF-8:
139
+
140
+ chcp 65001
141
+
142
+ 一旦你做了这个改变,所有的编码问题,都将迎刃而解。
143
+ 如果你使用的是像 Eclipse 这样的 IDE 集成开发工具,你也需要确保他被你设置为 UTF-8 编码。
144
+ 使用 UTF-8 能使 Asciidoctor 在任何地方都能正常工作。
145
+ ====
146
+
147
+ [#installation]
148
+ == 安装
149
+
150
+ Asciidoctor 可以通过三种方式安装(a)`gem install` 命令;(b)Bundler打包编译;(c)流行的 Linux 发行版的包管理器
151
+
152
+ TIP: 使用 Linux 包管理器安装的好处是如果你机器在之前没有安装 Ruby 和 RubyGems 库,当你选择这种方式安装时它们会一并安装上去。
153
+ 不利的是在 gem 发布之后,这类安装包并不是立即可用。
154
+ 如果你需要安装最新版,你应该总是优先使用 `gem` 命令安装。
155
+
156
+ [#a-gem-install]
157
+ === (a) gem 安装
158
+
159
+ 打开一个终端输入如下命令(不含开头的 `$`):
160
+
161
+ $ gem install asciidoctor
162
+
163
+ 如果想安装一个预览版(比如:候选发布版),请使用:
164
+
165
+ $ gem install asciidoctor --pre
166
+
167
+ .升级
168
+ [TIP]
169
+ ====
170
+ 如果你安装有的是旧版本 Asciidoctor,你可以使用下面的命令来升级:
171
+
172
+ $ gem update asciidoctor
173
+
174
+ 如果使用 `gem install` 命令来安装一个新版本的 gem 来代替升级,会安装多个版本。
175
+ 这种情况,你可以使用下面的 gem 命令来移除旧版本:
176
+
177
+ $ gem cleanup asciidoctor
178
+ ====
179
+
180
+ [#b-bundler]
181
+ === (b) Bundler
182
+
183
+ . 在项目的根目录(或者当前路径),创建一个 `Gemfile` 文件;
184
+ . 在这个文件中添加 `asciidoctor` gem 如下:
185
+ +
186
+ [source,subs=attributes+]
187
+ ----
188
+ source 'https://rubygems.org'
189
+ gem 'asciidoctor'
190
+ # 或者明确指明版本
191
+ # gem 'asciidoctor', '{release-version}'
192
+ ----
193
+
194
+ . 保存 `Gemfile` 文件
195
+ . 打开终端,使用如下命令安装 gem:
196
+
197
+ $ bundle
198
+
199
+ 要升级 gem 的话,在 `Gemfile` 文件中,指明新版本,然后再次运行 `bundle` 即可。
200
+ *不推荐* 直接使用 `bundle update` 命令,因为它还会升级其他 gem,也许会造成不可预料的结果。
201
+
202
+ [#c-linux-package-managers]
203
+ === (c) Linux 包管理
204
+
205
+ [#dnf-fedora-21-or-greater]
206
+ ==== DNF (Fedora 21 或更高版本)
207
+
208
+ 在 Fedora 21 或更高版本中安装这个 gem,可以使用 dnf。打开终端并输入如下命令:
209
+
210
+ $ sudo dnf install -y asciidoctor
211
+
212
+ 升级则使用:
213
+
214
+ $ sudo dnf update -y asciidoctor
215
+
216
+ TIP: 如果你的 Fedora 系统配置的是自动升级包,在这种情况下,不需要你亲自动手升级。
217
+
218
+ [#apt-get-debian-ubuntu-mint]
219
+ ==== apt-get (Debian, Ubuntu, Mint)
220
+
221
+ 在 Debian,Ubuntu 或 Mint 中安装这个 gem,请打开终端并输入如下命令:
222
+
223
+ $ sudo apt-get install -y asciidoctor
224
+
225
+ 升级则使用:
226
+
227
+ $ sudo apt-get upgrade -y asciidoctor
228
+
229
+ TIP: 如果你的 Debian 或 Ubuntu 系统配置的是自动升级包,在这种情况下,不需要你亲自动手升级。
230
+
231
+ 使用包管理器( apt-get )安装的 Asciidoctor 的版本也许不是最新发布版。
232
+ 请查看发行版的包库,来确定每个发行版是打包的哪个版本。
233
+
234
+ * https://packages.debian.org/search?keywords=asciidoctor&searchon=names&exact=1&suite=all&section=all[Debian 发行版中的 asciidoctor]
235
+ * http://packages.ubuntu.com/search?keywords=asciidoctor&searchon=names&exact=1&suite=all&section=all[Ubuntu 发行版中的 asciidoctor]
236
+ * https://community.linuxmint.com/software/view/asciidoctor[Mint 发行版中的 asciidoctor]
237
+
238
+ [CAUTION]
239
+ ====
240
+ 我们建议不要使用 `gem update` 来升级包管理的 gem。
241
+ 这样做会使系统进入不一致的状态,包管理工具将不再跟踪相关文件(通常安装在 /usr/local 下。)
242
+ 简单地说,系统的 gem 只能由包管理器进行管理。
243
+
244
+ 如果你想使用一个比包管理器安装的更新版本的 Asciidoctor,你应该使用 http://rvm.io[RVM] 在你的用户家目录(比如:用户空间)下安装 Ruby。
245
+ 然后,你就可以放心地使用 `gem` 命令来安装或者更新 Asciidoctor gem。
246
+ 当使用 RVM 时,gem 将被安装到与系统隔离的位置。
247
+ ====
248
+
249
+ [#apk-alpine-linux]
250
+ ==== apk (Alpine Linux)
251
+
252
+ 在 Alpine Linux 中安装这个 gem,请打开终端并输入如下命令:
253
+
254
+ $ sudo apk add asciidoctor
255
+
256
+ 升级则使用:
257
+
258
+ $ sudo apk add -u asciidoctor
259
+
260
+ TIP: 如果你的 Alpine Linux 系统配置的是自动升级包,在这种情况下,不需要你亲自动手升级。
261
+
262
+ [#other-installation-options]
263
+ === 其他安装选项
264
+
265
+ * {uri-install-docker}[使用 Docker 安装 Asciidoctor ]
266
+ * {uri-install-osx-doc}[在 Mac OS X 安装 Asciidoctor ]
267
+
268
+ [#usage]
269
+ == 使用
270
+
271
+ 如果成功安装 Asciidoctor,则在可执行程序路径中,`asciidoctor` 就可用了。
272
+ 为了验证它的可用性,你可以在终端中执行如下命令:
273
+
274
+ $ asciidoctor --version
275
+
276
+ 你应该看到关于 Asciidoctor 和 Ruby 环境信息将打印到你的终端上。
277
+
278
+ [.output,subs=attributes+]
279
+ ....
280
+ Asciidoctor {release-version} [http://asciidoctor.org]
281
+ Runtime Environment (ruby 2.4.1p111 [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:- ex:UTF-8)
282
+ ....
283
+
284
+ Asciidoctor 还提供了一套 API。
285
+ 这套 API 是为了整合其他的 Ruby 软件,例如 Rails、Sinatra、Github,甚至其他语言,比如 Java (通过 {uri-asciidoctorj}[AsciidoctorJ]) 和 JavaScript (通过 {uri-asciidoctorjs}[Asciidoctor.js])。
286
+
287
+ [#command-line-interface-cli]
288
+ === 命令行(CLI)
289
+
290
+ `asciidoctor` 命令可以让你通过命令行(比如:终端)来调用 Asciidoctor。
291
+
292
+ 下面的命令将 README.adoc 文件转化为 HTML,并且保存到同一目录下的 README.html 文件中。
293
+ 生成的 HTML 文件名源自源文件名,只是将其扩展名改为了 `.html`。
294
+
295
+ $ asciidoctor README.adoc
296
+
297
+ 您可以通过添加各种标志和开关控制 Asciidoctor 处理器,通过下面的命令你可以学习它的更多用法:
298
+
299
+ $ asciidoctor --help
300
+
301
+ 比如,将文件写入到不同路径里,使用如下命令:
302
+
303
+ $ asciidoctor -D output README.adoc
304
+
305
+ `asciidoctor` {uri-manpage}[帮助页面] 提供了这个命令的完整参考。
306
+
307
+ 点击下面的资源,学习更多关于 `asciidoctor` 命令的用法。
308
+
309
+ * {uri-render-doc}[如何转化文档?]
310
+ * {uri-themes-doc}[如何使用 Asciidoctor 样式工厂来创建自定义主题?]
311
+
312
+ [#ruby-api]
313
+ === Ruby API
314
+
315
+ 为了在你应用中使用 Asciidoctor,首先需要引入这个 gem:
316
+
317
+ [source]
318
+ require 'asciidoctor'
319
+
320
+ 然后,你可以通过下面的代码将 AsciiDoc 源文件转化成一个 HTML 文件:
321
+
322
+ [source]
323
+ Asciidoctor.convert_file 'README.adoc', to_file: true, safe: :safe
324
+
325
+ WARNING: 当你通过 API 使用 Asciidoctor 时,默认的安全模式是 `:secure`。
326
+ 在 secure 模式下,很多核心特性将不可用,包括 `include` 特性。
327
+ 如果你想启用这些特性,你需要明确设置安全模式为 `:server` (推荐)或 `:safe`。
328
+
329
+ 你也可以将 AsciiDoc 字符串转化我内嵌的 HTML (为了插入到一个 HTML 页面),用法如下:
330
+
331
+ [source]
332
+ ----
333
+ content = '_Zen_ in the art of writing http://asciidoctor.org[AsciiDoc].'
334
+ Asciidoctor.convert content, safe: :safe
335
+ ----
336
+
337
+ 如果你想得到完整的 HTML 文档,只需要启用 `header_footer` 选项即可。如下:
338
+
339
+ [source]
340
+ ----
341
+ content = '_Zen_ in the art of writing http://asciidoctor.org[AsciiDoc].'
342
+ html = Asciidoctor.convert content, header_footer: true, safe: :safe
343
+ ----
344
+
345
+ 如果你想访问已经处理过的文档,可以将转化过程拆分成离散的几步:
346
+
347
+ [source]
348
+ ----
349
+ content = '_Zen_ in the art of writing http://asciidoctor.org[AsciiDoc].'
350
+ document = Asciidoctor.load content, header_footer: true, safe: :safe
351
+ puts document.doctitle
352
+ html = document.convert
353
+ ----
354
+
355
+ 请注意:如果你不喜欢 Asciidoctor 输出结果,_你完全可以改变它。_
356
+ Asciidoctor 支持自定义转化器,它可以操作从待处理文件到生成文档整个环节。
357
+
358
+ 一个简单的、细微地自定义输出的方式是使用模板转化器。
359
+ 模板转化器运行你提供一个 {uri-tilt}[Tilt] 模板,这样通过模板文件来操作转化出的文档的每个节点。
360
+
361
+ 这样,你就 _可以_ 百分之百地控制你的输出。
362
+ 关于更多关于 API 或自定义输出信息,请参考 {uri-user-manual}[用户帮助手册]。
363
+
364
+ [#contributing]
365
+ == 贡献
366
+
367
+ 自由软件的精神鼓励 _每个人_ 来帮助改善这个项目。
368
+ 如果你在源码、文档或网站内容中发现错误或漏洞,请不要犹豫,提交一个议题或者推送一个修复请求。
369
+ 随时欢迎新的贡献者!
370
+
371
+ 这里有几种 *你* 可以做出贡献的方式:
372
+
373
+ * 使用预发布版本(alpha, beta 或 preview)
374
+ * 报告 Bug
375
+ * 提议新功能
376
+ * 编写文档
377
+ * 编写规范
378
+ * 编写 -- _任何补丁都不小。_
379
+ ** 修正错别字
380
+ ** 添加评论
381
+ ** 清理多余空白
382
+ ** 编写测试!
383
+ * 重构代码
384
+ * 修复 {uri-issues}[issues]
385
+ * 审查补丁
386
+
387
+ {uri-contribute}[贡献指南]提供了如何提供贡献,包括如何创建、修饰和提交问题、特性、需求、代码和文档给 Asciidoctor 项目。
388
+
389
+ [#getting-help]
390
+ == 获得帮助
391
+
392
+ 开发 Asciidoctor 项目是未来了帮助你更容易地书写和发布你的内容。
393
+ 但是,如果没有反馈,我们将寸步难行。
394
+ 我们鼓励你在讨论组、Twitter或聊天室里,提问为题,讨论项目的方方面面,
395
+
396
+ 讨论组 (Nabble):: {uri-discuss}
397
+ Twitter:: https://twitter.com/search?f=tweets&q=%23asciidoctor[#asciidoctor] 来加入话题 或 https://twitter.com/asciidoctor[@asciidoctor] at并提醒我们
398
+ 聊天 (Gitter):: image:https://badges.gitter.im/Join%20In.svg[Gitter, link=https://gitter.im/asciidoctor/asciidoctor]
399
+
400
+ ifdef::env-github[]
401
+ Further information and documentation about Asciidoctor can be found on the project's website.
402
+
403
+ {uri-project}/[Home] | {uri-news}[News] | {uri-docs}[Docs]
404
+ endif::[]
405
+
406
+ Asciidoctor 组织在 Github 托管代码、议案跟踪和相关子项目。
407
+
408
+ 代码库 (git):: {uri-repo}
409
+ 议案跟踪:: {uri-issues}
410
+ 在 GitHub 的 Asciidoctor 组织:: {uri-org}
411
+
412
+ [#copyright-and-licensing]
413
+ == 版权和协议
414
+
415
+ Copyright (C) 2012-2018 Dan Allen, Ryan Waldron and the Asciidoctor Project.
416
+ 这个软件的免费使用是在MIT许可条款授予的。
417
+
418
+ 请看 {uri-license}[版权声明] 文件来获取更多详细信息。
419
+
420
+ [#authors]
421
+ == 作者
422
+
423
+ *Asciidoctor* 由 https://github.com/mojavelinux[Dan Allen] 和 https://github.com/graphitefriction[Sarah White] 领导,并从 Asciidoctor 社区的 {uri-contributors}[很多其他独立开发者] 上收到了很多贡献。
424
+ 项目最初由 https://github.com/erebor[Ryan Waldron] 于 2012年基于 https://github.com/nickh[Nick Hengeveld] 的 {uri-prototype}[原型] 创建。
425
+
426
+ *AsciiDoc* 由 Stuart Rackham 启动,并从 AsciiDoc 社区的其他独立开发者上收到很多贡献。
427
+
428
+ == Changelog
429
+
430
+ 请看 {uri-changelog}[CHANGELOG]。
@@ -0,0 +1,454 @@
1
+ = Asciidoctor
2
+ Dan Allen <https://github.com/mojavelinux[@mojavelinux]>; Sarah White <https://github.com/graphitefriction[@graphitefriction]>; Ryan Waldron <https://github.com/erebor[@erebor]>
3
+ v1.5.7, 2018-05-02
4
+ // settings:
5
+ :idprefix:
6
+ :idseparator: -
7
+ :source-language: ruby
8
+ :language: {source-language}
9
+ ifndef::env-github[:icons: font]
10
+ ifdef::env-github[]
11
+ :status:
12
+ :outfilesuffix: .adoc
13
+ :caution-caption: :fire:
14
+ :important-caption: :exclamation:
15
+ :note-caption: :paperclip:
16
+ :tip-caption: :bulb:
17
+ :warning-caption: :warning:
18
+ endif::[]
19
+ // Variables:
20
+ :release-version: 1.5.7
21
+ // URIs:
22
+ :uri-org: https://github.com/asciidoctor
23
+ :uri-repo: {uri-org}/asciidoctor
24
+ :uri-asciidoctorj: {uri-org}/asciidoctorj
25
+ :uri-asciidoctorjs: {uri-org}/asciidoctor.js
26
+ :uri-project: https://asciidoctor.org
27
+ ifdef::env-site[:uri-project: link:]
28
+ :uri-docs: {uri-project}/docs
29
+ :uri-news: {uri-project}/news
30
+ :uri-manpage: {uri-project}/man/asciidoctor
31
+ :uri-issues: {uri-repo}/issues
32
+ :uri-contributors: {uri-repo}/graphs/contributors
33
+ :uri-rel-file-base: link:
34
+ :uri-rel-tree-base: link:
35
+ ifdef::env-site[]
36
+ :uri-rel-file-base: {uri-repo}/blob/master/
37
+ :uri-rel-tree-base: {uri-repo}/tree/master/
38
+ endif::[]
39
+ :uri-changelog: {uri-rel-file-base}CHANGELOG.adoc
40
+ :uri-contribute: {uri-rel-file-base}CONTRIBUTING.adoc
41
+ :uri-license: {uri-rel-file-base}LICENSE
42
+ :uri-tests: {uri-rel-tree-base}test
43
+ :uri-discuss: http://discuss.asciidoctor.org
44
+ :uri-irc: irc://irc.freenode.org/#asciidoctor
45
+ :uri-rubygem: https://rubygems.org/gems/asciidoctor
46
+ :uri-what-is-asciidoc: {uri-docs}/what-is-asciidoc
47
+ :uri-user-manual: {uri-docs}/user-manual
48
+ :uri-install-docker: https://github.com/asciidoctor/docker-asciidoctor
49
+ //:uri-install-doc: {uri-docs}/install-toolchain
50
+ :uri-install-macos-doc: {uri-docs}/install-asciidoctor-macos
51
+ :uri-render-doc: {uri-docs}/render-documents
52
+ :uri-themes-doc: {uri-docs}/produce-custom-themes-using-asciidoctor-stylesheet-factory
53
+ :uri-gitscm-repo: https://github.com/git/git-scm.com
54
+ :uri-prototype: {uri-gitscm-repo}/commits/master/lib/asciidoc.rb
55
+ :uri-freesoftware: https://www.gnu.org/philosophy/free-sw.html
56
+ :uri-foundation: https://foundation.zurb.com
57
+ :uri-tilt: https://github.com/rtomayko/tilt
58
+ :uri-ruby: https://www.ruby-lang.org
59
+ // images:
60
+ :image-uri-screenshot: https://raw.githubusercontent.com/asciidoctor/asciidoctor/master/screenshot.png
61
+
62
+ {uri-project}[Asciidoctor] is a _fast_ text processor and publishing toolchain for converting {uri-what-is-asciidoc}[AsciiDoc] content to HTML5, DocBook, PDF, and other formats.
63
+ Asciidoctor is written in Ruby, packaged and distributed as a gem to {uri-rubygem}[RubyGems.org], and packaged for popular Linux distributions, including Fedora, Debian, Ubuntu, and Alpine.
64
+ Asciidoctor can be run on the JVM using AsciidoctorJ and in all JavaScript environments using Asciidoctor.js.
65
+ Asciidoctor is {uri-license}[open source software] and {uri-repo}[hosted on GitHub].
66
+
67
+ ifndef::env-site[]
68
+ This document is also available in the following languages: +
69
+ {uri-rel-file-base}README-zh_CN.adoc[汉语]
70
+ |
71
+ {uri-rel-file-base}README-fr.adoc[Français]
72
+ |
73
+ {uri-rel-file-base}README-jp.adoc[日本語]
74
+ endif::[]
75
+
76
+ .Key documentation
77
+ [.compact]
78
+ * {uri-docs}/what-is-asciidoc[What is AsciiDoc?]
79
+ * {uri-docs}/asciidoc-writers-guide[AsciiDoc Writer's Guide]
80
+ * {uri-docs}/user-manual[Asciidoctor User Manual]
81
+ * {uri-docs}/asciidoc-syntax-quick-reference[AsciiDoc Syntax Reference]
82
+
83
+ ifdef::status[]
84
+ .*Project health*
85
+ image:https://img.shields.io/travis/asciidoctor/asciidoctor/master.svg[Build Status (Travis CI), link=https://travis-ci.org/asciidoctor/asciidoctor]
86
+ image:https://ci.appveyor.com/api/projects/status/ifplu67oxvgn6ceq/branch/master?svg=true&amp;passingText=green%20bar&amp;failingText=%23fail&amp;pendingText=building%2E%2E%2E[Build Status (AppVeyor), link=https://ci.appveyor.com/project/asciidoctor/asciidoctor]
87
+ //image:https://img.shields.io/coveralls/asciidoctor/asciidoctor/master.svg[Coverage Status, link=https://coveralls.io/r/asciidoctor/asciidoctor]
88
+ //image:https://codeclimate.com/github/asciidoctor/asciidoctor/badges/gpa.svg[Code Climate, link="https://codeclimate.com/github/asciidoctor/asciidoctor"]
89
+ image:https://inch-ci.org/github/asciidoctor/asciidoctor.svg?branch=master[Inline docs, link="https://inch-ci.org/github/asciidoctor/asciidoctor"]
90
+ endif::[]
91
+
92
+ == Sponsors
93
+
94
+ We want to recognize our generous sponsors, without whose support Asciidoctor would not be possible.
95
+ Thank you sponsors for your dedication to improving the state of technical documentation!
96
+
97
+ image:https://www.okta.com/sites/all/themes/Okta/images/blog/Logos/Okta_Logo_BrightBlue_Medium.png[Okta,280,link=https://developer.okta.com/signup?utm_source=asciidoctor&utm_medium=logo&utm_campaign=sponsor,title="Add User Auth to Your Apps in Minutes with Okta"]
98
+ &nbsp; &nbsp; &nbsp;
99
+ image:https://secure.gravatar.com/avatar/823717a797dbd78ceff7b26aa397f383.png?size=200[OpenDevise,100,link=https://opendevise.com,title="Let the Creators of Asciidoctor and Antora Help You to Accelerate Your Docs"]
100
+
101
+ Major funding for Asciidoctor is provided by our *Change Makers*, https://developer.okta.com/signup?utm_source=asciidoctor&utm_medium=text-link&utm_campaign=sponsor[Okta] and https://opendevise.com[OpenDevise], and our *Strategy Sponsors*, Khronos Group and Linda Roberts.
102
+ Additional funding is provided by our https://asciidoctor.org/supporters[Community Backers].
103
+
104
+ You can support this project by becoming a sponsor on https://opencollective.com/asciidoctor[OpenCollective].
105
+
106
+ == The Big Picture
107
+
108
+ 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.
109
+ Asciidoctor applies a default stylesheet to the HTML5 document to provide a pleasant out-of-the-box experience.
110
+
111
+ image::{image-uri-screenshot}[Preview of AsciiDoc source and corresponding rendered HTML]
112
+
113
+ == AsciiDoc Processing
114
+
115
+ 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 (or 4.5) or man(ual) page output.
116
+ You have the option of using your own converter or loading {uri-tilt}[Tilt]-supported templates to customize the generated output or produce additional formats.
117
+
118
+ NOTE: Asciidoctor is a drop-in replacement for the original AsciiDoc Python processor (`asciidoc.py`).
119
+ The Asciidoctor test suite has {uri-tests}[> 2,000 tests] to ensure compatibility with the AsciiDoc syntax.
120
+
121
+ 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]+`).
122
+ Asciidoctor also offers a modern, responsive theme based on {uri-foundation}[Foundation] to style the HTML5 output.
123
+
124
+ == Where Ruby goes, Asciidoctor follows
125
+
126
+ You can run Asciidoctor on the JVM using JRuby.
127
+ To invoke the Asciidoctor API directly from Java and other JVM languages, use {uri-asciidoctorj}[AsciidoctorJ].
128
+ There are plugins available, based on AsciidoctorJ, that integrate the Asciidoctor processor into Apache Maven, Gradle or Javadoc builds.
129
+
130
+ Asciidoctor also runs in JavaScript.
131
+ We use https://opalrb.com[Opal] to transcompile the Ruby source to JavaScript to produce {uri-asciidoctorjs}[Asciidoctor.js], a fully-functional version of Asciidoctor that works in any JavaScript environment, such as a web browser or Node.js.
132
+ Asciidoctor.js is used to power the AsciiDoc preview extensions for Chrome, Atom, Brackets and other web-based tooling.
133
+
134
+ == Requirements
135
+
136
+ Asciidoctor works on Linux, macOS and Windows and requires one of the following implementations of {uri-ruby}[Ruby]:
137
+
138
+ * Ruby (MRI/CRuby 1.8.7 - 2.5)
139
+ * JRuby (1.7 in Ruby 1.8 and 1.9 modes, 9000)
140
+ * Rubinius 2.2.x
141
+ * Opal (JavaScript)
142
+
143
+ We welcome your help testing Asciidoctor on these and other platforms.
144
+ Refer to the <<Contributing>> section to learn how to get involved.
145
+
146
+ [CAUTION]
147
+ ====
148
+ If you're using a non-English Windows environment, you may bump into an `Encoding::UndefinedConversionError` when invoking Asciidoctor.
149
+ To solve this issue, we recommend changing the active code page in your console to UTF-8:
150
+
151
+ chcp 65001
152
+
153
+ Once you make this change, all your Unicode headaches will be behind you.
154
+ If you're using an IDE like Eclipse, make sure you set the encoding to UTF-8 there as well.
155
+ Asciidoctor works best when you use UTF-8 everywhere.
156
+ ====
157
+
158
+ == Installation
159
+
160
+ Asciidoctor can be installed using (a) the `gem install` command, (b) Bundler, (c) package managers for popular Linux distributions, or (d) Homebrew for macOS.
161
+
162
+ TIP: The benefit of using a Linux 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.
163
+ The drawback is that the package may not be available immediately after the release of the gem.
164
+ If you need the latest version, you can always fallback to using the `gem` command.
165
+
166
+ === (a) gem install
167
+
168
+ Open a terminal and type (excluding the leading `$`):
169
+
170
+ $ gem install asciidoctor
171
+
172
+ If you want to install a pre-release version (e.g., a release candidate), use:
173
+
174
+ $ gem install asciidoctor --pre
175
+
176
+ .Upgrading your installation
177
+ [TIP]
178
+ ====
179
+ If you have an earlier version of Asciidoctor installed, you can update it using:
180
+
181
+ $ gem update asciidoctor
182
+
183
+ If you install a new version of the gem using `gem install` instead of gem update, you'll have multiple versions installed.
184
+ If that's the case, use the following gem command to remove the old versions:
185
+
186
+ $ gem cleanup asciidoctor
187
+ ====
188
+
189
+ === (b) Bundler
190
+
191
+ . Create a Gemfile in the root folder of your project (or the current directory)
192
+ . Add the `asciidoctor` gem to your Gemfile as follows:
193
+ +
194
+ [source,subs=attributes+]
195
+ ----
196
+ source 'https://rubygems.org'
197
+ gem 'asciidoctor'
198
+ # or specify the version explicitly
199
+ # gem 'asciidoctor', '{release-version}'
200
+ ----
201
+
202
+ . Save the Gemfile
203
+ . Open a terminal and install the gem using:
204
+
205
+ $ bundle
206
+
207
+ To upgrade the gem, specify the new version in the Gemfile and run `bundle` again.
208
+ Using `bundle update` is *not* recommended as it will also update other gems, which may not be the desired result.
209
+
210
+ === (c) Linux package managers
211
+
212
+ ==== DNF (Fedora 21 or greater)
213
+
214
+ To install the gem on Fedora 21 or greater using dnf, open a terminal and type:
215
+
216
+ $ sudo dnf install -y asciidoctor
217
+
218
+ To upgrade the gem, use:
219
+
220
+ $ sudo dnf update -y asciidoctor
221
+
222
+ TIP: Your system may be configured to automatically update rpm packages, in which case no action is required by you to update the gem.
223
+
224
+ ==== apt-get (Debian, Ubuntu, or Mint)
225
+
226
+ To install the gem on Debian, Ubuntu or Mint, open a terminal and type:
227
+
228
+ $ sudo apt-get install -y asciidoctor
229
+
230
+ To upgrade the gem, use:
231
+
232
+ $ sudo apt-get upgrade -y asciidoctor
233
+
234
+ TIP: Your system may be configured to automatically update deb packages, in which case no action is required by you to update the gem.
235
+
236
+ The version of Asciidoctor installed by the package manager (apt-get) may not match the latest release of Asciidoctor.
237
+ Consult the package repository for your distribution to find out which version is packaged per distribution release.
238
+
239
+ * https://packages.debian.org/search?keywords=asciidoctor&searchon=names&exact=1&suite=all&section=all[asciidoctor package by Debian release]
240
+ * https://packages.ubuntu.com/search?keywords=asciidoctor&searchon=names&exact=1&suite=all&section=all[asciidoctor package by Ubuntu release]
241
+ * https://community.linuxmint.com/software/view/asciidoctor[asciidoctor package by Mint release]
242
+
243
+ [CAUTION]
244
+ ====
245
+ You're advised against using the `gem update` command to update a gem managed by the package manager.
246
+ Doing so puts the system into an inconsistent state as the package manager can no longer track the files (which get installed under /usr/local).
247
+ Simply put, system gems should only be managed by the package manager.
248
+
249
+ If you want to use a version of Asciidoctor that is newer than what is installed by the package manager, you should use https://rvm.io[RVM] to install Ruby in your home directory (i.e., user space).
250
+ Then, you can safely use the `gem` command to install or update the Asciidoctor gem.
251
+ When using RVM, gems are installed in a location isolated from the system.
252
+ ====
253
+
254
+ ==== apk (Alpine Linux)
255
+
256
+ To install the gem on Alpine Linux, open a terminal and type:
257
+
258
+ $ sudo apk add asciidoctor
259
+
260
+ To upgrade the gem, use:
261
+
262
+ $ sudo apk add -u asciidoctor
263
+
264
+ TIP: Your system may be configured to automatically update apk packages, in which case no action is required by you to update the gem.
265
+
266
+ === (d) Homebrew (macOS)
267
+
268
+ You can use Homebrew to install Asciidoctor on macOS.
269
+ If you haven't yet installed Homebrew, follow the instructions at https://brew.sh/[brew.sh].
270
+
271
+ Once Homebrew is installed, you can install the `asciidoctor` gem using the http://brewformulas.org/Asciidoctor[asciidoctor] package.
272
+ To do so, open a terminal and type:
273
+
274
+ $ brew install asciidoctor
275
+
276
+ To upgrade the gem, use:
277
+
278
+ $ brew update
279
+ $ brew upgrade asciidoctor
280
+
281
+ TIP: Homebrew installs the `asciidoctor` gem into an exclusive prefix that's independent of system gems.
282
+
283
+ === Other installation options
284
+
285
+ * {uri-install-docker}[Installing Asciidoctor using Docker]
286
+ * {uri-install-macos-doc}[Installing Asciidoctor on macOS]
287
+ // at the moment, the following entry is just a reiteration of the information in this README
288
+ //* {uri-install-doc}[Installing the Asciidoctor toolchain]
289
+
290
+ == Usage
291
+
292
+ If the Asciidoctor gem installed successfully, the `asciidoctor` command line interface (CLI) will be available on your PATH.
293
+ To verify it's available, run the following in your terminal:
294
+
295
+ $ asciidoctor --version
296
+
297
+ You should see information about the Asciidoctor version and your Ruby environment printed in the terminal.
298
+
299
+ [.output,subs=attributes+]
300
+ ....
301
+ Asciidoctor {release-version} [https://asciidoctor.org]
302
+ Runtime Environment (ruby 2.4.1p111 [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:- ex:UTF-8)
303
+ ....
304
+
305
+ Asciidoctor also provides an API.
306
+ The API is intended for integration with other Ruby software, such as Rails, Sinatra and GitHub, and other languages, such as Java (via {uri-asciidoctorj}[AsciidoctorJ]) and JavaScript (via {uri-asciidoctorjs}[Asciidoctor.js]).
307
+
308
+ === Command line interface (CLI)
309
+
310
+ The `asciidoctor` command allows you to invoke Asciidoctor from the command line (i.e., a terminal).
311
+
312
+ The following command converts the file README.adoc to HTML and saves the result to the file README.html in the same directory.
313
+ The name of the generated HTML file is derived from the source file by changing its file extension to `.html`.
314
+
315
+ $ asciidoctor README.adoc
316
+
317
+ You can control the Asciidoctor processor by adding various flags and switches, which you can learn about using:
318
+
319
+ $ asciidoctor --help
320
+
321
+ For instance, to write the file to a different directory, use:
322
+
323
+ $ asciidoctor -D output README.adoc
324
+
325
+ The `asciidoctor` {uri-manpage}[man page] provides a complete reference of the command line interface.
326
+
327
+ Refer to the following resources to learn more about how to use the `asciidoctor` command.
328
+
329
+ * {uri-render-doc}[How do I convert a document?]
330
+ * {uri-themes-doc}[How do I use the Asciidoctor stylesheet factory to produce custom themes?]
331
+
332
+ === Ruby API
333
+
334
+ To use Asciidoctor in your application, you first need to require the gem:
335
+
336
+ [source]
337
+ require 'asciidoctor'
338
+
339
+ You can then convert an AsciiDoc source file to an HTML file using:
340
+
341
+ [source]
342
+ Asciidoctor.convert_file 'README.adoc', to_file: true, safe: :safe
343
+
344
+ WARNING: When using Asciidoctor via the API, the default safe mode is `:secure`.
345
+ In secure mode, several core features are disabled, including the `include` directive.
346
+ If you want to enable these features, you'll need to explicitly set the safe mode to `:server` (recommended) or `:safe`.
347
+
348
+ You can also convert an AsciiDoc string to embeddable HTML (for inserting in an HTML page) using:
349
+
350
+ [source]
351
+ ----
352
+ content = '_Zen_ in the art of writing https://asciidoctor.org[AsciiDoc].'
353
+ Asciidoctor.convert content, safe: :safe
354
+ ----
355
+
356
+ If you want the full HTML document, enable the `header_footer` option as follows:
357
+
358
+ [source]
359
+ ----
360
+ content = '_Zen_ in the art of writing https://asciidoctor.org[AsciiDoc].'
361
+ html = Asciidoctor.convert content, header_footer: true, safe: :safe
362
+ ----
363
+
364
+ If you need access to the parsed document, you can split the conversion into discrete steps:
365
+
366
+ [source]
367
+ ----
368
+ content = '_Zen_ in the art of writing https://asciidoctor.org[AsciiDoc].'
369
+ document = Asciidoctor.load content, header_footer: true, safe: :safe
370
+ puts document.doctitle
371
+ html = document.convert
372
+ ----
373
+
374
+ Keep in mind that if you don't like the output Asciidoctor produces, _you can change it!_
375
+ Asciidoctor supports custom converters that can handle converting from the parsed document to the generated output.
376
+
377
+ One easy way to customize the output piecemeal is by using the template converter.
378
+ The template converter allows you to supply a {uri-tilt}[Tilt]-supported template file to handle converting any node in the document.
379
+
380
+ However you go about it, you _can_ have 100% control over the output.
381
+ For more information about how to use the API or to customize the output, refer to the {uri-user-manual}[user manual].
382
+
383
+ == Contributing
384
+
385
+ In the spirit of {uri-freesoftware}[free software], _everyone_ is encouraged to help improve this project.
386
+ 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.
387
+ New contributors are always welcome!
388
+
389
+ Here are some ways *you* can contribute:
390
+
391
+ * by using prerelease (alpha, beta or preview) versions
392
+ * by reporting bugs
393
+ * by suggesting new features
394
+ * by writing or editing documentation
395
+ * by writing specifications
396
+ * by writing code -- _No patch is too small._
397
+ ** fix typos
398
+ ** add comments
399
+ ** clean up inconsistent whitespace
400
+ ** write tests!
401
+ * by refactoring code
402
+ * by fixing {uri-issues}[issues]
403
+ * by reviewing patches
404
+
405
+ The {uri-contribute}[Contributing] guide provides information on how to create, style, and submit issues, feature requests, code, and documentation to the Asciidoctor Project.
406
+
407
+ == Getting Help
408
+
409
+ The Asciidoctor project is developed to help you easily write and publish your content.
410
+ But we can't do it without your feedback!
411
+ We encourage you to ask questions and discuss any aspects of the project on the discussion list, on Twitter or in the chat room.
412
+
413
+ Discussion list (Nabble):: {uri-discuss}
414
+ Twitter:: https://twitter.com/search?f=tweets&q=%23asciidoctor[#asciidoctor] hashtag or https://twitter.com/asciidoctor[@asciidoctor] mention
415
+ Chat (Gitter):: image:https://badges.gitter.im/Join%20In.svg[Gitter, link=https://gitter.im/asciidoctor/asciidoctor]
416
+ ////
417
+ Chat (IRC):: {uri-irc}[#asciidoctor] on FreeNode IRC
418
+ ////
419
+
420
+ ifdef::env-github[]
421
+ Further information and documentation about Asciidoctor can be found on the project's website.
422
+
423
+ {uri-project}[Home] | {uri-news}[News] | {uri-docs}[Docs]
424
+ endif::[]
425
+
426
+ The Asciidoctor organization on GitHub hosts the project's source code, issue tracker, and sub-projects.
427
+
428
+ Source repository (git):: {uri-repo}
429
+ Issue tracker:: {uri-issues}
430
+ Asciidoctor organization on GitHub:: {uri-org}
431
+
432
+ == Copyright and Licensing
433
+
434
+ Copyright (C) 2012-2018 Dan Allen, Ryan Waldron and the Asciidoctor Project.
435
+ Free use of this software is granted under the terms of the MIT License.
436
+
437
+ See the {uri-license}[LICENSE] file for details.
438
+
439
+ == Authors
440
+
441
+ *Asciidoctor* is led by https://github.com/mojavelinux[Dan Allen] and https://github.com/graphitefriction[Sarah White] and has received contributions from {uri-contributors}[many other individuals] in Asciidoctor's awesome community.
442
+ The project was initiated in 2012 by https://github.com/erebor[Ryan Waldron] and based on {uri-prototype}[a prototype] written by https://github.com/nickh[Nick Hengeveld].
443
+
444
+ *AsciiDoc* was started by Stuart Rackham and has received contributions from many other individuals in the AsciiDoc community.
445
+
446
+ ifndef::env-site[]
447
+ == Changelog
448
+
449
+ ifeval::[{safe-mode-level} < 20]
450
+ include::CHANGELOG.adoc[tag=compact,leveloffset=+1]
451
+ endif::[]
452
+
453
+ Refer to the {uri-changelog}[CHANGELOG] for a complete list of changes in older releases.
454
+ endif::[]