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.
Files changed (186) hide show
  1. package/lib/__tests__/__fixtures__/honkit/book.d.ts +7 -0
  2. package/lib/__tests__/__fixtures__/honkit/book.d.ts.map +1 -0
  3. package/lib/__tests__/__fixtures__/honkit/book.js +9 -0
  4. package/lib/__tests__/e2e.test.d.ts +2 -0
  5. package/lib/__tests__/e2e.test.d.ts.map +1 -0
  6. package/lib/__tests__/e2e.test.js +81 -0
  7. package/lib/__tests__/init.d.ts +2 -0
  8. package/lib/__tests__/init.d.ts.map +1 -0
  9. package/lib/__tests__/init.js +19 -0
  10. package/lib/__tests__/satisfies.d.ts +2 -0
  11. package/lib/__tests__/satisfies.d.ts.map +1 -0
  12. package/lib/__tests__/satisfies.js +11 -0
  13. package/lib/__tests__/snapshot-asciidoc.d.ts +2 -0
  14. package/lib/__tests__/snapshot-asciidoc.d.ts.map +1 -0
  15. package/lib/__tests__/snapshot-asciidoc.js +48 -0
  16. package/lib/__tests__/snapshot-honkit.d.ts +2 -0
  17. package/lib/__tests__/snapshot-honkit.d.ts.map +1 -0
  18. package/lib/__tests__/snapshot-honkit.js +48 -0
  19. package/lib/cli/__tests__/watch.test.d.ts +2 -0
  20. package/lib/cli/__tests__/watch.test.d.ts.map +1 -0
  21. package/lib/cli/__tests__/watch.test.js +194 -0
  22. package/lib/cli/serve.d.ts.map +1 -1
  23. package/lib/cli/serve.js +49 -43
  24. package/lib/cli/watch.d.ts +22 -6
  25. package/lib/cli/watch.d.ts.map +1 -1
  26. package/lib/cli/watch.js +24 -10
  27. package/lib/constants/__tests__/configSchema.d.ts +2 -0
  28. package/lib/constants/__tests__/configSchema.d.ts.map +1 -0
  29. package/lib/constants/__tests__/configSchema.js +41 -0
  30. package/lib/fs/__tests__/mock.d.ts +2 -0
  31. package/lib/fs/__tests__/mock.d.ts.map +1 -0
  32. package/lib/fs/__tests__/mock.js +68 -0
  33. package/lib/models/__tests__/config.d.ts +2 -0
  34. package/lib/models/__tests__/config.d.ts.map +1 -0
  35. package/lib/models/__tests__/config.js +164 -0
  36. package/lib/models/__tests__/glossary.d.ts +2 -0
  37. package/lib/models/__tests__/glossary.d.ts.map +1 -0
  38. package/lib/models/__tests__/glossary.js +38 -0
  39. package/lib/models/__tests__/glossaryEntry.d.ts +2 -0
  40. package/lib/models/__tests__/glossaryEntry.d.ts.map +1 -0
  41. package/lib/models/__tests__/glossaryEntry.js +16 -0
  42. package/lib/models/__tests__/page.d.ts +2 -0
  43. package/lib/models/__tests__/page.d.ts.map +1 -0
  44. package/lib/models/__tests__/page.js +26 -0
  45. package/lib/models/__tests__/plugin.d.ts +2 -0
  46. package/lib/models/__tests__/plugin.d.ts.map +1 -0
  47. package/lib/models/__tests__/plugin.js +50 -0
  48. package/lib/models/__tests__/pluginDependency.d.ts +2 -0
  49. package/lib/models/__tests__/pluginDependency.d.ts.map +1 -0
  50. package/lib/models/__tests__/pluginDependency.js +71 -0
  51. package/lib/models/__tests__/summary.d.ts +2 -0
  52. package/lib/models/__tests__/summary.d.ts.map +1 -0
  53. package/lib/models/__tests__/summary.js +115 -0
  54. package/lib/models/__tests__/summaryArticle.d.ts +2 -0
  55. package/lib/models/__tests__/summaryArticle.d.ts.map +1 -0
  56. package/lib/models/__tests__/summaryArticle.js +117 -0
  57. package/lib/models/__tests__/summaryPart.d.ts +2 -0
  58. package/lib/models/__tests__/summaryPart.d.ts.map +1 -0
  59. package/lib/models/__tests__/summaryPart.js +24 -0
  60. package/lib/models/__tests__/templateBlock.d.ts +2 -0
  61. package/lib/models/__tests__/templateBlock.d.ts.map +1 -0
  62. package/lib/models/__tests__/templateBlock.js +172 -0
  63. package/lib/models/__tests__/templateEngine.d.ts +2 -0
  64. package/lib/models/__tests__/templateEngine.d.ts.map +1 -0
  65. package/lib/models/__tests__/templateEngine.js +49 -0
  66. package/lib/modifiers/config/__tests__/addPlugin.d.ts +2 -0
  67. package/lib/modifiers/config/__tests__/addPlugin.d.ts.map +1 -0
  68. package/lib/modifiers/config/__tests__/addPlugin.js +30 -0
  69. package/lib/modifiers/config/__tests__/removePlugin.d.ts +2 -0
  70. package/lib/modifiers/config/__tests__/removePlugin.d.ts.map +1 -0
  71. package/lib/modifiers/config/__tests__/removePlugin.js +29 -0
  72. package/lib/modifiers/config/__tests__/togglePlugin.d.ts +2 -0
  73. package/lib/modifiers/config/__tests__/togglePlugin.d.ts.map +1 -0
  74. package/lib/modifiers/config/__tests__/togglePlugin.js +28 -0
  75. package/lib/modifiers/summary/__tests__/editPartTitle.d.ts +2 -0
  76. package/lib/modifiers/summary/__tests__/editPartTitle.d.ts.map +1 -0
  77. package/lib/modifiers/summary/__tests__/editPartTitle.js +41 -0
  78. package/lib/modifiers/summary/__tests__/insertArticle.d.ts +2 -0
  79. package/lib/modifiers/summary/__tests__/insertArticle.d.ts.map +1 -0
  80. package/lib/modifiers/summary/__tests__/insertArticle.js +72 -0
  81. package/lib/modifiers/summary/__tests__/insertPart.d.ts +2 -0
  82. package/lib/modifiers/summary/__tests__/insertPart.d.ts.map +1 -0
  83. package/lib/modifiers/summary/__tests__/insertPart.js +56 -0
  84. package/lib/modifiers/summary/__tests__/mergeAtLevel.d.ts +2 -0
  85. package/lib/modifiers/summary/__tests__/mergeAtLevel.d.ts.map +1 -0
  86. package/lib/modifiers/summary/__tests__/mergeAtLevel.js +45 -0
  87. package/lib/modifiers/summary/__tests__/moveArticle.d.ts +2 -0
  88. package/lib/modifiers/summary/__tests__/moveArticle.d.ts.map +1 -0
  89. package/lib/modifiers/summary/__tests__/moveArticle.js +66 -0
  90. package/lib/modifiers/summary/__tests__/moveArticleAfter.d.ts +2 -0
  91. package/lib/modifiers/summary/__tests__/moveArticleAfter.d.ts.map +1 -0
  92. package/lib/modifiers/summary/__tests__/moveArticleAfter.js +75 -0
  93. package/lib/modifiers/summary/__tests__/removeArticle.d.ts +2 -0
  94. package/lib/modifiers/summary/__tests__/removeArticle.d.ts.map +1 -0
  95. package/lib/modifiers/summary/__tests__/removeArticle.js +54 -0
  96. package/lib/output/__tests__/ebook.d.ts +2 -0
  97. package/lib/output/__tests__/ebook.d.ts.map +1 -0
  98. package/lib/output/__tests__/ebook.js +17 -0
  99. package/lib/output/__tests__/json.d.ts +2 -0
  100. package/lib/output/__tests__/json.d.ts.map +1 -0
  101. package/lib/output/__tests__/json.js +43 -0
  102. package/lib/output/__tests__/plugin-hooks.d.ts +2 -0
  103. package/lib/output/__tests__/plugin-hooks.d.ts.map +1 -0
  104. package/lib/output/__tests__/plugin-hooks.js +57 -0
  105. package/lib/output/__tests__/website.d.ts +2 -0
  106. package/lib/output/__tests__/website.d.ts.map +1 -0
  107. package/lib/output/__tests__/website.js +121 -0
  108. package/lib/output/modifiers/__tests__/addHeadingId.d.ts +2 -0
  109. package/lib/output/modifiers/__tests__/addHeadingId.d.ts.map +1 -0
  110. package/lib/output/modifiers/__tests__/addHeadingId.js +23 -0
  111. package/lib/output/modifiers/__tests__/annotateText.d.ts +2 -0
  112. package/lib/output/modifiers/__tests__/annotateText.d.ts.map +1 -0
  113. package/lib/output/modifiers/__tests__/annotateText.js +71 -0
  114. package/lib/output/modifiers/__tests__/fetchRemoteImages.d.ts +2 -0
  115. package/lib/output/modifiers/__tests__/fetchRemoteImages.d.ts.map +1 -0
  116. package/lib/output/modifiers/__tests__/fetchRemoteImages.js +69 -0
  117. package/lib/output/modifiers/__tests__/highlightCode.d.ts +2 -0
  118. package/lib/output/modifiers/__tests__/highlightCode.d.ts.map +1 -0
  119. package/lib/output/modifiers/__tests__/highlightCode.js +48 -0
  120. package/lib/output/modifiers/__tests__/inlinePng.d.ts +2 -0
  121. package/lib/output/modifiers/__tests__/inlinePng.d.ts.map +1 -0
  122. package/lib/output/modifiers/__tests__/inlinePng.js +22 -0
  123. package/lib/output/modifiers/__tests__/inlineSvg.d.ts +2 -0
  124. package/lib/output/modifiers/__tests__/inlineSvg.d.ts.map +1 -0
  125. package/lib/output/modifiers/__tests__/inlineSvg.js +42 -0
  126. package/lib/output/modifiers/__tests__/resolveImages.d.ts +2 -0
  127. package/lib/output/modifiers/__tests__/resolveImages.d.ts.map +1 -0
  128. package/lib/output/modifiers/__tests__/resolveImages.js +39 -0
  129. package/lib/output/modifiers/__tests__/resolveLinks.d.ts +2 -0
  130. package/lib/output/modifiers/__tests__/resolveLinks.d.ts.map +1 -0
  131. package/lib/output/modifiers/__tests__/resolveLinks.js +81 -0
  132. package/lib/output/modifiers/__tests__/svgToImg.d.ts +2 -0
  133. package/lib/output/modifiers/__tests__/svgToImg.d.ts.map +1 -0
  134. package/lib/output/modifiers/__tests__/svgToImg.js +29 -0
  135. package/lib/output/website/__tests__/i18n.d.ts +2 -0
  136. package/lib/output/website/__tests__/i18n.d.ts.map +1 -0
  137. package/lib/output/website/__tests__/i18n.js +40 -0
  138. package/lib/parse/__tests__/listAssets.d.ts +2 -0
  139. package/lib/parse/__tests__/listAssets.d.ts.map +1 -0
  140. package/lib/parse/__tests__/listAssets.js +63 -0
  141. package/lib/parse/__tests__/parseBook.d.ts +2 -0
  142. package/lib/parse/__tests__/parseBook.d.ts.map +1 -0
  143. package/lib/parse/__tests__/parseBook.js +77 -0
  144. package/lib/parse/__tests__/parseGlossary.d.ts +2 -0
  145. package/lib/parse/__tests__/parseGlossary.d.ts.map +1 -0
  146. package/lib/parse/__tests__/parseGlossary.js +32 -0
  147. package/lib/parse/__tests__/parseIgnore.d.ts +2 -0
  148. package/lib/parse/__tests__/parseIgnore.d.ts.map +1 -0
  149. package/lib/parse/__tests__/parseIgnore.js +37 -0
  150. package/lib/parse/__tests__/parsePageFromString.d.ts +2 -0
  151. package/lib/parse/__tests__/parsePageFromString.d.ts.map +1 -0
  152. package/lib/parse/__tests__/parsePageFromString.js +34 -0
  153. package/lib/parse/__tests__/parseReadme.d.ts +2 -0
  154. package/lib/parse/__tests__/parseReadme.d.ts.map +1 -0
  155. package/lib/parse/__tests__/parseReadme.js +33 -0
  156. package/lib/parse/__tests__/parseSummary.d.ts +2 -0
  157. package/lib/parse/__tests__/parseSummary.d.ts.map +1 -0
  158. package/lib/parse/__tests__/parseSummary.js +30 -0
  159. package/lib/plugins/__tests__/listDependencies.d.ts +2 -0
  160. package/lib/plugins/__tests__/listDependencies.d.ts.map +1 -0
  161. package/lib/plugins/__tests__/listDependencies.js +28 -0
  162. package/lib/plugins/__tests__/sortDependencies.d.ts +2 -0
  163. package/lib/plugins/__tests__/sortDependencies.d.ts.map +1 -0
  164. package/lib/plugins/__tests__/sortDependencies.js +28 -0
  165. package/lib/plugins/__tests__/validatePlugin.d.ts +2 -0
  166. package/lib/plugins/__tests__/validatePlugin.d.ts.map +1 -0
  167. package/lib/plugins/__tests__/validatePlugin.js +99 -0
  168. package/lib/templating/__tests__/conrefsLoader.d.ts +2 -0
  169. package/lib/templating/__tests__/conrefsLoader.d.ts.map +1 -0
  170. package/lib/templating/__tests__/conrefsLoader.js +90 -0
  171. package/lib/templating/__tests__/postRender.d.ts +2 -0
  172. package/lib/templating/__tests__/postRender.d.ts.map +1 -0
  173. package/lib/templating/__tests__/postRender.js +52 -0
  174. package/lib/templating/__tests__/replaceShortcuts.d.ts +2 -0
  175. package/lib/templating/__tests__/replaceShortcuts.d.ts.map +1 -0
  176. package/lib/templating/__tests__/replaceShortcuts.js +27 -0
  177. package/lib/utils/__tests__/git.d.ts +2 -0
  178. package/lib/utils/__tests__/git.d.ts.map +1 -0
  179. package/lib/utils/__tests__/git.js +46 -0
  180. package/lib/utils/__tests__/location.d.ts +2 -0
  181. package/lib/utils/__tests__/location.d.ts.map +1 -0
  182. package/lib/utils/__tests__/location.js +81 -0
  183. package/lib/utils/__tests__/path.d.ts +2 -0
  184. package/lib/utils/__tests__/path.d.ts.map +1 -0
  185. package/lib/utils/__tests__/path.js +19 -0
  186. package/package.json +17 -19
