honkit 3.6.21

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 (278) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +10 -0
  3. package/bin/honkit.js +8 -0
  4. package/lib/BuildGenerator.js +2 -0
  5. package/lib/__tests__/__fixtures__/honkit/book.js +9 -0
  6. package/lib/__tests__/githon.js +11 -0
  7. package/lib/__tests__/init.js +19 -0
  8. package/lib/__tests__/snapshot-honkit.js +45 -0
  9. package/lib/api/decodeConfig.js +17 -0
  10. package/lib/api/decodeGlobal.js +21 -0
  11. package/lib/api/decodePage.js +41 -0
  12. package/lib/api/deprecate.js +113 -0
  13. package/lib/api/encodeConfig.js +30 -0
  14. package/lib/api/encodeGlobal.js +226 -0
  15. package/lib/api/encodeNavigation.js +60 -0
  16. package/lib/api/encodePage.js +37 -0
  17. package/lib/api/encodeProgress.js +58 -0
  18. package/lib/api/encodeSummary.js +52 -0
  19. package/lib/api/index.js +15 -0
  20. package/lib/bin.js +46 -0
  21. package/lib/browser.js +41 -0
  22. package/lib/cli/build.js +36 -0
  23. package/lib/cli/buildEbook.js +63 -0
  24. package/lib/cli/getBook.js +24 -0
  25. package/lib/cli/getOutputFolder.js +19 -0
  26. package/lib/cli/index.js +11 -0
  27. package/lib/cli/init.js +17 -0
  28. package/lib/cli/options.js +38 -0
  29. package/lib/cli/parse.js +65 -0
  30. package/lib/cli/serve.js +184 -0
  31. package/lib/cli/server.js +116 -0
  32. package/lib/cli/watch.js +35 -0
  33. package/lib/constants/__tests__/configSchema.js +41 -0
  34. package/lib/constants/configDefault.js +9 -0
  35. package/lib/constants/configFiles.js +3 -0
  36. package/lib/constants/configSchema.js +235 -0
  37. package/lib/constants/defaultBlocks.js +48 -0
  38. package/lib/constants/defaultFilters.js +18 -0
  39. package/lib/constants/defaultPlugins.js +20 -0
  40. package/lib/constants/extsAsciidoc.js +3 -0
  41. package/lib/constants/extsMarkdown.js +3 -0
  42. package/lib/constants/ignoreFiles.js +3 -0
  43. package/lib/constants/pluginAssetsFolder.js +3 -0
  44. package/lib/constants/pluginHooks.js +3 -0
  45. package/lib/constants/pluginPrefix.js +3 -0
  46. package/lib/constants/pluginResources.js +7 -0
  47. package/lib/constants/templatesFolder.js +3 -0
  48. package/lib/constants/themePrefix.js +3 -0
  49. package/lib/fs/__tests__/mock.js +68 -0
  50. package/lib/fs/mock.js +88 -0
  51. package/lib/fs/node.js +44 -0
  52. package/lib/honkit.js +34 -0
  53. package/lib/index.js +17 -0
  54. package/lib/init.js +79 -0
  55. package/lib/json/encodeBook.js +41 -0
  56. package/lib/json/encodeBookWithPage.js +25 -0
  57. package/lib/json/encodeFile.js +20 -0
  58. package/lib/json/encodeGlossary.js +22 -0
  59. package/lib/json/encodeGlossaryEntry.js +16 -0
  60. package/lib/json/encodeLanguages.js +29 -0
  61. package/lib/json/encodeOutput.js +26 -0
  62. package/lib/json/encodeOutputWithPage.js +26 -0
  63. package/lib/json/encodePage.js +38 -0
  64. package/lib/json/encodeReadme.js +19 -0
  65. package/lib/json/encodeSummary.js +22 -0
  66. package/lib/json/encodeSummaryArticle.js +25 -0
  67. package/lib/json/encodeSummaryPart.js +19 -0
  68. package/lib/json/index.js +27 -0
  69. package/lib/models/__tests__/config.js +164 -0
  70. package/lib/models/__tests__/glossary.js +38 -0
  71. package/lib/models/__tests__/glossaryEntry.js +16 -0
  72. package/lib/models/__tests__/page.js +26 -0
  73. package/lib/models/__tests__/plugin.js +26 -0
  74. package/lib/models/__tests__/pluginDependency.js +71 -0
  75. package/lib/models/__tests__/summary.js +115 -0
  76. package/lib/models/__tests__/summaryArticle.js +62 -0
  77. package/lib/models/__tests__/summaryPart.js +24 -0
  78. package/lib/models/__tests__/templateBlock.js +172 -0
  79. package/lib/models/__tests__/templateEngine.js +49 -0
  80. package/lib/models/book.js +312 -0
  81. package/lib/models/config.js +152 -0
  82. package/lib/models/file.js +83 -0
  83. package/lib/models/fs.js +255 -0
  84. package/lib/models/glossary.js +90 -0
  85. package/lib/models/glossaryEntry.js +34 -0
  86. package/lib/models/hash.js +191 -0
  87. package/lib/models/ignore.js +40 -0
  88. package/lib/models/language.js +22 -0
  89. package/lib/models/languages.js +64 -0
  90. package/lib/models/output.js +109 -0
  91. package/lib/models/page.js +91 -0
  92. package/lib/models/parser.js +102 -0
  93. package/lib/models/plugin.js +139 -0
  94. package/lib/models/pluginDependency.js +192 -0
  95. package/lib/models/readme.js +38 -0
  96. package/lib/models/summary.js +199 -0
  97. package/lib/models/summaryArticle.js +169 -0
  98. package/lib/models/summaryPart.js +53 -0
  99. package/lib/models/templateBlock.js +230 -0
  100. package/lib/models/templateEngine.js +115 -0
  101. package/lib/models/templateOutput.js +36 -0
  102. package/lib/models/templateShortcut.js +65 -0
  103. package/lib/modifiers/config/__tests__/addPlugin.js +30 -0
  104. package/lib/modifiers/config/__tests__/removePlugin.js +29 -0
  105. package/lib/modifiers/config/__tests__/togglePlugin.js +28 -0
  106. package/lib/modifiers/config/addPlugin.js +27 -0
  107. package/lib/modifiers/config/editPlugin.js +13 -0
  108. package/lib/modifiers/config/getPluginConfig.js +22 -0
  109. package/lib/modifiers/config/hasPlugin.js +15 -0
  110. package/lib/modifiers/config/index.js +21 -0
  111. package/lib/modifiers/config/isDefaultPlugin.js +17 -0
  112. package/lib/modifiers/config/removePlugin.js +27 -0
  113. package/lib/modifiers/config/togglePlugin.js +32 -0
  114. package/lib/modifiers/index.js +11 -0
  115. package/lib/modifiers/summary/__tests__/editPartTitle.js +41 -0
  116. package/lib/modifiers/summary/__tests__/insertArticle.js +72 -0
  117. package/lib/modifiers/summary/__tests__/insertPart.js +56 -0
  118. package/lib/modifiers/summary/__tests__/mergeAtLevel.js +45 -0
  119. package/lib/modifiers/summary/__tests__/moveArticle.js +66 -0
  120. package/lib/modifiers/summary/__tests__/moveArticleAfter.js +75 -0
  121. package/lib/modifiers/summary/__tests__/removeArticle.js +54 -0
  122. package/lib/modifiers/summary/editArticleRef.js +20 -0
  123. package/lib/modifiers/summary/editArticleTitle.js +20 -0
  124. package/lib/modifiers/summary/editPartTitle.js +21 -0
  125. package/lib/modifiers/summary/index.js +27 -0
  126. package/lib/modifiers/summary/indexArticleLevels.js +21 -0
  127. package/lib/modifiers/summary/indexLevels.js +18 -0
  128. package/lib/modifiers/summary/indexPartLevels.js +25 -0
  129. package/lib/modifiers/summary/insertArticle.js +47 -0
  130. package/lib/modifiers/summary/insertPart.js +21 -0
  131. package/lib/modifiers/summary/mergeAtLevel.js +68 -0
  132. package/lib/modifiers/summary/moveArticle.js +27 -0
  133. package/lib/modifiers/summary/moveArticleAfter.js +59 -0
  134. package/lib/modifiers/summary/removeArticle.js +36 -0
  135. package/lib/modifiers/summary/removePart.js +18 -0
  136. package/lib/modifiers/summary/unshiftArticle.js +27 -0
  137. package/lib/output/__tests__/ebook.js +17 -0
  138. package/lib/output/__tests__/json.js +43 -0
  139. package/lib/output/__tests__/plugin-hooks.js +57 -0
  140. package/lib/output/__tests__/website.js +121 -0
  141. package/lib/output/callHook.js +51 -0
  142. package/lib/output/callPageHook.js +23 -0
  143. package/lib/output/createTemplateEngine.js +42 -0
  144. package/lib/output/ebook/getConvertOptions.js +69 -0
  145. package/lib/output/ebook/getCoverPath.js +30 -0
  146. package/lib/output/ebook/getPDFTemplate.js +40 -0
  147. package/lib/output/ebook/index.js +16 -0
  148. package/lib/output/ebook/onFinish.js +84 -0
  149. package/lib/output/ebook/onPage.js +23 -0
  150. package/lib/output/ebook/options.js +17 -0
  151. package/lib/output/generateAssets.js +26 -0
  152. package/lib/output/generateBook.js +167 -0
  153. package/lib/output/generatePage.js +90 -0
  154. package/lib/output/generatePages.js +52 -0
  155. package/lib/output/getModifiers.js +63 -0
  156. package/lib/output/helper/fileToOutput.js +30 -0
  157. package/lib/output/helper/fileToURL.js +30 -0
  158. package/lib/output/helper/index.js +3 -0
  159. package/lib/output/helper/resolveFileToURL.js +25 -0
  160. package/lib/output/helper/writeFile.js +26 -0
  161. package/lib/output/index.js +27 -0
  162. package/lib/output/json/index.js +14 -0
  163. package/lib/output/json/onFinish.js +39 -0
  164. package/lib/output/json/onPage.js +37 -0
  165. package/lib/output/json/options.js +11 -0
  166. package/lib/output/modifiers/__tests__/addHeadingId.js +23 -0
  167. package/lib/output/modifiers/__tests__/annotateText.js +39 -0
  168. package/lib/output/modifiers/__tests__/fetchRemoteImages.js +32 -0
  169. package/lib/output/modifiers/__tests__/highlightCode.js +48 -0
  170. package/lib/output/modifiers/__tests__/inlinePng.js +22 -0
  171. package/lib/output/modifiers/__tests__/inlineSvg.js +42 -0
  172. package/lib/output/modifiers/__tests__/resolveImages.js +39 -0
  173. package/lib/output/modifiers/__tests__/resolveLinks.js +81 -0
  174. package/lib/output/modifiers/__tests__/svgToImg.js +29 -0
  175. package/lib/output/modifiers/addHeadingId.js +26 -0
  176. package/lib/output/modifiers/annotateText.js +76 -0
  177. package/lib/output/modifiers/editHTMLElement.js +17 -0
  178. package/lib/output/modifiers/fetchRemoteImages.js +42 -0
  179. package/lib/output/modifiers/highlightCode.js +59 -0
  180. package/lib/output/modifiers/index.js +26 -0
  181. package/lib/output/modifiers/inlineAssets.js +29 -0
  182. package/lib/output/modifiers/inlinePng.js +43 -0
  183. package/lib/output/modifiers/inlineSvg.js +39 -0
  184. package/lib/output/modifiers/modifyHTML.js +27 -0
  185. package/lib/output/modifiers/resolveImages.js +30 -0
  186. package/lib/output/modifiers/resolveLinks.js +46 -0
  187. package/lib/output/modifiers/svgToImg.js +58 -0
  188. package/lib/output/page-cache.js +15 -0
  189. package/lib/output/prepareAssets.js +22 -0
  190. package/lib/output/preparePages.js +25 -0
  191. package/lib/output/preparePlugins.js +36 -0
  192. package/lib/output/testing/createMock.js +39 -0
  193. package/lib/output/testing/generateMock.js +55 -0
  194. package/lib/output/website/__tests__/i18n.js +40 -0
  195. package/lib/output/website/copyPluginAssets.js +92 -0
  196. package/lib/output/website/createTemplateEngine.js +136 -0
  197. package/lib/output/website/index.js +22 -0
  198. package/lib/output/website/listSearchPaths.js +20 -0
  199. package/lib/output/website/onAsset.js +29 -0
  200. package/lib/output/website/onFinish.js +35 -0
  201. package/lib/output/website/onInit.js +19 -0
  202. package/lib/output/website/onPage.js +73 -0
  203. package/lib/output/website/options.js +15 -0
  204. package/lib/output/website/prepareI18n.js +28 -0
  205. package/lib/output/website/prepareResources.js +49 -0
  206. package/lib/output/website/state.js +20 -0
  207. package/lib/parse/__tests__/listAssets.js +63 -0
  208. package/lib/parse/__tests__/parseBook.js +77 -0
  209. package/lib/parse/__tests__/parseGlossary.js +32 -0
  210. package/lib/parse/__tests__/parseIgnore.js +37 -0
  211. package/lib/parse/__tests__/parsePageFromString.js +34 -0
  212. package/lib/parse/__tests__/parseReadme.js +33 -0
  213. package/lib/parse/__tests__/parseSummary.js +30 -0
  214. package/lib/parse/findParsableFile.js +33 -0
  215. package/lib/parse/index.js +31 -0
  216. package/lib/parse/listAssets.js +36 -0
  217. package/lib/parse/lookupStructureFile.js +21 -0
  218. package/lib/parse/parseBook.js +68 -0
  219. package/lib/parse/parseConfig.js +52 -0
  220. package/lib/parse/parseGlossary.js +25 -0
  221. package/lib/parse/parseIgnore.js +43 -0
  222. package/lib/parse/parseLanguages.js +26 -0
  223. package/lib/parse/parsePage.js +21 -0
  224. package/lib/parse/parsePageFromString.js +25 -0
  225. package/lib/parse/parsePagesList.js +80 -0
  226. package/lib/parse/parseReadme.js +26 -0
  227. package/lib/parse/parseStructureFile.js +64 -0
  228. package/lib/parse/parseSummary.js +43 -0
  229. package/lib/parse/validateConfig.js +31 -0
  230. package/lib/parse/walkSummary.js +34 -0
  231. package/lib/parsers.js +60 -0
  232. package/lib/plugins/PluginResolver.js +84 -0
  233. package/lib/plugins/__tests__/findInstalled.js +25 -0
  234. package/lib/plugins/__tests__/listDependencies.js +28 -0
  235. package/lib/plugins/__tests__/sortDependencies.js +28 -0
  236. package/lib/plugins/__tests__/validatePlugin.js +99 -0
  237. package/lib/plugins/findInstalled.js +87 -0
  238. package/lib/plugins/index.js +17 -0
  239. package/lib/plugins/listBlocks.js +19 -0
  240. package/lib/plugins/listDependencies.js +33 -0
  241. package/lib/plugins/listDepsForBook.js +20 -0
  242. package/lib/plugins/listFilters.js +18 -0
  243. package/lib/plugins/listResources.js +44 -0
  244. package/lib/plugins/loadForBook.js +38 -0
  245. package/lib/plugins/loadPlugin.js +89 -0
  246. package/lib/plugins/package-name-util.js +48 -0
  247. package/lib/plugins/sortDependencies.js +30 -0
  248. package/lib/plugins/toNames.js +16 -0
  249. package/lib/plugins/validateConfig.js +60 -0
  250. package/lib/plugins/validatePlugin.js +36 -0
  251. package/lib/templating/__tests__/conrefsLoader.js +93 -0
  252. package/lib/templating/__tests__/postRender.js +52 -0
  253. package/lib/templating/__tests__/replaceShortcuts.js +27 -0
  254. package/lib/templating/conrefsLoader.js +88 -0
  255. package/lib/templating/index.js +19 -0
  256. package/lib/templating/listShortcuts.js +29 -0
  257. package/lib/templating/postRender.js +46 -0
  258. package/lib/templating/render.js +41 -0
  259. package/lib/templating/renderFile.js +39 -0
  260. package/lib/templating/replaceShortcuts.js +36 -0
  261. package/lib/templating/themesLoader.js +98 -0
  262. package/lib/utils/__tests__/git.js +47 -0
  263. package/lib/utils/__tests__/location.js +81 -0
  264. package/lib/utils/__tests__/path.js +19 -0
  265. package/lib/utils/command.js +104 -0
  266. package/lib/utils/error.js +88 -0
  267. package/lib/utils/fs.js +163 -0
  268. package/lib/utils/genKey.js +13 -0
  269. package/lib/utils/git.js +116 -0
  270. package/lib/utils/images.js +22 -0
  271. package/lib/utils/location.js +129 -0
  272. package/lib/utils/logger.js +158 -0
  273. package/lib/utils/mergeDefaults.js +18 -0
  274. package/lib/utils/path.js +62 -0
  275. package/lib/utils/promise.js +142 -0
  276. package/lib/utils/reducedObject.js +31 -0
  277. package/lib/utils/timing.js +90 -0
  278. package/package.json +112 -0
