summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/page/html.js2
-rw-r--r--lib/plugins/plugin.js2
-rw-r--r--lib/template/blocks.js7
-rw-r--r--lib/template/index.js5
4 files changed, 12 insertions, 4 deletions
diff --git a/lib/page/html.js b/lib/page/html.js
index 016d75e..bd9ec91 100644
--- a/lib/page/html.js
+++ b/lib/page/html.js
@@ -110,7 +110,7 @@ HTMLPipeline.prototype.transformCodeBlocks = function() {
return Promise(this.opts.onCodeBlock(source, lang))
.then(function(blk) {
- if (blk.html !== true) {
+ if (blk.html === false) {
$code.text(blk.body);
} else {
$code.html(blk.body);
diff --git a/lib/plugins/plugin.js b/lib/plugins/plugin.js
index 4901579..e2a2ca6 100644
--- a/lib/plugins/plugin.js
+++ b/lib/plugins/plugin.js
@@ -282,7 +282,7 @@ BookPlugin.prototype.getBlocks = function() {
var that = this;
return _.mapValues(this.content.blocks || {}, function(block, blockName) {
- block = _.isFunction(block)? { exec: block } : block;
+ block = _.isFunction(block)? { process: block } : block;
var fn = block.exec;
block.exec = function() {
diff --git a/lib/template/blocks.js b/lib/template/blocks.js
index 0e04643..a079cde 100644
--- a/lib/template/blocks.js
+++ b/lib/template/blocks.js
@@ -7,5 +7,10 @@ module.exports = {
// Highlight a code block
// This block can be replaced by plugins
- code: _.identity
+ code: function(blk) {
+ return {
+ html: false,
+ body: blk.body
+ };
+ }
};
diff --git a/lib/template/index.js b/lib/template/index.js
index 8a52392..fc7603d 100644
--- a/lib/template/index.js
+++ b/lib/template/index.js
@@ -146,12 +146,15 @@ TemplateEngine.prototype.addBlock = function(name, block) {
block = _.defaults(block || {}, {
shortcuts: [],
end: 'end'+name,
- process: _.identity,
blocks: []
});
extName = blockExtName(name);
+ if (!block.process) {
+ throw new Error('Invalid block "' + name + '", it should have a "process" method');
+ }
+
if (this.hasBlock(name) && !defaultBlocks[name]) {
this.log.warn.ln('conflict in blocks, "'+name+'" is already defined');
}