Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82f814f

Browse files
committed
Fix GitbookIO#303: generate header id the same as github
1 parent 3842e5b commit 82f814f

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

lib/parse/renderer.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,10 @@ GitBookRenderer.prototype.code = function(code, lang, escaped) {
146146
);
147147
};
148148

149+
GitBookRenderer.prototype.heading = function(text, level, raw) {
150+
var id = this.options.headerPrefix + raw.toLowerCase().replace(/[^\w -]+/g, '').replace(/ /g, '-');
151+
return '<h' + level + ' id="' + id + '">' + text + '</h' + level + '>\n';
152+
};
153+
149154
// Exports
150155
module.exports = GitBookRenderer;

0 commit comments

Comments
 (0)