AsciiDocチートシート

1. Document Attributes

//Document Attributes
:source-highlighter: coderay
:doctype: book
:imagesdir: images
:icons: font
:experimental:
:pagenums:
:sectanchors:
:sectlinks:
:sectnums:
:toc: left
:toclevels: 3
//Document Attributes (Custum)
:disclaimer: Disclaimer…
:url-repo: https://github.com/tommylife88/asciidoc
:chapter-label:
asciidoc
このドキュメントのもととなるコードはMITライセンスで {url-repo}[公開します].

WARNING: {disclaimer}

このドキュメントのもととなるコードはMITライセンスで 公開します.

Disclaimer…

2. Element Attributes

2.1. ID Attributes

内部リンクや相互参照アンカー。CSSのIDセレクタのような特定の要素にスタイルを追加するために使用する。

asciidoc
[[attributes-id-anchor]]
=== ID属性

内部相互参照は、<<attributes-id-anchor,このように>>記述します。

内部相互参照は、このように記述します。

2.2. Role Attributes

CSSのClassセレクタのようなグループ要素にスタイルを追加するために使用する。

TBC

3. Document Header

asciidoc
= AsciiDoc Cheat sheet
//Document Header
:description: AsciiDoc Cheat sheet
:author: <Your name>
:revdate: <Date>
:revnumber: 1.0
:lang: ja

3.1. Document Types

Document Types
Article (article)

デフォルトのDoctype。付録、要約、参考文献、用語集、および索引の基本的なセクションが含まれている。本やマニュアルページを作成しているのでない限り、Articleで十分。

Book (book)

Articleに加えて本向けの特別なセクションが含まれる。

Man page (manpage)

UnixおよびUnixライクなマニュアルページ(manページ)を作成するために使用する。

Inline (inline)

AsciiDoc フォーマットをインラインで作成する場合に使用する。

4. Section

DocTypeによって意味が異なるが、Bookの場合。

asciidoc
= ドキュメントのタイトル(レベル0)

[[section-hoge-id]]//IDの付与
== セクション レベル1

=== セクション レベル2

==== セクション レベル3

===== セクション レベル4

====== セクション レベル5

== セクション レベル1

セクションアンカーとリンクは以下のドキュメント属性を定義する。

asciidoc
:sectanchors: //セクションアンカーアイコンを表示
:sectlinks: //セクションタイトルに自分自身へのリンクを付与

4.1. Styles

例えば、Bookドキュメントタイプでは、次のセクションスタイルが用意されている。

  • colophon (奥付)

  • dedication (献身)

  • acknowledgments (謝辞)

  • preface (序文)

  • part (部)

  • chapter (章)

  • appendix(付録)

  • glossary(用語集)

  • bibliography(参考文献)

  • index(索引)

Colophon

The Asciidoctor Press, Ceres and Denver.

© 2020 by The Asciidoctor Press

Published in the Milky Way Galaxy.

This book is designed by Dagger Flush, Denver, Colorado. The types are handset Volcano Dust and Papaya, designed by Leeloo. Leeloo created the typefaces to soften the bluntness of documentation.

Built with Asciidoctor on Fedora 33.

Printing and binding by Ceres Lithographing, Inc., Ceres, Milky Way.

Dedication

For S.S.T.--

thank you for the plague of archetypes.

Abstract

This article will take you on a wonderful adventure of knowledge.

You’ll start with the basics. Beyond that, where you go is up to you.

Preface

I awoke one morning and was confronted by the dark and stormy eyes of the chinchilla. She had conquered the mountain of government reports that had eroded into several minor foothills and a creeping alluvial plain of loose papers.

Glossary

mud

wet, cold dirt

rain

water falling from the sky

Bibliography

The Pragmatic Programmer [pp] should be required reading for all developers. To learn all about design patterns, refer to the book by the “Gang of Four” [gang].

