html - 在 Github 上创建目录 (TOC) : Is there a way I can get rid of the bullet points so I can have a cleaner TOC?

标签 html css github markdown tableofcontents

每当我尝试它时,即使使用带有 list-style-type: none 的 HTML 和 CSS ,我似乎无法摆脱要点。

我能做到的最远的是添加 <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的评论:GitHub 记录了他们的标记处理 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 :

Proper Github Table of Contents

请记住,这肯定不理想。因为 Github 可能会更改 id在任何时候,这都会破坏你的造型。尽管如此,在这种情况下id消失,在最坏的情况下,事情将默认为 <ul> - 这并不像他们完全扭曲 <ul> 的情况那么糟糕的行为,所以要小心!

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

关于html - 在 Github 上创建目录 (TOC) : Is there a way I can get rid of the bullet points so I can have a cleaner TOC?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65484669/

相关文章:

github - 要点没有完全显示在中

html - 使用 CSS 保持 div 的纵横比

html - 你能在 CSS flex 中指定包装元素的顺序吗?

javascript - Bootstrap 3同时打开多个导航元素

javascript - id(由 javascript 使用)在与 div 一起使用时不起作用,并且 div 的图像在另一个之后出现

asp.net - css 结构伪类

svn - 哪个版本控制系统或平台最适合跟踪和分发个人 Emacs 配置?

PyCharm 中的 Git 使用预先存在的存储库

jquery - 更改多背景 div 中一张背景图像的位置

html - 将 h1 安装在父级内部