减长表与长行

Nao*_*aor 24 markdown octopress

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

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. 
Run Code Online (Sandbox Code Playgroud)

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

Ste*_*sch 9

还有另一种选择.由于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.                                                    |
|-------------|---------------------------------------------------------------|
Run Code Online (Sandbox Code Playgroud)

... 并做了.

  • **快速读者的警告!**如果你需要获得一个HTML`表格,请不要使用这个.这个是生成一种ASCII艺术表.使用它四个空格缩进块(或GFM中的``'-wrapped block),你会得到一个单独的`tr`用于每一行(和每个连字符后的单独的`tbody`) (11认同)
  • 在移动设备或任何小屏幕/窗口上查看时,此情况会中断。 (3认同)

小智 6

遗憾的是您必须使用 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>
Run Code Online (Sandbox Code Playgroud)


Sam*_*Sam 5

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

Markdown支持"硬包装"文本段落.这与大多数其他文本到HTML格式化程序(包括Movable Type的"转换换行符"选项)明显不同,后者将段落中的每个换行符转换为<br />标记.

当您确实想要<br />使用Markdown 插入break标记时,您将结束包含两个或更多空格的行,然后键入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>
Run Code Online (Sandbox Code Playgroud)

我尝试添加style="width:75%"<td>s,没有任何影响.

*我应该注意到我遇到过这个因为我在使用GitHub风格的Markdown在表格中编写代码时遇到了类似的问题,这非常痛苦.但是我注意到这一点,因为它应该给我给出的例子着色:我所说的"有效"或"不起作用"的任何东西都来自那个环境.

编辑:如果你code的表中有块,可能还有一点值得注意的是这是无关紧要的.这不是Markdown的问题:HTML <code></code>块会导致表拉伸.

  • 我认为你错过了原来问题的要点。目标不是影响 Markdown 的最终渲染,而是控制输入文本的外观。`&lt;br/&gt;` 会在最终渲染中插入硬换行,但 OP 要求能够换行输入文件,这样其中的行就不会太长且难以阅读。 (7认同)