表格的其余行的单元格数量可以有所不同。如果单元格数量比标题行中的单元格数量少,则会插入空单元格。如果单元格数量多,则多余的单元格将被忽略:
当然,您可以始终退回到原始的HTML代码。事实上,GitHub在其白名单中包含了rowspan
(及colspan
)属性。
<table>
<thead>
<tr>
<th>Layer 1</th>
<th>Layer 2</th>
<th>Layer 3</th>
</tr>
</thead>
<tbody>
<tr>
<td rowspan=4>L1 Name</td>
<td rowspan=2>L2 Name A</td>
<td>L3 Name A</td>
</tr>
<tr>
<td>L3 Name B</td>
</tr>
<tr>
<td rowspan=2>L2 Name B</td>
<td>L3 Name C</td>
</tr>
<tr>
<td>L3 Name D</td>
</tr>
</tbody>
</table>
请在https://jsfiddle.net/7h89y55r/上自行尝试。
<table><tr><td>This is not emphasized text: *the asterisks* will be rendered literally.</td></tr></table>
- chharvey<td>\n\n*markdown* [foo]\n\n</td>
https://github.github.com/gfm/#example-157 - Kroltan| | Grouping ||
First Header | Second Header | Third Header |
------------ | :-----------: | -----------: |
Content | *Long Cell* ||
Content | **Cell** | Cell |
New section | More | Data |
And more | With an escaped '\|' ||
[Prototype table]
我通常使用markdown-it(VSCode内置的markdown和我的Ghost博客都使用它),它只支持Github风格的表格,但有人为这些表格创建了一个扩展程序(markdown-it-multimd-table)。最终,你有多种选择。
jekyll-spaceship - 一个Jekyll插件,提供强大的支持,包括表格、mathjax、plantuml、mermaid、video、youtube、emoji、vimeo、dailymotion等。
https://github.com/jeffreytse/jekyll-spaceship
目前,提供以下扩展功能:上述代码将被解析为:
我在评论区回答了OP提出的关于替代解决方案的问题,但由于评论被压缩成了一行,所以我将其添加到这里作为答案,以便正确显示格式。
你可以使用AsciiDoc而不是Markdown。GitHub现在支持它。只需使用README.adoc
而不是README.md
。你的AsciiDoc语法表格如下:
[cols="^.^,^.^,^.^"]
|===
|Layer1 |Layer2 |Layer3
.4+|L1 Name .2+|L2 Name A |L3 Name A
|L3 Name B
.2+|L2 Name B |L3 Name C
|L3 Name D
|===
| | Grouping || Grouping 2 || Not Grouped |
| First Header | Second Header | Third Header | Forth Header | Fifth Header | Sixth Header |
| ------------- | :-----------: | -------------: | :----------: | :----------: | --------------- |
| Tall Cell | *Long Cell* || *Long Long Cell* |||
| ^^ | **Bold** | 1. first item | *Italic* | 3. third item | + first point |\
| ^^ | | 1. second item | | 1. forth item | + second point |
| New section | More | Data | ... - -- --- |||
| And more | With an escaped \| || "Try 'quotes' in quotes " |||
[Compicated table]
将呈现为:
我正在使用Postman记录API,并发现您可以通过在| |分隔符中插入HTML来混合行自述文件.md注释,以创建更加强大的设计。我认为对于其他使用标记语言(如GitHub)的平台也是一样的,您可以尝试一下看看是否有效。
以下示例将一个表格嵌套在另一个表格单元格中:
| Field | Description | Optional | Default |
| ------ | ----------- | --------- | ------- |
| manual_entry_indicator | no: is not is allow manual entry <br /> yes: is manual entry enabled| yes | no |
| amounts | json object containing all transaction amounts <br /> <br /> <table> <tr> <td> Subfield </td> <td> Description </td> <td> Optional </td> <td> Default </td> </tr> <tr> <td> tip </td> <td> transaction tip amount </td> <td> yes </td> <td> NA </td> </tr> <tr> <td> total </td> <td> equal to Base Amount + Base amount for Reduced State Tax + City Tax + State Tax + Reduced State Tax + Tip or Cash back </td> <td> no </td> <td> NA </td> </tr> <tr> <td> cashback </td> <td> cash back amount </td> <td> yes </td> <td> NA </td> </tr> <tr> <td> state_tax </td> <td> State tax amount </td> <td> yes </td> <td> NA </td> </tr> <tr> <td> city_tax </td> <td> City tax amount </td> <td> yes </td> <td> NA </td> </tr> <tr> <td> reduced_tax </td> <td> Reduced state tax amount </td> <td> yes </td> <td> NA </td> </tr> <tr> <td> base_reduced_tax </td> <td> Reduced state tax base amount </td> <td> yes </td> <td> NA </td> </tr> </table> | no | NA |
[cols="^,^,^"] \n|=== \n|层1 |层2 |层3 \n \n.4+.^|L1名称 .2+.^|L2名称A |L3名称A \n|L3名称B \n.2+.^|L2名称B |L3名称C \n|L3名称D \n \n|===
。请将所有\n
替换为行分隔符。 - Peter