44

我正在使用降价来创建一个表。我的描述列包含很长的文本,因此当我换行时它在降价文件上看起来很糟糕:

Argument            | Description |
--------            | ----------- |
appDir              | The top level directory that contains your app. If this
option is used then it assumed your scripts are in |a subdirectory under this path. This option is not required. If it is not specified, then baseUrl below is the anchor point for finding things. If this option is specified, then all the files from the app directory will be copied to the dir: output area, and baseUrl will assume to be a relative path under this directory.  
baseUrl             | By default, all modules are located relative to this path. If baseUrl is not explicitly set, then all modules are loaded relative to the directory that holds the build file. If appDir is set, then baseUrl should be specified as relative to the appDir.
dir                 | The directory path to save the output. If not specified, then the path will default to be a directory called "build" as a sibling to the build file. All relative paths are relative to the build file. 
modules             | List the modules that will be optimized. All their immediate and deep dependencies will be included in the module's file when the build is done. If that module or any of its dependencies includes i18n bundles, only the root bundles will be included unless the locale: section is set above. 

我想换行,因为它对我来说更具可读性。
有没有办法让表格对编辑器更具可读性?

4

5 回答 5

12

还有另一种选择。由于哲学认为 Markdown 应该是轻量级的,而不是标记语言,并且旨在供人类自然消费(与 SGML/HTML 样式格式相比),我相信在特殊情况下回退到 ASCII 艺术是很好和自然的.

对于这个特殊的任务,角色艺术是很自然的。因此,只需将表格缩进四个空格,将其格式化以提高可读性,Markdown 只会将其视为预先格式化的文本,双方就可以停止相互争斗。

例如:

|  Sequence   | Result                                                        |
|-------------|---------------------------------------------------------------|
| `a?c`       | Matches `abc`, `axc`, and `aac`. Does not match `ac`, `abbc`, | 
|             | or `a/c`.                                                     |
|-------------|---------------------------------------------------------------|
| `a*c`       | Matches "ac", "abc" and "azzzzzzzc". Does not match "a/c".    |
|-------------|---------------------------------------------------------------|
| `foo...bar` | Matches "foobar", "fooxbar", and "fooz/blaz/rebar". Does not  |
|             | match "fo/obar", "fobar" or "food/bark".                      |
|-------------|---------------------------------------------------------------|
| `....obj`   | Matches all files anywhere in the current hierarchy that end  |
|             | in ".obj". Note that the first three periods are interpreted  |
|             | as "...", and the fourth one is interpreted as a literal "."  |
|             | character.                                                    |
|-------------|---------------------------------------------------------------|

... 并做了。

于 2016-10-18T07:24:21.197 回答
7

我相信@Naor 是对的:您必须使用 HTML 来创建换行符,尽管答案中没有说明这一点。并且显示的完整表格代码并不是绝对必要的:要实现换行符,您只需要双空格或<br />标记。来自 Markdown 规范

Markdown 支持“硬包装”文本段落。这与大多数其他将段落中的每个换行符转换为<br />标签的文本到 HTML 格式化程序(包括 Movable Type 的“转换换行符”选项)有很大不同。

当您确实想<br />使用 Markdown 插入中断标记时,请以两个或更多空格结束一行,然后键入 return。

请注意,我必须在文本中添加代码包装器,因为 SO 风格的 Markdown 需要转义 HTML 中断标记 - 所以我们知道<br />有效。

但是,如果您想做一些更复杂的事情,比如我*,您可以使用 HTML 设置各种属性,如下所示:

<table width="300">
  <tr>
    <td> This is some text </td>
    <td> This is some somewhat longer block of text </td>
    <td> This is some very long block of text repeated to make it even longer. This is some very long block of text repeated to make it even longer. This is some very long block of text repeated to make it even longer.  </td>
  </tr>
</table>

我尝试添加style="width:75%"<td>s 中,但没有影响。

*我应该注意到我遇到了这个问题,因为我在使用 GitHub 风格的 Markdown 编写表格中的代码时遇到了类似的问题,这非常痛苦。但我注意到这一点是因为它应该为我给出的示例着色:我所说的“有效”或“无效”的任何事情都来自那个环境。

code编辑:如果您的表中有块,则可能进一步值得注意的是,这无关紧要。不过,这不是 Markdown 的问题:HTML<code></code>块会导致表格拉伸。

于 2013-11-12T10:04:05.963 回答
3

嗨,我想知道同样的事情。我需要这个作为文档文件,这就是我处理这个的方式:

| key | description                        |
| --- | ---                                |
| foo | bla bla blabla bla blabla bla bla  |
|     | bla bla blabla bla bla bla bla bla |
| bar | something else bla                 |

我同意上述 Sam 的观点,即 Markdown 被认为是“硬包装”语言,因此这是作弊(我想这不是有效的 Markdown)。但例如在几个 Github 项目README.md文件中,我看到人们像这样包装列表项:

 * foo
 * bla bla bla bla bla bla bla bla bla bla 
   bla bla bla bla bla bla bla bla bla

我的学院还指出http://www.tablesgenerator.com/markdown_tables以类似的方式包装表格(感谢汤姆)

因此,如果您正在做一些不会被解析的事情(例如 Github 文档),我认为可以使用我的示例,但如果您正在对 HTML 解析器或 Cucumber 测试表进行一些 Markdown,则不应该换行。

但我可能错了

于 2014-10-24T10:14:38.590 回答
1

遗憾的是,您必须为此使用 HTML

<table>
<tr>
<th>Argument</th>
<th>Description</th>
</tr>
<tr>
<td>appDir</td>
<td>The top level directory that contains your app. If this option is used then
it assumed your scripts are in</td>
</tr>
<tr>
<td>baseUrl</td>
<td>By default, all modules are located relative to this path. If baseUrl is not
explicitly set, then all modules are loaded relative to the directory that holds
the build file. If appDir is set, then baseUrl should be specified as relative
to the appDir.</td>
</tr>
<tr>
<td>dir</td>
<td>The directory path to save the output. If not specified, then the path will
default to be a directory called "build" as a sibling to the build file. All
relative paths are relative to the build file.</td>
</tr>
<tr>
<td>modules</td>
<td>List the modules that will be optimized. All their immediate and deep
dependencies will be included in the module's file when the build is done. If
that module or any of its dependencies includes i18n bundles, only the root
bundles will be included unless the locale: section is set above.</td>
</tr>
</table>
于 2013-04-11T19:47:21.983 回答
1

这不是一个捷径,而是一个格式化选项:

而不是这样做:

| TABLE  | NUMBER | RELATIONSHIPS |
| ------ | ------ | ------------- |
| TABLEA | NUM001 | TABLE2, TABLE4, TABLE7 |
| TABLEB | NUM002 | TABLEA |

你可以这样做:

| TABLE  | NUMBER | RELATIONSHIPS |
| ------ | ------ | ------------- |
| TABLEA | NUM001 | TABLE2        | 
|        |        | TABLE4        |
|        |        | TABLE7        |
| TABLEB | NUM002 | TABLEA        |

并简单地在没有多行数据的列中留下空格。一个体面的代码编辑器可以帮助进行大量格式化,因此您无需手动输入多个空格。

于 2021-12-02T22:45:15.070 回答