Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
doctool: correct improperly nested ul/li handling
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Jan 23, 2012
1 parent 4fd3151 commit 5d7577c
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tools/doctool/doctool.js
Expand Up @@ -42,7 +42,11 @@ function generateToc(data) {
}

if (level > last_level) {
toc.push("<ul>");
var c = last_level - level;
do {
toc.push("<ul>");
c ++;
} while (c < -1);
} else if (level < last_level) {
for(var c=last_level-level; 0 < c ; c-- ) {
toc.push("</ul>");
Expand All @@ -61,7 +65,7 @@ function generateToc(data) {
toc.push("</ul>");
}

toc.push("<hr />")
toc.push("<hr>")
toc.push("</div>");

return toc.join("");
Expand Down Expand Up @@ -89,8 +93,14 @@ function convertData(data) {
.replace(/(\<h[2-6])\>([^<]+)(\<\/h[1-6]\>)/gmi, function(o, ts, c, te) {
return ts+' id="'+formatIdString(c)+'">'+c+te;
})
.replace(/(\<h[3-4][^>]+\>)([^<]+)(\<\/h[3-4]\>)/gmi, function(o, ts, c, te) {
return ts+c+' <a href="#'+formatIdString(c)+'">#</a>'+te;
.replace(/(\<h[2-4][^>]+\>)([^<]+)(\<\/h[2-4]\>)/gmi,
function(o, ts, c, te) {
var mark = ' <span>' +
'<a class="top" href="#">↑</a>' +
'<a class="mark" href="#' +
formatIdString(c) + '">#</a></span>';

return ts+c+mark+te;
});

return html;
Expand Down

0 comments on commit 5d7577c

Please sign in to comment.