References
  • [pp] Andy Hunt & Dave Thomas. The Pragmatic Programmer: From Journeyman to Master. Addison-Wesley. 1999.

  • [gang] Erich Gamma, Richard Helm, Ralph Johnson & John Vlissides. Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley. 1994.

Index

I, King Arthur.

Index

自動的にリスト化される。

WARN

AsciidoctorのHTML5コンバーターでは作成されない。

5. Paragraphs

Paragraphs don't require any special markup in AsciiDoc.
A paragraph is just one or more lines of consecutive text.

To begin a new paragraph, separate it by at least one blank line from the previous paragraph or block.

Paragraphs don’t require any special markup in AsciiDoc. A paragraph is just one or more lines of consecutive text.

To begin a new paragraph, separate it by at least one blank line from the previous paragraph or block.

5.1. Inline line break

Rubies are red, +
Topazes are blue.

Rubies are red,
Topazes are blue.

5.2. Paragraph Alignment

[.text-center]
This text is centered, so it must be important.

This text is centered, so it must be important.

6. Discrete Headings

****
Discrete headings are useful for making headings inside of other blocks, like this sidebar.

[discrete]
== Discrete Heading

Discrete headings can be used where sections are not permitted.
****

Discrete headings are useful for making headings inside of other blocks, like this sidebar.

Discrete Heading

Discrete headings can be used where sections are not permitted.

7. Breaks

8. Text Formatting

8.1. Bold,Italic,Monospace

A bold *word*, and a bold *phrase of text*.

Bold c**hara**cter**s** within a word.

`*_monospace bold italic phrase_*` & ``**__char__**``acter``**__s__**``

An italic _word_, and an italic _phrase of text_.

Italic c__hara__cter__s__ within a word.

"`Wait!`" Indigo plucked a small vial from her desk's top drawer
and held it toward us.
The vial's label read: `E=mc^2^`; the `E` represents _energy_,
but also pure _genius!_

A bold word, and a bold phrase of text.

Bold characters within a word.

monospace bold italic phrase & characters

An italic word, and an italic phrase of text.

Italic characters within a word.

“Wait!” Indigo plucked a small vial from her desk’s top drawer and held it toward us. The vial’s label read: E=mc2; the E represents energy, but also pure genius!

8.2. Marks, etc…​

The text #marker me# is markered.

The text [.underline]#underline me# is underlined.

The text [.overline]#overline me# is overlined.

The text [.small]#small me# is smalled.

The text [.big]#big me# is big.

The text [.line-through]#line-through me# is line-through.

The text marker me is markered.

The text underline me is underlined.

The text overline me is overlined.

The text small me is smalled.

The text big me is big.

The text line-through me is line-through.

8.3. Subscript and Superscript

