Tables

The idea behind lightweight markup languages such as Textile and Markdown is to keep the source text readable. This is the reason the | (the vertical bar) marker was chosen for tables. Thus, you can create a table using this code:

|             |Heading 1|Heading 2|Heading 3|
|Row heading 1|    ?    |    ?    |    ?    |
|Row heading 2|    ?    |    ?    |    ?    |
|Row heading 3|    ?    |    ?    |    ?    |

It will be formatted as follows:

Tables

The code looks very natural, doesn't it? In practice, however, users usually omit spaces, so the source text looks less readable.

Many Textile syntax rules support options (we will speak about this feature in detail later), and the table rule is among them. Thus, the _ option can be used to format the cell as a header. So, suppose we change the code to this:

|_.             |_.Heading 1|_.Heading 2|_.Heading 3|
|_.Row heading 1|     ?     |     ?     |     ?     |
|_.Row heading 2|     ?     |     ?     |     ?     |
|_.Row heading 3|     ?     |     ?     |     ?     |

Then, it will be formatted as seen in the following screenshot:

Tables

Unfortunately—as you can see—the more complex the code, the less readable the source text.

However, I personally can't imagine good table support without support for merged cells. In Textile, cells can be merged horizontally using the X option, where X is the number of cells to merge, and vertically using the /Y option, where Y is the number of cells as well. Let's see how it works, using the following code:

|_/22.                        |_2. Common heading    |
                               |_.Heading 1|_.Heading 2|
|_/3.Common row|_.Row heading 1|     ?     |     ?     |
               |_.Row heading 2|     ?     |     ?     |
               |_.Row heading 3|     ?     |     ?     |

Here is the result:

Tables

You might think that the table rule still misses some important options, for example, for aligning the content. But don't rush to a conclusion—wait for the advanced syntax that we will cover later in this chapter.

Note

In Markdown, the syntax for tables is similar in some ways:

|             |Heading 1|Heading 2|Heading 3|
|-------------|:-------:|:-------:|:-------:|
|Row heading 1|    ?    |    ?    |    ?    |
|Row heading 2|    ?    |    ?    |    ?    |
|Row heading 3|    ?    |    ?    |    ?    |

However, its table support is much more limited. Thus, it's not possible to merge cells. To align the content of a column , you can use a colon (:), as can be seen in the preceding example (if it was on the left side only, the content would be aligned to the left, and so on).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset