summaryrefslogtreecommitdiffstats
path: root/lib/parse
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2014-07-12 23:23:03 +0200
committerSamy Pessé <samypesse@gmail.com>2014-07-12 23:23:03 +0200
commit82f814fdbd34d202a17e3c26a8f72966b64a141f (patch)
treed6c0bdd4b8759c5aae8e43035f993fca0d1abfbc /lib/parse
parent3842e5bf4a42f75aed9ed413047a503920226589 (diff)
downloadgitbook-82f814fdbd34d202a17e3c26a8f72966b64a141f.zip
gitbook-82f814fdbd34d202a17e3c26a8f72966b64a141f.tar.gz
gitbook-82f814fdbd34d202a17e3c26a8f72966b64a141f.tar.bz2
Fix #303: generate header id the same as github
Diffstat (limited to 'lib/parse')
-rw-r--r--lib/parse/renderer.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/parse/renderer.js b/lib/parse/renderer.js
index dcbc261..c01fb81 100644
--- a/lib/parse/renderer.js
+++ b/lib/parse/renderer.js
@@ -146,5 +146,10 @@ GitBookRenderer.prototype.code = function(code, lang, escaped) {
);
};
+GitBookRenderer.prototype.heading = function(text, level, raw) {
+ var id = this.options.headerPrefix + raw.toLowerCase().replace(/[^\w -]+/g, '').replace(/ /g, '-');
+ return '<h' + level + ' id="' + id + '">' + text + '</h' + level + '>\n';
+};
+
// Exports
module.exports = GitBookRenderer;