目前,markdown的语法不支持表格的单元格合并,只能使用 html 的表格源码来实现。举例如下:
<table>
<tr>
<td>A1</td>
<td>B1</td>
<td>C1</td>
<td>D1</td>
</tr>
<tr>
<td>A2</td>
<td colspan="2">横跨两列</td>
<td>D2</td>
</tr>
<tr>
<td>A3</td>
<td>B3</td>
<td>C3</td>
<td>D3</td>
</tr>
</table>
A1 | B1 | C1 | D1 |
A2 | 横跨两列 | D2 | |
A3 | B3 | C3 | D3 |
<table>
<tr>
<td>A1</td>
<td>B1</td>
<td>C1</td>
<td>D1</td>
</tr>
<tr>
<td>A2</td>
<td rowspan="2">横跨两行</td>
<td>C2</td>
<td>D2</td>
</tr>
<tr>
<td>A3</td>
<td>C3</td>
<td>D3</td>
</tr>
<tr>
<td>A4</td>
<td>B4</td>
<td>C4</td>
<td>D4</td>
</tr>
</table>
A1 | B1 | C1 | D1 |
A2 | 横跨两行 | C2 | D2 |
A3 | C3 | D3 | |
A4 | B4 | C4 | D4 |
<table>
<tr>
<td>A1</td>
<td>B1</td>
<td>C1</td>
<td>D1</td>
</tr>
<tr>
<td>A2</td>
<td colspan="2" rowspan="3">横跨三行两列</td>
<td>D2</td>
</tr>
<tr>
<td>A3</td>
<td>D3</td>
</tr>
<tr>
<td>A4</td>
<td>D4</td>
</tr>
<tr>
<td>A5</td>
<td>B5</td>
<td>C5</td>
<td>D5</td>
</tr>
</table>
A1 | B1 | C1 | D1 |
A2 | 横跨三行两列 | D2 | |
A3 | D3 | ||
A4 | D4 | ||
A5 | B5 | C5 | D5 |
重点来了,markdown 语法的表格中,单元格如何换行?只需使用 <br />
即可,举例如下:
| 换行 | 未换行 |
|--- |--- |
| First <br /> Second <br /> Third | First Second Third |
换行 | 未换行 |
---|---|
First Second Third | First Second Third |