fix bug in toc generation - escaped chars not linked right

This commit is contained in:
walterhiggins 2014-01-04 20:08:24 +00:00
parent 2ee9dd6515
commit d742c5ae44

View file

@ -19,14 +19,16 @@ for (var i = 0; i < contents.length; i++){
line = contents[i]; line = contents[i];
if (line.match(/^##\s+/)){ if (line.match(/^##\s+/)){
var h2 = line.match(/^##\s+(.*)/)[1].trim(); var h2 = line.match(/^##\s+(.*)/)[1].trim();
var link = h2.replace(/[^a-zA-Z0-9 \-]/g,''); var link = '' + java.net.URLDecoder.decode(h2,"UTF-8");
link = link.replace(/[^a-zA-Z0-9 \-]/g,'');
link = link.replace(/ /g,'-'); link = link.replace(/ /g,'-');
link = link.toLowerCase(); link = link.toLowerCase();
println (' * [' + h2 + '](#' + link + ')'); println (' * [' + h2 + '](#' + link + ')');
} }
if (line.match(/^###\s+/)){ if (line.match(/^###\s+/)){
var h3 = line.match(/^###\s+(.*)/)[1].trim(); var h3 = line.match(/^###\s+(.*)/)[1].trim();
var link = h3.replace(/[^a-zA-Z0-9 \-]/g,''); var link = '' + java.net.URLDecoder.decode(h3,"UTF-8");
link = link.replace(/[^a-zA-Z0-9 \-]/g,'');
var link = link.replace(/ /g,'-'); var link = link.replace(/ /g,'-');
link = link.toLowerCase(); link = link.toLowerCase();
println (' * [' + h3 + '](#' + link + ')'); println (' * [' + h3 + '](#' + link + ')');