Skip to content

Instantly share code, notes, and snippets.

@bongole
Created April 27, 2015 07:03
Show Gist options
  • Save bongole/192706dcda8e70a98c2d to your computer and use it in GitHub Desktop.
Save bongole/192706dcda8e70a98c2d to your computer and use it in GitHub Desktop.
atom init.js for non ascii markdown-toc
var marked = require(atom.packages.resourcePath + "/node_modules/marked");
marked.Renderer.prototype.heading = function(text, level, raw) {
return '<h'
+ level
+ ' id="'
+ this.options.headerPrefix
+ raw.toLowerCase().replace(/[\s]+/g, '-')
+ '">'
+ text
+ '</h'
+ level
+ '>\n';
};
atom.packages.onDidActivatePackage(function(pkg){
if( pkg.name == "markdown-toc" ){
pkg.mainModule.toc.___createLink = function(name){
var hash = new String(name)
hash = hash.toLowerCase().replace(/[\s]+/g, "-");
var link = [];
link.push("[");
link.push(name);
link.push("](#");
link.push(hash);
link.push(")");
return link.join("");
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment