honkit 6.0.4 → 6.1.5
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__/__fixtures__/honkit/book.d.ts +7 -0
- package/lib/__tests__/__fixtures__/honkit/book.d.ts.map +1 -0
- package/lib/__tests__/__fixtures__/honkit/book.js +9 -0
- package/lib/__tests__/e2e.test.d.ts +2 -0
- package/lib/__tests__/e2e.test.d.ts.map +1 -0
- package/lib/__tests__/e2e.test.js +81 -0
- package/lib/__tests__/init.d.ts +2 -0
- package/lib/__tests__/init.d.ts.map +1 -0
- package/lib/__tests__/init.js +19 -0
- package/lib/__tests__/satisfies.d.ts +2 -0
- package/lib/__tests__/satisfies.d.ts.map +1 -0
- package/lib/__tests__/satisfies.js +11 -0
- package/lib/__tests__/snapshot-asciidoc.d.ts +2 -0
- package/lib/__tests__/snapshot-asciidoc.d.ts.map +1 -0
- package/lib/__tests__/snapshot-asciidoc.js +48 -0
- package/lib/__tests__/snapshot-honkit.d.ts +2 -0
- package/lib/__tests__/snapshot-honkit.d.ts.map +1 -0
- package/lib/__tests__/snapshot-honkit.js +48 -0
- package/lib/cli/__tests__/watch.test.d.ts +2 -0
- package/lib/cli/__tests__/watch.test.d.ts.map +1 -0
- package/lib/cli/__tests__/watch.test.js +194 -0
- package/lib/cli/serve.d.ts.map +1 -1
- package/lib/cli/serve.js +49 -43
- package/lib/cli/watch.d.ts +22 -6
- package/lib/cli/watch.d.ts.map +1 -1
- package/lib/cli/watch.js +24 -10
- package/lib/constants/__tests__/configSchema.d.ts +2 -0
- package/lib/constants/__tests__/configSchema.d.ts.map +1 -0
- package/lib/constants/__tests__/configSchema.js +41 -0
- package/lib/fs/__tests__/mock.d.ts +2 -0
- package/lib/fs/__tests__/mock.d.ts.map +1 -0
- package/lib/fs/__tests__/mock.js +68 -0
- package/lib/models/__tests__/config.d.ts +2 -0
- package/lib/models/__tests__/config.d.ts.map +1 -0
- package/lib/models/__tests__/config.js +164 -0
- package/lib/models/__tests__/glossary.d.ts +2 -0
- package/lib/models/__tests__/glossary.d.ts.map +1 -0
- package/lib/models/__tests__/glossary.js +38 -0
- package/lib/models/__tests__/glossaryEntry.d.ts +2 -0
- package/lib/models/__tests__/glossaryEntry.d.ts.map +1 -0
- package/lib/models/__tests__/glossaryEntry.js +16 -0
- package/lib/models/__tests__/page.d.ts +2 -0
- package/lib/models/__tests__/page.d.ts.map +1 -0
- package/lib/models/__tests__/page.js +26 -0
- package/lib/models/__tests__/plugin.d.ts +2 -0
- package/lib/models/__tests__/plugin.d.ts.map +1 -0
- package/lib/models/__tests__/plugin.js +50 -0
- package/lib/models/__tests__/pluginDependency.d.ts +2 -0
- package/lib/models/__tests__/pluginDependency.d.ts.map +1 -0
- package/lib/models/__tests__/pluginDependency.js +71 -0
- package/lib/models/__tests__/summary.d.ts +2 -0
- package/lib/models/__tests__/summary.d.ts.map +1 -0
- package/lib/models/__tests__/summary.js +115 -0
- package/lib/models/__tests__/summaryArticle.d.ts +2 -0
- package/lib/models/__tests__/summaryArticle.d.ts.map +1 -0
- package/lib/models/__tests__/summaryArticle.js +117 -0
- package/lib/models/__tests__/summaryPart.d.ts +2 -0
- package/lib/models/__tests__/summaryPart.d.ts.map +1 -0
- package/lib/models/__tests__/summaryPart.js +24 -0
- package/lib/models/__tests__/templateBlock.d.ts +2 -0
- package/lib/models/__tests__/templateBlock.d.ts.map +1 -0
- package/lib/models/__tests__/templateBlock.js +172 -0
- package/lib/models/__tests__/templateEngine.d.ts +2 -0
- package/lib/models/__tests__/templateEngine.d.ts.map +1 -0
- package/lib/models/__tests__/templateEngine.js +49 -0
- package/lib/modifiers/config/__tests__/addPlugin.d.ts +2 -0
- package/lib/modifiers/config/__tests__/addPlugin.d.ts.map +1 -0
- package/lib/modifiers/config/__tests__/addPlugin.js +30 -0
- package/lib/modifiers/config/__tests__/removePlugin.d.ts +2 -0
- package/lib/modifiers/config/__tests__/removePlugin.d.ts.map +1 -0
- package/lib/modifiers/config/__tests__/removePlugin.js +29 -0
- package/lib/modifiers/config/__tests__/togglePlugin.d.ts +2 -0
- package/lib/modifiers/config/__tests__/togglePlugin.d.ts.map +1 -0
- package/lib/modifiers/config/__tests__/togglePlugin.js +28 -0
- package/lib/modifiers/summary/__tests__/editPartTitle.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/editPartTitle.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/editPartTitle.js +41 -0
- package/lib/modifiers/summary/__tests__/insertArticle.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/insertArticle.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/insertArticle.js +72 -0
- package/lib/modifiers/summary/__tests__/insertPart.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/insertPart.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/insertPart.js +56 -0
- package/lib/modifiers/summary/__tests__/mergeAtLevel.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/mergeAtLevel.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/mergeAtLevel.js +45 -0
- package/lib/modifiers/summary/__tests__/moveArticle.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/moveArticle.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/moveArticle.js +66 -0
- package/lib/modifiers/summary/__tests__/moveArticleAfter.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/moveArticleAfter.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/moveArticleAfter.js +75 -0
- package/lib/modifiers/summary/__tests__/removeArticle.d.ts +2 -0
- package/lib/modifiers/summary/__tests__/removeArticle.d.ts.map +1 -0
- package/lib/modifiers/summary/__tests__/removeArticle.js +54 -0
- package/lib/output/__tests__/ebook.d.ts +2 -0
- package/lib/output/__tests__/ebook.d.ts.map +1 -0
- package/lib/output/__tests__/ebook.js +17 -0
- package/lib/output/__tests__/json.d.ts +2 -0
- package/lib/output/__tests__/json.d.ts.map +1 -0
- package/lib/output/__tests__/json.js +43 -0
- package/lib/output/__tests__/plugin-hooks.d.ts +2 -0
- package/lib/output/__tests__/plugin-hooks.d.ts.map +1 -0
- package/lib/output/__tests__/plugin-hooks.js +57 -0
- package/lib/output/__tests__/website.d.ts +2 -0
- package/lib/output/__tests__/website.d.ts.map +1 -0
- package/lib/output/__tests__/website.js +121 -0
- package/lib/output/modifiers/__tests__/addHeadingId.d.ts +2 -0
- package/lib/output/modifiers/__tests__/addHeadingId.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/addHeadingId.js +23 -0
- package/lib/output/modifiers/__tests__/annotateText.d.ts +2 -0
- package/lib/output/modifiers/__tests__/annotateText.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/annotateText.js +71 -0
- package/lib/output/modifiers/__tests__/fetchRemoteImages.d.ts +2 -0
- package/lib/output/modifiers/__tests__/fetchRemoteImages.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/fetchRemoteImages.js +69 -0
- package/lib/output/modifiers/__tests__/highlightCode.d.ts +2 -0
- package/lib/output/modifiers/__tests__/highlightCode.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/highlightCode.js +48 -0
- package/lib/output/modifiers/__tests__/inlinePng.d.ts +2 -0
- package/lib/output/modifiers/__tests__/inlinePng.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/inlinePng.js +22 -0
- package/lib/output/modifiers/__tests__/inlineSvg.d.ts +2 -0
- package/lib/output/modifiers/__tests__/inlineSvg.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/inlineSvg.js +42 -0
- package/lib/output/modifiers/__tests__/resolveImages.d.ts +2 -0
- package/lib/output/modifiers/__tests__/resolveImages.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/resolveImages.js +39 -0
- package/lib/output/modifiers/__tests__/resolveLinks.d.ts +2 -0
- package/lib/output/modifiers/__tests__/resolveLinks.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/resolveLinks.js +81 -0
- package/lib/output/modifiers/__tests__/svgToImg.d.ts +2 -0
- package/lib/output/modifiers/__tests__/svgToImg.d.ts.map +1 -0
- package/lib/output/modifiers/__tests__/svgToImg.js +29 -0
- package/lib/output/website/__tests__/i18n.d.ts +2 -0
- package/lib/output/website/__tests__/i18n.d.ts.map +1 -0
- package/lib/output/website/__tests__/i18n.js +40 -0
- package/lib/parse/__tests__/listAssets.d.ts +2 -0
- package/lib/parse/__tests__/listAssets.d.ts.map +1 -0
- package/lib/parse/__tests__/listAssets.js +63 -0
- package/lib/parse/__tests__/parseBook.d.ts +2 -0
- package/lib/parse/__tests__/parseBook.d.ts.map +1 -0
- package/lib/parse/__tests__/parseBook.js +77 -0
- package/lib/parse/__tests__/parseGlossary.d.ts +2 -0
- package/lib/parse/__tests__/parseGlossary.d.ts.map +1 -0
- package/lib/parse/__tests__/parseGlossary.js +32 -0
- package/lib/parse/__tests__/parseIgnore.d.ts +2 -0
- package/lib/parse/__tests__/parseIgnore.d.ts.map +1 -0
- package/lib/parse/__tests__/parseIgnore.js +37 -0
- package/lib/parse/__tests__/parsePageFromString.d.ts +2 -0
- package/lib/parse/__tests__/parsePageFromString.d.ts.map +1 -0
- package/lib/parse/__tests__/parsePageFromString.js +34 -0
- package/lib/parse/__tests__/parseReadme.d.ts +2 -0
- package/lib/parse/__tests__/parseReadme.d.ts.map +1 -0
- package/lib/parse/__tests__/parseReadme.js +33 -0
- package/lib/parse/__tests__/parseSummary.d.ts +2 -0
- package/lib/parse/__tests__/parseSummary.d.ts.map +1 -0
- package/lib/parse/__tests__/parseSummary.js +30 -0
- package/lib/plugins/__tests__/listDependencies.d.ts +2 -0
- package/lib/plugins/__tests__/listDependencies.d.ts.map +1 -0
- package/lib/plugins/__tests__/listDependencies.js +28 -0
- package/lib/plugins/__tests__/sortDependencies.d.ts +2 -0
- package/lib/plugins/__tests__/sortDependencies.d.ts.map +1 -0
- package/lib/plugins/__tests__/sortDependencies.js +28 -0
- package/lib/plugins/__tests__/validatePlugin.d.ts +2 -0
- package/lib/plugins/__tests__/validatePlugin.d.ts.map +1 -0
- package/lib/plugins/__tests__/validatePlugin.js +99 -0
- package/lib/templating/__tests__/conrefsLoader.d.ts +2 -0
- package/lib/templating/__tests__/conrefsLoader.d.ts.map +1 -0
- package/lib/templating/__tests__/conrefsLoader.js +90 -0
- package/lib/templating/__tests__/postRender.d.ts +2 -0
- package/lib/templating/__tests__/postRender.d.ts.map +1 -0
- package/lib/templating/__tests__/postRender.js +52 -0
- package/lib/templating/__tests__/replaceShortcuts.d.ts +2 -0
- package/lib/templating/__tests__/replaceShortcuts.d.ts.map +1 -0
- package/lib/templating/__tests__/replaceShortcuts.js +27 -0
- package/lib/utils/__tests__/git.d.ts +2 -0
- package/lib/utils/__tests__/git.d.ts.map +1 -0
- package/lib/utils/__tests__/git.js +46 -0
- package/lib/utils/__tests__/location.d.ts +2 -0
- package/lib/utils/__tests__/location.d.ts.map +1 -0
- package/lib/utils/__tests__/location.js +81 -0
- package/lib/utils/__tests__/path.d.ts +2 -0
- package/lib/utils/__tests__/path.d.ts.map +1 -0
- package/lib/utils/__tests__/path.js +19 -0
- package/package.json +17 -19
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const templateEngine_1 = __importDefault(require("../../models/templateEngine"));
|
|
8
|
+
const render_1 = __importDefault(require("../render"));
|
|
9
|
+
const conrefsLoader_1 = __importDefault(require("../conrefsLoader"));
|
|
10
|
+
describe("ConrefsLoader", () => {
|
|
11
|
+
const dirName = `${__dirname}/`;
|
|
12
|
+
const fileName = path_1.default.join(dirName, "test.md");
|
|
13
|
+
describe("Git", () => {
|
|
14
|
+
const engine = new templateEngine_1.default({
|
|
15
|
+
// @ts-expect-error: Expected 0 arguments, but got 1.
|
|
16
|
+
loader: new conrefsLoader_1.default(dirName),
|
|
17
|
+
});
|
|
18
|
+
test("should include content from git", () => {
|
|
19
|
+
// @ts-expect-error ts-migrate(2554) FIXME: Expected 4 arguments, but got 3.
|
|
20
|
+
return (0, render_1.default)(engine, fileName, '{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md" %}').then((out) => {
|
|
21
|
+
expect(out.getContent()).toBe("Hello from git");
|
|
22
|
+
});
|
|
23
|
+
}, 60 * 1000);
|
|
24
|
+
test("should handle deep inclusion (1)", () => {
|
|
25
|
+
// @ts-expect-error ts-migrate(2554) FIXME: Expected 4 arguments, but got 3.
|
|
26
|
+
return (0, render_1.default)(engine, fileName, '{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test2.md" %}').then((out) => {
|
|
27
|
+
expect(out.getContent()).toBe("First Hello. Hello from git");
|
|
28
|
+
});
|
|
29
|
+
}, 60 * 1000);
|
|
30
|
+
test("should handle deep inclusion (2)", () => {
|
|
31
|
+
// @ts-expect-error ts-migrate(2554) FIXME: Expected 4 arguments, but got 3.
|
|
32
|
+
return (0, render_1.default)(engine, fileName, '{% include "git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test3.md" %}').then((out) => {
|
|
33
|
+
expect(out.getContent()).toBe("First Hello. Hello from git");
|
|
34
|
+
});
|
|
35
|
+
}, 60 * 1000);
|
|
36
|
+
});
|
|
37
|
+
describe("Local", () => {
|
|
38
|
+
const engine = new templateEngine_1.default({
|
|
39
|
+
// @ts-expect-error: Expected 0 arguments, but got 1.
|
|
40
|
+
loader: new conrefsLoader_1.default(dirName),
|
|
41
|
+
});
|
|
42
|
+
describe("Relative", () => {
|
|
43
|
+
test("should resolve basic relative filepath", () => {
|
|
44
|
+
// @ts-expect-error ts-migrate(2554) FIXME: Expected 4 arguments, but got 3.
|
|
45
|
+
return (0, render_1.default)(engine, fileName, '{% include "include.md" %}').then((out) => {
|
|
46
|
+
expect(out.getContent()).toBe("Hello World");
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
test("should resolve basic parent filepath", () => {
|
|
50
|
+
// @ts-expect-error ts-migrate(2554) FIXME: Expected 4 arguments, but got 3.
|
|
51
|
+
return (0, render_1.default)(engine, path_1.default.join(dirName, "hello/test.md"), '{% include "../include.md" %}').then((out) => {
|
|
52
|
+
expect(out.getContent()).toBe("Hello World");
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
describe("Absolute", () => {
|
|
57
|
+
test("should resolve absolute filepath", () => {
|
|
58
|
+
// @ts-expect-error ts-migrate(2554) FIXME: Expected 4 arguments, but got 3.
|
|
59
|
+
return (0, render_1.default)(engine, fileName, '{% include "/include.md" %}').then((out) => {
|
|
60
|
+
expect(out.getContent()).toBe("Hello World");
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
test("should resolve absolute filepath when in a directory", () => {
|
|
64
|
+
// @ts-expect-error ts-migrate(2554) FIXME: Expected 4 arguments, but got 3.
|
|
65
|
+
return (0, render_1.default)(engine, path_1.default.join(dirName, "hello/test.md"), '{% include "/include.md" %}').then((out) => {
|
|
66
|
+
expect(out.getContent()).toBe("Hello World");
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
});
|
|
71
|
+
describe("transform", () => {
|
|
72
|
+
function transform(filePath, source) {
|
|
73
|
+
expect(typeof filePath).toBe("string");
|
|
74
|
+
expect(typeof source).toBe("string");
|
|
75
|
+
expect(filePath).toBe(path_1.default.resolve(__dirname, "include.md"));
|
|
76
|
+
expect(source).toBe("Hello World");
|
|
77
|
+
return `test-${source}-endtest`;
|
|
78
|
+
}
|
|
79
|
+
const engine = new templateEngine_1.default({
|
|
80
|
+
// @ts-expect-error: Expected 0 arguments, but got 1.
|
|
81
|
+
loader: new conrefsLoader_1.default(dirName, transform),
|
|
82
|
+
});
|
|
83
|
+
test("should transform included content", () => {
|
|
84
|
+
// @ts-expect-error ts-migrate(2554) FIXME: Expected 4 arguments, but got 3.
|
|
85
|
+
return (0, render_1.default)(engine, fileName, '{% include "include.md" %}').then((out) => {
|
|
86
|
+
expect(out.getContent()).toBe("test-Hello World-endtest");
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postRender.d.ts","sourceRoot":"","sources":["../../../src/templating/__tests__/postRender.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const templateEngine_1 = __importDefault(require("../../models/templateEngine"));
|
|
7
|
+
const templateBlock_1 = __importDefault(require("../../models/templateBlock"));
|
|
8
|
+
const render_1 = __importDefault(require("../render"));
|
|
9
|
+
const postRender_1 = __importDefault(require("../postRender"));
|
|
10
|
+
describe("postRender", () => {
|
|
11
|
+
let testPost;
|
|
12
|
+
const engine = templateEngine_1.default.create({
|
|
13
|
+
blocks: [
|
|
14
|
+
templateBlock_1.default.create("lower", (blk) => {
|
|
15
|
+
return blk.body.toLowerCase();
|
|
16
|
+
}),
|
|
17
|
+
templateBlock_1.default.create("prefix", (blk) => {
|
|
18
|
+
return {
|
|
19
|
+
body: `_${blk.body}_`,
|
|
20
|
+
post: function () {
|
|
21
|
+
testPost = true;
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
}),
|
|
25
|
+
],
|
|
26
|
+
});
|
|
27
|
+
test("should correctly replace block", () => {
|
|
28
|
+
// @ts-expect-error ts-migrate(2554) FIXME: Expected 4 arguments, but got 3.
|
|
29
|
+
return (0, render_1.default)(engine, "README.md", "Hello {% lower %}Samy{% endlower %}")
|
|
30
|
+
.then((output) => {
|
|
31
|
+
expect(output.getContent()).toMatch(/Hello \{\{\-([\S]+)\-\}\}/);
|
|
32
|
+
expect(output.getBlocks().size).toBe(1);
|
|
33
|
+
return (0, postRender_1.default)(engine, output);
|
|
34
|
+
})
|
|
35
|
+
.then((result) => {
|
|
36
|
+
expect(result).toBe("Hello samy");
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
test("should correctly replace blocks", () => {
|
|
40
|
+
// @ts-expect-error ts-migrate(2554) FIXME: Expected 4 arguments, but got 3.
|
|
41
|
+
return (0, render_1.default)(engine, "README.md", "Hello {% lower %}Samy{% endlower %}{% prefix %}Pesse{% endprefix %}")
|
|
42
|
+
.then((output) => {
|
|
43
|
+
expect(output.getContent()).toMatch(/Hello \{\{\-([\S]+)\-\}\}\{\{\-([\S]+)\-\}\}/);
|
|
44
|
+
expect(output.getBlocks().size).toBe(2);
|
|
45
|
+
return (0, postRender_1.default)(engine, output);
|
|
46
|
+
})
|
|
47
|
+
.then((result) => {
|
|
48
|
+
expect(result).toBe("Hello samy_Pesse_");
|
|
49
|
+
expect(testPost).toBe(true);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"replaceShortcuts.d.ts","sourceRoot":"","sources":["../../../src/templating/__tests__/replaceShortcuts.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const immutable_1 = __importDefault(require("immutable"));
|
|
7
|
+
const templateBlock_1 = __importDefault(require("../../models/templateBlock"));
|
|
8
|
+
const replaceShortcuts_1 = __importDefault(require("../replaceShortcuts"));
|
|
9
|
+
describe("replaceShortcuts", () => {
|
|
10
|
+
const blocks = immutable_1.default.List([
|
|
11
|
+
templateBlock_1.default.create("math", {
|
|
12
|
+
shortcuts: {
|
|
13
|
+
start: "$$",
|
|
14
|
+
end: "$$",
|
|
15
|
+
parsers: ["markdown"],
|
|
16
|
+
},
|
|
17
|
+
}),
|
|
18
|
+
]);
|
|
19
|
+
test("should correctly replace inline matches by block", () => {
|
|
20
|
+
const content = (0, replaceShortcuts_1.default)(blocks, "test.md", "Hello $$a = b$$");
|
|
21
|
+
expect(content).toBe("Hello {% math %}a = b{% endmath %}");
|
|
22
|
+
});
|
|
23
|
+
test("should correctly replace block matches", () => {
|
|
24
|
+
const content = (0, replaceShortcuts_1.default)(blocks, "test.md", "Hello\n$$\na = b\n$$\n");
|
|
25
|
+
expect(content).toBe("Hello\n{% math %}\na = b\n{% endmath %}\n");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../../src/utils/__tests__/git.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const git_1 = __importDefault(require("../git"));
|
|
8
|
+
describe("Git", () => {
|
|
9
|
+
describe("URL parsing", () => {
|
|
10
|
+
test("should correctly validate git urls", () => {
|
|
11
|
+
// HTTPS
|
|
12
|
+
expect(git_1.default.isUrl("git+https://github.com/Hello/world.git")).toBeTruthy();
|
|
13
|
+
// SSH
|
|
14
|
+
expect(git_1.default.isUrl("git+git@github.com:GitbookIO/gitbook.git/directory/README.md#e1594cde2c32e4ff48f6c4eff3d3d461743d74e1")).toBeTruthy();
|
|
15
|
+
// Non valid
|
|
16
|
+
expect(git_1.default.isUrl("https://github.com/Hello/world.git")).toBeFalsy();
|
|
17
|
+
expect(git_1.default.isUrl("README.md")).toBeFalsy();
|
|
18
|
+
}, 60 * 1000);
|
|
19
|
+
test("should parse HTTPS urls", () => {
|
|
20
|
+
const parts = git_1.default.parseUrl("git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md");
|
|
21
|
+
expect(parts.host).toBe("https://gist.github.com/69ea4542e4c8967d2fa7.git");
|
|
22
|
+
expect(parts.ref).toBe(null);
|
|
23
|
+
expect(parts.filepath).toBe("test.md");
|
|
24
|
+
}, 60 * 1000);
|
|
25
|
+
test("should parse HTTPS urls with a reference", () => {
|
|
26
|
+
const parts = git_1.default.parseUrl("git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md#1.0.0");
|
|
27
|
+
expect(parts.host).toBe("https://gist.github.com/69ea4542e4c8967d2fa7.git");
|
|
28
|
+
expect(parts.ref).toBe("1.0.0");
|
|
29
|
+
expect(parts.filepath).toBe("test.md");
|
|
30
|
+
}, 60 * 1000);
|
|
31
|
+
test("should parse SSH urls", () => {
|
|
32
|
+
const parts = git_1.default.parseUrl("git+git@github.com:GitbookIO/gitbook.git/directory/README.md#e1594cde2c32e4ff48f6c4eff3d3d461743d74e1");
|
|
33
|
+
expect(parts.host).toBe("git@github.com:GitbookIO/gitbook.git");
|
|
34
|
+
expect(parts.ref).toBe("e1594cde2c32e4ff48f6c4eff3d3d461743d74e1");
|
|
35
|
+
expect(parts.filepath).toBe("directory/README.md");
|
|
36
|
+
}, 60 * 1000);
|
|
37
|
+
});
|
|
38
|
+
describe("Cloning and resolving", () => {
|
|
39
|
+
test("should clone an HTTPS url", () => {
|
|
40
|
+
const git = new git_1.default();
|
|
41
|
+
return git.resolve("git+https://gist.github.com/69ea4542e4c8967d2fa7.git/test.md").then((filename) => {
|
|
42
|
+
expect(path_1.default.extname(filename)).toBe(".md");
|
|
43
|
+
});
|
|
44
|
+
}, 60 * 1000);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"location.d.ts","sourceRoot":"","sources":["../../../src/utils/__tests__/location.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const location_1 = __importDefault(require("../location"));
|
|
7
|
+
describe("LocationUtils", () => {
|
|
8
|
+
test("should correctly test external location", () => {
|
|
9
|
+
expect(location_1.default.isExternal("http://google.fr")).toBe(true);
|
|
10
|
+
expect(location_1.default.isExternal("https://google.fr")).toBe(true);
|
|
11
|
+
expect(location_1.default.isExternal("test.md")).toBe(false);
|
|
12
|
+
expect(location_1.default.isExternal("folder/test.md")).toBe(false);
|
|
13
|
+
expect(location_1.default.isExternal("/folder/test.md")).toBe(false);
|
|
14
|
+
expect(location_1.default.isExternal("data:image/png")).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
test("should correctly test data:uri location", () => {
|
|
17
|
+
expect(location_1.default.isDataURI("data:image/png")).toBe(true);
|
|
18
|
+
expect(location_1.default.isDataURI("http://google.fr")).toBe(false);
|
|
19
|
+
expect(location_1.default.isDataURI("https://google.fr")).toBe(false);
|
|
20
|
+
expect(location_1.default.isDataURI("test.md")).toBe(false);
|
|
21
|
+
expect(location_1.default.isDataURI("data.md")).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
test("should correctly detect anchor location", () => {
|
|
24
|
+
expect(location_1.default.isAnchor("#test")).toBe(true);
|
|
25
|
+
expect(location_1.default.isAnchor(" #test")).toBe(true);
|
|
26
|
+
expect(location_1.default.isAnchor("https://google.fr#test")).toBe(false);
|
|
27
|
+
expect(location_1.default.isAnchor("test.md#test")).toBe(false);
|
|
28
|
+
});
|
|
29
|
+
describe(".relative", () => {
|
|
30
|
+
test("should resolve to a relative path (same folder)", () => {
|
|
31
|
+
expect(location_1.default.relative("links/", "links/test.md")).toBe("test.md");
|
|
32
|
+
});
|
|
33
|
+
test("should resolve to a relative path (parent folder)", () => {
|
|
34
|
+
expect(location_1.default.relative("links/", "test.md")).toBe("../test.md");
|
|
35
|
+
});
|
|
36
|
+
test("should resolve to a relative path (child folder)", () => {
|
|
37
|
+
expect(location_1.default.relative("links/", "links/hello/test.md")).toBe("hello/test.md");
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
describe(".flatten", () => {
|
|
41
|
+
test("should remove leading slash", () => {
|
|
42
|
+
expect(location_1.default.flatten("/test.md")).toBe("test.md");
|
|
43
|
+
expect(location_1.default.flatten("/hello/cool.md")).toBe("hello/cool.md");
|
|
44
|
+
});
|
|
45
|
+
test("should remove leading slashes", () => {
|
|
46
|
+
expect(location_1.default.flatten("///test.md")).toBe("test.md");
|
|
47
|
+
});
|
|
48
|
+
test("should not break paths", () => {
|
|
49
|
+
expect(location_1.default.flatten("hello/cool.md")).toBe("hello/cool.md");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
describe(".toAbsolute", () => {
|
|
53
|
+
test("should correctly transform as absolute", () => {
|
|
54
|
+
// @ts-expect-error
|
|
55
|
+
expect(location_1.default.toAbsolute("http://google.fr")).toBe("http://google.fr");
|
|
56
|
+
expect(location_1.default.toAbsolute("test.md", "./", "./")).toBe("test.md");
|
|
57
|
+
expect(location_1.default.toAbsolute("folder/test.md", "./", "./")).toBe("folder/test.md");
|
|
58
|
+
});
|
|
59
|
+
test("should correctly handle windows path", () => {
|
|
60
|
+
expect(location_1.default.toAbsolute("folder\\test.md", "./", "./")).toBe("folder/test.md");
|
|
61
|
+
});
|
|
62
|
+
test("should correctly handle absolute path", () => {
|
|
63
|
+
expect(location_1.default.toAbsolute("/test.md", "./", "./")).toBe("test.md");
|
|
64
|
+
expect(location_1.default.toAbsolute("/test.md", "test", "test")).toBe("../test.md");
|
|
65
|
+
expect(location_1.default.toAbsolute("/sub/test.md", "test", "test")).toBe("../sub/test.md");
|
|
66
|
+
expect(location_1.default.toAbsolute("/test.png", "folder", "")).toBe("test.png");
|
|
67
|
+
});
|
|
68
|
+
test("should correctly handle absolute path (windows)", () => {
|
|
69
|
+
expect(location_1.default.toAbsolute("\\test.png", "folder", "")).toBe("test.png");
|
|
70
|
+
});
|
|
71
|
+
test("should resolve path starting by \"/\" in root directory", () => {
|
|
72
|
+
expect(location_1.default.toAbsolute("/test/hello.md", "./", "./")).toBe("test/hello.md");
|
|
73
|
+
});
|
|
74
|
+
test("should resolve path starting by \"/\" in child directory", () => {
|
|
75
|
+
expect(location_1.default.toAbsolute("/test/hello.md", "./hello", "./")).toBe("test/hello.md");
|
|
76
|
+
});
|
|
77
|
+
test("should resolve path starting by \"/\" in child directory, with same output directory", () => {
|
|
78
|
+
expect(location_1.default.toAbsolute("/test/hello.md", "./hello", "./hello")).toBe("../test/hello.md");
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../../src/utils/__tests__/path.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const path_1 = __importDefault(require("path"));
|
|
7
|
+
const path_2 = __importDefault(require("../path"));
|
|
8
|
+
describe("Paths", () => {
|
|
9
|
+
describe("setExtension", () => {
|
|
10
|
+
test("should correctly change extension of filename", () => {
|
|
11
|
+
expect(path_2.default.setExtension("test.md", ".html")).toBe("test.html");
|
|
12
|
+
expect(path_2.default.setExtension("test.md", ".json")).toBe("test.json");
|
|
13
|
+
});
|
|
14
|
+
test("should correctly change extension of path", () => {
|
|
15
|
+
expect(path_2.default.setExtension("hello/test.md", ".html")).toBe(path_1.default.normalize("hello/test.html"));
|
|
16
|
+
expect(path_2.default.setExtension("hello/test.md", ".json")).toBe(path_1.default.normalize("hello/test.json"));
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "honkit",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.5",
|
|
4
4
|
"description": "HonKit is building beautiful books using Markdown.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"git",
|
|
@@ -29,20 +29,7 @@
|
|
|
29
29
|
"lib",
|
|
30
30
|
"!__tests__"
|
|
31
31
|
],
|
|
32
|
-
"scripts": {
|
|
33
|
-
"prepublish": "npm run clean && npm run build",
|
|
34
|
-
"build": "tsc -p .",
|
|
35
|
-
"clean": "rimraf lib/",
|
|
36
|
-
"test": "jest src",
|
|
37
|
-
"updateSnapshot": "jest src -u"
|
|
38
|
-
},
|
|
39
32
|
"dependencies": {
|
|
40
|
-
"@honkit/asciidoc": "6.0.4",
|
|
41
|
-
"@honkit/honkit-plugin-fontsettings": "6.0.4",
|
|
42
|
-
"@honkit/honkit-plugin-highlight": "6.0.4",
|
|
43
|
-
"@honkit/honkit-plugin-theme-default": "6.0.4",
|
|
44
|
-
"@honkit/html": "6.0.4",
|
|
45
|
-
"@honkit/markdown-legacy": "6.0.4",
|
|
46
33
|
"bash-color": "^0.0.4",
|
|
47
34
|
"cheerio": "^1.0.0",
|
|
48
35
|
"chokidar": "^3.6.0",
|
|
@@ -86,10 +73,15 @@
|
|
|
86
73
|
"send": "^0.17.2",
|
|
87
74
|
"tiny-lr": "^1.1.1",
|
|
88
75
|
"tmp": "0.2.4",
|
|
89
|
-
"urijs": "^1.19.11"
|
|
76
|
+
"urijs": "^1.19.11",
|
|
77
|
+
"@honkit/asciidoc": "6.1.5",
|
|
78
|
+
"@honkit/honkit-plugin-fontsettings": "6.1.5",
|
|
79
|
+
"@honkit/honkit-plugin-highlight": "6.1.5",
|
|
80
|
+
"@honkit/honkit-plugin-theme-default": "6.1.5",
|
|
81
|
+
"@honkit/markdown-legacy": "6.1.5",
|
|
82
|
+
"@honkit/html": "6.1.5"
|
|
90
83
|
},
|
|
91
84
|
"devDependencies": {
|
|
92
|
-
"@honkit/internal-test-utils": "6.0.4",
|
|
93
85
|
"@relmify/jest-serializer-strip-ansi": "^1.0.2",
|
|
94
86
|
"@types/jest": "^29.5.13",
|
|
95
87
|
"@types/node": "^22.7.4",
|
|
@@ -97,7 +89,13 @@
|
|
|
97
89
|
"jest": "^29.7.0",
|
|
98
90
|
"jest-mock-process": "^2.0.0",
|
|
99
91
|
"rimraf": "^6.0.1",
|
|
100
|
-
"typescript": "^5.6.2"
|
|
92
|
+
"typescript": "^5.6.2",
|
|
93
|
+
"@honkit/internal-test-utils": "6.1.5"
|
|
101
94
|
},
|
|
102
|
-
"
|
|
103
|
-
|
|
95
|
+
"scripts": {
|
|
96
|
+
"build": "tsc -p .",
|
|
97
|
+
"clean": "rimraf lib/",
|
|
98
|
+
"test": "jest src",
|
|
99
|
+
"updateSnapshot": "jest src -u"
|
|
100
|
+
}
|
|
101
|
+
}
|