Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

doctool: correct improperly nested ul/li handling

  • Loading branch information...
isaacs committed Jan 23, 2012
1 parent 4fd3151 commit 5d7577c71ab535dfd5c3f29b8c15a725137ff3b8
Showing with 14 additions and 4 deletions.
  1. +14 −4 tools/doctool/doctool.js
@@ -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>");
@@ -61,7 +65,7 @@ function generateToc(data) {
toc.push("</ul>");
}

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

return toc.join("");
@@ -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;

0 comments on commit 5d7577c

Please sign in to comment.
You can’t perform that action at this time.