Created
April 27, 2015 07:03
-
-
Save bongole/192706dcda8e70a98c2d to your computer and use it in GitHub Desktop.
atom init.js for non ascii markdown-toc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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