diff --git a/resources/template.html b/resources/template.html index 0567380d..6b597de3 100644 --- a/resources/template.html +++ b/resources/template.html @@ -39,10 +39,17 @@ } }); - var markdownToHtml = function (markdown) { - return marked(markdown, { renderer: renderer }); + var markdownToHtml = function (markdown, needToc) { + toc = []; + if (needToc) { + var html = marked(markdown, { renderer: renderer }); + return html.replace(/

\[TOC\]<\/p>/ig, '

'); + } else { + return marked(markdown); + } }; + // Handle wrong title levels, such as '#' followed by '###' var toPerfectToc = function (toc) { var i; var curLevel = 1; @@ -67,6 +74,7 @@ return '' + item.title + ''; }; + // Turn a perfect toc to a tree using