@@ -0,0 +1,121 @@
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 fs_1 = __importDefault(require("fs"));
7
+ const generateMock_1 = __importDefault(require("../testing/generateMock"));
8
+ const website_1 = __importDefault(require("../website"));
9
+ const longTest = (name, fn) => test(name, fn, 1000 * 30);
10
+ describe("WebsiteGenerator", () => {
11
+ test("should generate an index.html", async () => {
12
+ const folder = await (0, generateMock_1.default)(website_1.default, {
13
+ "README.md": "Hello World"
14
+ });
15
+ expect(folder).toHaveFile("index.html");
16
+ }, 60 * 1000);
17
+ describe("Glossary", () => {
18
+ let folder;
19
+ beforeAll(() => {
20
+ return (0, generateMock_1.default)(website_1.default, {
21
+ "README.md": "Hello World",
22
+ "SUMMARY.md": "* [Deep](folder/page.md)",
23
+ folder: {
24
+ "page.md": "Hello World"
25
+ },
26
+ "GLOSSARY.md": "# Glossary\n\n## Hello\n\nHello World"
27
+ }).then((_folder) => {
28
+ folder = _folder;
29
+ });
30
+ });
31
+ longTest("should generate a GLOSSARY.html", () => {
32
+ expect(folder).toHaveFile("GLOSSARY.html");
33
+ });
34
+ longTest("should correctly resolve glossary links in README", () => {
35
+ const html = fs_1.default.readFileSync(`${folder}/index.html`, "utf8");
36
+ expect(html).toHaveDOMElement(".page-inner a[href=\"GLOSSARY.html#hello\"]");
37
+ });
38
+ longTest("should correctly resolve glossary links in directory", () => {
39
+ const html = fs_1.default.readFileSync(`${folder}/folder/page.html`, "utf8");
40
+ expect(html).toHaveDOMElement(".page-inner a[href=\"../GLOSSARY.html#hello\"]");
41
+ });
42
+ longTest("should accept a custom glossary file", () => {
43
+ return (0, generateMock_1.default)(website_1.default, {
44
+ "README.md": "Hello World",
45
+ "book.json": "{ \"structure\": { \"glossary\": \"custom.md\" } }",
46
+ "custom.md": "# Glossary\n\n## Hello\n\nHello World"
47
+ }).then((folder) => {
48
+ expect(folder).toHaveFile("custom.html");
49
+ expect(folder).not.toHaveFile("GLOSSARY.html");
50
+ const html = fs_1.default.readFileSync(`${folder}/index.html`, "utf8");
51
+ expect(html).toHaveDOMElement(".page-inner a[href=\"custom.html#hello\"]");
52
+ });
53
+ });
54
+ });
55
+ test.skip("should copy asset files", () => {
56
+ return (0, generateMock_1.default)(website_1.default, {
57
+ "README.md": "Hello World",
58
+ "myJsFile.js": "var a = \"test\";",
59
+ folder: {
60
+ "AnotherAssetFile.md": "# Even md"
61
+ }
62
+ }).then((folder) => {
63
+ expect(folder).toHaveFile("index.html");
64
+ expect(folder).toHaveFile("myJsFile.js");
65
+ expect(folder).toHaveFile("folder/AnotherAssetFile.md");
66
+ });
67
+ });
68
+ test.skip("should generate an index.html for AsciiDoc", async () => {
69
+ const folder = await (0, generateMock_1.default)(website_1.default, {
70
+ "README.adoc": "Hello World"
71
+ });
72
+ expect(folder).toHaveFile("index.html");
73
+ });
74
+ longTest("should generate an HTML file for each articles", () => {
75
+ return (0, generateMock_1.default)(website_1.default, {
76
+ "README.md": "Hello World",
77
+ "SUMMARY.md": "# Summary\n\n* [Page](test/page.md)",
78
+ test: {
79
+ "page.md": "Hello 2"
80
+ }
81
+ }).then((folder) => {
82
+ expect(folder).toHaveFile("index.html");
83
+ expect(folder).toHaveFile("test/page.html");
84
+ });
85
+ });
86
+ longTest("should not generate file if entry file doesn't exist", () => {
87
+ return (0, generateMock_1.default)(website_1.default, {
88
+ "README.md": "Hello World",
89
+ "SUMMARY.md": "# Summary\n\n* [Page 1](page.md)\n* [Page 2](test/page.md)",
90
+ test: {
91
+ "page.md": "Hello 2"
92
+ }
93
+ }).then((folder) => {
94
+ expect(folder).toHaveFile("index.html");
95
+ expect(folder).not.toHaveFile("page.html");
96
+ expect(folder).toHaveFile("test/page.html");
97
+ });
98
+ });
99
+ longTest("should generate a multilingual book", () => {
100
+ return (0, generateMock_1.default)(website_1.default, {
101
+ "LANGS.md": "# Languages\n\n* [en](en)\n* [fr](fr)",
102
+ en: {
103
+ "README.md": "Hello"
104
+ },
105
+ fr: {
106
+ "README.md": "Bonjour"
107
+ }
108
+ }).then((folder) => {
109
+ // It should generate languages
110
+ expect(folder).toHaveFile("en/index.html");
111
+ expect(folder).toHaveFile("fr/index.html");
112
+ // Should not copy languages as assets
113
+ expect(folder).not.toHaveFile("en/README.md");
114
+ expect(folder).not.toHaveFile("fr/README.md");
115
+ // Should copy assets only once
116
+ expect(folder).toHaveFile("gitbook/style.css");
117
+ expect(folder).not.toHaveFile("en/gitbook/style.css");
118
+ expect(folder).toHaveFile("index.html");
119
+ });
120
+ });
121
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=addHeadingId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addHeadingId.d.ts","sourceRoot":"","sources":["../../../../src/output/modifiers/__tests__/addHeadingId.ts"],"names":[],"mappings":""}
@@ -0,0 +1,23 @@
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 html_1 = require("@honkit/html");
7
+ const addHeadingId_1 = __importDefault(require("../addHeadingId"));
8
+ describe("addHeadingId", () => {
9
+ test("should add an ID if none", () => {
10
+ const $ = (0, html_1.loadHtml)("<h1>Hello World</h1><h2>Cool !!</h2>");
11
+ return (0, addHeadingId_1.default)($).then(() => {
12
+ const html = $.html();
13
+ expect(html).toBe("<h1 id=\"hello-world\">Hello World</h1><h2 id=\"cool-\">Cool !!</h2>");
14
+ });
15
+ });
16
+ test("should not change existing IDs", () => {
17
+ const $ = (0, html_1.loadHtml)("<h1 id=\"awesome\">Hello World</h1>");
18
+ return (0, addHeadingId_1.default)($).then(() => {
19
+ const html = $.html();
20
+ expect(html).toBe("<h1 id=\"awesome\">Hello World</h1>");
21
+ });
22
+ });
23
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=annotateText.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotateText.d.ts","sourceRoot":"","sources":["../../../../src/output/modifiers/__tests__/annotateText.ts"],"names":[],"mappings":""}
@@ -0,0 +1,71 @@
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 html_1 = require("@honkit/html");
8
+ const glossaryEntry_1 = __importDefault(require("../../../models/glossaryEntry"));
9
+ const annotateText_1 = __importDefault(require("../annotateText"));
10
+ describe("annotateText", () => {
11
+ const entries = immutable_1.default.List([
12
+ new glossaryEntry_1.default({ name: "Word" }),
13
+ new glossaryEntry_1.default({ name: "Multiple Words" }),
14
+ new glossaryEntry_1.default({ name: ".MD files" }),
15
+ new glossaryEntry_1.default({ name: "Brancaleone von Andalò" }),
16
+ new glossaryEntry_1.default({ name: "Henry (VII)" }),
17
+ ]);
18
+ test("should annotate text", () => {
19
+ const $ = (0, html_1.loadHtml)("<p>This is a word, and multiple words</p>");
20
+ (0, annotateText_1.default)(entries, "GLOSSARY.md", $);
21
+ const links = $("a");
22
+ expect(links.length).toBe(2);
23
+ const word = $(links.get(0));
24
+ expect(word.attr("href")).toBe("/GLOSSARY.md#word");
25
+ expect(word.text()).toBe("word");
26
+ expect(word.hasClass("glossary-term")).toBeTruthy();
27
+ const words = $(links.get(1));
28
+ expect(words.attr("href")).toBe("/GLOSSARY.md#multiple-words");
29
+ expect(words.text()).toBe("multiple words");
30
+ expect(words.hasClass("glossary-term")).toBeTruthy();
31
+ });
32
+ test("should annotate text with regardless of glossary order", () => {
33
+ const $ = (0, html_1.loadHtml)("<p>This is multiple words, and another word.</p>");
34
+ (0, annotateText_1.default)(entries, "GLOSSARY.md", $);
35
+ const links = $("a");
36
+ expect(links.length).toBe(2);
37
+ const word = $(links.get(0));
38
+ expect(word.attr("href")).toBe("/GLOSSARY.md#multiple-words");
39
+ expect(word.text()).toBe("multiple words");
40
+ expect(word.hasClass("glossary-term")).toBeTruthy();
41
+ const words = $(links.get(1));
42
+ expect(words.attr("href")).toBe("/GLOSSARY.md#word");
43
+ expect(words.text()).toBe("word");
44
+ expect(words.hasClass("glossary-term")).toBeTruthy();
45
+ });
46
+ test("should not annotate scripts", () => {
47
+ const $ = (0, html_1.loadHtml)("<script>This is a word, and multiple words</script>");
48
+ (0, annotateText_1.default)(entries, "GLOSSARY.md", $);
49
+ expect($("a").length).toBe(0);
50
+ });
51
+ test('should not annotate when has class "no-glossary"', () => {
52
+ const $ = (0, html_1.loadHtml)('<p class="no-glossary">This is a word, and multiple words</p>');
53
+ (0, annotateText_1.default)(entries, "GLOSSARY.md", $);
54
+ expect($("a").length).toBe(0);
55
+ });
56
+ test('should annotate terms with starting dots', () => {
57
+ const $ = (0, html_1.loadHtml)('<p>I write in .MD files when documenting.</p>');
58
+ (0, annotateText_1.default)(entries, "GLOSSARY.md", $);
59
+ expect($("a").length).toBe(1);
60
+ });
61
+ test('should annotate terms with starting non-English chars', () => {
62
+ const $ = (0, html_1.loadHtml)('<p>Der Papst gehört nicht nach Anagni oder Lyon, nicht nach Perugia oder Assisi, sondern nach Rom.« Ein kraftvoller Mann gab den Römern diese Sprache ein, Brancaleone von Andalò, ihr damaliger Senator.</p>');
63
+ (0, annotateText_1.default)(entries, "GLOSSARY.md", $);
64
+ expect($("a").length).toBe(1);
65
+ });
66
+ test('should annotate terms with parens at start or end', () => {
67
+ const $ = (0, html_1.loadHtml)('<p>Tell me everything you know about Henry (VII) and his reign.</p>');
68
+ (0, annotateText_1.default)(entries, "GLOSSARY.md", $);
69
+ expect($("a").length).toBe(1);
70
+ });
71
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=fetchRemoteImages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetchRemoteImages.d.ts","sourceRoot":"","sources":["../../../../src/output/modifiers/__tests__/fetchRemoteImages.ts"],"names":[],"mappings":""}
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ const html_1 = require("@honkit/html");
30
+ const tmp_1 = __importDefault(require("tmp"));
31
+ const path_1 = __importDefault(require("path"));
32
+ const fetchRemoteImages_1 = __importDefault(require("../fetchRemoteImages"));
33
+ const promises_1 = __importDefault(require("fs/promises"));
34
+ const assert_1 = __importDefault(require("assert"));
35
+ const constants = __importStar(require("constants"));
36
+ const URL = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/47/PNG_transparency_demonstration_1.png/280px-PNG_transparency_demonstration_1.png";
37
+ // download image from remote server is flaky
38
+ jest.retryTimes(3);
39
+ describe("fetchRemoteImages", () => {
40
+ let dir;
41
+ beforeEach(() => {
42
+ dir = tmp_1.default.dirSync();
43
+ return promises_1.default.rm(dir.name, { recursive: true, force: true });
44
+ });
45
+ afterEach(() => {
46
+ // remove tmp `dir`
47
+ return promises_1.default.rm(dir.name, { recursive: true, force: true });
48
+ });
49
+ it("should download image file", async () => {
50
+ const $ = (0, html_1.loadHtml)(`<img src="${URL}" />`);
51
+ await (0, fetchRemoteImages_1.default)(dir.name, "index.html", $);
52
+ const $img = $("img");
53
+ const src = $img.attr("src");
54
+ const expected = path_1.default.join(dir.name, src);
55
+ await assert_1.default.doesNotReject(() => {
56
+ return promises_1.default.access(expected, constants.F_OK);
57
+ });
58
+ }, 15 * 1000);
59
+ it("should download image file and replace with relative path", async () => {
60
+ const $ = (0, html_1.loadHtml)(`<img src="${URL}" />`);
61
+ await (0, fetchRemoteImages_1.default)(dir.name, "test/index.html", $);
62
+ const $img = $("img");
63
+ const src = $img.attr("src");
64
+ const expected = path_1.default.join(dir.name, "test/" + src);
65
+ await assert_1.default.doesNotReject(() => {
66
+ return promises_1.default.access(expected, constants.F_OK);
67
+ });
68
+ }, 15 * 1000);
69
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=highlightCode.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"highlightCode.d.ts","sourceRoot":"","sources":["../../../../src/output/modifiers/__tests__/highlightCode.ts"],"names":[],"mappings":""}
@@ -0,0 +1,48 @@
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 html_1 = require("@honkit/html");
7
+ const promise_1 = __importDefault(require("../../../utils/promise"));
8
+ const highlightCode_1 = __importDefault(require("../highlightCode"));
9
+ describe("highlightCode", () => {
10
+ function doHighlight(lang, code) {
11
+ return {
12
+ text: `${lang || ""}$${code}`
13
+ };
14
+ }
15
+ function doHighlightAsync(lang, code) {
16
+ return (0, promise_1.default)().then(() => {
17
+ return doHighlight(lang, code);
18
+ });
19
+ }
20
+ test("should call it for normal code element", () => {
21
+ const $ = (0, html_1.loadHtml)("<p>This is a <code>test</code></p>");
22
+ return (0, highlightCode_1.default)(doHighlight, $).then(() => {
23
+ const $code = $("code");
24
+ expect($code.text()).toBe("$test");
25
+ });
26
+ });
27
+ test("should call it for markdown code block", () => {
28
+ const $ = (0, html_1.loadHtml)("<pre><code class=\"lang-js\">test</code></pre>");
29
+ return (0, highlightCode_1.default)(doHighlight, $).then(() => {
30
+ const $code = $("code");
31
+ expect($code.text()).toBe("js$test");
32
+ });
33
+ });
34
+ test("should call it for asciidoc code block", () => {
35
+ const $ = (0, html_1.loadHtml)("<pre><code class=\"language-python\">test</code></pre>");
36
+ return (0, highlightCode_1.default)(doHighlight, $).then(() => {
37
+ const $code = $("code");
38
+ expect($code.text()).toBe("python$test");
39
+ });
40
+ });
41
+ test("should accept async highlighter", () => {
42
+ const $ = (0, html_1.loadHtml)("<pre><code class=\"language-python\">test</code></pre>");
43
+ return (0, highlightCode_1.default)(doHighlightAsync, $).then(() => {
44
+ const $code = $("code");
45
+ expect($code.text()).toBe("python$test");
46
+ });
47
+ });
48
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inlinePng.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inlinePng.d.ts","sourceRoot":"","sources":["../../../../src/output/modifiers/__tests__/inlinePng.ts"],"names":[],"mappings":""}
@@ -0,0 +1,22 @@
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 html_1 = require("@honkit/html");
7
+ const tmp_1 = __importDefault(require("tmp"));
8
+ const inlinePng_1 = __importDefault(require("../inlinePng"));
9
+ describe("inlinePng", () => {
10
+ let dir;
11
+ beforeEach(() => {
12
+ dir = tmp_1.default.dirSync();
13
+ });
14
+ test("should write an inline PNG using data URI as a file", () => {
15
+ const $ = (0, html_1.loadHtml)("<img alt=\"HonKit Logo 20x20\" src=\"data:image/png;base64,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\"/>");
16
+ return (0, inlinePng_1.default)(dir.name, "index.html", $).then(() => {
17
+ const $img = $("img");
18
+ const src = $img.attr("src");
19
+ expect(dir.name).toHaveFile(src);
20
+ });
21
+ });
22
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inlineSvg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inlineSvg.d.ts","sourceRoot":"","sources":["../../../../src/output/modifiers/__tests__/inlineSvg.ts"],"names":[],"mappings":""}
@@ -0,0 +1,42 @@
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 html_1 = require("@honkit/html");
7
+ const tmp_1 = __importDefault(require("tmp"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const fs_1 = __importDefault(require("fs"));
10
+ const inlineSvg_1 = __importDefault(require("../inlineSvg"));
11
+ describe("inlineSvg", () => {
12
+ let dir;
13
+ let svgPath;
14
+ beforeEach(() => {
15
+ dir = tmp_1.default.dirSync();
16
+ svgPath = path_1.default.join(dir.name, "test.svg");
17
+ });
18
+ test("should inline svg icons", () => {
19
+ const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.1"><rect width="200" height="100" stroke-width="6"/></svg>';
20
+ const $ = (0, html_1.loadHtml)('<img src="test.svg"/>');
21
+ return fs_1.default.promises
22
+ .writeFile(svgPath, svg)
23
+ .then(() => {
24
+ return (0, inlineSvg_1.default)(dir.name, "index.html", $);
25
+ })
26
+ .then(() => {
27
+ expect($("svg").attr("fill")).toBe("currentColor");
28
+ });
29
+ });
30
+ test("should not inline svgs with style tags", () => {
31
+ const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.1" style="background-color:red"><rect width="200" height="100" stroke="black" stroke-width="6" fill="green"/></svg>';
32
+ const $ = (0, html_1.loadHtml)('<img src="test.svg"/>');
33
+ return fs_1.default.promises
34
+ .writeFile(svgPath, svg)
35
+ .then(() => {
36
+ return (0, inlineSvg_1.default)(dir.name, "index.html", $);
37
+ })
38
+ .then(() => {
39
+ expect($("svg").length).toBe(0);
40
+ });
41
+ });
42
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=resolveImages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveImages.d.ts","sourceRoot":"","sources":["../../../../src/output/modifiers/__tests__/resolveImages.ts"],"names":[],"mappings":""}
@@ -0,0 +1,39 @@
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 html_1 = require("@honkit/html");
7
+ const resolveImages_1 = __importDefault(require("../resolveImages"));
8
+ describe("resolveImages", () => {
9
+ describe("img tag", () => {
10
+ const TEST = "<img src=\"http://www.github.com\">";
11
+ test("no error occurs and return undefined", () => {
12
+ const $ = (0, html_1.loadHtml)(TEST);
13
+ return (0, resolveImages_1.default)("hello.md", $).then(() => {
14
+ const src = $("img").attr("src");
15
+ expect(src).toBe("http://www.github.com");
16
+ });
17
+ });
18
+ });
19
+ describe("img tag with break line", () => {
20
+ const TEST = "<img \nsrc=\"http://www.github.com\">";
21
+ test("no error occurs and return undefined", () => {
22
+ const $ = (0, html_1.loadHtml)(TEST);
23
+ return (0, resolveImages_1.default)("hello.md", $).then(() => {
24
+ const src = $("img").attr("src");
25
+ expect(src).toBe("http://www.github.com");
26
+ });
27
+ });
28
+ });
29
+ describe("img tag with src with plus sign", () => {
30
+ const TEST = "<img +src=\"http://www.github.com\">";
31
+ test("no error occurs and return undefined", () => {
32
+ const $ = (0, html_1.loadHtml)(TEST);
33
+ return (0, resolveImages_1.default)("hello.md", $).then(() => {
34
+ const src = $("img").attr("src");
35
+ expect(src).toBe(undefined);
36
+ });
37
+ });
38
+ });
39
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=resolveLinks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolveLinks.d.ts","sourceRoot":"","sources":["../../../../src/output/modifiers/__tests__/resolveLinks.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 path_1 = __importDefault(require("path"));
7
+ const html_1 = require("@honkit/html");
8
+ const resolveLinks_1 = __importDefault(require("../resolveLinks"));
9
+ describe("resolveLinks", () => {
10
+ function resolveFileBasic(href) {
11
+ return `fakeDir/${href}`;
12
+ }
13
+ function resolveFileCustom(href) {
14
+ if (path_1.default.extname(href) == ".md") {
15
+ return `${href.slice(0, -3)}.html`;
16
+ }
17
+ return href;
18
+ }
19
+ describe("Absolute path", () => {
20
+ const TEST = "<p>This is a <a href=\"/test/cool.md\"></a></p>";
21
+ test("should resolve path starting by \"/\" in root directory", () => {
22
+ const $ = (0, html_1.loadHtml)(TEST);
23
+ return (0, resolveLinks_1.default)("hello.md", resolveFileBasic, $).then(() => {
24
+ const link = $("a");
25
+ expect(link.attr("href")).toBe("fakeDir/test/cool.md");
26
+ });
27
+ });
28
+ test("should resolve path starting by \"/\" in child directory", () => {
29
+ const $ = (0, html_1.loadHtml)(TEST);
30
+ return (0, resolveLinks_1.default)("afolder/hello.md", resolveFileBasic, $).then(() => {
31
+ const link = $("a");
32
+ expect(link.attr("href")).toBe("../fakeDir/test/cool.md");
33
+ });
34
+ });
35
+ });
36
+ describe("Anchor", () => {
37
+ test("should prevent anchors in resolution", () => {
38
+ const TEST = "<p>This is a <a href=\"test/cool.md#an-anchor\"></a></p>";
39
+ const $ = (0, html_1.loadHtml)(TEST);
40
+ return (0, resolveLinks_1.default)("hello.md", resolveFileCustom, $).then(() => {
41
+ const link = $("a");
42
+ expect(link.attr("href")).toBe("test/cool.html#an-anchor");
43
+ });
44
+ });
45
+ test("should ignore pure anchor links", () => {
46
+ const TEST = "<p>This is a <a href=\"#an-anchor\"></a></p>";
47
+ const $ = (0, html_1.loadHtml)(TEST);
48
+ return (0, resolveLinks_1.default)("hello.md", resolveFileCustom, $).then(() => {
49
+ const link = $("a");
50
+ expect(link.attr("href")).toBe("#an-anchor");
51
+ });
52
+ });
53
+ });
54
+ describe("Custom Resolver", () => {
55
+ const TEST = "<p>This is a <a href=\"/test/cool.md\"></a> <a href=\"afile.png\"></a></p>";
56
+ test("should resolve path correctly for absolute path", () => {
57
+ const $ = (0, html_1.loadHtml)(TEST);
58
+ return (0, resolveLinks_1.default)("hello.md", resolveFileCustom, $).then(() => {
59
+ const link = $("a").first();
60
+ expect(link.attr("href")).toBe("test/cool.html");
61
+ });
62
+ });
63
+ test("should resolve path correctly for absolute path (2)", () => {
64
+ const $ = (0, html_1.loadHtml)(TEST);
65
+ return (0, resolveLinks_1.default)("afodler/hello.md", resolveFileCustom, $).then(() => {
66
+ const link = $("a").first();
67
+ expect(link.attr("href")).toBe("../test/cool.html");
68
+ });
69
+ });
70
+ });
71
+ describe("External link", () => {
72
+ const TEST = "<p>This is a <a href=\"http://www.github.com\">external link</a></p>";
73
+ test("should have target=\"_blank\" attribute", () => {
74
+ const $ = (0, html_1.loadHtml)(TEST);
75
+ return (0, resolveLinks_1.default)("hello.md", resolveFileBasic, $).then(() => {
76
+ const link = $("a");
77
+ expect(link.attr("target")).toBe("_blank");
78
+ });
79
+ });
80
+ });
81
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=svgToImg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"svgToImg.d.ts","sourceRoot":"","sources":["../../../../src/output/modifiers/__tests__/svgToImg.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
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 html_1 = require("@honkit/html");
7
+ const tmp_1 = __importDefault(require("tmp"));
8
+ const svgToImg_1 = __importDefault(require("../svgToImg"));
9
+ describe("svgToImg", () => {
10
+ let dir;
11
+ beforeEach(() => {
12
+ dir = tmp_1.default.dirSync();
13
+ });
14
+ test("should write svg as a file", () => {
15
+ const $ = (0, html_1.loadHtml)('<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.1"><rect width="200" height="100" stroke="black" stroke-width="6" fill="green"/></svg>');
16
+ return (0, svgToImg_1.default)(dir.name, "index.html", $).then(() => {
17
+ const $img = $("img");
18
+ const src = $img.attr("src");
19
+ expect(dir.name).toHaveFile(src);
20
+ });
21
+ });
22
+ it("should not write icon svg as a file", () => {
23
+ const $ = (0, html_1.loadHtml)('<svg xmlns="http://www.w3.org/2000/svg" width="200" height="100" version="1.1" fill="currentColor"><rect width="200" height="100" stroke-width="6"/></svg>');
24
+ return (0, svgToImg_1.default)(dir.name, "index.html", $).then(() => {
25
+ // @ts-expect-error
26
+ expect($.contains("img")).toBe(false);
27
+ });
28
+ });
29
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../../../../src/output/website/__tests__/i18n.ts"],"names":[],"mappings":""}