diff options
author | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-03-31 12:09:28 -0700 |
---|---|---|
committer | Aaron O'Mullan <aaron.omullan@friendco.de> | 2014-03-31 12:09:28 -0700 |
commit | 89593f46ab0c7dddab8414c5da55f0faeb3e61a4 (patch) | |
tree | 9649f634aebcd644b96225a8f2e596fe216ed180 /lib/parse/renderer.js | |
parent | 1d321207b045f7f9c34267fa4ce86fb41a1172a4 (diff) | |
download | gitbook-89593f46ab0c7dddab8414c5da55f0faeb3e61a4.zip gitbook-89593f46ab0c7dddab8414c5da55f0faeb3e61a4.tar.gz gitbook-89593f46ab0c7dddab8414c5da55f0faeb3e61a4.tar.bz2 |
Normalize .md links to .html when rendering pages
Diffstat (limited to 'lib/parse/renderer.js')
-rw-r--r-- | lib/parse/renderer.js | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/lib/parse/renderer.js b/lib/parse/renderer.js new file mode 100644 index 0000000..66aad46 --- /dev/null +++ b/lib/parse/renderer.js @@ -0,0 +1,27 @@ +var inherits = require('util').inherits; + +var marked = require('marked'); + + +function GitBookRenderer(options) { + if(!(this instanceof GitBookRenderer)) { + return new GitBookRenderer(options); + } + GitBookRenderer.super_.call(this, options); +} +inherits(GitBookRenderer, marked.Renderer); + + +GitBookRenderer.prototype.link = function(href, title, text) { + // Replace .md extensions by .html + return GitBookRenderer.super_.prototype.link.call( + this, + href.replace(/\.md$/, '.html'), + title, + text + ); +}; + + +// Exports +module.exports = GitBookRenderer; |