在 Github 上创建 Table 的目录 (TOC):有没有办法去掉要点,使目录更清晰?

Creating a Table of Contents (TOC) on Github: Is there a way I can get rid of the bullet points so I can have a cleaner TOC?

每当我尝试时,即使将 HTML 和 CSS 与 list-style-type: none 一起使用,我似乎也无法摆脱要点。

我设法得到的最远的是添加一个 <style> 元素,它确实有效但 Github 没有完全解析 HTML 并且 <style> 元素也显示为纯文本,这不是我在 VS Code 上获得的行为。

<style>
  #TOC ul {
    list-style-type: none;
  }
</style>

<div id="TOC">
  <ul>
    ...
  </ul>
</div>

渲染后文本 <style> #TOC ul { list-style-type: none; } </style> 将出现在真实目录之前。

来自 @Waylan's comment: GitHub documents their Markup processing here。请注意,第二步——在第一步中将 Markdown 转换为 HTML 之后——通过以下方式清理 HTML:

(...) aggressively removing things that could harm you and your kin—such as script tags, inline-styles, and class or id attributes.

这意味着 Github 故意不希望用户创建自定义样式,因此,理论上,您不能真正按照您的要求去做。但是,在实践中,您仍然可以通过以下方式利用 Github 的 CSS:

<div id="user-content-toc">
  <ul>
    ...
  </ul>
</div>

这就是最终实践中的样子——你可以查看示例 here:

请记住,这肯定不是理想的。因为 Github 可能会随时更改 id,这会破坏您的样式。尽管如此,在 id 消失的情况下,在最坏的情况下,事情将默认为 <ul> — 这并不像它们完全扭曲 <ul> 的行为的情况那么糟糕,所以请注意出来了!

I've converted this whole ordeal into a post on my website, fanaro.io.