summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-02-25 14:26:27 +0100
committerSamy Pessé <samypesse@gmail.com>2016-02-25 14:26:27 +0100
commit32f52f2d955ffa0080ad366910567962d178d78b (patch)
tree42576854e0027eeb09ed63a6aa37822b3f23eb8a
parent9215edc0a08e909763bae67ce7babb46fe655a4d (diff)
downloadgitbook-32f52f2d955ffa0080ad366910567962d178d78b.zip
gitbook-32f52f2d955ffa0080ad366910567962d178d78b.tar.gz
gitbook-32f52f2d955ffa0080ad366910567962d178d78b.tar.bz2
Call page hooks during transformation to HTML
-rw-r--r--lib/page/index.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/page/index.js b/lib/page/index.js
index 57b048d..e8c4de7 100644
--- a/lib/page/index.js
+++ b/lib/page/index.js
@@ -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;