Tables
The formatter supports GFM (GitHub Flavored Markdown) tables and normalizes their formatting. HTML tables are also handled by the formatHtmlBlocksInMdx option.
Rules
- GFM table syntax is supported
- Pipes are padded with spaces for readability
- Column alignment markers (
:---,:---:,---:) are preserved
Examples
GFM table normalization
Before:
|Name|Value|Description|
|---|---|---|
|foo|1|First item|
|bar|2|Second item|
After:
| Name | Value | Description |
| ---- | ----- | ----------- |
| foo | 1 | First item |
| bar | 2 | Second item |
Table with alignment
Before:
|Left|Center|Right|
|:---|:---:|---:|
|a|b|c|
|dd|ee|ff|
After:
| Left | Center | Right |
| :--- | :----: | ----: |
| a | b | c |
| dd | ee | ff |
HTML table indentation
HTML tables in MDX are formatted by the formatHtmlBlocksInMdx rule:
Before:
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</tbody>
</table>
After:
<table>
<thead>
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
</thead>
<tbody>
<tr>
<td>Data 1</td>
<td>Data 2</td>
</tr>
</tbody>
</table>