Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copyedit the grid table extension documentation #678

Merged
merged 1 commit into from
Dec 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 22 additions & 21 deletions src/Markdig.Tests/Specs/GridTableSpecs.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ This section describes the different extensions supported:

## Grid Table

A grid table allows to have multiple lines per cells and allows to span cells over multiple columns. The following shows a simple grid table
A grid table allows having multiple lines per cells and allows spanning cells over multiple columns.
The following shows a simple grid table:

```
+---------+---------+
Expand All @@ -25,17 +26,20 @@ A grid table allows to have multiple lines per cells and allows to span cells ov
```

**Rule #1**
The first line of a grid table must a **row separator**. It must start with the column separator character `+` used to separate columns in a row separator. Each column separator is:
- starting by optional spaces
- followed by an optional `:` to specify left align, followed by optional spaces
- followed by a sequence of at least one `-` character, followed by optional spaces
- followed by an optional `:` to specify right align (or center align if left align is also defined)
- ending by optional spaces
The first line of a grid table must be a **row separator**.
It must start with the column separator character `+` used to separate columns in a row separator.

The first row separator must be followed by a *regular row*. A regular row must start with the character `|` that is starting at the same position than the column separator `+` of the first row separator.
Each column separator:
- starts with optional spaces
- followed by an optional `:` to specify left align, followed by optional spaces
- followed by a sequence of one or more `-` characters, followed by optional spaces
- followed by an optional `:` to specify right align (or center align if left align is also defined)
- ends with optional spaces

The first row separator must be followed by a *regular row*.
A regular row must start with a `|` character starting at the same position as the column separator `+` of the first row separator.

The following is a valid row separator
The following is a valid row separator:

```````````````````````````````` example
+---------+---------+
Expand All @@ -53,8 +57,8 @@ The following is a valid row separator
</table>
````````````````````````````````

The following is not a valid row separator:

The following is not a valid row separator
```````````````````````````````` example
|-----xxx----+---------+
| This is | not a table
Expand All @@ -64,7 +68,8 @@ The following is not a valid row separator
````````````````````````````````

**Rule #2**
A regular row can continue a previous regular row when column separator `|` are positioned at the same position than the previous line. If they are positioned at the same location, the column may span over multiple columns:
A regular row can continue a previous regular row when the column separators `|` are positioned at the same position as those of the previous line.
If they are positioned at the same location, the column may span over multiple columns:

```````````````````````````````` example
+---------+---------+---------+
Expand Down Expand Up @@ -134,15 +139,13 @@ The last column separator `|` may be omitted:
</table>
````````````````````````````````

The respective width of the columns are calculated from the ratio between the total size of the first table row without counting the `+`: `+----+--------+----+` would be divided between:
The respective widths of the columns are calculated from the ratio between the total size of the first table row without counting the `+`: `+----+--------+----+` would be divided between:

Total size is : 16
- `----` → 4 characters
- `--------` → 8 characters
- `----` → 4 characters

- `----` -> 4
- `--------` -> 8
- `----` -> 4

So the width would be 4/16 = 25%, 8/16 = 50%, 4/16 = 25%
The total size is 16 characters, so the widths would be 4/16 = 25%, 8/16 = 50%, and 4/16 = 25%.

```````````````````````````````` example
+----+--------+----+
Expand All @@ -165,7 +168,6 @@ So the width would be 4/16 = 25%, 8/16 = 50%, 4/16 = 25%

Alignment might be specified on the first row using the character `:`:


```````````````````````````````` example
+-----+:---:+-----+
| A | B | C |
Expand Down Expand Up @@ -220,7 +222,7 @@ D</td>
</table>
````````````````````````````````

A grid table may have cells with both colspan and rowspan:
A grid table may have cells with both `colspan` and `rowspan`:

```````````````````````````````` example
+---+---+---+
Expand Down Expand Up @@ -276,7 +278,6 @@ A grid table may not have irregularly shaped cells:

An empty `+` on a line should result in a simple empty list output:


```````````````````````````````` example
+
.
Expand Down