Browse Source

doctool: correct improperly nested ul/li handling

v0.7.4-release
isaacs 13 years ago
parent
commit
5d7577c71a
  1. 18
      tools/doctool/doctool.js

18
tools/doctool/doctool.js

@ -42,7 +42,11 @@ function generateToc(data) {
} }
if (level > last_level) { 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) { } else if (level < last_level) {
for(var c=last_level-level; 0 < c ; c-- ) { for(var c=last_level-level; 0 < c ; c-- ) {
toc.push("</ul>"); toc.push("</ul>");
@ -61,7 +65,7 @@ function generateToc(data) {
toc.push("</ul>"); toc.push("</ul>");
} }
toc.push("<hr />") toc.push("<hr>")
toc.push("</div>"); toc.push("</div>");
return toc.join(""); return toc.join("");
@ -89,8 +93,14 @@ function convertData(data) {
.replace(/(\<h[2-6])\>([^<]+)(\<\/h[1-6]\>)/gmi, function(o, ts, c, te) { .replace(/(\<h[2-6])\>([^<]+)(\<\/h[1-6]\>)/gmi, function(o, ts, c, te) {
return ts+' id="'+formatIdString(c)+'">'+c+te; return ts+' id="'+formatIdString(c)+'">'+c+te;
}) })
.replace(/(\<h[3-4][^>]+\>)([^<]+)(\<\/h[3-4]\>)/gmi, function(o, ts, c, te) { .replace(/(\<h[2-4][^>]+\>)([^<]+)(\<\/h[2-4]\>)/gmi,
return ts+c+' <a href="#'+formatIdString(c)+'">#</a>'+te; 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; return html;

Loading…
Cancel
Save