
【Asciidoc】基本構文(26) 〜 表(Tables).1 〜
「基本構文」を解説していきます。
今回は「表(Tables)」について・・・。
項目が多いので何回かに分けるつもりです。
表について以前いくつかの記事を紹介います。
結構書いていますね・・・。この、基本構文記事いらないかもと思いながら・・・。
末尾にリンクを載せておきます。
例題〜タイトル、ヘッダー行、2列、2行のコンテンツを持つ表〜
.Table Title
|===
|Column 1, Header Row |Column 2, Header Row ①
②
|Cell in column 1, row 1
|Cell in column 2, row 1
|Cell in column 1, row 2
|Cell in column 2, row 2
|===
① Unless the cols attribute is specified, the number of columns is equal to the number of cell separators on the first (non-empty) line.
cols属性が指定されない限り、列の数は最初の(空でない)行のセル区切りの数に等しい。
② When an empty line immediately follows a non-empty line at the start of the table, the cells in the first line get promoted to the table header.
テーブルの先頭で、空でない行の直後に空行があると、最初の行のセルはテーブル・ヘッダーに昇格する。
変換してみます。

タイトル、ヘッダー行、2列、2行のコンテンツを持つ表
タイトルは他のブロックと同じく.マークアップで定義します。
基本的なテーブルは|====で始まり|====で終了します。
冒頭ブロック区切り直後の行に一行でセル構成を書くとヘッダー行として処理されます。
ヘッダー行の後には空行が必要です。
ブロックが|====で設定された場合、セルは|で区切られます。
表の行が終わる毎に空行が必要です。
例題〜ヘッダー行、2列、2行のコンテンツを持つテーブル〜
[%header,cols=2*] ①
|===
|Name of Column 1
|Name of Column 2
|Cell in column 1, row 1
|Cell in column 2, row 1
|Cell in column 1, row 2
|Cell in column 2, row 2
|===
① The * in the cols attribute is the repeat operator. It means repeat the column specification across the remaining columns. In this case, we are repeating the default formatting across 2 columns. When the cells in the header are not defined on a single line, you must use the cols attribute to set the number of columns in the table and the %header option (or options=header attribute) to promote the first row to the table header.
cols属性の*は繰り返し演算子です。これは、残りの列にわたって列の指定を繰り返すことを意味します。この場合、デフォルトの書式を2列にわたって繰り返します。ヘッダーのセルが一行で定義されていない場合、cols属性でテーブルの列数を設定し、%headerオプション(またはoptions=header属性)で最初の行をテーブルのヘッダーに昇格させる必要があります。
変換すると

ヘッダー行、2列、2行のコンテンツを持つテーブル
ヘッダー行は%headerオプションもしくはoptions=header属性を表属性と定義することでも行えます。
ヘッダーオプション属性を指定すると冒頭から必要な分をヘッダーセルとして処理します。
cols=属性で列属性を指定できます。
例題〜ヘッダー行、3列、2行のコンテンツを持つ表〜
.Applications
[cols="1,1,2"] ①
|===
|Name |Category |Description
|Firefox
|Browser
|Mozilla Firefox is an open source web browser.
It's designed for standards compliance,
performance, portability.
|Arquillian
|Testing
|An innovative and highly extensible testing platform.
Empowers developers to easily create real, automated tests.
|===
① In this example, the cols attribute has two functions. It specifies that this table has three columns, and it sets their relative widths.
この例では、cols属性は二つの機能を持っています。それは、このテーブルが3つの列を持つことを指定し、それらの相対的な幅を設定します。
変換すると

ヘッダー行、3列、2行のコンテンツを持つ表
cols属性は"幅,幅,幅,・・・"で列数と列幅の割合を指定できます。
とりあえず、基本形を・・・。
「Syntax Quick Reference」を読み返してみると意外とわかりにくい構成かも・・・。
少し、「AsciiDoc」の表に関する記事が人気なのもわかるような気がします。
取り敢えず今回はここまで。
ではまた。
当Noteは下記の「AsciiDoc Language Documentation」の文法に従っています。
ガイドライン
参考記事:
「【Asciidoc】簡単な表を作ってみる」
「【Asciidoc】表のセルを結合してみる」
「【Asciidoc】表の文字配置を指定してみる」
「【Asciidoc】表の罫線を変えてみる、そしてシマウマ。。。」
「【Asciidoc】表に画像をはめてみる。。。」