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

HTML看起来是这样的:

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

当前回答

$ cat foo.md
Key 1 | Value 1
Key 2 | Value 2
$ kramdown foo.md
<table>
  <tbody>
    <tr>
      <td>Key 1</td>
      <td>Value 1</td>
    </tr>
    <tr>
      <td>Key 2</td>
      <td>Value 2</td>
    </tr>
  </tbody>
</table>

其他回答

什么工作在GitHub问题编辑器是

&nbsp; |&nbsp;
------ | ---
Foo    | Bar

但它确实显示了一个空标题

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

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

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

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

通用解决方案

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

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

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

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

至少对于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 |