1
0
mirror of https://github.com/namibia/tips.git synced 2024-11-15 17:47:12 +00:00
git-tips/.doxie.render.toc.js

20 lines
615 B
JavaScript
Raw Normal View History

2015-07-16 03:46:42 +00:00
// from https://gist.github.com/mathewbyrne/1280286
slugify = function(text){
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}
2015-07-15 11:01:27 +00:00
var render = function(data) {
var data = data.data;
2016-06-02 11:14:58 +00:00
var out = '* [' + data.title + '](#' + slugify(data.title) + ')\n';
2015-07-15 11:01:27 +00:00
return out;
};
module.exports = render;