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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
var path = require('path');
var fs = require('fs');
var Plugin = require('../lib/plugin');
var PLUGINS_ROOT = path.resolve(__dirname, 'plugins');
describe('Code Highlighting', function () {
var book, PAGE;
before(function() {
return books.generate('highlight', 'website', {
prepare: function(_book) {
book = _book;
var plugin = new Plugin(book, 'replace_highlight');
plugin.load('./replace_highlight', PLUGINS_ROOT);
book.plugins.load(plugin);
}
})
.then(function() {
PAGE = fs.readFileSync(
path.join(book.options.output, 'index.html'),
{ encoding: 'utf-8' }
);
});
});
it('should correctly replace highlighting', function() {
PAGE.should.be.html({
'code': {
index: 0,
text: 'code_test 1\n_code'
}
});
});
it('should correctly replace highlighting with language', function() {
PAGE.should.be.html({
'code': {
index: 1,
text: 'lang_test 2\n_lang'
}
});
});
it('should correctly replace highlighting for inline code', function() {
PAGE.should.be.html({
'code': {
index: 2,
text: 'code_test 3_code'
}
});
});
it('should correctly replace highlighting for inline code with html tags', function() {
PAGE.should.be.html({
'code': {
index: 3,
text: 'code_<test>_code'
}
});
});
});
|