如何在降价表内写入列表?

时间:2013-11-13 09:57:32

标签: html markdown github-flavored-markdown

可以在降价表内创建一个列表(子弹,编号或不编号)。

表格如下:

| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
| zebra stripes | are neat      |    $1 |

列表如下所示:

* one
* two
* three

我能以某种方式合并吗?

6 个答案:

答案 0 :(得分:205)

是的,您可以使用HTML合并它们。当我在Github的.md文件中创建表时,我总是喜欢使用HTML代码而不是降价。

Github Flavored Markdown支持.md文件中的基本HTML。所以这就是答案:

Markdown与HTML混合:

| Tables        | Are           | Cool  |
| ------------- |:-------------:| -----:|
| col 3 is      | right-aligned | $1600 |
| col 2 is      | centered      |   $12 |
| zebra stripes | are neat      |    $1 |
| <ul><li>item1</li><li>item2</li></ul>| See the list | from the first column|

或纯HTML:

<table>
  <tbody>
    <tr>
      <th>Tables</th>
      <th align="center">Are</th>
      <th align="right">Cool</th>
    </tr>
    <tr>
      <td>col 3 is</td>
      <td align="center">right-aligned</td>
      <td align="right">$1600</td>
    </tr>
    <tr>
      <td>col 2 is</td>
      <td align="center">centered</td>
      <td align="right">$12</td>
    </tr>
    <tr>
      <td>zebra stripes</td>
      <td align="center">are neat</td>
      <td align="right">$1</td>
    </tr>
    <tr>
      <td>
        <ul>
          <li>item1</li>
          <li>item2</li>
        </ul>
      </td>
      <td align="center">See the list</td>
      <td align="right">from the first column</td>
    </tr>
  </tbody>
</table>

这就是它在Github上的表现:

  

答案 1 :(得分:73)

如果您想在单元格中使用无子弹列表(或任何其他非标准用途)或更多行,请使用<br />

| Event         | Platform      | Description |
| ------------- |-----------| -----:|
| `message_received`| `facebook-messenger`<br/>`skype`|

答案 2 :(得分:42)

我不知道,因为我知道所有降价参考,like this one,提及:

  

单元格内容必须只在一行

您可以使用Markdown Tables Generator进行尝试(其示例与您在问题中提到的示例类似,因此您可能已经意识到这一点。)

Pandoc

如果您使用Pandoc’s markdown所基于的{{3>}(扩展 John Gruber’s markdown syntax),您可以使用GitHub Flavored Markdown

+---------------+---------------+--------------------+
| Fruit         | Price         | Advantages         |
+===============+===============+====================+
| Bananas       | $1.34         | - built-in wrapper |
|               |               | - bright color     |
+---------------+---------------+--------------------+
| Oranges       | $2.10         | - cures scurvy     |
|               |               | - tasty            |
+---------------+---------------+--------------------+

grid_tables

-------------------------------------------------------------
 Centered   Default           Right Left
  Header    Aligned         Aligned Aligned
----------- ------- --------------- -------------------------
   First    row                12.0 Example of a row that
                                    spans multiple lines.

  Second    row                 5.0 Here's another one. Note
                                    the blank line between
                                    rows.
-------------------------------------------------------------

答案 3 :(得分:2)

另一种解决方案,您可以在表中添加<br>标记

    |Method name| Behavior |
    |--|--|
    | OnAwakeLogicController(); | Its called when MainLogicController is loaded into the memory , its also hold the following actions :- <br> 1. Checking Audio Settings <br>2. Initializing Level Controller|

enter image description here

答案 4 :(得分:1)

我最近实现的另一种方法是将div-table pluginpanflute一起使用。

这会根据一组带围栏的div(在markdown的pandoc实现中为标准)创建一个表格,其布局类似于html:

---
panflute-filters: [div-table]
panflute-path: 'panflute/docs/source'
---

::::: {.divtable}
:::: {.tcaption}
a caption here (optional), only the first paragraph is used.
::::
:::: {.thead}
[Header 1]{width=0.4 align=center}
[Header 2]{width=0.6 align=default}
::::
:::: {.trow}
::: {.tcell}

1. any
2. normal markdown
3. can go in a cell

:::
::: {.tcell}
![](https://pixabay.com/get/e832b60e2cf7043ed1584d05fb0938c9bd22ffd41cb2144894f9c57aae/bird-1771435_1280.png?attachment){width=50%}

some text
:::
::::
:::: {.trow bypara=true}
If bypara=true

Then each paragraph will be treated as a separate column
::::
any text outside a div will be ignored
:::::

看起来像:

enter image description here

答案 5 :(得分:1)

如果您使用html方法:

不要添加空行

赞:

<table>
    <tbody>

        <tr>
            <td>1</td>
            <td>2</td>
        </tr>

        <tr>
            <td>1</td>
            <td>2</td>
        </tr>

    </tbody>
</table>

标记将中断。

删除空白行:

<table>
    <tbody>
        <tr>
            <td>1</td>
            <td>2</td>
        </tr>
        <tr>
            <td>1</td>
            <td>2</td>
        </tr>
    </tbody>
</table>