Markdown/github - 带有可折叠部分的嵌套缩进列表

问题描述 投票:0回答:1

如何创建 Markdown 列表:

  • 每个项目是否可折叠
  • 项目缩进,子项目缩进2次等等...
  • 每个级别包含的每个项目“主体”都有能力携带常规MD,包括子列表,也可折叠..等

这个页面提供了一些解决方案,但最可行的是纯HTML,不再有MD的意义了

markdown github-flavored-markdown readme
1个回答
0
投票

我们必须玩

details
summary
,还有......空格! 空格??是的:

  • 结束行上放置结束
    details
    标签的位置
  • 如何缩进整个章节正文

空间决定了它是否有效。

这是一个 2 级列表,其中包含可折叠元素和子元素,以及一些其他常规 Markdown 项目。

示例 在 github 中渲染。也适用于 VS-Code。不确定其他哪个引擎支持它。

代码:

- <details open>
  <summary><a href="#">Section 1 with a link</a></summary>

  - <details>
    <summary><a href="../src/actions/">subsection 2 with a link</a></summary>

    - a list
    - with some stuff

    > and other things

    - [x] like
    - [ ] a task list 

    </details>

  - <details>
    <summary><b>another subsection</a></summary>

    a. with another list
    b. and some other stuff
    d. [and](),
      [more](),
      [classic](),
      [md]
    e. _no need_ __of html__
    </details>

  - <details>
    <summary>last sub-section</a></summary>

    blablabla

    ```rb
    def some_code
      puts "Rails is so cool"
    end
    ```
    </details>

  - a random not collapsable section
    > legacy. Should be restructured.

    ```js
    console.log("look what I found, a new js framework. Still no real alternative to rails though")
    ```

  - <details>
    <summary>and another collapsable section</summary>

    ...
  </details>

- <details>
  <summary>section 2</summary>
      
  some parent content

  and another list

  - <details>
    <summary>section 2.1</summary>

      and some content
    </details>

  - <details>
    <summary>section 2.2</summary>

      and some content
    </details>
  
  - section 2.3
    and some no collapsed content

</details>

如您所见,并非所有引擎都支持它......就像这样一个:

  • 第 1 部分有链接
    • 第2小节带有链接
      • 清单
      • 一些东西

      还有其他事情

      • [x]喜欢
      • [ ] 任务列表
    • 另一小节

      a.与另一个列表 b.和其他一些东西 d.和, 更多的, 经典的, [MD] e. 不需要 html

    • 最后一小节

      布拉布拉布拉

      def some_code
        puts "Rails is so cool"
      end
      
    • 随机不可折叠部分

      遗产。应该重组。

      console.log("look what I found, a new js framework. Still no real alternative to rails though")
      
    • 和另一个可折叠部分

      ...

  • 第2节

    一些家长内容

    还有另一个列表

    • 第2.1节

      以及一些内容

    • 第2.2节

      以及一些内容

    • 第 2.3 节 还有一些没有折叠的内容

© www.soinside.com 2019 - 2024. All rights reserved.