代码之家  ›  专栏  ›  技术社区  ›  dev-masih Ash Ghal

我可以合并降价中的表行吗

  •  153
  • dev-masih Ash Ghal  · 技术社区  · 7 年前

    有没有办法在标记文件(如自述文件)中的表列中创建合并行。md文件?

    table

    7 回复  |  直到 7 年前
        1
  •  110
  •   Waylan    7 年前

    不,这在GitHub风格的降价中是不可能的。作为 spec 解释(增加强调):

    其余的表格行可能因单元格数量而异。如果单元格数量少于标题行中的单元格数量, . 如果有更大的,则 忽略多余部分 :

    当然,您总是可以回到原始HTML。事实上,GitHub包括 rowspan (和 colspan )属性 whitelist .

    <table>
        <thead>
            <tr>
                <th>Layer 1</th>
                <th>Layer 2</th>
                <th>Layer 3</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td rowspan=4>L1 Name</td>
                <td rowspan=2>L2 Name A</td>
                <td>L3 Name A</td>
            </tr>
            <tr>
                <td>L3 Name B</td>
            </tr>
            <tr>
                <td rowspan=2>L2 Name B</td>
                <td>L3 Name C</td>
            </tr>
            <tr>
                <td>L3 Name D</td>
            </tr>
        </tbody>
    </table>
    

    你自己试试吧 https://jsfiddle.net/7h89y55r/

        2
  •  33
  •   Ben Creasy Dgon Tarn    6 年前

    标准commonmark不支持表,也不引用或推荐任何特定的表扩展( latest revision permalink as of 2018-03 ). 您的问题并没有具体询问Github风格的标记(GFM),但GFM基于commonmark,带有一个表扩展,不支持这一点。

    MultiMarkdown 至少v5支持这些类型的表( docs permalink )与PHP Markdown Extra的Michael Fortin相同,他转向:

    |             |          Grouping           ||
    First Header  | Second Header | Third Header |
     ------------ | :-----------: | -----------: |
    Content       |          *Long Cell*        ||
    Content       |   **Cell**    |         Cell |
    
    New section   |     More      |         Data |
    And more      | With an escaped '\|'         ||  
    [Prototype table]
    

    进入 Table

    我经常使用 markdown-it (VSCode内置降价&我的Ghost博客使用它),它只支持Github风格的表,但有人创建了一个扩展( markdown-it-multimd-table

        3
  •  11
  •   J.T.    3 年前

    如果您使用的是Jekyll,则支持表格单元格 对齐 , 合并 等等,我认为下面我写的可以帮助你做得更容易。

    杰基尔太空船- 一个Jekyll插件,为

    https://github.com/jeffreytse/jekyll-spaceship

    目前,提供了以下扩展功能:

    • 跨多列的单元格
    • 跨多行的单元格
    • 不需要表格标题
    • 分组的表标题行或数据行

    table code

    上述代码将解析为:

    html table

        4
  •  4
  •   PickBoy    5 年前

    vscode插件 Markdown Extended 通过集成,支持其他答案描述的扩展表格式 markdown-it-multimd-table

        5
  •  4
  •   Peter    4 年前

    我在关于替代解决方案的评论中回答了OP的问题,但评论被压缩到了一行。将其作为答案添加到此处以正确显示格式。

    README.adoc 而不是 README.md 您的AsciiDoc语法表:

    [cols="^.^,^.^,^.^"]
    |===
    |Layer1 |Layer2 |Layer3
    
    .4+|L1 Name .2+|L2 Name A |L3 Name A
    |L3 Name B
    .2+|L2 Name B |L3 Name C
    |L3 Name D
    |===
    
        6
  •  3
  •   arkhein    3 年前

    在标准降价中是不可能的,但是,有一些解决方案支持此功能。前面提到的多重降价之一,但我想推荐另一个支持它的在线降价编辑器: μr² editor

    它支持行和列合并,还可以从输出中生成漂亮的PDF。例子:

    |               |          Grouping             ||         Grouping 2         ||  Not Grouped    |
    | First Header  | Second Header | Third Header   | Forth Header | Fifth Header | Sixth Header    |
    | ------------- | :-----------: | -------------: | :----------: | :----------: | --------------- |
    | Tall Cell     |          *Long Cell*          ||         *Long Long Cell*                    |||
    | ^^            |   **Bold**    | 1. first item  | *Italic*     | 3. third item | + first point  |\
    | ^^            |               | 1. second item |              | 1. forth item | + second point |
    
    | New section   |     More      |         Data   | ... - -- --- |||
    | And more      | With an escaped \|          || "Try 'quotes' in quotes "         |||
    [Compicated table]
    

    将呈现为:

    enter image description here

        7
  •  0
  •   Shay Ribera    3 年前

    我使用Postman来记录一个API,发现你可以混合行自述。通过在| |分隔符中插入HTML来使用HTML进行md标记,从而使设计更加稳健。我假设其他使用标记的平台(如GitHub)也是如此,试试看它是否适合您。

    以下示例将表格嵌套在表格单元格中:

           | Field  | Description |  Optional | Default |
           | ------ | ----------- | --------- | ------- |
           | manual_entry_indicator | no: is not is allow manual entry <br /> yes: is manual entry enabled| yes | no |
           | amounts | json object containing all transaction amounts <br /> <br /> <table> <tr> <td> Subfield </td> <td> Description </td> <td> Optional </td> <td> Default </td> </tr> <tr> <td> tip </td>  <td> transaction tip amount </td> <td> yes </td> <td> NA </td> </tr> <tr> <td> total </td> <td> equal to Base  Amount + Base amount for  Reduced State Tax + City Tax + State Tax + Reduced State Tax + Tip or Cash back </td> <td> no </td> <td> NA </td> </tr> <tr> <td> cashback </td> <td> cash back amount </td> <td> yes </td> <td> NA </td> </tr> <tr> <td> state_tax </td> <td> State tax amount </td> <td> yes </td> <td> NA </td> </tr> <tr> <td> city_tax </td> <td> City tax amount </td> <td> yes </td> <td> NA </td> </tr> <tr> <td> reduced_tax </td> <td> Reduced state tax amount </td> <td> yes </td> <td> NA </td> </tr> <tr> <td> base_reduced_tax </td> <td> Reduced state tax base amount </td> <td> yes </td> <td> NA </td> </tr> </table> | no | NA |
    

    will be rendered like this