honkit 3.7.0 → 3.7.1
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/lib/__tests__/init.js +1 -1
- package/lib/__tests__/snapshot-honkit.js +1 -1
- package/lib/api/decodeGlobal.js +1 -1
- package/lib/api/encodeConfig.js +0 -4
- package/lib/api/encodeGlobal.js +9 -9
- package/lib/api/encodeNavigation.js +0 -4
- package/lib/api/encodePage.js +1 -5
- package/lib/api/encodeProgress.js +1 -6
- package/lib/api/encodeSummary.js +3 -5
- package/lib/bin.js +1 -1
- package/lib/cli/build.js +3 -3
- package/lib/cli/buildEbook.js +2 -2
- package/lib/cli/getBook.js +1 -1
- package/lib/cli/index.js +1 -1
- package/lib/cli/init.js +1 -1
- package/lib/cli/parse.js +1 -1
- package/lib/cli/serve.js +7 -7
- package/lib/cli/server.js +3 -3
- package/lib/constants/__tests__/configSchema.js +7 -7
- package/lib/constants/configDefault.js +1 -1
- package/lib/constants/defaultFilters.js +2 -2
- package/lib/fs/__tests__/mock.js +1 -1
- package/lib/index.js +1 -1
- package/lib/init.js +1 -1
- package/lib/json/encodeBook.js +5 -5
- package/lib/json/encodeBookWithPage.js +3 -3
- package/lib/json/encodeGlossary.js +1 -1
- package/lib/json/encodeLanguages.js +1 -1
- package/lib/json/encodeOutput.js +1 -1
- package/lib/json/encodeOutputWithPage.js +3 -3
- package/lib/json/encodePage.js +9 -8
- package/lib/json/encodeReadme.js +1 -1
- package/lib/json/encodeSummary.js +1 -1
- package/lib/json/encodeSummaryArticle.js +8 -1
- package/lib/json/encodeSummaryArticleWithCache.js +36 -0
- package/lib/models/__tests__/summaryArticle.js +55 -0
- package/lib/models/__tests__/templateBlock.js +2 -2
- package/lib/models/book.js +1 -1
- package/lib/models/config.js +1 -1
- package/lib/models/fs.js +5 -5
- package/lib/models/glossaryEntry.js +1 -1
- package/lib/models/ignore.js +2 -2
- package/lib/models/output.js +1 -1
- package/lib/models/page.js +1 -1
- package/lib/models/parser.js +11 -11
- package/lib/models/templateBlock.js +3 -3
- package/lib/modifiers/config/__tests__/addPlugin.js +1 -1
- package/lib/modifiers/config/__tests__/removePlugin.js +3 -3
- package/lib/modifiers/config/__tests__/togglePlugin.js +2 -2
- package/lib/modifiers/config/addPlugin.js +2 -2
- package/lib/modifiers/config/isDefaultPlugin.js +1 -1
- package/lib/modifiers/config/removePlugin.js +2 -2
- package/lib/modifiers/config/togglePlugin.js +1 -1
- package/lib/modifiers/summary/__tests__/editPartTitle.js +3 -3
- package/lib/modifiers/summary/__tests__/insertArticle.js +2 -2
- package/lib/modifiers/summary/__tests__/insertPart.js +2 -2
- package/lib/modifiers/summary/__tests__/mergeAtLevel.js +2 -2
- package/lib/modifiers/summary/__tests__/moveArticle.js +3 -3
- package/lib/modifiers/summary/__tests__/moveArticleAfter.js +5 -5
- package/lib/modifiers/summary/__tests__/removeArticle.js +1 -1
- package/lib/modifiers/summary/editArticleRef.js +1 -1
- package/lib/modifiers/summary/editArticleTitle.js +1 -1
- package/lib/modifiers/summary/indexPartLevels.js +1 -1
- package/lib/modifiers/summary/insertArticle.js +2 -2
- package/lib/modifiers/summary/insertPart.js +1 -1
- package/lib/modifiers/summary/moveArticle.js +2 -2
- package/lib/modifiers/summary/moveArticleAfter.js +4 -4
- package/lib/modifiers/summary/removeArticle.js +2 -2
- package/lib/modifiers/summary/removePart.js +1 -1
- package/lib/modifiers/summary/unshiftArticle.js +1 -1
- package/lib/output/Generator.js +2 -0
- package/lib/output/__tests__/ebook.js +1 -1
- package/lib/output/__tests__/json.js +3 -3
- package/lib/output/__tests__/plugin-hooks.js +3 -3
- package/lib/output/__tests__/website.js +8 -8
- package/lib/output/callHook.js +1 -1
- package/lib/output/callPageHook.js +1 -1
- package/lib/output/createTemplateEngine.js +1 -0
- package/lib/output/ebook/getConvertOptions.js +8 -8
- package/lib/output/ebook/getPDFTemplate.js +3 -1
- package/lib/output/ebook/index.js +1 -1
- package/lib/output/ebook/onFinish.js +3 -3
- package/lib/output/generateAssets.js +1 -1
- package/lib/output/generateBook.js +54 -46
- package/lib/output/generatePage.js +5 -5
- package/lib/output/generatePages.js +3 -3
- package/lib/output/getModifiers.js +2 -2
- package/lib/output/helper/fileToURL.js +1 -1
- package/lib/output/helper/resolveFileToURL.js +1 -1
- package/lib/output/index.js +0 -2
- package/lib/output/json/onFinish.js +1 -1
- package/lib/output/json/onPage.js +2 -2
- package/lib/output/modifiers/__tests__/addHeadingId.js +2 -2
- package/lib/output/modifiers/__tests__/annotateText.js +3 -3
- package/lib/output/modifiers/__tests__/fetchRemoteImages.js +2 -2
- package/lib/output/modifiers/__tests__/highlightCode.js +5 -5
- package/lib/output/modifiers/__tests__/inlinePng.js +1 -1
- package/lib/output/modifiers/__tests__/inlineSvg.js +2 -2
- package/lib/output/modifiers/__tests__/resolveImages.js +3 -3
- package/lib/output/modifiers/__tests__/resolveLinks.js +7 -7
- package/lib/output/modifiers/__tests__/svgToImg.js +2 -2
- package/lib/output/modifiers/addHeadingId.js +2 -2
- package/lib/output/modifiers/annotateText.js +1 -1
- package/lib/output/modifiers/fetchRemoteImages.js +1 -1
- package/lib/output/modifiers/highlightCode.js +2 -2
- package/lib/output/modifiers/inlineAssets.js +1 -1
- package/lib/output/modifiers/inlinePng.js +1 -1
- package/lib/output/modifiers/inlineSvg.js +1 -1
- package/lib/output/modifiers/resolveImages.js +1 -1
- package/lib/output/modifiers/resolveLinks.js +1 -1
- package/lib/output/modifiers/svgToImg.js +2 -2
- package/lib/output/preparePages.js +1 -1
- package/lib/output/preparePlugins.js +1 -1
- package/lib/output/testing/createMock.js +2 -2
- package/lib/output/testing/generateMock.js +3 -3
- package/lib/output/website/__tests__/i18n.js +6 -6
- package/lib/output/website/copyPluginAssets.js +4 -4
- package/lib/output/website/createTemplateEngine.js +7 -7
- package/lib/output/website/onFinish.js +3 -3
- package/lib/output/website/onInit.js +1 -1
- package/lib/output/website/onPage.js +5 -5
- package/lib/output/website/prepareI18n.js +2 -2
- package/lib/output/website/prepareResources.js +2 -2
- package/lib/output/website/state.js +1 -1
- package/lib/parse/__tests__/listAssets.js +6 -6
- package/lib/parse/__tests__/parseBook.js +6 -6
- package/lib/parse/__tests__/parseGlossary.js +4 -4
- package/lib/parse/__tests__/parseIgnore.js +2 -2
- package/lib/parse/__tests__/parsePageFromString.js +3 -3
- package/lib/parse/__tests__/parseReadme.js +5 -5
- package/lib/parse/__tests__/parseSummary.js +4 -4
- package/lib/parse/lookupStructureFile.js +1 -1
- package/lib/parse/parseBook.js +3 -3
- package/lib/parse/parseConfig.js +2 -2
- package/lib/parse/parseGlossary.js +1 -1
- package/lib/parse/parseIgnore.js +1 -1
- package/lib/parse/parseLanguages.js +1 -1
- package/lib/parse/parsePage.js +1 -1
- package/lib/parse/parsePageFromString.js +2 -2
- package/lib/parse/parsePagesList.js +2 -2
- package/lib/parse/parseReadme.js +1 -1
- package/lib/parse/parseStructureFile.js +1 -1
- package/lib/parse/parseSummary.js +1 -1
- package/lib/parse/validateConfig.js +2 -2
- package/lib/parse/walkSummary.js +1 -1
- package/lib/plugins/PluginResolver.js +5 -5
- package/lib/plugins/__tests__/findInstalled.js +1 -1
- package/lib/plugins/__tests__/listDependencies.js +6 -6
- package/lib/plugins/__tests__/sortDependencies.js +4 -4
- package/lib/plugins/__tests__/validatePlugin.js +3 -3
- package/lib/plugins/findInstalled.js +2 -2
- package/lib/plugins/listDependencies.js +1 -1
- package/lib/plugins/listDepsForBook.js +1 -1
- package/lib/plugins/loadForBook.js +2 -2
- package/lib/plugins/loadPlugin.js +2 -2
- package/lib/plugins/validateConfig.js +2 -2
- package/lib/plugins/validatePlugin.js +1 -1
- package/lib/templating/__tests__/conrefsLoader.js +11 -8
- package/lib/templating/__tests__/postRender.js +4 -4
- package/lib/templating/__tests__/replaceShortcuts.js +2 -2
- package/lib/templating/conrefsLoader.js +1 -1
- package/lib/templating/render.js +1 -1
- package/lib/templating/renderFile.js +2 -2
- package/lib/templating/replaceShortcuts.js +2 -2
- package/lib/templating/themesLoader.js +1 -1
- package/lib/utils/command.js +1 -33
- package/lib/utils/error.js +10 -10
- package/lib/utils/fs.js +6 -6
- package/lib/utils/git.js +4 -4
- package/lib/utils/promise.js +6 -6
- package/package.json +9 -8
- package/CHANGELOG.md +0 -448
|
@@ -24,15 +24,15 @@ function moveArticleAfter(summary, origin, afterTarget) {
|
|
|
24
24
|
const targetLevel = increment(afterTargetLevel);
|
|
25
25
|
if (targetLevel < origin) {
|
|
26
26
|
// Remove first
|
|
27
|
-
const removed = removeArticle_1.default(summary, originLevel);
|
|
27
|
+
const removed = (0, removeArticle_1.default)(summary, originLevel);
|
|
28
28
|
// Insert then
|
|
29
|
-
return insertArticle_1.default(removed, article, targetLevel);
|
|
29
|
+
return (0, insertArticle_1.default)(removed, article, targetLevel);
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
32
|
// Insert right after first
|
|
33
|
-
const inserted = insertArticle_1.default(summary, article, targetLevel);
|
|
33
|
+
const inserted = (0, insertArticle_1.default)(summary, article, targetLevel);
|
|
34
34
|
// Remove old one
|
|
35
|
-
return removeArticle_1.default(inserted, originLevel);
|
|
35
|
+
return (0, removeArticle_1.default)(inserted, originLevel);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
/**
|
|
@@ -30,7 +30,7 @@ function removeArticle(summary, level) {
|
|
|
30
30
|
parent = parent.set("articles", articles);
|
|
31
31
|
// Reindex the level from here
|
|
32
32
|
// @ts-expect-error ts-migrate(2554) FIXME: Expected 2 arguments, but got 1.
|
|
33
|
-
parent = indexArticleLevels_1.default(parent);
|
|
34
|
-
return mergeAtLevel_1.default(summary, parent.getLevel(), parent);
|
|
33
|
+
parent = (0, indexArticleLevels_1.default)(parent);
|
|
34
|
+
return (0, mergeAtLevel_1.default)(summary, parent.getLevel(), parent);
|
|
35
35
|
}
|
|
36
36
|
exports.default = removeArticle;
|
|
@@ -13,6 +13,6 @@ const indexLevels_1 = __importDefault(require("./indexLevels"));
|
|
|
13
13
|
*/
|
|
14
14
|
function removePart(summary, index) {
|
|
15
15
|
const parts = summary.getParts().remove(index);
|
|
16
|
-
return indexLevels_1.default(summary.set("parts", parts));
|
|
16
|
+
return (0, indexLevels_1.default)(summary.set("parts", parts));
|
|
17
17
|
}
|
|
18
18
|
exports.default = removePart;
|
|
@@ -22,6 +22,6 @@ function unshiftArticle(summary, article) {
|
|
|
22
22
|
part = part.set("articles", articles);
|
|
23
23
|
parts = parts.set(0, part);
|
|
24
24
|
summary = summary.set("parts", parts);
|
|
25
|
-
return indexLevels_1.default(summary);
|
|
25
|
+
return (0, indexLevels_1.default)(summary);
|
|
26
26
|
}
|
|
27
27
|
exports.default = unshiftArticle;
|
|
@@ -7,7 +7,7 @@ const generateMock_1 = __importDefault(require("../testing/generateMock"));
|
|
|
7
7
|
const ebook_1 = __importDefault(require("../ebook"));
|
|
8
8
|
describe("EbookGenerator", () => {
|
|
9
9
|
test("should generate a SUMMARY.html", () => {
|
|
10
|
-
return generateMock_1.default(ebook_1.default, {
|
|
10
|
+
return (0, generateMock_1.default)(ebook_1.default, {
|
|
11
11
|
"README.md": "Hello World"
|
|
12
12
|
}).then((folder) => {
|
|
13
13
|
expect(folder).toHaveFile("SUMMARY.html");
|
|
@@ -7,14 +7,14 @@ const generateMock_1 = __importDefault(require("../testing/generateMock"));
|
|
|
7
7
|
const json_1 = __importDefault(require("../json"));
|
|
8
8
|
describe("JSONGenerator", () => {
|
|
9
9
|
test("should generate a README.json", () => {
|
|
10
|
-
return generateMock_1.default(json_1.default, {
|
|
10
|
+
return (0, generateMock_1.default)(json_1.default, {
|
|
11
11
|
"README.md": "Hello World"
|
|
12
12
|
}).then((folder) => {
|
|
13
13
|
expect(folder).toHaveFile("README.json");
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
test("should generate a json file for each articles", () => {
|
|
17
|
-
return generateMock_1.default(json_1.default, {
|
|
17
|
+
return (0, generateMock_1.default)(json_1.default, {
|
|
18
18
|
"README.md": "Hello World",
|
|
19
19
|
"SUMMARY.md": "# Summary\n\n* [Page](test/page.md)",
|
|
20
20
|
test: {
|
|
@@ -26,7 +26,7 @@ describe("JSONGenerator", () => {
|
|
|
26
26
|
});
|
|
27
27
|
});
|
|
28
28
|
test("should generate a multilingual book", () => {
|
|
29
|
-
return generateMock_1.default(json_1.default, {
|
|
29
|
+
return (0, generateMock_1.default)(json_1.default, {
|
|
30
30
|
"LANGS.md": "# Languages\n\n* [en](en)\n* [fr](fr)",
|
|
31
31
|
en: {
|
|
32
32
|
"README.md": "Hello"
|
|
@@ -10,7 +10,7 @@ const generatePages_1 = __importDefault(require("../generatePages"));
|
|
|
10
10
|
const plugin_1 = __importDefault(require("../../models/plugin"));
|
|
11
11
|
const json_1 = __importDefault(require("../json"));
|
|
12
12
|
const createOutputWithPlugin = async ({ Generator, plugin, files }) => {
|
|
13
|
-
const { output } = await generateMock_1.generateMockBook(Generator, files);
|
|
13
|
+
const { output } = await (0, generateMock_1.generateMockBook)(Generator, files);
|
|
14
14
|
// add plugin
|
|
15
15
|
return output.merge({
|
|
16
16
|
plugins: [plugin],
|
|
@@ -48,8 +48,8 @@ describe("plugin-hooks", function () {
|
|
|
48
48
|
},
|
|
49
49
|
});
|
|
50
50
|
// call twice
|
|
51
|
-
await generatePages_1.default(json_1.default, output);
|
|
52
|
-
await generatePages_1.default(json_1.default, output);
|
|
51
|
+
await (0, generatePages_1.default)(json_1.default, output);
|
|
52
|
+
await (0, generatePages_1.default)(json_1.default, output);
|
|
53
53
|
// assert
|
|
54
54
|
assert_1.default.strictEqual(onPageBeforeCount, 2);
|
|
55
55
|
assert_1.default.strictEqual(onPageCount, 2);
|
|
@@ -9,7 +9,7 @@ const website_1 = __importDefault(require("../website"));
|
|
|
9
9
|
const longTest = (name, fn) => test(name, fn, 1000 * 30);
|
|
10
10
|
describe("WebsiteGenerator", () => {
|
|
11
11
|
test("should generate an index.html", async () => {
|
|
12
|
-
const folder = await generateMock_1.default(website_1.default, {
|
|
12
|
+
const folder = await (0, generateMock_1.default)(website_1.default, {
|
|
13
13
|
"README.md": "Hello World"
|
|
14
14
|
});
|
|
15
15
|
expect(folder).toHaveFile("index.html");
|
|
@@ -17,7 +17,7 @@ describe("WebsiteGenerator", () => {
|
|
|
17
17
|
describe("Glossary", () => {
|
|
18
18
|
let folder;
|
|
19
19
|
beforeAll(() => {
|
|
20
|
-
return generateMock_1.default(website_1.default, {
|
|
20
|
+
return (0, generateMock_1.default)(website_1.default, {
|
|
21
21
|
"README.md": "Hello World",
|
|
22
22
|
"SUMMARY.md": "* [Deep](folder/page.md)",
|
|
23
23
|
folder: {
|
|
@@ -40,7 +40,7 @@ describe("WebsiteGenerator", () => {
|
|
|
40
40
|
expect(html).toHaveDOMElement(".page-inner a[href=\"../GLOSSARY.html#hello\"]");
|
|
41
41
|
});
|
|
42
42
|
longTest("should accept a custom glossary file", () => {
|
|
43
|
-
return generateMock_1.default(website_1.default, {
|
|
43
|
+
return (0, generateMock_1.default)(website_1.default, {
|
|
44
44
|
"README.md": "Hello World",
|
|
45
45
|
"book.json": "{ \"structure\": { \"glossary\": \"custom.md\" } }",
|
|
46
46
|
"custom.md": "# Glossary\n\n## Hello\n\nHello World"
|
|
@@ -53,7 +53,7 @@ describe("WebsiteGenerator", () => {
|
|
|
53
53
|
});
|
|
54
54
|
});
|
|
55
55
|
test.skip("should copy asset files", () => {
|
|
56
|
-
return generateMock_1.default(website_1.default, {
|
|
56
|
+
return (0, generateMock_1.default)(website_1.default, {
|
|
57
57
|
"README.md": "Hello World",
|
|
58
58
|
"myJsFile.js": "var a = \"test\";",
|
|
59
59
|
folder: {
|
|
@@ -66,13 +66,13 @@ describe("WebsiteGenerator", () => {
|
|
|
66
66
|
});
|
|
67
67
|
});
|
|
68
68
|
test.skip("should generate an index.html for AsciiDoc", async () => {
|
|
69
|
-
const folder = await generateMock_1.default(website_1.default, {
|
|
69
|
+
const folder = await (0, generateMock_1.default)(website_1.default, {
|
|
70
70
|
"README.adoc": "Hello World"
|
|
71
71
|
});
|
|
72
72
|
expect(folder).toHaveFile("index.html");
|
|
73
73
|
});
|
|
74
74
|
longTest("should generate an HTML file for each articles", () => {
|
|
75
|
-
return generateMock_1.default(website_1.default, {
|
|
75
|
+
return (0, generateMock_1.default)(website_1.default, {
|
|
76
76
|
"README.md": "Hello World",
|
|
77
77
|
"SUMMARY.md": "# Summary\n\n* [Page](test/page.md)",
|
|
78
78
|
test: {
|
|
@@ -84,7 +84,7 @@ describe("WebsiteGenerator", () => {
|
|
|
84
84
|
});
|
|
85
85
|
});
|
|
86
86
|
longTest("should not generate file if entry file doesn't exist", () => {
|
|
87
|
-
return generateMock_1.default(website_1.default, {
|
|
87
|
+
return (0, generateMock_1.default)(website_1.default, {
|
|
88
88
|
"README.md": "Hello World",
|
|
89
89
|
"SUMMARY.md": "# Summary\n\n* [Page 1](page.md)\n* [Page 2](test/page.md)",
|
|
90
90
|
test: {
|
|
@@ -97,7 +97,7 @@ describe("WebsiteGenerator", () => {
|
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
longTest("should generate a multilingual book", () => {
|
|
100
|
-
return generateMock_1.default(website_1.default, {
|
|
100
|
+
return (0, generateMock_1.default)(website_1.default, {
|
|
101
101
|
"LANGS.md": "# Languages\n\n* [en](en)\n* [fr](fr)",
|
|
102
102
|
en: {
|
|
103
103
|
"README.md": "Hello"
|
package/lib/output/callHook.js
CHANGED
|
@@ -31,7 +31,7 @@ function callHook(name, getArgument, handleResult, output) {
|
|
|
31
31
|
const context = api_1.default.encodeGlobal(output);
|
|
32
32
|
return timing_1.default.measure(`call.hook.${name}`,
|
|
33
33
|
// Get the arguments
|
|
34
|
-
promise_1.default(getArgument(output))
|
|
34
|
+
(0, promise_1.default)(getArgument(output))
|
|
35
35
|
// Call the hooks in serie
|
|
36
36
|
.then((arg) => {
|
|
37
37
|
return promise_1.default.reduce(plugins, (prev, plugin) => {
|
|
@@ -14,7 +14,7 @@ const callHook_1 = __importDefault(require("./callHook"));
|
|
|
14
14
|
@return {Promise<Page>}
|
|
15
15
|
*/
|
|
16
16
|
function callPageHook(name, output, page) {
|
|
17
|
-
return callHook_1.default(name, (out) => {
|
|
17
|
+
return (0, callHook_1.default)(name, (out) => {
|
|
18
18
|
return api_1.default.encodePage(out, page);
|
|
19
19
|
}, (out, result) => {
|
|
20
20
|
return api_1.default.decodePage(out, page, result);
|
|
@@ -28,6 +28,7 @@ function createTemplateEngine(output) {
|
|
|
28
28
|
filters = defaultFilters_1.default.merge(filters);
|
|
29
29
|
// Create loader
|
|
30
30
|
const transformFn = templating_1.default.replaceShortcuts.bind(null, blocks);
|
|
31
|
+
// @ts-expect-error: Expected 0 arguments, but got 3.
|
|
31
32
|
const loader = new templating_1.default.ConrefsLoader(rootFolder, transformFn, logger);
|
|
32
33
|
// Create API context
|
|
33
34
|
const context = api_1.default.encodeGlobal(output);
|
|
@@ -18,8 +18,8 @@ function getConvertOptions(output) {
|
|
|
18
18
|
const format = options.get("format");
|
|
19
19
|
const book = output.getBook();
|
|
20
20
|
const config = book.getConfig();
|
|
21
|
-
return promise_1.default().then(() => {
|
|
22
|
-
const coverPath = getCoverPath_1.default(output);
|
|
21
|
+
return (0, promise_1.default)().then(() => {
|
|
22
|
+
const coverPath = (0, getCoverPath_1.default)(output);
|
|
23
23
|
let options = {
|
|
24
24
|
"--cover": coverPath,
|
|
25
25
|
"--title": config.getValue("title"),
|
|
@@ -45,15 +45,15 @@ function getConvertOptions(output) {
|
|
|
45
45
|
if (format !== "pdf") {
|
|
46
46
|
return options;
|
|
47
47
|
}
|
|
48
|
-
return promise_1.default.all([getPDFTemplate_1.default(output, "header"), getPDFTemplate_1.default(output, "footer")]).spread((headerTpl, footerTpl) => {
|
|
48
|
+
return promise_1.default.all([(0, getPDFTemplate_1.default)(output, "header"), (0, getPDFTemplate_1.default)(output, "footer")]).spread((headerTpl, footerTpl) => {
|
|
49
49
|
const pdfOptions = config.getValue("pdf").toJS();
|
|
50
|
-
return (options = extend_1.default(options, {
|
|
50
|
+
return (options = (0, extend_1.default)(options, {
|
|
51
51
|
"--chapter-mark": String(pdfOptions.chapterMark),
|
|
52
52
|
"--page-breaks-before": String(pdfOptions.pageBreaksBefore),
|
|
53
|
-
"--margin-left": String(pdfOptions.margin.left),
|
|
54
|
-
"--margin-right": String(pdfOptions.margin.right),
|
|
55
|
-
"--margin-top": String(pdfOptions.margin.top),
|
|
56
|
-
"--margin-bottom": String(pdfOptions.margin.bottom),
|
|
53
|
+
"--pdf-page-margin-left": String(pdfOptions.margin.left),
|
|
54
|
+
"--pdf-page-margin-right": String(pdfOptions.margin.right),
|
|
55
|
+
"--pdf-page-margin-top": String(pdfOptions.margin.top),
|
|
56
|
+
"--pdf-page-margin-bottom": String(pdfOptions.margin.bottom),
|
|
57
57
|
"--pdf-default-font-size": String(pdfOptions.fontSize),
|
|
58
58
|
"--pdf-mono-font-size": String(pdfOptions.fontSize),
|
|
59
59
|
"--paper-size": String(pdfOptions.paperSize),
|
|
@@ -35,6 +35,8 @@ function getPDFTemplate(output, type) {
|
|
|
35
35
|
relativeTo: outputRoot,
|
|
36
36
|
},
|
|
37
37
|
});
|
|
38
|
-
})
|
|
38
|
+
})
|
|
39
|
+
.then((tplOut) => tplOut.replace(/\n/g, " ")) // PDF templates need to be on one line for inclusion in spawned command
|
|
40
|
+
);
|
|
39
41
|
}
|
|
40
42
|
exports.default = getPDFTemplate;
|
|
@@ -8,7 +8,7 @@ const website_1 = __importDefault(require("../website"));
|
|
|
8
8
|
const options_1 = __importDefault(require("./options"));
|
|
9
9
|
const onPage_1 = __importDefault(require("./onPage"));
|
|
10
10
|
const onFinish_1 = __importDefault(require("./onFinish"));
|
|
11
|
-
exports.default = extend_1.default({}, website_1.default, {
|
|
11
|
+
exports.default = (0, extend_1.default)({}, website_1.default, {
|
|
12
12
|
name: "ebook",
|
|
13
13
|
Options: options_1.default,
|
|
14
14
|
onPage: onPage_1.default,
|
|
@@ -29,7 +29,7 @@ function writeSummary(output) {
|
|
|
29
29
|
return (templating_1.default.renderFile(engine, `${prefix}/summary.html`, context)
|
|
30
30
|
// Write it to the disk
|
|
31
31
|
.then((tplOut) => {
|
|
32
|
-
return writeFile_1.default(output, filePath, tplOut.getContent());
|
|
32
|
+
return (0, writeFile_1.default)(output, filePath, tplOut.getContent());
|
|
33
33
|
}));
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
@@ -44,9 +44,9 @@ function runEbookConvert(output) {
|
|
|
44
44
|
const format = options.get("format");
|
|
45
45
|
const outputFolder = output.getRoot();
|
|
46
46
|
if (!format) {
|
|
47
|
-
return promise_1.default(output);
|
|
47
|
+
return (0, promise_1.default)(output);
|
|
48
48
|
}
|
|
49
|
-
return getConvertOptions_1.default(output)
|
|
49
|
+
return (0, getConvertOptions_1.default)(output)
|
|
50
50
|
.then((options) => {
|
|
51
51
|
const cmd = [
|
|
52
52
|
"ebook-convert",
|
|
@@ -16,7 +16,7 @@ function generateAssets(generator, output) {
|
|
|
16
16
|
const logger = output.getLogger();
|
|
17
17
|
// Is generator ignoring assets?
|
|
18
18
|
if (!generator.onAsset) {
|
|
19
|
-
return promise_1.default(output);
|
|
19
|
+
return (0, promise_1.default)(output);
|
|
20
20
|
}
|
|
21
21
|
return promise_1.default.reduce(assets, (out, assetFile) => {
|
|
22
22
|
logger.debug.ln(`copy asset "${assetFile}"`);
|
|
@@ -15,6 +15,50 @@ const preparePages_1 = __importDefault(require("./preparePages"));
|
|
|
15
15
|
const prepareAssets_1 = __importDefault(require("./prepareAssets"));
|
|
16
16
|
const generateAssets_1 = __importDefault(require("./generateAssets"));
|
|
17
17
|
const generatePages_1 = __importDefault(require("./generatePages"));
|
|
18
|
+
const updateBookConfig = callHook_1.default.bind(null, "config", (output) => {
|
|
19
|
+
const book = output.getBook();
|
|
20
|
+
const config = book.getConfig();
|
|
21
|
+
const values = config.getValues();
|
|
22
|
+
return values.toJS();
|
|
23
|
+
}, (output, result) => {
|
|
24
|
+
let book = output.getBook();
|
|
25
|
+
let config = book.getConfig();
|
|
26
|
+
config = config.updateValues(result);
|
|
27
|
+
book = book.set("config", config);
|
|
28
|
+
return output.set("book", book);
|
|
29
|
+
});
|
|
30
|
+
/**
|
|
31
|
+
* Update multiple languages books if the book has LANGS.md
|
|
32
|
+
* @param generator
|
|
33
|
+
* @param output
|
|
34
|
+
*/
|
|
35
|
+
const generateMultipleLanguages = (generator, output) => {
|
|
36
|
+
const book = output.getBook();
|
|
37
|
+
if (!book.isMultilingual()) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const logger = book.getLogger();
|
|
41
|
+
const books = book.getBooks();
|
|
42
|
+
const outputRoot = output.getRoot();
|
|
43
|
+
const plugins = output.getPlugins();
|
|
44
|
+
const state = output.getState();
|
|
45
|
+
const options = output.getOptions();
|
|
46
|
+
const bookList = books.map((langBook) => {
|
|
47
|
+
// Inherits plugins list, options and state
|
|
48
|
+
const langOptions = options.set("root", path_1.default.join(outputRoot, langBook.getLanguage()));
|
|
49
|
+
const langOutput = new output_1.default({
|
|
50
|
+
book: langBook,
|
|
51
|
+
options: langOptions,
|
|
52
|
+
state: state,
|
|
53
|
+
generator: generator.name,
|
|
54
|
+
plugins: plugins,
|
|
55
|
+
});
|
|
56
|
+
logger.info.ln("");
|
|
57
|
+
logger.info.ln(`generating language "${langBook.getLanguage()}"`);
|
|
58
|
+
return processOutput(generator, langOutput);
|
|
59
|
+
});
|
|
60
|
+
return promise_1.default.all(bookList.toArray()).thenResolve(output);
|
|
61
|
+
};
|
|
18
62
|
/**
|
|
19
63
|
* Process an output to generate the book
|
|
20
64
|
*
|
|
@@ -23,22 +67,11 @@ const generatePages_1 = __importDefault(require("./generatePages"));
|
|
|
23
67
|
* @return {Promise<Output>}
|
|
24
68
|
*/
|
|
25
69
|
function processOutput(generator, output) {
|
|
26
|
-
return promise_1.default(output)
|
|
70
|
+
return (0, promise_1.default)(output)
|
|
27
71
|
.then(preparePlugins_1.default)
|
|
28
72
|
.then(preparePages_1.default)
|
|
29
73
|
.then(prepareAssets_1.default)
|
|
30
|
-
.then(
|
|
31
|
-
const book = output.getBook();
|
|
32
|
-
const config = book.getConfig();
|
|
33
|
-
const values = config.getValues();
|
|
34
|
-
return values.toJS();
|
|
35
|
-
}, (output, result) => {
|
|
36
|
-
let book = output.getBook();
|
|
37
|
-
let config = book.getConfig();
|
|
38
|
-
config = config.updateValues(result);
|
|
39
|
-
book = book.set("config", config);
|
|
40
|
-
return output.set("book", book);
|
|
41
|
-
}))
|
|
74
|
+
.then(updateBookConfig)
|
|
42
75
|
.then(callHook_1.default.bind(null, "init", (output) => {
|
|
43
76
|
return {};
|
|
44
77
|
}, (output) => {
|
|
@@ -50,35 +83,9 @@ function processOutput(generator, output) {
|
|
|
50
83
|
}
|
|
51
84
|
return generator.onInit(output);
|
|
52
85
|
})
|
|
53
|
-
.then((output) => generateAssets_1.default(generator, output))
|
|
54
|
-
.then((output) => generatePages_1.default(generator, output))
|
|
55
|
-
.tap((output) =>
|
|
56
|
-
const book = output.getBook();
|
|
57
|
-
if (!book.isMultilingual()) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const logger = book.getLogger();
|
|
61
|
-
const books = book.getBooks();
|
|
62
|
-
const outputRoot = output.getRoot();
|
|
63
|
-
const plugins = output.getPlugins();
|
|
64
|
-
const state = output.getState();
|
|
65
|
-
const options = output.getOptions();
|
|
66
|
-
const bookList = books.map((langBook) => {
|
|
67
|
-
// Inherits plugins list, options and state
|
|
68
|
-
const langOptions = options.set("root", path_1.default.join(outputRoot, langBook.getLanguage()));
|
|
69
|
-
const langOutput = new output_1.default({
|
|
70
|
-
book: langBook,
|
|
71
|
-
options: langOptions,
|
|
72
|
-
state: state,
|
|
73
|
-
generator: generator.name,
|
|
74
|
-
plugins: plugins,
|
|
75
|
-
});
|
|
76
|
-
logger.info.ln("");
|
|
77
|
-
logger.info.ln(`generating language "${langBook.getLanguage()}"`);
|
|
78
|
-
return processOutput(generator, langOutput);
|
|
79
|
-
});
|
|
80
|
-
return promise_1.default.all(bookList.toArray()).thenResolve(output);
|
|
81
|
-
})
|
|
86
|
+
.then((output) => (0, generateAssets_1.default)(generator, output))
|
|
87
|
+
.then((output) => (0, generatePages_1.default)(generator, output))
|
|
88
|
+
.tap((output) => generateMultipleLanguages(generator, output))
|
|
82
89
|
.then(callHook_1.default.bind(null, "finish:before", (output) => {
|
|
83
90
|
return {};
|
|
84
91
|
}, (output) => {
|
|
@@ -121,7 +128,7 @@ function generateBook(generator, book, options = {}) {
|
|
|
121
128
|
options = generator.Options(options);
|
|
122
129
|
const state = generator.State ? new generator.State({}) : immutable_1.default.Map();
|
|
123
130
|
const start = Date.now();
|
|
124
|
-
return (promise_1.default(new output_1.default({
|
|
131
|
+
return ((0, promise_1.default)(new output_1.default({
|
|
125
132
|
book: book,
|
|
126
133
|
options: options,
|
|
127
134
|
state: state,
|
|
@@ -154,14 +161,15 @@ exports.generateBook = generateBook;
|
|
|
154
161
|
*/
|
|
155
162
|
function incrementalBuild(generator, output) {
|
|
156
163
|
const start = Date.now();
|
|
157
|
-
return generateAssets_1.default(generator, output)
|
|
158
|
-
.then((output) => generatePages_1.default(generator, output))
|
|
164
|
+
return (0, generateAssets_1.default)(generator, output)
|
|
165
|
+
.then((output) => (0, generatePages_1.default)(generator, output))
|
|
159
166
|
.then((output) => {
|
|
160
167
|
const logger = output.getLogger();
|
|
161
168
|
const end = Date.now();
|
|
162
169
|
const duration = (end - start) / 1000;
|
|
163
170
|
logger.info.ok(`generation finished with success in ${duration.toFixed(1)}s !`);
|
|
164
171
|
return output;
|
|
165
|
-
})
|
|
172
|
+
})
|
|
173
|
+
.tap((output) => generateMultipleLanguages(generator, output));
|
|
166
174
|
}
|
|
167
175
|
exports.incrementalBuild = incrementalBuild;
|
|
@@ -22,9 +22,9 @@ const page_1 = __importDefault(require("../models/page"));
|
|
|
22
22
|
*/
|
|
23
23
|
function generatePage(output, page) {
|
|
24
24
|
const book = output.getBook();
|
|
25
|
-
const engine = createTemplateEngine_1.default(output);
|
|
26
|
-
const cache = page_cache_1.getCache();
|
|
27
|
-
return timing_1.default.measure("page.generate", promise_1.default(page).then((resultPage) => {
|
|
25
|
+
const engine = (0, createTemplateEngine_1.default)(output);
|
|
26
|
+
const cache = (0, page_cache_1.getCache)();
|
|
27
|
+
return timing_1.default.measure("page.generate", (0, promise_1.default)(page).then((resultPage) => {
|
|
28
28
|
const file = resultPage.getFile();
|
|
29
29
|
const filePath = file.getPath();
|
|
30
30
|
const parser = file.getParser();
|
|
@@ -36,7 +36,7 @@ function generatePage(output, page) {
|
|
|
36
36
|
}
|
|
37
37
|
// Call hook "page:before"
|
|
38
38
|
// const start = Date.now();
|
|
39
|
-
return (callPageHook_1.default("page:before", output, resultPage)
|
|
39
|
+
return ((0, callPageHook_1.default)("page:before", output, resultPage)
|
|
40
40
|
// Escape code blocks with raw tags
|
|
41
41
|
.then((currentPage) => {
|
|
42
42
|
// console.log("page:before", Date.now() - start);
|
|
@@ -83,7 +83,7 @@ function generatePage(output, page) {
|
|
|
83
83
|
})
|
|
84
84
|
// Call final hook
|
|
85
85
|
.then((currentPage) => {
|
|
86
|
-
return callPageHook_1.default("page", output, currentPage);
|
|
86
|
+
return (0, callPageHook_1.default)("page", output, currentPage);
|
|
87
87
|
}));
|
|
88
88
|
}));
|
|
89
89
|
}
|
|
@@ -15,12 +15,12 @@ const page_cache_1 = require("./page-cache");
|
|
|
15
15
|
@return {Promise<Output>}
|
|
16
16
|
*/
|
|
17
17
|
function generatePages(generator, output) {
|
|
18
|
-
const cache = page_cache_1.getCache();
|
|
18
|
+
const cache = (0, page_cache_1.getCache)();
|
|
19
19
|
const pages = output.getPages();
|
|
20
20
|
const logger = output.getLogger();
|
|
21
21
|
// Is generator ignoring assets?
|
|
22
22
|
if (!generator.onPage) {
|
|
23
|
-
return promise_1.default(output);
|
|
23
|
+
return (0, promise_1.default)(output);
|
|
24
24
|
}
|
|
25
25
|
const root = output.book.getContentRoot();
|
|
26
26
|
const isIncrementBuilding = output.incrementalChangeFileSet.size !== 0;
|
|
@@ -32,7 +32,7 @@ function generatePages(generator, output) {
|
|
|
32
32
|
logger.debug.ln(`skip generate page "${file.getPath()}"`);
|
|
33
33
|
return; // Skip build
|
|
34
34
|
}
|
|
35
|
-
return generatePage_1.default(output, page)
|
|
35
|
+
return (0, generatePage_1.default)(output, page)
|
|
36
36
|
.then((resultPage) => {
|
|
37
37
|
// It call renderToString
|
|
38
38
|
// Create page file
|
|
@@ -25,7 +25,7 @@ function getModifiers(output, page) {
|
|
|
25
25
|
// Glossary entries
|
|
26
26
|
const entries = glossary.getEntries();
|
|
27
27
|
const glossaryFile = glossary.getFile();
|
|
28
|
-
const glossaryFilename = fileToOutput_1.default(output, glossaryFile.getPath());
|
|
28
|
+
const glossaryFilename = (0, fileToOutput_1.default)(output, glossaryFile.getPath());
|
|
29
29
|
// Current file path
|
|
30
30
|
const currentFilePath = file.getPath();
|
|
31
31
|
// Get TemplateBlock for highlighting
|
|
@@ -44,7 +44,7 @@ function getModifiers(output, page) {
|
|
|
44
44
|
modifiers_1.default.resolveLinks.bind(null, currentFilePath, resolveFileToURL_1.default.bind(null, output)),
|
|
45
45
|
// Highlight code blocks using "code" block
|
|
46
46
|
modifiers_1.default.highlightCode.bind(null, (lang, source) => {
|
|
47
|
-
return promise_1.default(code.applyBlock({
|
|
47
|
+
return (0, promise_1.default)(code.applyBlock({
|
|
48
48
|
body: source,
|
|
49
49
|
kwargs: {
|
|
50
50
|
language: lang,
|
|
@@ -21,7 +21,7 @@ const fileToOutput_1 = __importDefault(require("./fileToOutput"));
|
|
|
21
21
|
function fileToURL(output, filePath) {
|
|
22
22
|
const options = output.getOptions();
|
|
23
23
|
const directoryIndex = options.get("directoryIndex");
|
|
24
|
-
filePath = fileToOutput_1.default(output, filePath);
|
|
24
|
+
filePath = (0, fileToOutput_1.default)(output, filePath);
|
|
25
25
|
if (directoryIndex && path_1.default.basename(filePath) == "index.html") {
|
|
26
26
|
filePath = `${path_1.default.dirname(filePath)}/`;
|
|
27
27
|
}
|
|
@@ -18,7 +18,7 @@ function resolveFileToURL(output, filePath) {
|
|
|
18
18
|
const page = output.getPage(filePath);
|
|
19
19
|
// if file is a page, return correct .html url
|
|
20
20
|
if (page) {
|
|
21
|
-
filePath = fileToURL_1.default(output, filePath);
|
|
21
|
+
filePath = (0, fileToURL_1.default)(output, filePath);
|
|
22
22
|
}
|
|
23
23
|
return location_1.default.normalize(filePath);
|
|
24
24
|
}
|
package/lib/output/index.js
CHANGED
|
@@ -11,8 +11,6 @@ const ebook_1 = __importDefault(require("./ebook"));
|
|
|
11
11
|
const generators = immutable_1.default.List([json_1.default, website_1.default, ebook_1.default]);
|
|
12
12
|
/**
|
|
13
13
|
Return a specific generator by its name
|
|
14
|
-
|
|
15
|
-
@param {string}
|
|
16
14
|
@return {Generator}
|
|
17
15
|
*/
|
|
18
16
|
function getGenerator(name) {
|
|
@@ -17,7 +17,7 @@ function onFinish(output) {
|
|
|
17
17
|
const book = output.getBook();
|
|
18
18
|
const outputRoot = output.getRoot();
|
|
19
19
|
if (!book.isMultilingual()) {
|
|
20
|
-
return promise_1.default(output);
|
|
20
|
+
return (0, promise_1.default)(output);
|
|
21
21
|
}
|
|
22
22
|
// Get main language
|
|
23
23
|
const languages = book.getLanguages();
|
|
@@ -19,7 +19,7 @@ const JSON_VERSION = "3";
|
|
|
19
19
|
function onPage(output, page) {
|
|
20
20
|
const file = page.getFile();
|
|
21
21
|
const readme = output.getBook().getReadme().getFile();
|
|
22
|
-
return modifiers_1.default.modifyHTML(page, getModifiers_1.default(output, page)).then((resultPage) => {
|
|
22
|
+
return modifiers_1.default.modifyHTML(page, (0, getModifiers_1.default)(output, page)).then((resultPage) => {
|
|
23
23
|
// Generate the JSON
|
|
24
24
|
const json = json_1.default.encodeBookWithPage(output.getBook(), resultPage);
|
|
25
25
|
// Delete some private properties
|
|
@@ -31,7 +31,7 @@ function onPage(output, page) {
|
|
|
31
31
|
let filePath = file.getPath() == readme.getPath() ? "README.json" : file.getPath();
|
|
32
32
|
filePath = path_1.default.setExtension(filePath, ".json");
|
|
33
33
|
// Write it to the disk
|
|
34
|
-
return writeFile_1.default(output, filePath, JSON.stringify(json, null, 4));
|
|
34
|
+
return (0, writeFile_1.default)(output, filePath, JSON.stringify(json, null, 4));
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
exports.onPage = onPage;
|
|
@@ -8,14 +8,14 @@ const addHeadingId_1 = __importDefault(require("../addHeadingId"));
|
|
|
8
8
|
describe("addHeadingId", () => {
|
|
9
9
|
test("should add an ID if none", () => {
|
|
10
10
|
const $ = cheerio_1.default.load("<h1>Hello World</h1><h2>Cool !!</h2>");
|
|
11
|
-
return addHeadingId_1.default($).then(() => {
|
|
11
|
+
return (0, addHeadingId_1.default)($).then(() => {
|
|
12
12
|
const html = $.html();
|
|
13
13
|
expect(html).toBe("<h1 id=\"hello-world\">Hello World</h1><h2 id=\"cool-\">Cool !!</h2>");
|
|
14
14
|
});
|
|
15
15
|
});
|
|
16
16
|
test("should not change existing IDs", () => {
|
|
17
17
|
const $ = cheerio_1.default.load("<h1 id=\"awesome\">Hello World</h1>");
|
|
18
|
-
return addHeadingId_1.default($).then(() => {
|
|
18
|
+
return (0, addHeadingId_1.default)($).then(() => {
|
|
19
19
|
const html = $.html();
|
|
20
20
|
expect(html).toBe("<h1 id=\"awesome\">Hello World</h1>");
|
|
21
21
|
});
|
|
@@ -14,7 +14,7 @@ describe("annotateText", () => {
|
|
|
14
14
|
]);
|
|
15
15
|
test("should annotate text", () => {
|
|
16
16
|
const $ = cheerio_1.default.load("<p>This is a word, and multiple words</p>");
|
|
17
|
-
annotateText_1.default(entries, "GLOSSARY.md", $);
|
|
17
|
+
(0, annotateText_1.default)(entries, "GLOSSARY.md", $);
|
|
18
18
|
const links = $("a");
|
|
19
19
|
expect(links.length).toBe(2);
|
|
20
20
|
const word = $(links.get(0));
|
|
@@ -28,12 +28,12 @@ describe("annotateText", () => {
|
|
|
28
28
|
});
|
|
29
29
|
test("should not annotate scripts", () => {
|
|
30
30
|
const $ = cheerio_1.default.load("<script>This is a word, and multiple words</script>");
|
|
31
|
-
annotateText_1.default(entries, "GLOSSARY.md", $);
|
|
31
|
+
(0, annotateText_1.default)(entries, "GLOSSARY.md", $);
|
|
32
32
|
expect($("a").length).toBe(0);
|
|
33
33
|
});
|
|
34
34
|
test('should not annotate when has class "no-glossary"', () => {
|
|
35
35
|
const $ = cheerio_1.default.load('<p class="no-glossary">This is a word, and multiple words</p>');
|
|
36
|
-
annotateText_1.default(entries, "GLOSSARY.md", $);
|
|
36
|
+
(0, annotateText_1.default)(entries, "GLOSSARY.md", $);
|
|
37
37
|
expect($("a").length).toBe(0);
|
|
38
38
|
});
|
|
39
39
|
});
|
|
@@ -15,7 +15,7 @@ describe.skip("fetchRemoteImages", () => {
|
|
|
15
15
|
});
|
|
16
16
|
test("should download image file", () => {
|
|
17
17
|
const $ = cheerio_1.default.load(`<img src="${URL}" />`);
|
|
18
|
-
return fetchRemoteImages_1.default(dir.name, "index.html", $).then(() => {
|
|
18
|
+
return (0, fetchRemoteImages_1.default)(dir.name, "index.html", $).then(() => {
|
|
19
19
|
const $img = $("img");
|
|
20
20
|
const src = $img.attr("src");
|
|
21
21
|
expect(dir.name).toHaveFile(src);
|
|
@@ -23,7 +23,7 @@ describe.skip("fetchRemoteImages", () => {
|
|
|
23
23
|
});
|
|
24
24
|
test("should download image file and replace with relative path", () => {
|
|
25
25
|
const $ = cheerio_1.default.load(`<img src="${URL}" />`);
|
|
26
|
-
return fetchRemoteImages_1.default(dir.name, "test/index.html", $).then(() => {
|
|
26
|
+
return (0, fetchRemoteImages_1.default)(dir.name, "test/index.html", $).then(() => {
|
|
27
27
|
const $img = $("img");
|
|
28
28
|
const src = $img.attr("src");
|
|
29
29
|
expect(dir.name).toHaveFile(path_1.default.join("test", src));
|