diff options
author | Samy Pessé <samypesse@gmail.com> | 2016-02-25 14:41:46 +0100 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2016-02-25 14:41:46 +0100 |
commit | 1ba63675d5f3c97a76861af81cdf23013e551c47 (patch) | |
tree | 0ebbc09d6b744c67b41384b09a398a8f53948e70 /lib/page | |
parent | 32f52f2d955ffa0080ad366910567962d178d78b (diff) | |
download | gitbook-1ba63675d5f3c97a76861af81cdf23013e551c47.zip gitbook-1ba63675d5f3c97a76861af81cdf23013e551c47.tar.gz gitbook-1ba63675d5f3c97a76861af81cdf23013e551c47.tar.bz2 |
Support "sections" from gitbook 2 as deprecated for page hooks
Diffstat (limited to 'lib/page')
-rw-r--r-- | lib/page/index.js | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/page/index.js b/lib/page/index.js index e8c4de7..8b4fcc9 100644 --- a/lib/page/index.js +++ b/lib/page/index.js @@ -7,6 +7,7 @@ var pathUtil = require('../utils/path'); var location = require('../utils/location'); var parsers = require('../parsers'); var gitbook = require('../gitbook'); +var pluginCompatibility = require('../plugins/compatibility'); var HTMLPipeline = require('./html'); /* @@ -142,10 +143,14 @@ Page.prototype.toHTML = function(output) { this.log.debug.ln('start parsing file', this.path); + // Call a hook in the output + // using an utility to "keep" compatibility with gitbook 2 function hook(name) { - return output.plugins.hook(name, that.getContext().page) + return pluginCompatibility.pageHook(that, function(ctx) { + return output.plugins.hook(name, ctx); + }) .then(function(result) { - if(result) that.update(result.content); + if(_.isString(result)) that.update(result); }); } |