"`Well the H~2~O formula written on their whiteboard could be part
of a shopping list, but I don't think the local bodega sells
E=mc^2^,`" Lazarus replied.

“Well the H2O formula written on their whiteboard could be part of a shopping list, but I don’t think the local bodega sells E=mc2,” Lazarus replied.

8.4. Quotation Marks and Apostrophes

"`What kind of charm?`" Lazarus asked.
"`An odoriferous one or a mineral one?`"

Kizmet shrugged.
"`The note from Olaf's desk says '`wormwood and licorice,`'
but these could be normal groceries for werewolves.`"

“What kind of charm?” Lazarus asked. “An odoriferous one or a mineral one?”

Kizmet shrugged. “The note from Olaf’s desk says ‘wormwood and licorice,’ but these could be normal groceries for werewolves.”

9. Lists

.Unordered Lists
* Edgar Allan Poe
* Sheri S. Tepper
* Bill Bryson

.Ordered Lists
. Protons
. Electrons
. Neutrons

.Checklists
* [*] checked
* [x] also checked
* [ ] not checked
* normal list item

.Basic description list
CPU:: The brain of the computer.
Hard drive:: Permanent storage for operating system and/or user files.
RAM:: Temporarily stores information the CPU uses during operation.
Keyboard:: Used to enter text or control items on the screen.
Mouse:: Used to point to and select items on your computer screen.
Monitor:: Displays information in visual form using text and graphics.

.Basic description list
[horizontal]
CPU:: The brain of the computer.
Hard drive:: Permanent storage for operating system and/or user files.
RAM:: Temporarily stores information the CPU uses during operation.
Keyboard:: Used to enter text or control items on the screen.
Mouse:: Used to point to and select items on your computer screen.
Monitor:: Displays information in visual form using text and graphics.

.Question and Answer Lists
[qanda]
What is the answer?::
This is the answer.

Have you seen my duck?:: No.

.list continuation
* parent list item
.. second child list item
*** third list item
.. second child list item
*** third list item

+
paragraph attached to parent list item
Unordered Lists
  • Edgar Allan Poe

  • Sheri S. Tepper

  • Bill Bryson

Ordered Lists
  1. Protons

  2. Electrons

  3. Neutrons

Checklists
  • checked

  • also checked

  • not checked

  • normal list item

Basic description list
CPU

The brain of the computer.

Hard drive

Permanent storage for operating system and/or user files.

RAM

Temporarily stores information the CPU uses during operation.

Keyboard

Used to enter text or control items on the screen.

Mouse

Used to point to and select items on your computer screen.

Monitor

Displays information in visual form using text and graphics.

Basic description list
CPU

The brain of the computer.

Hard drive

Permanent storage for operating system and/or user files.

RAM

Temporarily stores information the CPU uses during operation.

Keyboard

Used to enter text or control items on the screen.

Mouse

Used to point to and select items on your computer screen.

Monitor

Displays information in visual form using text and graphics.

Question and Answer Lists
  1. What is the answer?

    This is the answer.

  2. Have you seen my duck?

    No.

list continuation
  • parent list item

    1. second child list item

      • third list item

    2. second child list item

      • third list item

    paragraph attached to parent list item

https://docs.asciidoctor.org/ - atuo link

https://docs.asciidoctor.org/[Asciidoctor]

https://github.com/asciidoctor[Asciidoctor @ *GitHub*]

//Windows形式でもOK
link:\\server\share\whitepaper.pdf[Whitepaper]

//相対パスもOK
link:downloads/report.pdf[Get Report]

//ルール指定
https://discuss.asciidoctor.org[Discuss Asciidoctor,role=resource,window=_blank]

11. Footnotes

The hail-and-rainbow protocol can be initiated at five levels:

. doublefootnote:[The double hail-and-rainbow level makes my toes tingle.]
. tertiary
. supernumerary
. supermassive
. apocalyptic

A bold statement!footnote:disclaimer[Opinions are my own.]

Another outrageous statement.footnote:disclaimer[]

The hail-and-rainbow protocol can be initiated at five levels:

  1. double[1]

  2. tertiary

  3. supernumerary

  4. supermassive

  5. apocalyptic

A bold statement![2]

Another outrageous statement.[2]

12. Images

image::sunset.jpg[Sunset]

[#img-sunset]
.A mountain sunset
[link=https://www.flickr.com/photos/javh/5448336655]
image::sunset.jpg[Sunset,200,100]

You can find image:https://upload.wikimedia.org/wikipedia/commons/3/35/Tux.svg[Linux,25,35] everywhere these days.

image::sample.svg[Static,300]
Sunset
Sunset
Figure 1. A mountain sunset

You can find Tiger everywhere these days.

Static

13. Media

video::RvRhUHTV_8k/PLDitloyBcHOm49bxNhvGgg0f9NRZ5lSaP[youtube,width=640,height=480]

14. Icon

14.1. Icon Fonts

NOTE: NOTE

TIP: TIP

IMPORTANT: IMPORTANT

WARNING: WARNING

CAUTION: CAUTION
NOTE
TIP
IMPORTANT
WARNING
CAUTION

15. Keyboard Macro

|===
|Shortcut |Purpose

|kbd:[F11]
|Toggle fullscreen

|kbd:[Ctrl+T]
|Open a new tab

|kbd:[Ctrl+Shift+N]
|New incognito window

|kbd:[\ ]
|Used to escape characters

|kbd:[Ctrl+\]]
|Jump to keyword

|kbd:[Ctrl + +]
|Increase zoom
|===
Shortcut Purpose

F11

Toggle fullscreen

Ctrl+T

Open a new tab

Ctrl+Shift+N

New incognito window

\

Used to escape characters

Ctrl+]

Jump to keyword

Ctrl++

Increase zoom

16. UI Macro

Press the btn:[OK] button when you are finished.

Select a file in the file navigator and click btn:[Open].

To save the file, select menu:File[Save].

Select menu:View[Zoom > Reset] to reset the zoom level to the default setting.

Press the OK button when you are finished.

Select a file in the file navigator and click Open.

To save the file, select File  Save.

Select View  Zoom  Reset to reset the zoom level to the default setting.

17. Block

17.1. Example Blocks

[example]
This is an example of an example block.

.Onomatopoeia
====
The book hit the floor with a *thud*.

He could hear doves *cooing* in the pine trees`' branches.
====
Example 1. Optional title
This is an example of an example block.
Example 2. Onomatopoeia

