使用Visual Studio Code Markdown是否可以创建和预览表格?

11
我正在使用Visual Studio Code编写一些笔记,其中使用了它的Markdown支持。我想添加一些表格,但是我找不到实现的方法。似乎Visual Studio Code实现的是CommonMark标准,该标准规范中并没有包含表格。
我知道GitHub flavoured Markdown有一个表格扩展,提供了这个功能,并且有一些用于格式化表格的Visual Studio Code扩展(在此处和此处)。但是它们只是很好地布局了文本。我想在预览窗格中显示一个表格。
在Visual Studio Code中如何实现Markdown中的表格?
2个回答

19

现在您可以这样做:

| Letter | Digit | Character |
| :----: | :---: | :-------: |
| a      | 4     | $         |
|        | 365   | (         |
| b      |       | ^         |

“空”单元格中必须至少有一个空格。在 vscode 的 markdown 预览中会显示为:

markdown table demo in vscode preview


3

原始的Markdown规则如下:

For any markup that is not covered by Markdown's syntax, you simply use HTML itself. There's no need to preface it or delimit it to indicate that you're switching from Markdown to HTML; you just use the tags.

The only restrictions are that block-level HTML elements -- e.g. <div>, <table>, <pre>, <p>, etc. -- must be separated from surrounding content by blank lines, and the start and end tags of the block should not be indented with tabs or spaces. Markdown is smart enough not to add extra (unwanted) <p> tags around HTML block-level tags.

For example, to add an HTML table to a Markdown article:

This is a regular paragraph.

<table>
    <tr>
        <td>Foo</td>
    </tr>
</table>

This is another regular paragraph.

Note that Markdown formatting syntax is not processed within block-level HTML tags. E.g., you can't use Markdown-style *emphasis* inside an HTML block.


我猜它不是很漂亮,但它能用 - 谢谢。 - Captain Whippet

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接