Markdown中的目录,仅使用标准/开箱即用的Github Pages工具?

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

尝试使用纯托管/“开箱即用”GitHub Pages Jekyll设置博客/文档;我特意试图避免在本地运行Jekyll(尽管我可以)。

我尝试过http://www.seanbuscay.com/blog/jekyll-toc-markdown/,但这不起作用。

这是可能的,还是真的需要额外的工具?

jekyll github-pages
1个回答
5
投票

默认情况下,Jekyll使用Kramdown,它已经配备了TOC生成器。你不需要一个插件,所以它将与github页面一起使用。

kramdown支持自动生成具有ID集的所有标头的目录。只需使用IAL将引用名称“toc”分配给有序或无序列表,列表将替换为实际目录,如果“toc”应用于无序列表或嵌套列表,则呈现为嵌套无序列表有序清单。应用于原始列表的所有属性也将应用于生成的TOC列表,如果未设置ID,它将获得markdown-toc的ID。

# Contents
{:.no_toc}

* Will be replaced with the ToC, excluding the "Contents" header
{:toc}

# H1 header

## H2 header

那会给你:

  <h1 class="no_toc" id="contents">Contents</h1>

<ul id="markdown-toc">
  <li><a href="#h1-header" id="markdown-toc-h1-header">H1 header</a>    <ul>
      <li><a href="#h2-header" id="markdown-toc-h2-header">H2 header</a></li>
    </ul>
  </li>
</ul>

<h1 id="h1-header">H1 header</h1>

<h2 id="h2-header">H2 header</h2>

https://kramdown.gettalong.org/converter/html.html#toc

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