有可能在Markdown中创建一个没有标题的表吗?

HTML看起来是这样的:

<table>
<tr>
    <td>Key 1</td>
    <td>Value 1</td>
</tr>
<tr>
    <td>Key 2</td>
    <td>Value 2</td>
</tr>
</table>

当前回答

至少对于GitHub flavated Markdown,你可以通过使用常规的__或**格式使所有非标题行条目加粗来产生错觉:

|Regular | text | in header | turns bold |
|-|-|-|-|
| __So__ | __bold__ | __all__ | __table entries__ |
| __and__ | __it looks__ | __like a__ | __"headerless table"__ |

其他回答

<style>
    .headerless th {
        display: none;
    }
</style>

<div class="headerless">

| | |
|---|---|
|Some |table |
| WITHOUT | header |
</div>

|This|is|
|---|---|
|Some |table |
| WITH |header |

通用解决方案

不幸的是,许多建议并不适用于所有Markdown查看器/编辑器,例如,流行的Markdown查看器Chrome扩展,但它们确实适用于iA Writer。

在这两种流行的程序中(可能也适用于您的特定应用程序)使用HTML注释块('<!- - - - - >”):

| <!-- -->    | <!-- -->    |
|-------------|-------------|
| Foo         | Bar         |

就像前面提到的一些建议一样,这确实会在Markdown查看器/编辑器中添加一个空标题行。在iA Writer中,它在美学上足够小,不会对我造成太大影响。

如果你不介意留空浪费一行,可以考虑下面的hack(这是一个hack,只有当你不喜欢添加任何额外的插件时才使用它)。

|   |   |
|---|---|
|__Bold Key__| Value1 |
| Normal Key | Value2 |

要查看上面的效果,请复制上面的内容并访问https://stackedit.io/app

它与GitLab/GitHub的Markdown实现一起工作。

你可以隐藏一个标题,如果你可以添加以下CSS:

<style>
    th {
        display: none;
    }
</style>

这有点笨重,并且没有区分表,但是对于一个简单的任务来说可以做到。

更新

HTML输出在Markdown编辑器之间是不同的,但是如果表格包含了一个标题元素,你可以更具体地针对空标题单元格:

thead th:empty {
    border: thin solid red !important;
    display: none;
}

如果标题行不包含可见内容,则此方法有效。条形之间的空格是可以的。

至少对于GitHub flavated Markdown,你可以通过使用常规的__或**格式使所有非标题行条目加粗来产生错觉:

|Regular | text | in header | turns bold |
|-|-|-|-|
| __So__ | __bold__ | __all__ | __table entries__ |
| __and__ | __it looks__ | __like a__ | __"headerless table"__ |