blob: 1143aaae873a47f2d4a76a88d6043ce5a80b5460 (
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
|
var JSONUtils = require('../../json');
var Modifier = require('../modifier');
var Writer = require('../writer');
/**
Write a page as a json file
@param {Output} output
@param {Page} page
*/
function onPage(output, page) {
return Modifier.modifyHTML(page, [
Modifier.addHeadingId,
Modifier.resolveLinks
])
.then(function(resultPage) {
// Generate the JSON
var json = JSONUtils.encodeBookWithPage(output.getBook(), resultPage);
// Write it to the disk
return Writer.writePage(
output,
page,
JSON.stringify(json, null, 4),
{
extension: '.json'
}
);
});
}
module.exports = onPage;
|