【问题标题】:Create a Table with highlighted Source Code in Asciidoc在 Asciidoc 中使用突出显示的源代码创建表
【发布时间】:2019-04-03 06:24:28
【问题描述】:

我想在表格中突出显示我的一些代码。我尝试了很多方法,但我可以解决它。

如果有人可以帮助我,我将不胜感激。

【问题讨论】:

    标签: ascii asciidoc ascii-art asciidoctor


    【解决方案1】:

    好问题!

    大多数 AsciiDoc 语法不会在表中呈现,只有基本语法,如 *bold*。 您必须明确告诉 Asciidoctor 渲染整个功能集。

    有两种方法:

    1) 将字符 a 添加到您希望 Asciidoctor 呈现完整语法的单元格的 |

    2) 通过在表格前面说明您的愿望,将整列配置为呈现为 AsciiDoc:[cols="a,a"] 将在两列表的两列中呈现 AsciiDoc。

    这里有一个要点来证明这一点: https://gist.github.com/rdmueller/b79f4b00890f75644a0186c4adda589a

    文档可以在这里找到:https://asciidoctor.org/docs/user-manual/#cols-format

    例子:

    |====
    |Col1 | Col2
    | even complex formattings like source code highlighting works this way
    a|
    [source, groovy]
    ----
    5.times {
        println it
    }
    ----
    |====
    
    [cols="a,a"]
    |====
    |Col1 | Col2
    | even complex formattings like source code highlighting works this way
    |
    [source, groovy]
    ----
    5.times {
        println it
    }
    ----
    |====
    

    查看这些示例的渲染要点

    【讨论】:

    • 你能给我举个例子吗?
    • 这些例子适合吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-09
    • 2010-11-21
    • 1970-01-01
    • 2015-09-14
    相关资源
    最近更新 更多