重新回歸簡書晾捏,目前仍在使用的
- 博客: http://skyrover.me
- Github: https://github.com/Microndgt
Toggle是一個給markdown文件或者數(shù)據(jù)加目錄的小工具,點(diǎn)擊目錄項(xiàng)就可以跳轉(zhuǎn)到相應(yīng)章節(jié),簡書貌似不支持markdown錨點(diǎn)登下,Github上的md文件預(yù)覽是可以的卓练,比如https://github.com/Microndgt/toggle
已經(jīng)發(fā)布在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顯示網(wǎng)頁的url
- filename: 輸入為文件路徑
- content: 輸入為文件內(nèi)容數(shù)據(jù),list,每一項(xiàng)為文件數(shù)據(jù)的一行,若同時輸入文件名和文件數(shù)據(jù),以文件數(shù)據(jù)優(yōu)先
- match_rules: 匹配規(guī)則,dict,默認(rèn)匹配 === 和 ---,值為該匹配項(xiàng)對應(yīng)生成的md目錄行的前綴,如===對應(yīng)
-
- sub_rules: 替換規(guī)則,dict以替換標(biāo)題項(xiàng)中的字符,使得符合markdown解析規(guī)則,比如替換'.'為''