The book hit the floor with a thud.

He could hear doves cooing in the pine trees’ branches.

17.2. Blockquotes

.After landing the cloaked Klingon bird of prey in Golden Gate park:
[quote, Captain James T. Kirk, Star Trek IV: The Voyage Home]
Everybody remember where we parked.

[quote, Monty Python and the Holy Grail]
____
Dennis: Come and see the violence inherent in the system. Help! Help! I'm being repressed!

King Arthur: Bloody peasant!

Dennis: Oh, what a giveaway! Did you hear that? Did you hear that, eh? That's what I'm on about! Did you see him repressing me? You saw him, Didn't you?
____
After landing the cloaked Klingon bird of prey in Golden Gate park:
Everybody remember where we parked.
— Captain James T. Kirk
Star Trek IV: The Voyage Home

Dennis: Come and see the violence inherent in the system. Help! Help! I’m being repressed!

King Arthur: Bloody peasant!

Dennis: Oh, what a giveaway! Did you hear that? Did you hear that, eh? That’s what I’m on about! Did you see him repressing me? You saw him, Didn’t you?

— Monty Python and the Holy Grail

17.3. Source Code

ドキュメント属性で highlighters を選択
:source-highlighter: coderay
[source,ruby]
-----
require 'sinatra'

get '/hi' do
  "Hello World!"
end
-----
require 'sinatra'

get '/hi' do
  "Hello World!"
end

17.4. Open

--
An open block can be an anonymous container,
or it can masquerade as any other block.
--

An open block can be an anonymous container, or it can masquerade as any other block.

17.5. Collapsible

.Click to reveal the answer
[%collapsible]
====
This is the answer.
====
Click to reveal the answer

This is the answer.

18. Tables

.表の見出し
|===
|カラム名1 |カラム名2 |カラム名3

|セル11
|セル12
|セル13

|セル21
|セル22
|セル23
|===

.セルの結合
[cols="1a,1a,1a",options="autowidth"]
|===
|1A|1B|1C

2+|「数値+」で横結合|2C

.2+|「.数値+」で縦結合|3B|3C

|4B
|* 4C
* セル内でも
* *asciidoc 書ける*
|===

.CSV
[%header,format=csv]
|===
Artist,Track,Genre
Baauer,Harlem Shake,Hip Hop
The Lumineers,Ho Hey,Folk Rock
|===

.表の属性
[cols=>1h;2d,width=50%,frame=topbot]
|===
| Attribute Name | Values

