@canopycanopycanopy/b-ber-tasks 2.0.0 → 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clean/index.js +0 -15
- package/dist/container/index.js +1 -20
- package/dist/copy/index.js +2 -20
- package/dist/cover/index.js +20 -75
- package/dist/deploy/index.js +11 -54
- package/dist/epub/index.js +0 -12
- package/dist/footnotes/index.js +0 -27
- package/dist/generate/index.js +5 -32
- package/dist/index.js +0 -52
- package/dist/init/index.js +4 -29
- package/dist/inject/index.js +3 -31
- package/dist/loi/index.js +16 -61
- package/dist/mobi/index.js +8 -17
- package/dist/mobi/mobi-css.js +2 -39
- package/dist/opf/ManifestAndMetadata.js +18 -35
- package/dist/opf/Navigation.js +28 -82
- package/dist/opf/Opf.js +3 -20
- package/dist/opf/helpers.js +5 -20
- package/dist/opf/index.js +0 -10
- package/dist/pdf/index.js +3 -29
- package/dist/reader/index.js +11 -69
- package/dist/render/index.js +2 -28
- package/dist/sample/index.js +0 -6
- package/dist/sass/index.js +30 -66
- package/dist/scripts/index.js +0 -24
- package/dist/serialize.js +1 -20
- package/dist/serve/index.js +5 -29
- package/dist/validate/index.js +0 -24
- package/dist/web/Template.js +0 -21
- package/dist/web/index.js +31 -128
- package/dist/xml/index.js +0 -30
- package/package.json +10 -10
package/dist/opf/Navigation.js
CHANGED
|
@@ -1,99 +1,71 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.default = void 0;
|
|
12
|
-
|
|
13
9
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
14
|
-
|
|
15
10
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
16
|
-
|
|
17
11
|
var _forEach = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/for-each"));
|
|
18
|
-
|
|
19
12
|
var _find = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/find"));
|
|
20
|
-
|
|
21
13
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
22
|
-
|
|
23
14
|
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
|
|
24
|
-
|
|
25
15
|
var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
|
|
26
|
-
|
|
27
16
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
28
|
-
|
|
29
17
|
var _indexOf = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/index-of"));
|
|
30
|
-
|
|
31
18
|
var _splice = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/splice"));
|
|
32
|
-
|
|
33
19
|
var _path = _interopRequireDefault(require("path"));
|
|
34
|
-
|
|
35
20
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
36
|
-
|
|
37
21
|
var _vinyl = _interopRequireDefault(require("vinyl"));
|
|
38
|
-
|
|
39
22
|
var _glob = _interopRequireDefault(require("glob"));
|
|
40
|
-
|
|
41
23
|
var _find2 = _interopRequireDefault(require("lodash/find"));
|
|
42
|
-
|
|
43
24
|
var _difference = _interopRequireDefault(require("lodash/difference"));
|
|
44
|
-
|
|
45
25
|
var _remove = _interopRequireDefault(require("lodash/remove"));
|
|
46
|
-
|
|
47
26
|
var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
|
|
48
|
-
|
|
49
27
|
var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
|
|
50
|
-
|
|
51
28
|
var _Toc = _interopRequireDefault(require("@canopycanopycanopy/b-ber-templates/Toc"));
|
|
52
|
-
|
|
53
29
|
var _Ncx = _interopRequireDefault(require("@canopycanopycanopy/b-ber-templates/Ncx"));
|
|
54
|
-
|
|
55
30
|
var _Guide = _interopRequireDefault(require("@canopycanopycanopy/b-ber-templates/Opf/Guide"));
|
|
56
|
-
|
|
57
31
|
var _Spine = _interopRequireDefault(require("@canopycanopycanopy/b-ber-templates/Opf/Spine"));
|
|
58
|
-
|
|
59
32
|
var _bBerLib = require("@canopycanopycanopy/b-ber-lib");
|
|
60
|
-
|
|
61
33
|
var _inject = require("../inject");
|
|
62
|
-
|
|
63
34
|
class Navigation {
|
|
64
35
|
// Remove the `toc.xhtml` and `toc.ncx` from the output directory
|
|
65
36
|
static createEmptyNavDocuments() {
|
|
66
37
|
const navDocs = ['toc.ncx', 'toc.xhtml'];
|
|
67
|
-
|
|
68
38
|
_bBerLogger.default.info(`opf build navigation documents [${navDocs.join(', ')}]`);
|
|
69
|
-
|
|
70
39
|
const promises = (0, _map.default)(navDocs).call(navDocs, doc => _fsExtra.default.writeFile(_State.default.dist.ops(doc), ''));
|
|
71
40
|
return _promise.default.all(promises);
|
|
72
|
-
}
|
|
73
|
-
// and those that are listed in the YAML manifest
|
|
74
|
-
|
|
41
|
+
}
|
|
75
42
|
|
|
43
|
+
// Resolve discrepancies between files that exist in the output directory
|
|
44
|
+
// and those that are listed in the YAML manifest
|
|
76
45
|
static compareXhtmlWithYaml() {
|
|
77
46
|
var _context;
|
|
78
|
-
|
|
79
47
|
// Get the XHTML file names
|
|
80
|
-
const files = (0, _map.default)(_context = _glob.default.sync(_State.default.dist.ops('**', '*.xhtml'))).call(_context, file => _path.default.basename(file, '.xhtml'));
|
|
48
|
+
const files = (0, _map.default)(_context = _glob.default.sync(_State.default.dist.ops('**', '*.xhtml'))).call(_context, file => _path.default.basename(file, '.xhtml'));
|
|
81
49
|
|
|
50
|
+
// Set up our promise chain
|
|
82
51
|
const promises = [_promise.default.resolve()];
|
|
83
52
|
const missing = [];
|
|
84
|
-
const redundant = [];
|
|
53
|
+
const redundant = [];
|
|
54
|
+
|
|
55
|
+
// Check if we need to compare agains the global toc.yml, or an
|
|
85
56
|
// overrides (type.yml) file
|
|
57
|
+
const tocFile = _fsExtra.default.existsSync(_State.default.src.root(`${_State.default.build}.yml`)) ? _State.default.src.root(`${_State.default.build}.yml`) : _State.default.src.root('toc.yml');
|
|
86
58
|
|
|
87
|
-
|
|
59
|
+
// Load the TOC from the YAML file directly. We know that the spine
|
|
88
60
|
// contains the correct entries since we load any files that haven't
|
|
89
61
|
// been declared in the TOC when initializing the Spine object, so no
|
|
90
62
|
// need to update anything there
|
|
63
|
+
const tocEntries = _State.default.spine.flattenYAML(_bBerLib.YamlAdaptor.load(tocFile));
|
|
91
64
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const missingEntries = (0, _difference.default)(files, tocEntries); // Add the missing entries to the YAML file (either toc.yml or type.yml)
|
|
65
|
+
// Files on the system that are not included in the TOC
|
|
66
|
+
const missingEntries = (0, _difference.default)(files, tocEntries);
|
|
96
67
|
|
|
68
|
+
// Add the missing entries to the YAML file (either toc.yml or type.yml)
|
|
97
69
|
(0, _forEach.default)(missingEntries).call(missingEntries, name => {
|
|
98
70
|
if (_State.default.contains('loi', {
|
|
99
71
|
name
|
|
@@ -101,9 +73,10 @@ class Navigation {
|
|
|
101
73
|
const entry = (0, _find.default)(_State.default).call(_State.default, 'spine.flattened', {
|
|
102
74
|
name
|
|
103
75
|
});
|
|
104
|
-
let yamlString = `\n- ${name}`;
|
|
105
|
-
// write the attributes along with the name
|
|
76
|
+
let yamlString = `\n- ${name}`;
|
|
106
77
|
|
|
78
|
+
// If the entry has default attributes only write the name, otherwise
|
|
79
|
+
// write the attributes along with the name
|
|
107
80
|
if (entry) {
|
|
108
81
|
// Get attributes that may have been dynamically added to the entry and
|
|
109
82
|
// list them in the YAML
|
|
@@ -111,56 +84,49 @@ class Navigation {
|
|
|
111
84
|
linear,
|
|
112
85
|
in_toc
|
|
113
86
|
} = entry; // eslint-disable-line camelcase
|
|
114
|
-
|
|
115
87
|
const attributes = {};
|
|
116
88
|
if (linear === false) attributes.linear = false;
|
|
117
89
|
if (in_toc === false) attributes.in_toc = false; // eslint-disable-line camelcase
|
|
118
90
|
|
|
119
91
|
if ((0, _keys.default)(attributes).length) {
|
|
120
92
|
var _context2;
|
|
121
|
-
|
|
122
93
|
const space = '\n ';
|
|
123
94
|
yamlString += ':';
|
|
124
95
|
yamlString = (0, _reduce.default)(_context2 = (0, _entries.default)(attributes)).call(_context2, (acc, [key, val]) => (0, _concat.default)(acc).call(acc, `${space}${key}: ${val}`), yamlString);
|
|
125
96
|
}
|
|
126
97
|
}
|
|
127
|
-
|
|
128
98
|
missing.push(name);
|
|
129
99
|
promises.push(_fsExtra.default.appendFile(tocFile, yamlString));
|
|
130
|
-
});
|
|
100
|
+
});
|
|
131
101
|
|
|
132
|
-
|
|
133
|
-
|
|
102
|
+
// Files in the TOC that don't exist in the project directory
|
|
103
|
+
const redundantEntries = (0, _difference.default)(tocEntries, files);
|
|
134
104
|
|
|
105
|
+
// Strip out `cover` entry during PDF build since it's handled separately
|
|
106
|
+
// in the project's config.yml
|
|
135
107
|
if (_State.default.build === 'pdf') {
|
|
136
108
|
const coverIndex = (0, _indexOf.default)(redundantEntries).call(redundantEntries, 'cover');
|
|
137
109
|
if (coverIndex > -1) (0, _splice.default)(redundantEntries).call(redundantEntries, coverIndex, 1);
|
|
138
|
-
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// Notify the user of any entries that are listed in the YAML file but
|
|
139
113
|
// not present on the system. The user has to resolve these conflicts
|
|
140
114
|
// manually because deeply nested structures can't be reliably
|
|
141
115
|
// processed.
|
|
142
|
-
|
|
143
|
-
|
|
144
116
|
(0, _forEach.default)(redundantEntries).call(redundantEntries, name => redundant.push(name));
|
|
145
|
-
|
|
146
117
|
if (missing.length) {
|
|
147
118
|
(0, _forEach.default)(missing).call(missing, name => _bBerLogger.default.warn('opf [%s] was not declared in the TOC. Adding [%s] to [%s]', name, name, _path.default.basename(tocFile)));
|
|
148
119
|
}
|
|
149
|
-
|
|
150
120
|
if (redundant.length) {
|
|
151
121
|
let message = 'Files declared in the TOC do not exist in the _markdown directory';
|
|
152
122
|
message += `\nThe following entries must be removed manually from [${_path.default.basename(tocFile)}]:`;
|
|
153
123
|
message += `\n${(0, _map.default)(redundant).call(redundant, name => `[${name}]`).join('\n')}`;
|
|
154
|
-
|
|
155
124
|
_bBerLogger.default.error(message);
|
|
156
125
|
}
|
|
157
|
-
|
|
158
126
|
return _promise.default.all(promises);
|
|
159
127
|
}
|
|
160
|
-
|
|
161
128
|
static async createTocStringsFromTemplate() {
|
|
162
129
|
_bBerLogger.default.info('opf build [toc.xhtml]');
|
|
163
|
-
|
|
164
130
|
const {
|
|
165
131
|
toc
|
|
166
132
|
} = _State.default;
|
|
@@ -176,36 +142,28 @@ class Navigation {
|
|
|
176
142
|
}] = await (0, _inject.getFileObjects)(file);
|
|
177
143
|
return contents;
|
|
178
144
|
}
|
|
179
|
-
|
|
180
145
|
static createNcxStringsFromTemplate() {
|
|
181
146
|
_bBerLogger.default.info('opf build [toc.ncx]');
|
|
182
|
-
|
|
183
147
|
const {
|
|
184
148
|
toc
|
|
185
149
|
} = _State.default;
|
|
186
|
-
|
|
187
150
|
const ncxXML = _Ncx.default.navPoints(toc);
|
|
188
|
-
|
|
189
151
|
return _bBerLib.Template.render(ncxXML, _Ncx.default.document());
|
|
190
152
|
}
|
|
191
|
-
|
|
192
153
|
static createGuideStringsFromTemplate() {
|
|
193
154
|
_bBerLogger.default.info('opf build [guide]');
|
|
194
|
-
|
|
195
155
|
const guideXML = _Guide.default.items(_State.default.guide);
|
|
196
|
-
|
|
197
156
|
return _bBerLib.Template.render(guideXML, _Guide.default.body());
|
|
198
157
|
}
|
|
199
|
-
|
|
200
158
|
static createSpineStringsFromTemplate() {
|
|
201
159
|
_bBerLogger.default.info('opf build [spine]');
|
|
202
|
-
|
|
203
160
|
const {
|
|
204
161
|
flattened
|
|
205
|
-
} = _State.default.spine;
|
|
162
|
+
} = _State.default.spine;
|
|
163
|
+
|
|
164
|
+
// We add entries to the spine programatically, but then they're
|
|
206
165
|
// also found on the system, so we dedupe them here
|
|
207
166
|
// TODO: but also, this is super confusing ...
|
|
208
|
-
|
|
209
167
|
const generatedFiles = (0, _remove.default)(flattened, file => file.generated === true);
|
|
210
168
|
(0, _forEach.default)(generatedFiles).call(generatedFiles, file => {
|
|
211
169
|
if (!(0, _find2.default)(flattened, {
|
|
@@ -214,28 +172,19 @@ class Navigation {
|
|
|
214
172
|
flattened.push(file);
|
|
215
173
|
}
|
|
216
174
|
});
|
|
217
|
-
|
|
218
175
|
const spineXML = _Spine.default.items(flattened);
|
|
219
|
-
|
|
220
176
|
return _bBerLib.Template.render(spineXML, _Spine.default.body());
|
|
221
177
|
}
|
|
222
|
-
|
|
223
178
|
static writeTocXhtmlFile(toc) {
|
|
224
179
|
const filepath = _State.default.dist.ops('toc.xhtml');
|
|
225
|
-
|
|
226
180
|
_bBerLogger.default.info(`opf emit toc.xhtml [${filepath}]`);
|
|
227
|
-
|
|
228
181
|
return _fsExtra.default.writeFile(filepath, toc);
|
|
229
182
|
}
|
|
230
|
-
|
|
231
183
|
static writeTocNcxFile(ncx) {
|
|
232
184
|
const filepath = _State.default.dist.ops('toc.ncx');
|
|
233
|
-
|
|
234
185
|
_bBerLogger.default.info(`opf emit toc.ncx [${filepath}]`);
|
|
235
|
-
|
|
236
186
|
return _fsExtra.default.writeFile(filepath, ncx);
|
|
237
187
|
}
|
|
238
|
-
|
|
239
188
|
static async writeFiles([toc, ncx, guide, spine]) {
|
|
240
189
|
await _promise.default.all([Navigation.writeTocXhtmlFile(toc), Navigation.writeTocNcxFile(ncx)]);
|
|
241
190
|
return {
|
|
@@ -243,12 +192,9 @@ class Navigation {
|
|
|
243
192
|
guide
|
|
244
193
|
};
|
|
245
194
|
}
|
|
246
|
-
|
|
247
195
|
static init() {
|
|
248
196
|
return Navigation.createEmptyNavDocuments().then(() => Navigation.compareXhtmlWithYaml()).then(() => _promise.default.all([Navigation.createTocStringsFromTemplate(), Navigation.createNcxStringsFromTemplate(), Navigation.createGuideStringsFromTemplate(), Navigation.createSpineStringsFromTemplate()])).then(resp => Navigation.writeFiles(resp)).catch(_bBerLogger.default.error);
|
|
249
197
|
}
|
|
250
|
-
|
|
251
198
|
}
|
|
252
|
-
|
|
253
199
|
var _default = Navigation;
|
|
254
200
|
exports.default = _default;
|
package/dist/opf/Opf.js
CHANGED
|
@@ -1,50 +1,35 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.default = void 0;
|
|
12
|
-
|
|
13
9
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
14
|
-
|
|
15
10
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
16
|
-
|
|
17
11
|
var _layouts = _interopRequireDefault(require("layouts"));
|
|
18
|
-
|
|
19
12
|
var _vinyl = _interopRequireDefault(require("vinyl"));
|
|
20
|
-
|
|
21
13
|
var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
|
|
22
|
-
|
|
23
14
|
var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
|
|
24
|
-
|
|
25
15
|
var _Pkg = _interopRequireDefault(require("@canopycanopycanopy/b-ber-templates/Opf/Pkg"));
|
|
26
|
-
|
|
27
16
|
var _ = require(".");
|
|
28
|
-
|
|
29
17
|
// Generates metadata, manifest, guide, and spine XML and writes to to `content.opf`
|
|
18
|
+
|
|
30
19
|
class Opf {
|
|
31
20
|
static createOpf() {
|
|
32
21
|
const manifestAndMetadata = new _.ManifestAndMetadata();
|
|
33
22
|
return _promise.default.all([manifestAndMetadata.init(), _.Navigation.init()]).then(Opf.createOpfPackageString).then(Opf.writeOPF).catch(_bBerLogger.default.error);
|
|
34
23
|
}
|
|
35
|
-
|
|
36
24
|
static writeOPF(contents) {
|
|
37
25
|
const opsPath = _State.default.dist.ops('content.opf');
|
|
38
|
-
|
|
39
26
|
_bBerLogger.default.info(`opf emit content.opf [${opsPath}]`);
|
|
40
|
-
|
|
41
27
|
return _fsExtra.default.writeFile(opsPath, contents);
|
|
42
|
-
}
|
|
43
|
-
|
|
28
|
+
}
|
|
44
29
|
|
|
30
|
+
// Create the root `package` element and inject metadata, manifest, and navigation data
|
|
45
31
|
static createOpfPackageString([manifestAndMetadataXML, navigationXML]) {
|
|
46
32
|
_bBerLogger.default.info('opf build [package]');
|
|
47
|
-
|
|
48
33
|
const {
|
|
49
34
|
metadata,
|
|
50
35
|
manifest
|
|
@@ -67,8 +52,6 @@ class Opf {
|
|
|
67
52
|
}).contents.toString();
|
|
68
53
|
return opfString;
|
|
69
54
|
}
|
|
70
|
-
|
|
71
55
|
}
|
|
72
|
-
|
|
73
56
|
var _default = Opf;
|
|
74
57
|
exports.default = _default;
|
package/dist/opf/helpers.js
CHANGED
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.pathInfoFromFiles = exports.nestedContentToYAML = void 0;
|
|
12
|
-
|
|
13
9
|
var _map = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/map"));
|
|
14
|
-
|
|
15
10
|
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
|
|
16
|
-
|
|
17
11
|
var _path = _interopRequireDefault(require("path"));
|
|
18
|
-
|
|
19
12
|
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
20
|
-
|
|
21
13
|
/* eslint-disable import/prefer-default-export */
|
|
22
|
-
const isRemote = file => /^http/.test(file);
|
|
23
14
|
|
|
15
|
+
const isRemote = file => /^http/.test(file);
|
|
24
16
|
const pathInfoFromFile = (file, dest) => {
|
|
25
17
|
if (isRemote(file)) {
|
|
26
18
|
return {
|
|
@@ -31,7 +23,6 @@ const pathInfoFromFile = (file, dest) => {
|
|
|
31
23
|
remote: true
|
|
32
24
|
};
|
|
33
25
|
}
|
|
34
|
-
|
|
35
26
|
return {
|
|
36
27
|
absolutePath: file,
|
|
37
28
|
opsPath: (0, _utils.opsPath)(file, dest),
|
|
@@ -40,33 +31,27 @@ const pathInfoFromFile = (file, dest) => {
|
|
|
40
31
|
remote: false
|
|
41
32
|
};
|
|
42
33
|
};
|
|
34
|
+
const pathInfoFromFiles = (arr, dest) => (0, _map.default)(arr).call(arr, file => pathInfoFromFile(file, dest));
|
|
43
35
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
36
|
+
// TODO: move into Spine class? although it's called against the toc
|
|
47
37
|
exports.pathInfoFromFiles = pathInfoFromFiles;
|
|
48
|
-
|
|
49
38
|
const nestedContentToYAML = arr => (0, _reduce.default)(arr).call(arr, (acc, curr) => {
|
|
50
39
|
const model = {};
|
|
51
|
-
|
|
52
40
|
if (curr.linear === false || curr.in_toc === false) {
|
|
53
|
-
if (curr.linear === false) model.linear = false;
|
|
54
|
-
|
|
41
|
+
if (curr.linear === false) model.linear = false;
|
|
42
|
+
// eslint-disable-next-line camelcase
|
|
55
43
|
if (curr.in_toc === false) model.in_toc = false;
|
|
56
44
|
acc.push({
|
|
57
45
|
[curr.fileName]: model
|
|
58
46
|
});
|
|
59
47
|
} else {
|
|
60
48
|
acc.push(curr.fileName);
|
|
61
|
-
|
|
62
49
|
if (curr.nodes && curr.nodes.length) {
|
|
63
50
|
acc.push({
|
|
64
51
|
section: nestedContentToYAML(curr.nodes)
|
|
65
52
|
});
|
|
66
53
|
}
|
|
67
54
|
}
|
|
68
|
-
|
|
69
55
|
return acc;
|
|
70
56
|
}, []);
|
|
71
|
-
|
|
72
57
|
exports.nestedContentToYAML = nestedContentToYAML;
|
package/dist/opf/index.js
CHANGED
|
@@ -1,42 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
_Object$defineProperty(exports, "ManifestAndMetadata", {
|
|
12
9
|
enumerable: true,
|
|
13
10
|
get: function () {
|
|
14
11
|
return _ManifestAndMetadata.default;
|
|
15
12
|
}
|
|
16
13
|
});
|
|
17
|
-
|
|
18
14
|
_Object$defineProperty(exports, "Navigation", {
|
|
19
15
|
enumerable: true,
|
|
20
16
|
get: function () {
|
|
21
17
|
return _Navigation.default;
|
|
22
18
|
}
|
|
23
19
|
});
|
|
24
|
-
|
|
25
20
|
_Object$defineProperty(exports, "Opf", {
|
|
26
21
|
enumerable: true,
|
|
27
22
|
get: function () {
|
|
28
23
|
return _Opf.default;
|
|
29
24
|
}
|
|
30
25
|
});
|
|
31
|
-
|
|
32
26
|
exports.default = void 0;
|
|
33
|
-
|
|
34
27
|
var _Opf = _interopRequireDefault(require("./Opf"));
|
|
35
|
-
|
|
36
28
|
var _ManifestAndMetadata = _interopRequireDefault(require("./ManifestAndMetadata"));
|
|
37
|
-
|
|
38
29
|
var _Navigation = _interopRequireDefault(require("./Navigation"));
|
|
39
|
-
|
|
40
30
|
const opf = _Opf.default.createOpf;
|
|
41
31
|
var _default = opf;
|
|
42
32
|
exports.default = _default;
|
package/dist/pdf/index.js
CHANGED
|
@@ -1,54 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js-stable/object/define-property");
|
|
4
|
-
|
|
5
4
|
var _interopRequireDefault = require("@babel/runtime-corejs3/helpers/interopRequireDefault");
|
|
6
|
-
|
|
7
5
|
_Object$defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
|
-
|
|
11
8
|
exports.default = void 0;
|
|
12
|
-
|
|
13
9
|
var _set = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/set"));
|
|
14
|
-
|
|
15
10
|
var _keys = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/keys"));
|
|
16
|
-
|
|
17
11
|
var _reduce = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/reduce"));
|
|
18
|
-
|
|
19
12
|
var _entries = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/object/entries"));
|
|
20
|
-
|
|
21
13
|
var _concat = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/concat"));
|
|
22
|
-
|
|
23
14
|
var _includes = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/instance/includes"));
|
|
24
|
-
|
|
25
15
|
var _promise = _interopRequireDefault(require("@babel/runtime-corejs3/core-js-stable/promise"));
|
|
26
|
-
|
|
27
16
|
var _path = _interopRequireDefault(require("path"));
|
|
28
|
-
|
|
29
17
|
var _fsExtra = _interopRequireDefault(require("fs-extra"));
|
|
30
|
-
|
|
31
18
|
var _kebabCase = _interopRequireDefault(require("lodash/kebabCase"));
|
|
32
|
-
|
|
33
19
|
var _bBerLogger = _interopRequireDefault(require("@canopycanopycanopy/b-ber-logger"));
|
|
34
|
-
|
|
35
20
|
var _State = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/State"));
|
|
36
|
-
|
|
37
21
|
var _EbookConvert = _interopRequireDefault(require("@canopycanopycanopy/b-ber-lib/EbookConvert"));
|
|
38
|
-
|
|
39
22
|
var _utils = require("@canopycanopycanopy/b-ber-lib/utils");
|
|
40
|
-
|
|
41
23
|
const booleans = new _set.default(['pdf_mark_links', 'preserve_cover_aspect_ratio', 'pretty_print', 'uncompressed_pdf', 'pdf_page_numbers', 'pdf_add_toc', 'use_profile_size', 'disable_font_rescaling', 'subset_embedded_fonts', 'embed_all_fonts ', 'linearize_tables', 'expand_css', 'smarten_punctuation', 'unsmarten_punctuation', 'insert_blank_line', 'remove_paragraph_spacing', 'asciiize', 'keep_ligatures', 'enable_heuristics', 'disable_markup_chapter_headings', 'disable_italicize_common_cases', 'disable_fix_indents', 'disable_unwrap_lines', 'disable_delete_blank_paragraphs', 'disable_format_scene_breaks', 'disable_dehyphenate', 'disable_renumber_headings', 'prefer_metadata_cover', 'remove_first_image', 'insert_metadata ', 'disable_remove_fake_margins', 'no_chapters_in_toc', 'use_auto_toc', 'duplicate_links_in_toc']);
|
|
42
24
|
const settings = new _set.default(['u', 'unit', 'm', 'read_metadata_from_opf', 'from_opf', 'custom_size', 'pdf_standard_font', 'pdf_page_margin_top', 'pdf_page_margin_right', 'toc_title', 'pdf_serif_family', 'pdf_mono_font_size', 'pdf_page_margin_left', 'pdf_page_margin_bottom', 'pdf_footer_template', 'pdf_default_font_size', 'pdf_sans_family', 'pdf_mono_family', 'paper_size', 'pdf_header_template', 'base_font_size', 'font_size_mapping', 'embed_font_family', 'line_height', 'minimum_line_height', 'extra_css', 'filter_css', 'transform_css_rules', 'margin_top', 'margin_left', 'margin_right', 'margin_bottom', 'change_justification', 'insert_blank_line_size', 'remove_paragraph_spacing_indent_size', 'html_unwrap_factor', 'replace_scene_breaks', 'sr1_search', 'sr1_replace', 'sr2_search', 'sr2_replace', 'sr3_search', 'sr3_replace', 'search_replace', 'chapter', 'chapter_mark', 'page_breaks_before', 'start_reading_at', 'level1_toc', 'level2_toc', 'level3_toc', 'toc_threshold', 'max_toc_links', 'toc_filter', 'title', 'authors', 'title_sort', 'author_sort', 'cover', 'comments', 'publisher', 'series', 'series_index', 'rating', 'isbn', 'tags', 'book_producer', 'language', 'pubdate', 'timestamp']);
|
|
43
|
-
|
|
44
25
|
const toArg = (key, val) => {
|
|
45
26
|
if (typeof val === 'undefined') return `--${(0, _kebabCase.default)(key)}`;
|
|
46
27
|
return `--${(0, _kebabCase.default)(key)}=${val}`;
|
|
47
28
|
};
|
|
48
|
-
|
|
49
29
|
const getPDFFlags = options => {
|
|
50
30
|
var _context;
|
|
51
|
-
|
|
52
31
|
if ((0, _keys.default)(options).length < 1) return [];
|
|
53
32
|
const flags = (0, _reduce.default)(_context = (0, _entries.default)(options)).call(_context, (acc, [key, val]) => {
|
|
54
33
|
if (booleans.has(key)) return (0, _concat.default)(acc).call(acc, toArg(key));
|
|
@@ -57,21 +36,17 @@ const getPDFFlags = options => {
|
|
|
57
36
|
}, []);
|
|
58
37
|
return flags;
|
|
59
38
|
};
|
|
60
|
-
|
|
61
39
|
const pdf = () => {
|
|
62
40
|
const opsPath = _State.default.dist.ops();
|
|
63
|
-
|
|
64
41
|
const inputPath = _path.default.join(opsPath, 'content.opf');
|
|
65
|
-
|
|
66
42
|
const pdfOptions = _State.default.config.pdf_options || {};
|
|
67
|
-
const flags = getPDFFlags(pdfOptions);
|
|
68
|
-
// ebook-convert to skip it.
|
|
43
|
+
const flags = getPDFFlags(pdfOptions);
|
|
69
44
|
|
|
45
|
+
// Remove TOC manually since there's no option in
|
|
46
|
+
// ebook-convert to skip it.
|
|
70
47
|
const tocPath = _path.default.join(opsPath, 'toc.xhtml');
|
|
71
|
-
|
|
72
48
|
return _fsExtra.default.remove(tocPath).then(() => {
|
|
73
49
|
var _context2;
|
|
74
|
-
|
|
75
50
|
return (0, _includes.default)(_context2 = process.argv).call(_context2, '--no-compile') ? _promise.default.resolve() : _EbookConvert.default.convert({
|
|
76
51
|
inputPath,
|
|
77
52
|
outputPath: process.cwd(),
|
|
@@ -81,6 +56,5 @@ const pdf = () => {
|
|
|
81
56
|
}).catch(_bBerLogger.default.error);
|
|
82
57
|
});
|
|
83
58
|
};
|
|
84
|
-
|
|
85
59
|
var _default = pdf;
|
|
86
60
|
exports.default = _default;
|