summaryrefslogtreecommitdiffstats
path: root/lib/template/blocks.js
blob: 5dfb0c8c1ea44bcb2f02bb87047dd530721b0bd5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var _ = require('lodash');

module.exports = {
    // Return non-parsed html
    // since blocks are by default non-parsable, a simple identity method works fine
    html: _.identity,

    // Highlight a code block
    // This block can be replaced by plugins
    code: function(blk) {
        return {
            html: false,
            body: blk.body
        };
    },

    // Render some markdown to HTML
    markdown: function(blk) {
        return this.book.renderInline('markdown', blk.body)
        .then(function(out) {
            return { body: out };
        });
    },
    asciidoc: function(blk) {
        return this.book.renderInline('asciidoc', blk.body)
        .then(function(out) {
            return { body: out };
        });
    },
    markup: function(blk) {
        return this.book.renderInline(this.ctx.file.type, blk.body)
        .then(function(out) {
            return { body: out };
        });
    }
};