| options
| header,footer,autowidth

| cols
| colspec[;colspec;...]

| grid
| all \| cols \| rows \| none

| frame
| all \| sides \| topbot \| none

| stripes
| all \| even \| odd \| none

| width
| (0%..100%)

| format
| psv {vbar} csv {vbar} dsv
|===
Table 1. 表の見出し
カラム名1 カラム名2 カラム名3

セル11

セル12

セル13

セル21

セル22

セル23

Table 2. セルの結合
1A 1B 1C

「数値+」で横結合

2C

「.数値+」で縦結合

3B

3C

4B

  • 4C

  • セル内でも

  • asciidoc書ける

Table 3. CSV
Artist Track Genre

Baauer

Harlem Shake

Hip Hop

The Lumineers

Ho Hey

Folk Rock

Table 4. 表の属性
Attribute Name Values

options

header,footer,autowidth

cols

colspec[;colspec;…​]

grid

all | cols | rows | none

frame

all | sides | topbot | none

stripes

all | even | odd | none

width

(0%..100%)

format

psv | csv | dsv

19. Comments

// A single-line comment.

////
A block comment.

Notice it's a delimited block.
////

20. TOC

:toc: left
:toclevels: 3
:toc-title: 目次

21. Captions

表や図のキャプションを入れることができる。番号も自動で割り振ってくれる。

:example-caption: 例
:table-caption: 表
:figure-caption: 図
#図や表のブロックの前に ".キャプション" を付ける

.GitHub mascot
image::https://asciidoctor.org/images/octocat.jpg[GitHub mascot]
キャプションと自動採番
GitHub mascot
Figure 2. GitHub mascot
Table 5. タイトル、ヘッダ付き2×3
カラム名1 カラム名2 カラム名3

セル11

セル12

セル13

セル21

セル22

セル23

Table 6. ヘッダ付き2×2
カラム名1 カラム名2

セル11

セル12

セル21

セル22

Example 3. サンプルドキュメント

これはサンプルです。

  • 項目1

  • 項目2

  • 項目3

Example 4. サンプルソース
= Hello, AsciiDoc!
Doc Writer <doc@example.com>

An introduction to http://asciidoc.org[AsciiDoc].

== First Section

* item 1
* item 2

[source,ruby]
puts "Hello, World!"

22. Includes

include::docs/subdoc.adoc[]

外部のファイルを読み込むことができる。

ファイル全体を取り込み
include::sample.adoc[]


= Hello, AsciiDoc!
Doc Writer <doc@example.com>

An introduction to http://asciidoc.org[AsciiDoc].

== First Section

* item 1
* item 2

[source,ruby]
puts "Hello, World!"

行数を指定した取り込み
include::sample.adoc[lines=1..5]


= Hello, AsciiDoc!
Doc Writer <doc@example.com>

An introduction to http://asciidoc.org[AsciiDoc].

23. Diagram

Asciidoctor-PDF だと期待した結果にならない場合も。
PlantUML
Activity::
[plantuml,activity,svg]
-----
@startuml
start
:Hello world;
:This is defined on
several **lines**;
end
@enduml
-----

Class::
[plantuml,class,svg]
-----
@startuml
class Foo {
+ field1
+ field2
}

class Bar {
+ field3
+ field4
}

Foo::field1 --> Bar::field3 : foo
Foo::field2 --> Bar::field4 : bar
@enduml
-----

Sequence::
[plantuml,sequence,svg]
-----
include::sequence.pu[]
-----

State::
[plantuml,state,svg]
-----
include::state.pu[]
-----

Use Case::
[plantuml,usecase,svg]
-----
include::usecase.pu[]
-----
PlantUML
Activity
activity
Class
class
Sequence
sequence
State
state
Use Case
usecase

Appendix B: How to setup


1. The double hail-and-rainbow level makes my toes tingle.
2. Opinions are my own.