Skip to content

Instantly share code, notes, and snippets.

@jenux
Created July 11, 2014 06:29
Show Gist options
  • Save jenux/690081ae4c626aa85710 to your computer and use it in GitHub Desktop.
Save jenux/690081ae4c626aa85710 to your computer and use it in GitHub Desktop.
Sample codes of generate TOC for markdown with js
<!--
copy from https://www.dropbox.com/s/bus9jw8yqm03z3b/markdown-toc-v2.txt
http://jianshu.io/p/34c92cbd0aaf
-->
<ul id="tree" class="ztree"></ul>
<article class='markdown-body'>
# titleI
## titleII
### titleIII
# titleI
## again
### nice
1. zheli
2. women
haha
> test
</article>
<script type="text/javascript" src="http://i5ting.github.io/git-quick-start/preview/js/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="http://i5ting.github.io/git-quick-start/preview/js/jquery.ztree.all-3.5.min.js"></script>
<script type="text/javascript" src="http://i5ting.github.io/git-quick-start/preview/js/jquery.ztree_toc.js"></script>
<SCRIPT type="text/javascript" >
<!--
$(document).ready(function(){
$('#tree').ztree_toc({
is_auto_number:true,
documment_selector:'.markdown-body',
ztreeStyle: {
width:'260px',
overflow: 'auto',
position: 'fixed',
'z-index': 2147483647,
border: '0px none',
left: '0px',
top: '0px'
}
});
});
//-->
</SCRIPT>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment