fix links

This commit is contained in:
walterhiggins 2014-01-04 20:23:17 +00:00
parent 5239709fcf
commit cc3c87da23
2 changed files with 12 additions and 12 deletions

View file

@ -14,14 +14,14 @@ Walter Higgins
* [The lib directory](#the-lib-directory) * [The lib directory](#the-lib-directory)
* [plugins sub-directories](#plugins-sub-directories) * [plugins sub-directories](#plugins-sub-directories)
* [Global variables](#global-variables) * [Global variables](#global-variables)
* [__plugin variable](#plugin-variable) * [__plugin variable](#__plugin-variable)
* [server variable](#server-variable) * [server variable](#server-variable)
* [self variable](#self-variable) * [self variable](#self-variable)
* [config variable](#config-variable) * [config variable](#config-variable)
* [events variable](#events-variable) * [events variable](#events-variable)
* [Module variables](#module-variables) * [Module variables](#module-variables)
* [__filename variable](#filename-variable) * [__filename variable](#__filename-variable)
* [__dirname variable](#dirname-variable) * [__dirname variable](#__dirname-variable)
* [Global functions](#global-functions) * [Global functions](#global-functions)
* [echo function](#echo-function) * [echo function](#echo-function)
* [require() function](#require-function) * [require() function](#require-function)
@ -99,7 +99,7 @@ Walter Higgins
* [Drone.sphere0() method](#dronesphere0-method) * [Drone.sphere0() method](#dronesphere0-method)
* [Drone.hemisphere() method](#dronehemisphere-method) * [Drone.hemisphere() method](#dronehemisphere-method)
* [Drone.hemisphere0() method](#dronehemisphere0-method) * [Drone.hemisphere0() method](#dronehemisphere0-method)
* [Drone.spiral_stairs() method](#dronespiralstairs-method) * [Drone.spiral_stairs() method](#dronespiral_stairs-method)
* [Example Plugin #1 - A simple extension to Minecraft.](#example-plugin-1---a-simple-extension-to-minecraft) * [Example Plugin #1 - A simple extension to Minecraft.](#example-plugin-1---a-simple-extension-to-minecraft)
* [Usage:](#usage) * [Usage:](#usage)
* [Example Plugin #2 - Making extensions available for all players.](#example-plugin-2---making-extensions-available-for-all-players) * [Example Plugin #2 - Making extensions available for all players.](#example-plugin-2---making-extensions-available-for-all-players)

View file

@ -13,24 +13,24 @@ while ( (line = br.readLine()) != null){
} }
br.close(); br.close();
var createLink = function(text){
var result = text.replace(/_/g,'_');
result = result.replace(/[^a-zA-Z0-9 _\-]/g,'');
result = result.replace(/ /g,'-');
return result.toLowerCase();
};
println('## Table of Contents'); println('## Table of Contents');
for (var i = 0; i < contents.length; i++){ 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(/&#95;/g,''); var link = createLink(h2);
link = link.replace(/[^a-zA-Z0-9 \-]/g,'');
link = link.replace(/ /g,'-');
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(/&#95;/g,''); var link = createLink(h3);
link = link.replace(/[^a-zA-Z0-9 \-]/g,'');
var link = link.replace(/ /g,'-');
link = link.toLowerCase();
println (' * [' + h3 + '](#' + link + ')'); println (' * [' + h3 + '](#' + link + ')');
} }
} }