119

有没有办法在github markdown上有“ colspan ” ?

我正在尝试创建一个表格,其中一行占用四列。

| One     | Two        | Three   | Four          | 
| ------------- |-------------| ---------| ------------- |
| One                | Two               | Three          | Four                |

| One     | Two        | Three   | Four          | 
| ------------- |-------------| ---------| ------------- |
| Span Across ||||

您可以通过在此处粘贴以上内容来查看实时预览 http://markdown-here.com/livedemo.html

4

5 回答 5

100

您可以在 GitHub 上使用 HTML 表格(但不能在 StackOverflow 上)

<table>
  <tr>
    <td>One</td>
    <td>Two</td>
  </tr>
  <tr>
    <td colspan="2">Three</td>
  </tr>
</table>

变成

HTML表格输出

于 2014-08-19T18:08:42.707 回答
66

妥协最小解决方案:

| One    | Two | Three | Four    | Five  | Six 
| -
| Span <td colspan=3>triple  <td colspan=2>double

因此,您可以省略关闭</td>以提高速度,或者可以离开以保持一致性。

来自http://markdown-here.com/livedemo.html的结果: 带有 colspan 的降价表

在 Jupyter Markdown 中工作。

更新:

从 2019 年开始,Jupyter Markdown 中的所有第二行管道都是强制性的。

| One    | Two | Three | Four    | Five  | Six
|-|-|-|-|-|-
| Span <td colspan=3>triple  <td colspan=2>double

最低限度:

One    | Two | Three | Four    | Five  | Six
-|||||-
Span <td colspan=3>triple  <td colspan=2>double
于 2017-02-07T13:25:27.263 回答
19

没有办法这样做。要么使用 HTML 表格,要么将相同的文本放在多个单元格上。

像这样:

| Can Reorder | 2nd operation |2nd operation |2nd operation |
| :---: | --- |
|1st operation|Normal Load <br/>Normal Store| Volatile Load <br/>MonitorEnter|Volatile Store<br/> MonitorExit|
|Normal Load <br/> Normal Store| | | No|
|Volatile Load <br/> MonitorEnter| No|No|No|
|Volatile store <br/> MonitorExit| | No|No|

看起来像

HTML 表格

于 2015-12-03T09:05:33.257 回答
15

我最近需要做同样的事情,并且很高兴 colspan 在连续管道上运行良好 ||

MultiMarkdown v4.5

在 v4.5(macports 上的最新版本)和 v5.4(homebrew 上的最新版本)上测试。不知道为什么它在您提供的实时预览网站上不起作用。

我开始的一个简单测试是:

| Header ||
|--------------|
| 0 | 1 |

使用命令:

multimarkdown -t html test.md > test.html
于 2016-10-10T12:16:04.200 回答
-11

添加break解决您的问题。由于 Markdown 不支持太多功能,因此您可以在单元格中存储多条记录。

于 2019-07-04T07:41:44.703 回答