@@ -0,0 +1,116 @@
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 events_1 = __importDefault(require("events"));
7
+ const http_1 = __importDefault(require("http"));
8
+ const send_1 = __importDefault(require("send"));
9
+ const url_1 = __importDefault(require("url"));
10
+ const promise_1 = __importDefault(require("../utils/promise"));
11
+ class Server extends events_1.default.EventEmitter {
12
+ constructor() {
13
+ super();
14
+ this.running = null;
15
+ this.dir = null;
16
+ this.port = 0;
17
+ this.sockets = [];
18
+ }
19
+ /**
20
+ Return true if the server is running
21
+
22
+ @return {boolean}
23
+ */
24
+ isRunning() {
25
+ return !!this.running;
26
+ }
27
+ /**
28
+ Stop the server
29
+
30
+ @return {Promise}
31
+ */
32
+ stop() {
33
+ const that = this;
34
+ if (!this.isRunning())
35
+ return promise_1.default();
36
+ const d = promise_1.default.defer();
37
+ this.running.close((err) => {
38
+ that.running = null;
39
+ that.emit("state", false);
40
+ if (err)
41
+ d.reject(err);
42
+ else
43
+ d.resolve();
44
+ });
45
+ for (let i = 0; i < this.sockets.length; i++) {
46
+ this.sockets[i].destroy();
47
+ }
48
+ return d.promise;
49
+ }
50
+ /**
51
+ Start the server
52
+
53
+ @return {Promise}
54
+ */
55
+ start(dir, port) {
56
+ const that = this;
57
+ let pre = promise_1.default();
58
+ port = port || 8004;
59
+ if (that.isRunning())
60
+ pre = this.stop();
61
+ return pre.then(() => {
62
+ const d = promise_1.default.defer();
63
+ that.running = http_1.default.createServer((req, res) => {
64
+ // Render error
65
+ function error(err) {
66
+ res.statusCode = err.status || 500;
67
+ res.end(err.message);
68
+ }
69
+ // Redirect to directory's index.html
70
+ function redirect() {
71
+ const resultURL = urlTransform(req.url, (parsed) => {
72
+ parsed.pathname += "/";
73
+ return parsed;
74
+ });
75
+ res.statusCode = 301;
76
+ res.setHeader("Location", resultURL);
77
+ res.end(`Redirecting to ${resultURL}`);
78
+ }
79
+ res.setHeader("X-Current-Location", req.url);
80
+ // Send file
81
+ send_1.default(req, url_1.default.parse(req.url).pathname, {
82
+ root: dir,
83
+ })
84
+ .on("error", error)
85
+ .on("directory", redirect)
86
+ .pipe(res);
87
+ });
88
+ that.running.on("connection", (socket) => {
89
+ that.sockets.push(socket);
90
+ socket.setTimeout(4000);
91
+ socket.on("close", () => {
92
+ that.sockets.splice(that.sockets.indexOf(socket), 1);
93
+ });
94
+ });
95
+ that.running.listen(port, () => {
96
+ that.port = port;
97
+ that.dir = dir;
98
+ that.emit("state", true);
99
+ d.resolve();
100
+ });
101
+ return d.promise;
102
+ });
103
+ }
104
+ }
105
+ /**
106
+ urlTransform is a helper function that allows a function to transform
107
+ a url string in it's parsed form and returns the new url as a string
108
+
109
+ @param {string} uri
110
+ @param {Function} fn
111
+ @return {string}
112
+ */
113
+ function urlTransform(uri, fn) {
114
+ return url_1.default.format(fn(url_1.default.parse(uri)));
115
+ }
116
+ exports.default = Server;
@@ -0,0 +1,35 @@
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 chokidar_1 = __importDefault(require("chokidar"));
8
+ const parsers_1 = __importDefault(require("../parsers"));
9
+ /**
10
+ Watch a folder and resolve promise once a file is modified
11
+
12
+ @param {string} dir
13
+ @param callback
14
+ @return {Promise}
15
+ */
16
+ function watch(dir, callback) {
17
+ dir = path_1.default.resolve(dir);
18
+ const toWatch = ["book.json", "book.js", "_layouts/**"];
19
+ // Watch all parsable files
20
+ parsers_1.default.extensions.forEach((ext) => {
21
+ toWatch.push(`**/*${ext}`);
22
+ });
23
+ const watcher = chokidar_1.default.watch(toWatch, {
24
+ cwd: dir,
25
+ ignored: "_book/**",
26
+ ignoreInitial: true,
27
+ });
28
+ watcher.on("all", (e, filepath) => {
29
+ callback(null, path_1.default.resolve(dir, filepath));
30
+ });
31
+ watcher.on("error", (err) => {
32
+ callback(err);
33
+ });
34
+ }
35
+ exports.default = watch;
@@ -0,0 +1,41 @@
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 jsonschema_1 = __importDefault(require("jsonschema"));
7
+ const configSchema_1 = __importDefault(require("../configSchema"));
8
+ describe("configSchema", () => {
9
+ function validate(cfg) {
10
+ const v = new jsonschema_1.default.Validator();
11
+ return v.validate(cfg, configSchema_1.default, {
12
+ propertyName: "config",
13
+ });
14
+ }
15
+ describe("structure", () => {
16
+ test("should accept dot in filename", () => {
17
+ const result = validate({
18
+ structure: {
19
+ readme: "book-intro.adoc",
20
+ },
21
+ });
22
+ expect(result.errors.length).toBe(0);
23
+ });
24
+ test("should accept uppercase in filename", () => {
25
+ const result = validate({
26
+ structure: {
27
+ readme: "BOOK.adoc",
28
+ },
29
+ });
30
+ expect(result.errors.length).toBe(0);
31
+ });
32
+ test("should not accept filepath", () => {
33
+ const result = validate({
34
+ structure: {
35
+ readme: "folder/myFile.md",
36
+ },
37
+ });
38
+ expect(result.errors.length).toBe(1);
39
+ });
40
+ });
41
+ });
@@ -0,0 +1,9 @@
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 configSchema_1 = __importDefault(require("./configSchema"));
7
+ const immutable_1 = __importDefault(require("immutable"));
8
+ const json_schema_defaults_1 = __importDefault(require("json-schema-defaults"));
9
+ exports.default = immutable_1.default.fromJS(json_schema_defaults_1.default(configSchema_1.default));
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = ["book.js", "book.json"];
@@ -0,0 +1,235 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const FILENAME_REGEX = "^[a-zA-Z-._d,s]+$";
4
+ exports.default = {
5
+ $schema: "http://json-schema.org/schema#",
6
+ id: "https://gitbook.com/schemas/book.json",
7
+ title: "HonKit Configuration",
8
+ type: "object",
9
+ properties: {
10
+ root: {
11
+ type: "string",
12
+ title: "Path fro the root folder containing the book's content",
13
+ },
14
+ title: {
15
+ type: "string",
16
+ title: "Title of the book, default is extracted from README",
17
+ },
18
+ author: {
19
+ type: "string",
20
+ title: "Name of the author",
21
+ },
22
+ authorSort: {
23
+ type: "string",
24
+ title: "String to be used to sort the author(s)",
25
+ },
26
+ producer: {
27
+ type: "string",
28
+ title: "Name of the producer",
29
+ },
30
+ publisher: {
31
+ type: "string",
32
+ title: "Name of the publisher",
33
+ },
34
+ pubdate: {
35
+ type: "string",
36
+ title: "Publication date of the book",
37
+ },
38
+ series: {
39
+ type: "string",
40
+ title: "Series this book belongs to",
41
+ },
42
+ seriesIndex: {
43
+ type: "string",
44
+ title: "Index of the book in this series",
45
+ },
46
+ isbn: {
47
+ type: "string",
48
+ title: "ISBN for published book",
49
+ },
50
+ language: {
51
+ type: "string",
52
+ title: "Language of the book",
53
+ },
54
+ gitbook: {
55
+ type: "string",
56
+ default: "*",
57
+ title: "GitBook/HonKit version to match",
58
+ },
59
+ direction: {
60
+ type: "string",
61
+ enum: ["ltr", "rtl"],
62
+ title: "Direction of texts, default is detected in the pages",
63
+ },
64
+ theme: {
65
+ type: "string",
66
+ default: "default",
67
+ title: "Name of the theme plugin to use",
68
+ },
69
+ variables: {
70
+ type: "object",
71
+ title: "Templating context variables",
72
+ },
73
+ plugins: {
74
+ oneOf: [{ $ref: "#/definitions/pluginsArray" }, { $ref: "#/definitions/pluginsString" }],
75
+ default: [],
76
+ },
77
+ pluginsConfig: {
78
+ type: "object",
79
+ title: "Configuration for plugins",
80
+ },
81
+ structure: {
82
+ type: "object",
83
+ properties: {
84
+ langs: {
85
+ default: "LANGS.md",
86
+ type: "string",
87
+ title: "File to use as languages index",
88
+ pattern: FILENAME_REGEX,
89
+ },
90
+ readme: {
91
+ default: "README.md",
92
+ type: "string",
93
+ title: "File to use as preface",
94
+ pattern: FILENAME_REGEX,
95
+ },
96
+ glossary: {
97
+ default: "GLOSSARY.md",
98
+ type: "string",
99
+ title: "File to use as glossary index",
100
+ pattern: FILENAME_REGEX,
101
+ },
102
+ summary: {
103
+ default: "SUMMARY.md",
104
+ type: "string",
105
+ title: "File to use as table of contents",
106
+ pattern: FILENAME_REGEX,
107
+ },
108
+ },
109
+ additionalProperties: false,
110
+ },
111
+ pdf: {
112
+ type: "object",
113
+ title: "PDF specific configurations",
114
+ properties: {
115
+ pageNumbers: {
116
+ type: "boolean",
117
+ default: true,
118
+ title: "Add page numbers to the bottom of every page",
119
+ },
120
+ fontSize: {
121
+ type: "integer",
122
+ minimum: 8,
123
+ maximum: 30,
124
+ default: 12,
125
+ title: "Font size for the PDF output",
126
+ },
127
+ fontFamily: {
128
+ type: "string",
129
+ default: "Arial",
130
+ title: "Font family for the PDF output",
131
+ },
132
+ paperSize: {
133
+ type: "string",
134
+ enum: [
135
+ "a0",
136
+ "a1",
137
+ "a2",
138
+ "a3",
139
+ "a4",
140
+ "a5",
141
+ "a6",
142
+ "b0",
143
+ "b1",
144
+ "b2",
145
+ "b3",
146
+ "b4",
147
+ "b5",
148
+ "b6",
149
+ "legal",
150
+ "letter",
151
+ ],
152
+ default: "a4",
153
+ title: "Paper size for the PDF",
154
+ },
155
+ chapterMark: {
156
+ type: "string",
157
+ enum: ["pagebreak", "rule", "both", "none"],
158
+ default: "pagebreak",
159
+ title: "How to mark detected chapters",
160
+ },
161
+ pageBreaksBefore: {
162
+ type: "string",
163
+ default: "/",
164
+ title: 'An XPath expression. Page breaks are inserted before the specified elements. To disable use the expression: "/"',
165
+ },
166
+ margin: {
167
+ type: "object",
168
+ properties: {
169
+ right: {
170
+ type: "integer",
171
+ title: "Right Margin",
172
+ minimum: 0,
173
+ maximum: 100,
174
+ default: 62,
175
+ },
176
+ left: {
177
+ type: "integer",
178
+ title: "Left Margin",
179
+ minimum: 0,
180
+ maximum: 100,
181
+ default: 62,
182
+ },
183
+ top: {
184
+ type: "integer",
185
+ title: "Top Margin",
186
+ minimum: 0,
187
+ maximum: 100,
188
+ default: 56,
189
+ },
190
+ bottom: {
191
+ type: "integer",
192
+ title: "Bottom Margin",
193
+ minimum: 0,
194
+ maximum: 100,
195
+ default: 56,
196
+ },
197
+ },
198
+ },
199
+ embedFonts: {
200
+ type: "boolean",
201
+ default: false,
202
+ title: "Embed all fonts into the PDF",
203
+ },
204
+ },
205
+ },
206
+ },
207
+ required: [],
208
+ definitions: {
209
+ pluginsArray: {
210
+ type: "array",
211
+ items: {
212
+ oneOf: [{ $ref: "#/definitions/pluginObject" }, { $ref: "#/definitions/pluginString" }],
213
+ },
214
+ },
215
+ pluginsString: {
216
+ type: "string",
217
+ },
218
+ pluginString: {
219
+ type: "string",
220
+ },
221
+ pluginObject: {
222
+ type: "object",
223
+ properties: {
224
+ name: {
225
+ type: "string",
226
+ },
227
+ version: {
228
+ type: "string",
229
+ },
230
+ },
231
+ additionalProperties: false,
232
+ required: ["name"],
233
+ },
234
+ },
235
+ };
@@ -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 immutable_1 = __importDefault(require("immutable"));
7
+ const templateBlock_1 = __importDefault(require("../models/templateBlock"));
8
+ exports.default = immutable_1.default.Map({
9
+ html: new templateBlock_1.default({
10
+ name: "html",
11
+ process: function (blk) {
12
+ return blk;
13
+ },
14
+ }),
15
+ code: new templateBlock_1.default({
16
+ name: "code",
17
+ process: function (blk) {
18
+ return {
19
+ html: false,
20
+ body: blk.body,
21
+ };
22
+ },
23
+ }),
24
+ markdown: new templateBlock_1.default({
25
+ name: "markdown",
26
+ process: function (blk) {
27
+ return this.book.renderInline("markdown", blk.body).then((out) => {
28
+ return { body: out };
29
+ });
30
+ },
31
+ }),
32
+ asciidoc: new templateBlock_1.default({
33
+ name: "asciidoc",
34
+ process: function (blk) {
35
+ return this.book.renderInline("asciidoc", blk.body).then((out) => {
36
+ return { body: out };
37
+ });
38
+ },
39
+ }),
40
+ markup: new templateBlock_1.default({
41
+ name: "markup",
42
+ process: function (blk) {
43
+ return this.book.renderInline(this.ctx.file.type, blk.body).then((out) => {
44
+ return { body: out };
45
+ });
46
+ },
47
+ }),
48
+ });