mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-23 19:06:31 +00:00
Call page hooks during transformation to HTML
This commit is contained in:
@@ -142,8 +142,19 @@ Page.prototype.toHTML = function(output) {
|
||||
|
||||
this.log.debug.ln('start parsing file', this.path);
|
||||
|
||||
function hook(name) {
|
||||
return output.plugins.hook(name, that.getContext().page)
|
||||
.then(function(result) {
|
||||
if(result) that.update(result.content);
|
||||
});
|
||||
}
|
||||
|
||||
return this.read()
|
||||
|
||||
.then(function() {
|
||||
return hook('page:before');
|
||||
})
|
||||
|
||||
// Pre-process page with parser
|
||||
.then(function() {
|
||||
return that.parser.page.prepare(that.content)
|
||||
@@ -198,6 +209,10 @@ Page.prototype.toHTML = function(output) {
|
||||
.then(that.update);
|
||||
})
|
||||
|
||||
.then(function() {
|
||||
return hook('page');
|
||||
})
|
||||
|
||||
// Return content itself
|
||||
.then(function() {
|
||||
return that.content;
|
||||
|
||||
Reference in New Issue
Block a user