Markdown中的目录表,仅使用标准的/开箱即用的Github Pages工具吗? [英] Table of Contents in Markdown, using only the standard / out of the box Github Pages tooling?

查看:131
本文介绍了Markdown中的目录表,仅使用标准的/开箱即用的Github Pages工具吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用纯粹托管的开箱即用" GitHub Pages Jekyll建立博客/文档;我专门试图避免在本地运行Jekyll(尽管可以).

Trying to setup up a blog / documentation using purely hosted / "out of the box" GitHub Pages Jekyll; I am specifically trying to avoid having to run Jekyll locally (although I can).

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

I have tried http://www.seanbuscay.com/blog/jekyll-toc-markdown/ but that doesn't work.

这是否可行,或者确实需要其他工具吗?

Is this possible, or does it truly require additional tooling?

推荐答案

默认情况下,Jekyll使用Kramdown,它已经附带了TOC生成器.您不需要为此的插件,因此它可以与github-pages一起使用.

By default Jekyll uses Kramdown, it already comes with a TOC generator. You don't need a plugin for this so it will work with github-pages.

kramdown支持自动生成目录的目录 设置了ID的所有标头.只需指定参考名称"toc" 使用IAL排序到有序列表或无序列表,该列表将是 替换为实际的目录,呈现为嵌套 无序列表(如果将"toc"应用于无序列表),否则为 嵌套的有序列表.应用于原始列表的所有属性将 也将应用于生成的目录列表,它将获得ID为 如果未设置ID,则为markdown-toc.

kramdown supports the automatic generation of the table of contents of all headers that have an ID set. Just assign the reference name "toc" to an ordered or unordered list by using an IAL and the list will be replaced with the actual table of contents, rendered as nested unordered lists if "toc" was applied to an unordered list or else as nested ordered lists. All attributes applied to the original list will also be applied to the generated TOC list and it will get an ID of markdown-toc if no ID was set.

# 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

这篇关于Markdown中的目录表,仅使用标准的/开箱即用的Github Pages工具吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