Asciidoctorは 高速な テキストプロセッサで AsciiDoc をHTML5, DocBook 5(4.5)や他のフォーマットに変換するツールチェインを配布しています. AsciidoctorはRubyで書かれており, RubyGemとしてパッケージされ, RubyGems.org で配布されています. gemはいくつかのLinuxディストリビューション, Fedora, Debian, Ubuntuにも含まれています. Asciidoctorはオープンソース hosted on Github で the MIT licenceのもとに配布されます.
Translations of this document are available in the following languages:
The Big Picture
Asciidoctorは下図の左側のパネルに示されるように, 平文で書かれた内容を読み, 右のパネルに描かれるようにHTML5に変換します. Asciidoctorは枠にとらわれない快適なエクスペリエンスのためにデフォルトスタイルシートをHTML5ドキュメントに適用します.
image::{image-uri-screenshot}[Preview of AsciiDoc source and corresponding rendered HTML]
AsciiDoc Processing
AsciidoctorはAsciiDoc文法で書かれたテキストを読み込み解釈し, それからHTML5, DocBook5(4.5)やman(ual)を出力するために内蔵コンバータセットにパースツリーを渡します. 生成された出力をカスタマイズ, あるいは追加のフォーマットをつくるためにあなた自身のコンバータを使うことや Tilt-supported テンプレートを読み込むオプションがあります.
Note
|
AsciidoctorはオリジナルのAsciiDoc Pythonプロセッサ(asciidoc.py )の完全互換です.
Asciidoctorテストスイートは > 1,600 tests をAsciiDoc文法との互換性を保証するために有しています.
|
クラシックなAsciiDoc文法に加えて, Asciidoctorは追加のマークアップとフォントベースのicons(例えば, icon:fire[]
)などのフォーマッティングオプションとUIエレメント(button:[Save]
)を 受け付けます.
AsciidoctorはHTML5出力をスタイルするため, モダンで, Foundation に基づいたレスポンシブテーマをも提供します.
Requirements
AsciidoctorはLinux, OS X (Mac)とWindowsで動き, 下記の Ruby実装の一つを必要とします.
-
MRI (Ruby 1.8.7, 1.9.3, 2.0, 2.1, 2.2 & 2.3)
-
JRuby (1.7 in Ruby 1.8 and 1.9 modes, 9000)
-
Rubinius 2.2.x
-
Opal (JavaScript)
Caution
|
もし非英語環境のWindowsを使っているなら, Asciidoctorを起動した時に chcp 65001 に変更することを推奨します. 一度この変更をすると, Unicode関連の頭痛の種は消えるでしょう. もしEclipseのようなIDEを使っているなら, 同様にエンコーディングをUTF-8にするのを忘れないでください. AsciidoctorはUTF-8が使われているところで最高の働きを見せます. |
Installation
Asciidoctorは (a) gem install
コマンド, (b) Bundler あるいは (c) 有名Linuxディストリビューションのパッケージマネージャ を用いてインストールされます.
Tip
|
Linuxパッケージマネージャを用いてインストールすることの利点は, もしRubyやRubyGemsライブラリがまだインストールされていなかったら, それらを処理してくれることです.
欠点はgemのリリース直後にはすぐには有効にならないことです.
もし最新バージョンを使いたければ, 必ず gem コマンドを使いましょう.
|
(a) gem install
ターミナルを開き, 入力しましょう (先頭の`$`は除く):
$ gem install asciidoctor
もし, 先行リリースバージョン(例えばリリース候補版)をインストールしたければ
$ gem install asciidoctor --pre
Tip
|
アップグレード
もしAsciidoctorの以前のバージョンがインストール済みであれば, 以下によってアップデートできます: $ gem update asciidoctor もし gem update の代わりに $ gem cleanup asciidoctor |
(b) Bundler
-
プロジェクトフォルダーのルート(かカレントディレクトリ)にGemfileを作成
-
asciidoctor
gemをGemfileに以下のように追加:source 'https://rubygems.org' gem 'asciidoctor' # or specify the version explicitly # gem 'asciidoctor', '1.5.8'
-
Gemfileを保存
-
ターミナルを開き, gemをインストール:
$ bundle
gemをアップグレードするには, Gemfileで新バージョンを指定し, bundle
を再び実行してください.
bundle update
は他のgemもアップデートするため推奨されて いない ので, 思わぬ結果になるかも知れません.
(c) Linux package managers
DNF (Fedora 21 or greater)
dnfを使いFedora21かそれ以上にインストールするには, ターミナルを開き, 以下を入力してください:
$ sudo dnf install -y asciidoctor
gemをアップグレードするには:
$ sudo dnf update -y asciidoctor
Tip
|
お使いのシステムは自動的にrpmパッケージをアップデートするよう設定されているかも知れません.その場合, gemのアップデートのためにあなたがすべきことはありません. |
apt-get (Debian, Ubuntu, Mint)
Debian, UbuntuまたはMintにインストールするには, ターミナルを開き, 以下を入力してください:
$ sudo apt-get install -y asciidoctor
gemをアップグレードするには:
$ sudo apt-get upgrade -y asciidoctor
Tip
|
お使いのシステムは自動的にdebパッケージをアップデートするよう設定されているかも知れません.その場合, gemのアップデートのためにあなたがすべきことはありません. |
パッケージマネージャ(apt-get)によってインストールされたバージョンのAsciidoctorは最新リリースのAsciidoctorではないかもしれません. ディストリビューションのリリース毎に, どのバージョンがパッケージされているかはパッケージリポジトリを調べてください.
Caution
|
パッケージマネージャによって管理されているgemをアップデートするのに |
apk (Alpine Linux)
Alpine Linuxにgemをインストールするには, ターミナルを開き, 以下を入力してください:
$ sudo apk add asciidoctor
gemをアップグレードするには:
$ sudo apk add -u asciidoctor
Tip
|
お使いのシステムは自動的にapkパッケージをアップデートするよう設定されているかも知れません.その場合, gemのアップデートのためにあなたがすべきことはありません. |
Other installation options
Usage
Asciidoctorのインストールに成功すれば, asciidoctor
コマンドラインインターフェース(CLI)がPATH中で有効になります.
確認のために, 以下をターミナルで実行しましょう:
$ asciidoctor --version
AsciidoctorのバージョンとRuby環境についての情報がターミナルに出力されたのを見ることができるはずです.
Asciidoctor 1.5.8 [http://asciidoctor.org] Runtime Environment (ruby 2.4.1p111 [x86_64-linux]) (lc:UTF-8 fs:UTF-8 in:- ex:UTF-8)
AsciidoctorはAPIを提供します. APIは他のRubyソフトウェア, Rails, SinatraとGitHub, そして他の言語, Java (via AsciidoctorJ )とJavaScript (via Asciidoctor.js)との統合を意図しています.
Command line interface (CLI)
asciidoctor
コマンドはAsciidoctorをコマンドライン(つまりターミナル)から起動することを可能にします.
次のコマンドはファイルREADME.adocをHTMLに変換し, 結果を同じディレクトリのREADME.htmlに保存します.
生成されたHTMLファイルの名前はソースファイル依存し, その拡張子を .html
に変えます.
$ asciidoctor README.adoc
Asciidoctorプロセッサに様々なフラグやスイッチを与えることで制御できます.それは以下を用いて調べることができます:
$ asciidoctor --help
例えば, ファイルを異なるディレクトリに書き出すには:
$ asciidoctor -D output README.adoc
asciidoctor
man page はコマンドライン・インタフェースの完全なリファレンスを提供します.
asciidoctor
コマンドの使い方についてもっと学ぶには以下を参照してください.
Ruby API
Asciidoctorをアプリケーションの中で使うには, まずgemをrequireする必要があります:
require 'asciidoctor'
それから, AsciiDocソースファイルをHTMLファイルに変換できます:
Asciidoctor.convert_file 'README.adoc', to_file: true, safe: :safe
Warning
|
AsciidoctorをAPI経由で使っている時, デフォルトのセーフモードは :secure です.
セキュアモードでは, include ディレクティブを含むいくつかのコア機能は無効化されています.
もしこれらの機能を有効化したい場合, 明示的にセーフモードを :server (推奨)か :safe にする必要があります.
|
AsciiDoc文字列を埋め込みHTML(HTMLページヘの挿入)へ変換することもできます:
content = '_Zen_ in the art of writing http://asciidoctor.org[AsciiDoc].'
Asciidoctor.convert content, safe: :safe
もし完全なHTMLドキュメントを求めるのであれば, header_footer
オプションを以下の通り有効にしてください:
content = '_Zen_ in the art of writing http://asciidoctor.org[AsciiDoc].'
html = Asciidoctor.convert content, header_footer: true, safe: :safe
パースされたドキュメントにアクセスしたいのなら, 変換を個々のステップに分割することが出来ます:
content = '_Zen_ in the art of writing http://asciidoctor.org[AsciiDoc].'
document = Asciidoctor.load content, header_footer: true, safe: :safe
puts document.doctitle
html = document.convert
Asciidoctorの生成する出力が気に入らないのであれば, あなたはそれを変更できる ことを忘れないでください! Asciidoctorはパースされたドキュメントを生成された出力に変換する処理を扱うカスタムコンバーターをサポートしています.
断片的な出力をカスタマイズする簡単な方法の一つはテンプレートコンバーターを使うことです. テンプレートコンバーターによって, ドキュメント中のあらゆるノードの変換を扱うために Tilt-supportedテンプレートファイルを使うことができます.
そのようにすれば, 出力を100%制御することが できます . APIの使い方や出力のカスタマイズ方法についてのより詳しい情報は user manual を参照してください.
Contributing
free software の精神においては, everyone がこのプロジェクトを改良するのをたすけることが勧められています. もしエラーや手抜かりをソースコード, ドキュメント, あるいはウェブサイトに見つけたのなら, 恥じることなく修正と共にpull requestの開設やissueの送信をしてください. New contributors are always welcome!
あなた にもできることがあります:
-
先行バージョン(alpha, beta or preview)の使用
-
バグレポート
-
新機能提案
-
ドキュメントの執筆
-
仕様の執筆
-
コーディング — パッチでも, 足りなすぎるなんてことはありません
-
typoの修正
-
コメントの追加
-
一貫性のないホワイトスペースの除去
-
テストの記述!
-
-
リファクタリング
-
issues の修正
-
パッチの批評
Contributing ガイドはどうやってスタイルをつくるか, issueを送るか, 機能リクエスト, コーディング, ドキュメンテーションをAsciidoctor Projectにするかについての情報を提供しています.
Getting Help
Asciidoctorプロジェクトはあなたが簡単に著作を書いて, 配布するのをたすけるため開発されています. しかしあなたのフィードバックなしにはできません! ディスカッションリストで, Twitterで, チャットルームで, 質問し, プロジェクトのあらゆる側面について話し合うようお勧めします.
- Discussion list (Nabble)
-
#asciidoctor hashtag or @asciidoctor mention
GitHub上のAsciidoctorはプロジェクトのソースコード, イシュートラッカー, サブプロジェクトを管理しています.
- Source repository (git)
- Issue tracker
- Asciidoctor organization on GitHub
Copyright and Licensing
Copyright © 2012-2018 Dan Allen, Ryan Waldron and the Asciidoctor Project. 本ソフトウェアはMITライセンスのもとで自由に使用できます.
詳細は LICENSE ファイルを参照してください.
Authors
Asciidoctor は Dan Allen と Sarah White が先導し, Asciidoctorの素晴らしきコミュニティの数多くのメンバからコントリビューションを受けてきました. このプロジェクトは2012年から Nick Hengeveld の プロトタイプ をベースに Ryan Waldron により創始されました.
AsciiDoc は Stuart Rackham により創始され, AsciiDocコミュニティの数多くのメンバからコントリビューションを受けてきました.
Changelog
1.5.7.1 (2018-05-10) - @mojavelinux
- Fixes
-
-
fix regression where block attributes where being inherited by sibling blocks in a complex list item (#2771)
-
don’t apply lead styling to first paragraph in nested document (AsciiDoc table cell) if role is present (#2624)
-
- Build / Infrastructure
-
-
drop obsolete logic in rake build (@aerostitch)
-
allow lib dir to be overridden for tests using an environment variable (PR #2758) (@aerostitch)
-
load asciidoctor/version from LOAD_PATH in gemspec if not found locally (PR #2760) (@aerostitch)
-
1.5.7 (2018-05-02) - @mojavelinux
- Enhancements
-
-
BREAKING: drop XML tags, character refs, and non-word characters (except hyphen, dot, and space) when auto-generating section IDs (#794)
-
hyphen, dot, and space are replaced with value of idseparator, if set; otherwise, spaces are dropped
-
-
allow attribute names to contain any word character defined by Unicode (#2376, PR #2393)
-
do not recognize attribute entry line if name contains a colon (PR #2377)
-
route all processor messages through a logger instead of using Kernel#warn (#44, PR #2660)
-
add MemoryLogger for capturing messages sent to logger into memory (#44, PR #2660)
-
add NullLogger to prevent messages from being logged (#44, PR #2660)
-
log message containing source location / cursor as an object; provides more context (#44, PR #2660)
-
pass cursor for include file to
:include_location
key in message context (PR #2729) -
add
:logger
option to API to set logger instance (#44, PR #2660) -
add
--failure-level=LEVEL
option to CLI to force non-zero exit code if specified logging level is reached (#2003, PR #2674) -
parse text of xref macro as attributes if attribute signature found (equal sign) (#2381)
-
allow xrefstyle to be specified per xref by assigning the xrefstyle attribute on the xref macro (#2365)
-
recognize target with .adoc extension in xref macro as an interdocument xref
-
resolve nested includes in remote documents relative to URI (#2506, PR #2511)
-
allow
relfilesuffix
attribute to control file extension used for interdoc xrefs (#1273) -
support
!name@
(preferred),!name=@
,name!@
, andname!=@
syntax to soft unset attribute from API or CLI (#642, PR #2649) -
allow modifier to be placed at end of name to soft set an attribute (e.g.,
icons@=font
) (#642, PR #2649) -
interpret
false
attribute value defined using API as a soft unset (#642, PR #2649) -
number parts if
partnums
attribute is set (#2298) -
allow footnote macro to define or reference footnote reference (footnoteref macro now deprecated) (#2347, PR #2362)
-
allow custom converter to be used with custom templates; converter must declare that it supports templates (#2619)
-
allow manpage path for manpage help topic to be specified using ASCIIDOCTOR_MANPAGE_PATH environment variable (PR #2653) (@aerostitch)
-
if manpage cannot be found in default path inside gem, use
man -w asciidoctor
to resolve installed path (PR #2653) -
uncompress contents of manpage for manpage help topic if path ends with .gz (PR #2653) (@aerostitch)
-
define source and manual refmiscinfo entries in manpage output if manual and source attributes are defined (PR #2636) (@tiwai)
-
add syntax for adding hard line breaks in block AsciiMath equations (#2497, PR #2579) (@dimztimz)
-
add positioning option to sectanchors attribute (sectanchors=before or sectanchors=after) (#2485, PR #2486)
-
allow table striping to be configured using stripes attribute (even, odd, all, or none) or stripes roles on table (#1365, PR #2588)
-
recognize
ends
as an alias totopbot
for configuring the table frame -
add rel=nofollow property to links (text or image) when nofollow option is set (#2605, PR #2692)
-
populate Document#source_location when sourcemap option is enabled (#2478, PR #2488)
-
populate source_location property on list items when sourcemap option is set on document (PR #2069) (@mogztter)
-
populate Table::Cell#source_location when sourcemap option is enabled (#2705)
-
allow local include to be flagged as optional by setting optional option (#2389, PR #2413)
-
allow block title to begin with a period (#2358, PR #2359)
-
catalog inline anchor at start of list items in ordered and unordered lists, description list terms, and table cells (#2257)
-
register document in catalog if id is set; assign reftext to document attributes if specified in a block attribute line (#2301, PR #2428)
-
allow automatic width to be applied to individual columns in a table using the special value
~
(#1844) -
use the quote element in DocBook converter to represent smart quotes (#2272, PR #2356) (@bk2204)
-
parse and pass all manpage names to output document master (i.e., shadow man pages) (#1811, #2543, PR #2414)
-
parse credit line of shorthand quote block as block attributes; apply normal subs to credit line in shorthand quote blocks (#1667, PR #2452)
-
populate copyright element in DocBook output from value of copyright attribute (#2728)
-
preserve directories if source dir and destination dir are set (#1394, PR #2421)
-
allow linkcss to be unset from API or CLI when safe mode is secure
-
convert quote to epigraph element in DocBook output if block has epigraph role (#1195, PR #2664) (@bk2204)
-
number special sections in addition to regular sections when sectnums=all (#661, PR #2463)
-
upgrade to Font Awesome 4.7.0 (#2569)
-
upgrade to MathJax 4.7.4
-
- Bug fixes
-
-
set
:to_dir
option value correctly when output file is specified (#2382) -
preserve leading indentation in contents of AsciiDoc table cell if contents starts with a newline (#2712)
-
the shorthand syntax on the style to set block attributes (id, roles, options) no longer resets block style (#2174)
-
match include tags anywhere on line as long as offset by word boundary on left and space or newline on right (#2369, PR #2683)
-
warn if an include tag specified in the include directive is unclosed in the included file (#2361, PR #2696)
-
use correct parse mode when parsing blocks attached to list item (#1926)
-
fix typo in gemspec that removed README and CONTRIBUTING files from the generated gem (PR #2650) (@aerostitch)
-
preserve id, role, title, and reftext on open block when converting to DocBook; wrap in
<para>
or<formalpara>
(#2276) -
don’t turn bare URI scheme (no host) into a link (#2609, PR #2611)
-
don’t convert inter-document xref to internal anchor unless entire target file is included into current file (#2200)
-
fix em dash replacement in manpage converter (#2604, PR #2607)
-
don’t output e-mail address twice when replacing bare e-mail address in manpage output (#2654, PR #2665)
-
use alternate macro for monospaced text in manpage output to not conflict w/ AsciiDoc macros (#2751)
-
enforce that absolute start path passed to PathResolver#system_path is inside of jail path (#2642, PR #2644)
-
fix behavior of PathResolver#descends_from? when base path equals / (#2642, PR #2644)
-
automatically recover if start path passed to PathResolver#system_path is outside of jail path (#2642, PR #2644)
-
re-enable left justification after invoking tmac URL macro (#2400, PR #2409)
-
don’t report warning about same level 0 section multiple times (#2572)
-
record timings when calling convert and write on Document (#2574, PR #2575)
-
duplicate header attributes when restoring; allows header attributes to be restored an arbitrary number of times (#2567, PR #2570)
-
propagate
:catalog_assets
option to nested document (#2564, PR #2565) -
preserve newlines in quoted CSV data (#2041)
-
allow opening quote around quoted CSV field to be on a line by itself
-
output table footer after body rows (#2556, PR #2566) (@PauloFrancaLacerda)
-
move @page outside of @media print in default stylesheet (#2531, PR #2532)
-
don’t throw exception if text of dd node is nil (#2529, PR #2530)
-
don’t double escape ampersand in manpage output (#2525) (@dimztimz)
-
fix crash when author_1 attribute is assigned directly (#2481, PR #2487)
-
fix CSS for highlighted source block inside colist (#2474, PR #2490)
-
don’t append file extension to data uri of admonition icon (#2465, PR #2466)
-
fix race condition in Helpers.mkdir_p (#2457, PR #2458)
-
correctly process nested passthrough inside unconstrained monospaced (#2442, PR #2443)
-
add test to ensure ampersand in author line is not double escaped (#2439, PR #2440)
-
prevent footnote ID from clashing with auto-generated footnote IDs (#2019)
-
fix alignment of icons in footnote (#2415, PR #2416)
-
add graceful fallback if pygments.rb fails to return a value (#2341, PR #2342)
-
escape specialchars in source if pygments fails to highlight (#2341)
-
do not recognize attribute entry line if name contains colon (PR #2377)
-
allow flow indexterm to be enclosed in round brackets (#2363, PR #2364)
-
set outfilesuffix to match file extension of output file (#2258, PR #2367)
-
add block title to dlist in manpage output (#1611, PR #2434)
-
scale text to 80% in print styles (#1484, PR #2576)
-
fix alignment of abstract title when using default stylesheet (PR #2732)
-
only set nowrap style on table caption for auto-width table (#2392)
-
output non-breaking space for man manual if absent in DocBook output (PR #2636)
-
don’t crash if stem type is not recognized (instead, fallback to asciimath)
-
- Improvements / Refactoring
-
-
BREAKING: rename table spread role to stretch (#2589, PR #2591)
-
use cursor marks to track lines more accurately; record cursor at the start of each block, list item, or table cell (PR #2701, PR #2547) (@seikichi)
-
log a warning message if an unterminated delimited block is detected (#1133, PR #2612)
-
log a warning when nested section is found inside special section that doesn’t support nested sections (#2433, PR #2672)
-
read files in binary mode to disable automatic endline coercion (then explicitly coerce to UTF-8) (PR #2583, PR #2694)
-
resolve / expand parent references in start path passed to PathResolver#system_path (#2642, PR #2644)
-
update PathResolver#expand_path to resolve parent references (#2642, PR #2644)
-
allow start path passed to PathResolver#system_path to be outside jail if target brings resolved path back inside jail (#2642, PR #2644)
-
don’t run File.expand_path on Dir.pwd (assume Dir.pwd is absolute) (#2642, PR #2644)
-
posixify working_dir passed to PathResolver constructor if absolute (#2642, PR #2644)
-
optimize detection for footnote* and indexterm* macros (#2347, PR #2362)
-
log a warning if a footnote reference cannot be resolved (#2669)
-
set logger level to DEBUG when verbose is enabled
-
coerce value of
:template_dirs
option to an Array (PR #2621) -
make block roles specified using shorthand syntax additive (#2174)
-
allow paragraph to masquerade as open block (PR #2412)
-
move callouts into document catalog (PR #2394)
-
document ID defined in block attribute line takes precedence over ID defined inside document title line
-
don’t look for link and window attributes on document when resolving these attributes for an image
-
when linkattrs is set, only parse attributes in link macro if equals is present
-
skip line comments in name section of manpage (#2584, PR #2585)
-
always activate extension registry passed to processor (PR #2379)
-
skip extension registry activation if no groups are registered (PR #2373)
-
don’t apply lead styling to first paragraph if role is present (#2624, PR #2625)
-
raise clearer exception when extension class cannot be resolved (#2622, PR #2623)
-
add methods to read results from timings (#2578, PR #2580)
-
collapse bottom margin of last block in AsciiDoc table cell (#2568, PR #2593)
-
set authorcount to 0 if there are no authors (#2519, PR #2520)
-
validate fragment of interdoc xref that resolves to current doc (#2448, PR #2449)
-
put id attribute on tag around phrase instead of preceding anchor (#2445, PR #2446)
-
add .plist extension to XML circumfix comment family (#2430, PR #2431) (@akosma)
-
alias Document#title method to no args Document#doctitle method (#2429, PR #2432)
-
upgrade missing or unreadable include file to an error (#2424, PR #2426)
-
add compliance setting to disable natural cross references (#2405, PR #2460)
-
make hash in inter-document xref target optional if target has extension (#2404, PR #2406)
-
add CSS class to part that matches role (#2401, PR #2402)
-
add fit-content class to auto-width table (#2392)
-
automatically assign parent reference when adding node to parent (#2398, PR #2403)
-
leave inline anchor in section title as is if section has ID (#2243, PR #2427)
-
align and improve error message about invalid use of partintro between HTML5 and DocBook converters
-
rephrase warning when level 0 sections are found and the doctype is not book
-
report correct line number when duplicate bibliography anchor is found
-
only warn if thread_safe gem is missing when using built-in template cache
-
rename enumerate_section to assign_numeral; update API docs
-
drop deprecated compact option from CLI; remove from manpage
-
use more robust mechanism for lazy loading the asciimath gem
-
use consistent phrase to indicate the processor is automatically recovering from a problem
-
change Reader#skip_comment_lines to not return skipped lines
-
add styles to default stylesheet for display on Kindle (kf8) devices (PR #2475)
-
purge render method from test suite (except to verify alias)
-
- Documentation
-
-
translate 'section-refsig' for German language (PR #2633) (@ahus1)
-
synchronize French README with English version (PR #2637) (@flashcode)
-
- Build / Infrastructure
-
-
create an official logo for the project (#48) (@mmajko)
-
update Ruby versions in appveyor build matrix (PR #2388) (@miltador)
-
add mailinglist, changelog, source, and issues URI to gem spec
-
allow blocks and substitutions tests to be run directly
-
asciidoctor formula now available for Homebrew (@zmwangx)
-
- Distribution Packages
リリースごとの変更一覧は CHANGELOG を参照してください.