是否有可能生成一个自动目录使用Github调味Markdown?


当前回答

现在有一个GitHub行动完成这一点:

https://github.com/marketplace/actions/toc-generator

指定TOC的位置(选项) 例如README.md

<!-- START doctoc -->
<!-- END doctoc -->

设置工作流程 例如.github /工作流/ toc.yml

on: push
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/toc-generator@v2

其他回答

Github调味Markdown使用红地毯作为他们的Markdown引擎。 摘自RedCarpet回购:

:with_toc_data -添加HTML锚的每个头在输出HTML, 允许链接到每个部分。

似乎你需要在渲染器级别设置这个标志,这在Github上显然是不可能的。然而,Github Pages的最新更新,似乎自动锚定是为标题打开的,创建可链接的标题。这不是你想要的,但它可能会帮助你更容易地为你的文档创建一个TOC(尽管是手动的)。

现在有一个GitHub行动完成这一点:

https://github.com/marketplace/actions/toc-generator

指定TOC的位置(选项) 例如README.md

<!-- START doctoc -->
<!-- END doctoc -->

设置工作流程 例如.github /工作流/ toc.yml

on: push
name: TOC Generator
jobs:
  generateTOC:
    name: TOC Generator
    runs-on: ubuntu-latest
    steps:
      - uses: technote-space/toc-generator@v2

更新2022 - 02年

在VSCode中,检查扩展“Markdown All In One”。自动生成并更新减记的TOC。

安装扩展。 将光标放在您想要插入TOC的位置。 运行命令“Markdown All in One:创建目录” 享受吧!

无耻的“借用”这个SO答案。

你可以用Pandoc做到这一点。

pandoc -s --toc input.md -o input_toc.md 

注意:输入和输出文件的顺序在这里很重要。

可以从README中使用http://documentup.com/自动生成一个网页。md文件。它不是创建TOC,但对于许多人来说,它可能解决了想要创建TOC的原因。

Documentup的另一个替代方案是Flatdoc: http://ricostacruz.com/flatdoc/