【问题标题】:sublist numbering in asciidocasciidoc 中的子列表编号
【发布时间】:2023-03-04 15:32:01
【问题描述】:

我需要以这种确切格式显示一个列表:

1. First item 1.1. Subitem 1.1.1. Sub-subitem 1.1.2. Sub-subitem 1.2. Subitem 2. Second item ...

有没有办法使用 asciidoc 实现这一点?

我发现更接近的方法是使用水平标记列表,但呈现与普通编号列表不同。

【问题讨论】:

    标签: text-formatting asciidoc asciidoctor


    【解决方案1】:

    到目前为止我找到的更接近的解决方案:

    {empty}1. First item +
    {nbsp}{nbsp}1.1. Subitem +
    {nbsp}{nbsp}{nbsp}{nbsp}1.1.1. Sub-subitem +
    {nbsp}{nbsp}{nbsp}{nbsp}1.1.2. Sub-subitem +
    {nbsp}{nbsp}1.2. Subitem +
    {empty}2. Second item +
    ...
    

    呈现为:

    1. First item
      1.1. Subitem
        1.1.1. Sub-subitem
        1.1.2. Sub-subitem
      1.2 Subitem
    2. Second item
    ...
    

    【讨论】:

      【解决方案2】:

      如果你想让 CSS 完成编号的工作,你可以向 Asciidoctor 申请 this solution

      ++++
      <style>
      ol {
        list-style-type: none;
        counter-reset: item;
        margin: 0;
        padding: 0;
      }
      
      ol > li {
        display: table;
        counter-increment: item;
        margin-bottom: 0.6em;
      }
      
      ol > li:before {
        content: counters(item, ".") ". ";
        display: table-cell;
        padding-right: 0.6em;
      }
      
      li ol > li {
        margin: 0;
      }
      
      li ol > li:before {
        content: counters(item, ".") " ";
      }
      </style>
      ++++
      
      . First item
      .. Subitem
      ... Sub-subitem
      ... Sub-subitem
      .. Subitem
      . Second item
      

      会产生

      【讨论】:

        【解决方案3】:

        这是给PDF

        将此文件放入文件夹并运行asciidoctor-pdf -r ./numbers.rb example.adoc

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2016-12-27
          • 1970-01-01
          • 1970-01-01
          • 2022-07-11
          • 1970-01-01
          • 2014-01-16
          • 2016-09-17
          • 1970-01-01
          相关资源
          最近更新 更多