Home

Awesome

markdown_toc

a flexible markdown toc with more custom style && freedom

用法

see demo/lite/index.html

<script type="text/javascript" src="../../js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../../src/markdown_toc.js"></script>
<script type="text/javascript" >
$(document).ready(function(){
	$('#tree').markdown_toc({
		is_auto_number:true
	});
});
</script>

依赖

目前只有1个依赖库

定制

定制步骤

  1. 修改markdown_toc里的compile_headers_with_item函数
  2. 按照自己的需求修改返回的html结构,参数item是节点对象

定制方法

<script type="text/javascript" src="../../js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="../../src/markdown_toc.js"></script>
<script type="text/javascript" >
$(document).ready(function(){
	$('#tree').markdown_toc({
		is_auto_number:true,
		compile_headers_with_item:function(item){
			return " <h"+item.level +"><a href='#" +item.id+ "'>" + item.orderd_title + "</a></h"+item.level +">"
		}
	});
});
</script>

item对象

item = {
  "id": 2105,
  "level": 1,
  "orderd_title": "21.5. 三部分的关系",
  "origin_title": "三部分的关系",
  "open": true,
  "pId": 21,
  "target": "_self",
  "url": "#2105"
}

item对象属性说明

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

推荐

版本历史

欢迎fork和反馈

如有建议或意见,请在issue提问或邮件

License

this repo is released under the MIT License.