Kamis, 04 Juli 2024

AsciiDoctor Table 2

Default table syntax

a vertical bar and three equal signs ( |=== )  as table row delimiters for beginning and closing.

Each table's column cell is specified by a vertical bar ( ).

Example:

[cols=2*,separator=¦]

|===

¦The default separator in PSV tables is the \| character.

¦The \| character is often referred to as a "`pipe`".

|===

Result

The default separator in PSV tables is the | character.

The | character is often referred to as a “pipe”.

Supported data formats

The default table data format is prefix-separated values (PSV); that means the processor creates a new cell each time it encounters a vertical bar (|). AsciiDoc also supports:

  • comma-separated values (CSV) (,)
  • tab-separated values (TSV)
  • delimited data separated values (DSV)

Escape the cell separator

If the cell contains the cell separator, you must escape that character. There are three ways to escape it:

  • Prefix the character with a leading backslash (i.e., \|), which will be removed from the output.

  • Use the {vbar} attribute reference in place of | in content.

  • Change the cell separator used by the table.

Example of AsciiDoctor CSVTable


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

Result: Rendered CSV table

Artist Track Genre
Baauer Harlem Shake Hip Hop
The Lumineers Ho Hey Folk Rock

Example

Accessible Table Of AsciiDoctor Sample

.Vegetable prices in Darwin and Hobart
[%header, cols=5*]
|===
||Beans|Peas|Carrots|Tomatoes

5+|Darwin

|Wholesale|$1.00|$1.25|$1.20|$1.00

|Retail|$2.00|$3.00|$1.80|$1.60

4+|Hobart

|Wholesale|$1.20|$1.30|$1.00|$0.80

|Retail|$1.60|$2.00|$2.00|$1.50

|===

Result

Table 1. Vegetable prices in Darwin and Hobart
Beans Peas Carrots Tomatoes
Darwin
Wholesale $1.00 $1.25 $1.20 $1.00
Retail $2.00 $3.00 $1.80 $1.60
Hobart
Wholesale $1.20 $1.30 $1.00 $0.80
Retail $1.60 $2.00 $2.00 $1.50

Notes:

The display of result on the above maybe a little different, because the result is based on how you build the table, AsciiDoctor role attribute, tools.

Bibliography

AsciiDoctor manual
https://usability.com.au/

lightweight markup language, document format, office digital file, documentation and manual

Related Post

Tidak ada komentar:

Posting Komentar