Toggle

重新回归简书,目前仍在使用的

  1. 博客: http://skyrover.me
  2. Github: https://github.com/Microndgt

Toggle是一个给markdown文件或者数据加目录的小工具,点击目录项就可以跳转到相应章节,简书貌似不支持markdown锚点,Github上的md文件预览是可以的,比如https://github.com/Microndgt/toggle

已经发布在Github上了toggle in GitHub,欢迎star和修正。

toggle

generate and update markdown table of contents on the top of md file

Usage

QuickStart

t = Toggle(filename="path/to/file", url_prefix="content/url/prefix")
# 生成目录
t.generate()  # return contents of md
# 更新目录
t.update()  # return contents of md

arguments of Toggle

  • url_prefix: 该md显示网页的url
  • filename: 输入为文件路径
  • content: 输入为文件内容数据,list,每一项为文件数据的一行,若同时输入文件名和文件数据,以文件数据优先
  • match_rules: 匹配规则,dict,默认匹配 === 和 ---,值为该匹配项对应生成的md目录行的前缀,如===对应-
  • sub_rules: 替换规则,dict以替换标题项中的字符,使得符合markdown解析规则,比如替换'.'为''

Author

SkyRover

推荐阅读更多精彩内容