@honkit/asciidoc 4.0.8 → 5.1.0

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.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=glossary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glossary.d.ts","sourceRoot":"","sources":["../../src/__tests__/glossary.ts"],"names":[],"mappings":""}
@@ -6,11 +6,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const fs_1 = __importDefault(require("fs"));
7
7
  const path_1 = __importDefault(require("path"));
8
8
  const assert_1 = __importDefault(require("assert"));
9
- const glossary = require("../").glossary;
9
+ const __1 = __importDefault(require("../"));
10
10
  let LEXED;
11
11
  beforeAll(() => {
12
12
  const CONTENT = fs_1.default.readFileSync(path_1.default.join(__dirname, "fixtures/GLOSSARY.adoc"), "utf8");
13
- LEXED = glossary(CONTENT);
13
+ LEXED = __1.default.glossary(CONTENT);
14
14
  });
15
15
  it("should only get heading + paragraph pairs", () => {
16
16
  assert_1.default.equal(LEXED.length, 4);
@@ -21,6 +21,6 @@ it("should output simple name/description objects", () => {
21
21
  }));
22
22
  });
23
23
  it("should correctly convert it to text", () => {
24
- const text = glossary.toText(LEXED);
25
- assert_1.default.deepEqual(glossary(text), LEXED);
24
+ const text = __1.default.glossary.toText(LEXED);
25
+ assert_1.default.deepEqual(__1.default.glossary(text), LEXED);
26
26
  });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inline.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../src/__tests__/inline.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
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 assert_1 = __importDefault(require("assert"));
7
+ const __1 = __importDefault(require("../"));
8
+ it("should render inline AsciiDoc", function () {
9
+ assert_1.default.equal(__1.default.inline("Hello **World**").content, "Hello <strong>World</strong>");
10
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=langs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"langs.d.ts","sourceRoot":"","sources":["../../src/__tests__/langs.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
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 path_1 = __importDefault(require("path"));
8
+ const assert_1 = __importDefault(require("assert"));
9
+ const __1 = __importDefault(require("../"));
10
+ var LEXED;
11
+ beforeAll(function () {
12
+ var CONTENT = fs_1.default.readFileSync(path_1.default.join(__dirname, "./fixtures/LANGS.adoc"), "utf8");
13
+ LEXED = __1.default.langs(CONTENT);
14
+ });
15
+ it("should detect paths and titles", function () {
16
+ assert_1.default.equal(LEXED[0].ref, "en/");
17
+ assert_1.default.equal(LEXED[0].title, "English");
18
+ assert_1.default.equal(LEXED[1].ref, "fr/");
19
+ assert_1.default.equal(LEXED[1].title, "French");
20
+ });
21
+ it("should correctly convert it to text", function () {
22
+ var text = __1.default.langs.toText(LEXED);
23
+ assert_1.default.deepEqual(__1.default.langs(text), LEXED);
24
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/__tests__/page.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 fs_1 = __importDefault(require("fs"));
8
+ const assert_1 = __importDefault(require("assert"));
9
+ const __1 = __importDefault(require("../"));
10
+ it("should gen content", function () {
11
+ const CONTENT = fs_1.default.readFileSync(path_1.default.join(__dirname, "./fixtures/PAGE.adoc"), "utf8");
12
+ const LEXED = __1.default.page(CONTENT);
13
+ (0, assert_1.default)(LEXED.content);
14
+ });
15
+ it("should include file", function () {
16
+ const result = __1.default.page(`= GitBook User Manual
17
+
18
+ == Usage
19
+
20
+ include::src/__tests__/fixtures/usage.adoc[]
21
+ `).content;
22
+ // assert.match is available in Node > 12.16.0
23
+ (0, assert_1.default)(result.match(/create a book/g) !== null);
24
+ });
25
+ it("should use font icons by default", function () {
26
+ const result = __1.default.page(`= HonKit User Manual
27
+
28
+ == Install
29
+
30
+ IMPORTANT: Do not forgot to install \`yarn\`
31
+ `).content;
32
+ // assert.match is available in Node > 12.16.0
33
+ (0, assert_1.default)(result.match(/fa icon-important/g) !== null);
34
+ });
35
+ it("should allow users to override icons attribute", function () {
36
+ const result = __1.default.page(`= HonKit User Manual
37
+ // override icons attribute
38
+ :icons:
39
+
40
+ == Install
41
+
42
+ IMPORTANT: Do not forgot to install \`yarn\`
43
+ `).content;
44
+ // assert.doesNotMatch is available in Node > 12.16.0
45
+ (0, assert_1.default)(result.match(/fa icon-important/g) === null);
46
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=readme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"readme.d.ts","sourceRoot":"","sources":["../../src/__tests__/readme.ts"],"names":[],"mappings":""}
@@ -0,0 +1,26 @@
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 path_1 = __importDefault(require("path"));
8
+ const assert_1 = __importDefault(require("assert"));
9
+ const __1 = __importDefault(require("../"));
10
+ var LEXED;
11
+ beforeAll(function () {
12
+ var CONTENT = fs_1.default.readFileSync(path_1.default.join(__dirname, "./fixtures/README.adoc"), "utf8");
13
+ LEXED = __1.default.readme(CONTENT);
14
+ });
15
+ it("should contain a title", function () {
16
+ (0, assert_1.default)(LEXED.title);
17
+ });
18
+ it("should contain a description", function () {
19
+ (0, assert_1.default)(LEXED.description);
20
+ });
21
+ it("should extract the right title", function () {
22
+ assert_1.default.equal(LEXED.title, "This is the title");
23
+ });
24
+ it("should extract the right description", function () {
25
+ assert_1.default.equal(LEXED.description, "This is the book description.");
26
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=summary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/__tests__/summary.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 fs_1 = __importDefault(require("fs"));
7
+ const path_1 = __importDefault(require("path"));
8
+ const assert_1 = __importDefault(require("assert"));
9
+ const __1 = __importDefault(require("../"));
10
+ var LEXED, PART;
11
+ beforeAll(function () {
12
+ var CONTENT = fs_1.default.readFileSync(path_1.default.join(__dirname, "./fixtures/SUMMARY.adoc"), "utf8");
13
+ LEXED = __1.default.summary(CONTENT);
14
+ PART = LEXED.parts[0];
15
+ // todo: add support for parts in asciidoc
16
+ });
17
+ it("should detect parts", function () {
18
+ assert_1.default.equal(LEXED.parts.length, 1);
19
+ });
20
+ it("should detect articles", function () {
21
+ assert_1.default.equal(PART.articles.length, 5);
22
+ });
23
+ it("should support articles", function () {
24
+ assert_1.default.equal(PART.articles[0].articles.length, 2);
25
+ assert_1.default.equal(PART.articles[1].articles.length, 0);
26
+ assert_1.default.equal(PART.articles[2].articles.length, 0);
27
+ });
28
+ it("should detect paths and titles", function () {
29
+ (0, assert_1.default)(PART.articles[0].ref);
30
+ (0, assert_1.default)(PART.articles[1].ref);
31
+ (0, assert_1.default)(PART.articles[2].ref);
32
+ (0, assert_1.default)(PART.articles[3].ref);
33
+ assert_1.default.equal(PART.articles[4].ref, null);
34
+ (0, assert_1.default)(PART.articles[0].title);
35
+ (0, assert_1.default)(PART.articles[1].title);
36
+ (0, assert_1.default)(PART.articles[2].title);
37
+ (0, assert_1.default)(PART.articles[3].title);
38
+ (0, assert_1.default)(PART.articles[4].title);
39
+ });
40
+ it("should normalize paths from .md", function () {
41
+ assert_1.default.equal(PART.articles[0].ref, "chapter-1/README.adoc");
42
+ assert_1.default.equal(PART.articles[1].ref, "chapter-2/README.adoc");
43
+ assert_1.default.equal(PART.articles[2].ref, "chapter-3/README.adoc");
44
+ });
45
+ it("should correctly convert it to text", function () {
46
+ var text = __1.default.summary.toText(LEXED);
47
+ assert_1.default.deepEqual(__1.default.summary(text), LEXED);
48
+ });
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ declare const _default: import("@honkit/html").Parsers;
2
+ export default _default;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAIA,wBAAgD"}
package/lib/index.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const html_1 = __importDefault(require("@honkit/html"));
6
+ const html_1 = require("@honkit/html");
7
7
  const toHTML_1 = __importDefault(require("./toHTML"));
8
8
  const toAsciidoc_1 = __importDefault(require("./toAsciidoc"));
9
- module.exports = html_1.default.createParser(toHTML_1.default, toAsciidoc_1.default);
9
+ exports.default = (0, html_1.createParser)(toHTML_1.default, toAsciidoc_1.default);
@@ -0,0 +1,15 @@
1
+ declare const _default: {
2
+ onTitleStart: (level: any) => string;
3
+ onTitleEnd: (level: any) => any;
4
+ onParagraphStart: () => any;
5
+ onParagraphEnd: () => any;
6
+ onLinkStart: (href: any) => string;
7
+ onLinkEnd: () => string;
8
+ onListStart: (level: any) => string;
9
+ onListEnd: () => string;
10
+ onListItemStart: (level: any) => string;
11
+ onListItemEnd: () => string;
12
+ onHR: () => string;
13
+ };
14
+ export default _default;
15
+ //# sourceMappingURL=toAsciidoc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toAsciidoc.d.ts","sourceRoot":"","sources":["../src/toAsciidoc.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAKA,wBAuCE"}
@@ -0,0 +1,7 @@
1
+ import { ToHTMLFunction } from "@honkit/html";
2
+ declare const _default: {
3
+ block: ToHTMLFunction;
4
+ inline: ToHTMLFunction;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=toHTML.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toHTML.d.ts","sourceRoot":"","sources":["../src/toHTML.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;;;;;AAkB9C,wBAGE"}
package/lib/toHTML.js CHANGED
@@ -6,14 +6,18 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  const asciidoctor_1 = __importDefault(require("asciidoctor"));
7
7
  const asciidoctor = (0, asciidoctor_1.default)();
8
8
  // Render Asciidoc to HTML (block)
9
- function asciidocToHTML(content) {
10
- return asciidoctor.convert(content, { safe: "server", attributes: { showtitle: "", icons: "font@" } });
11
- }
9
+ const asciidocToHTML = (content, options) => {
10
+ return asciidoctor.convert(content, {
11
+ safe: "server",
12
+ attributes: { showtitle: "", icons: "font@" },
13
+ base_dir: options === null || options === void 0 ? void 0 : options.baseDirectory
14
+ });
15
+ };
12
16
  // Render Asciidoc to HTML (inline)
13
- function asciidocToHTMLInline(content) {
14
- return asciidoctor.convert(content, { doctype: "inline" });
15
- }
17
+ const asciidocToHTMLInline = (content, options) => {
18
+ return asciidoctor.convert(content, { doctype: "inline", base_dir: options === null || options === void 0 ? void 0 : options.baseDirectory });
19
+ };
16
20
  exports.default = {
17
21
  block: asciidocToHTML,
18
- inline: asciidocToHTMLInline,
22
+ inline: asciidocToHTMLInline
19
23
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honkit/asciidoc",
3
- "version": "4.0.8",
3
+ "version": "5.1.0",
4
4
  "description": "Parse AsciiDoc content for gitbook",
5
5
  "homepage": "https://github.com/honkit/honkit",
6
6
  "bugs": {
@@ -32,20 +32,21 @@
32
32
  ],
33
33
  "scripts": {
34
34
  "build": "tsc -p .",
35
- "test": "yarn build && jest src",
35
+ "test": "jest src",
36
36
  "prepublish": "npm run --if-present build"
37
37
  },
38
38
  "dependencies": {
39
- "@honkit/html": "^4.0.8",
39
+ "@honkit/html": "^5.1.0",
40
40
  "asciidoctor": "^2.2.0",
41
41
  "lodash": "^4.13.1"
42
42
  },
43
43
  "devDependencies": {
44
- "mocha": "^10.0.0"
44
+ "jest": "^29.0.3",
45
+ "ts-jest": "^29.1.1"
45
46
  },
46
47
  "publishConfig": {
47
48
  "access": "public"
48
49
  },
49
50
  "authors": "azu <azuciao@gmail.com>",
50
- "gitHead": "6a2337bdac8357887496ce7e84a8184e40907235"
51
+ "gitHead": "6acb1146ae4c21d64283f88f06f26427a35f349b"
51
52
  }