1sters / material_design_zh

Material Design 中文协同翻译 - design.1sters.com

Home Page:http://design.1sters.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

如何添加锚点

vincent4j opened this issue · comments

markdown 在 标题标签(#、## 等)下会自动将其添加为锚点,并且锚点的 id 就为标签的内容;然而,我们的内容大多是中文,就会被转化成 Unicode,可读性较差。

不考虑可读性

直接添加标题标签自动生成的锚点 id,形如:#%E6%94%AF%E6%8C%81-android-21-%E5%8F%8A%E4%BB%A5%E4%B8%8A%E7%89%88%E6%9C%AC

举例:

https://github.com/vincent4j/android-training-course-in-chinese/blob/gh-pages/SOURCE/basics/actionbar/setting-up.md#%E4%BB%85%E6%94%AF%E6%8C%81-android-30-%E5%8F%8A%E4%BB%A5%E4%B8%8A%E7%89%88%E6%9C%AC

考虑可读性

不使用 标题标签,直接通过 html 语言替代,如此锚点 id 就可以自行指定。
效果:http://daringfireball.net/projects/markdown/syntax#overview
源码:http://daringfireball.net/projects/markdown/syntax.text

提示:此方法在 github 上不可行,但在 Jekyll 上是可行的。原因应该是,github 上的 markdown 语法是对标准 markdown 语法有过优化。所以对我们的工程来说,这样写是完全没问题的,因为我们最终跑在 Jekyll 上。
示例效果:
http://design.1sters.com/material_design/components/menus.html#menus_behavior
示例源码:
https://github.com/1sters/material_design_zh/blob/master/SOURCE/components/menus.md