@honkit/markdown 5.1.4 → 6.0.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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # `@honkit/markdow`
1
+ # `@honkit/markdown`
2
2
 
3
- This node module uses `@honkit/markup-i`t to parse markdown for gitbook (SUMMARY.md, README.md).
3
+ This node module uses `@honkit/markup-it` to parse markdown for gitbook (SUMMARY.md, README.md).
4
4
 
5
5
  ## Note
6
6
 
package/lib/page.js CHANGED
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
23
23
  return result;
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.preparePage = void 0;
26
+ exports.preparePage = preparePage;
27
27
  const MarkupIt = __importStar(require("@honkit/markup-it"));
28
28
  const gitbookSyntax = require("@honkit/markup-it/syntaxes/markdown");
29
29
  const RAW_START = "{% raw %}";
@@ -74,4 +74,3 @@ function preparePage(src) {
74
74
  });
75
75
  return textMarkdown;
76
76
  }
77
- exports.preparePage = preparePage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honkit/markdown",
3
- "version": "5.1.4",
3
+ "version": "6.0.0",
4
4
  "description": "Parse markdown content for honkit",
5
5
  "homepage": "https://github.com/honkit/honkit",
6
6
  "bugs": {
@@ -38,16 +38,18 @@
38
38
  "prepublish": "npm run --if-present build"
39
39
  },
40
40
  "dependencies": {
41
- "@honkit/html": "^5.1.4",
42
- "@honkit/markup-it": "^5.1.4",
43
- "markdown-escape": "^1.0.1"
41
+ "@honkit/html": "6.0.0",
42
+ "@honkit/markup-it": "6.0.0",
43
+ "markdown-escape": "^1.1.0"
44
44
  },
45
45
  "devDependencies": {
46
- "jest": "^29.0.3",
47
- "ts-jest": "^29.1.1"
46
+ "@types/jest": "^29.5.13",
47
+ "@types/node": "^22.7.4",
48
+ "jest": "^29.7.0",
49
+ "ts-jest": "^29.2.5"
48
50
  },
49
51
  "publishConfig": {
50
52
  "access": "public"
51
53
  },
52
- "gitHead": "1c26afb66065cd7437e0e8f9d226327d49259313"
54
+ "gitHead": "367fe659a4a33c656ae51a1ec75fff0447365f9f"
53
55
  }
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=glossary.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"glossary.d.ts","sourceRoot":"","sources":["../../src/__tests__/glossary.ts"],"names":[],"mappings":""}
@@ -1,29 +0,0 @@
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 path_1 = __importDefault(require("path"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const __1 = __importDefault(require("../"));
10
- const glossary = __1.default.glossary;
11
- describe("Glossary parsing", () => {
12
- let LEXED;
13
- beforeAll(() => {
14
- const CONTENT = fs_1.default.readFileSync(path_1.default.join(__dirname, "./fixtures/GLOSSARY.md"), "utf8");
15
- LEXED = glossary(CONTENT);
16
- });
17
- it("should only get heading + paragraph pairs", () => {
18
- assert_1.default.equal(LEXED.length, 4);
19
- });
20
- it("should output simple name/description objects", () => {
21
- assert_1.default.equal(true, !LEXED.some((e) => {
22
- return !(e.name && e.description);
23
- }));
24
- });
25
- it("should correctly convert it to text", () => {
26
- const text = glossary.toText(LEXED);
27
- assert_1.default.deepEqual(glossary(text), LEXED);
28
- });
29
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=inline.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../src/__tests__/inline.ts"],"names":[],"mappings":""}
@@ -1,13 +0,0 @@
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 __1 = __importDefault(require("../"));
7
- const assert_1 = __importDefault(require("assert"));
8
- const inline = __1.default.inline;
9
- describe("Inline", () => {
10
- it("should render inline markdown", () => {
11
- assert_1.default.equal(inline("Hello **World**").content, "Hello <strong>World</strong>");
12
- });
13
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=langs.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"langs.d.ts","sourceRoot":"","sources":["../../src/__tests__/langs.ts"],"names":[],"mappings":""}
@@ -1,28 +0,0 @@
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 __1 = __importDefault(require("../"));
7
- const assert_1 = __importDefault(require("assert"));
8
- const path_1 = __importDefault(require("path"));
9
- const fs_1 = __importDefault(require("fs"));
10
- const langs = __1.default.langs;
11
- describe("Languages parsing", () => {
12
- let LEXED;
13
- beforeAll(() => {
14
- const CONTENT = fs_1.default.readFileSync(path_1.default.join(__dirname, "./fixtures/LANGS.md"), "utf8");
15
- LEXED = langs(CONTENT);
16
- });
17
- it("should detect paths and titles", () => {
18
- assert_1.default.equal(LEXED.length, 2);
19
- assert_1.default.equal(LEXED[0].ref, "en/");
20
- assert_1.default.equal(LEXED[0].title, "English");
21
- assert_1.default.equal(LEXED[1].ref, "fr/");
22
- assert_1.default.equal(LEXED[1].title, "French");
23
- });
24
- it("should correctly convert it to text", () => {
25
- const text = langs.toText(LEXED);
26
- assert_1.default.deepEqual(langs(text), LEXED);
27
- });
28
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=page.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../src/__tests__/page.ts"],"names":[],"mappings":""}
@@ -1,134 +0,0 @@
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
- const page = __1.default.page;
11
- describe("Page parsing", () => {
12
- let LEXED;
13
- beforeAll(() => {
14
- const CONTENT = fs_1.default.readFileSync(path_1.default.join(__dirname, "./fixtures/PAGE.md"), "utf8");
15
- LEXED = page(CONTENT);
16
- });
17
- it("should gen content", () => {
18
- (0, assert_1.default)(LEXED.content);
19
- });
20
- it("should not add id to headings", () => {
21
- assert_1.default.equal(page("# Hello").content, "<h1>Hello</h1>");
22
- assert_1.default.equal(page("# Hello {#test}").content, '<h1 id="test">Hello</h1>');
23
- });
24
- it("should escape codeblocks in preparation (1)", () => {
25
- assert_1.default.equal(page.prepare("Hello `world`"), "Hello {% raw %}`world`{% endraw %}\n\n");
26
- assert_1.default.equal(page.prepare("Hello `world test`"), "Hello {% raw %}`world test`{% endraw %}\n\n");
27
- assert_1.default.equal(page.prepare("Hello ```world test```"), "Hello {% raw %}`world test`{% endraw %}\n\n");
28
- assert_1.default.equal(page.prepare("Hello\n```js\nworld test\n```\n"), "Hello\n\n{% raw %}```js\nworld test\n```\n\n{% endraw %}");
29
- expect(page.prepare("Hello\n```\ntest\n\tworld\n\ttest\n```")).toMatchInlineSnapshot(`
30
- "Hello
31
-
32
- {% raw %}\`\`\`
33
- test
34
- world
35
- test
36
- \`\`\`
37
-
38
- {% endraw %}"
39
- `);
40
- // preserve \t in CodeBlock
41
- expect(page.prepare("Hello\n```js\n\tvar a = 1;\n\tconsole.log(a);\n```")).toMatchInlineSnapshot(`
42
- "Hello
43
-
44
- {% raw %}\`\`\`js
45
- var a = 1;
46
- console.log(a);
47
- \`\`\`
48
-
49
- {% endraw %}"
50
- `);
51
- });
52
- it("should escape codeblocks in preparation (2)", () => {
53
- expect(page.prepare(`Hello
54
-
55
-
56
- \tworld
57
- \thello
58
-
59
-
60
- test`)).toMatchInlineSnapshot(`
61
- "Hello
62
-
63
- {% raw %} world
64
- hello
65
-
66
- {% endraw %}test
67
-
68
- "
69
- `);
70
- expect(page.prepare(`Hello
71
-
72
-
73
- \tworld
74
- \thello
75
-
76
-
77
- `)).toMatchInlineSnapshot(`
78
- "Hello
79
-
80
- {% raw %} world
81
- hello
82
-
83
- {% endraw %}"
84
- `);
85
- });
86
- it("should escape codeblocks with nunjucks tags", () => {
87
- assert_1.default.equal(page.prepare('Hello {{ "Bonjour" }} ```test```'), 'Hello {{ "Bonjour" }} {% raw %}`test`{% endraw %}\n\n');
88
- });
89
- it("should escape codeblocks with nunjucks tags in {% raw %} tags", () => {
90
- assert_1.default.equal(page.prepare('{% raw %}Hello {{ "Bonjour" }} ```test```{% endraw %}'), '{% raw %}Hello {{ "Bonjour" }} `test`{% endraw %}\n\n');
91
- assert_1.default.equal(page.prepare('{% raw %}Hello {{ "Bonjour" }} {% raw %}{% endraw %}```test```'), '{% raw %}Hello {{ "Bonjour" }} {% raw %}{% endraw %}{% raw %}`test`{% endraw %}\n\n');
92
- assert_1.default.equal(page.prepare('```{% raw %}Hello {{ "Bonjour" }} {% raw %}```'), '{% raw %}`{% raw %}Hello {{ "Bonjour" }} {% raw %}`{% endraw %}\n\n');
93
- assert_1.default.equal(page.prepare("```\ntest\n```\n\n\n### Test"), "{% raw %}```\ntest\n```\n\n{% endraw %}### Test\n\n");
94
- });
95
- it("escape {% uml %} block tags + Indented code block", () => {
96
- const code = `{% uml %}
97
- @startuml
98
-
99
- \tClass Stage
100
- \tClass Timeout {
101
- \t\t+constructor:function(cfg)
102
- \t\t+timeout:function(ctx)
103
- \t\t+overdue:function(ctx)
104
- \t\t+stage: Stage
105
- \t}
106
- \tStage <|-- Timeout
107
-
108
- @enduml
109
- {% enduml %}
110
- `;
111
- expect(page.prepare(code)).toMatchInlineSnapshot(`
112
- "{% uml %}
113
- @startuml
114
-
115
- {% raw %} Class Stage
116
- Class Timeout {
117
- +constructor:function(cfg)
118
- +timeout:function(ctx)
119
- +overdue:function(ctx)
120
- +stage: Stage
121
- }
122
- Stage <|-- Timeout
123
-
124
- {% endraw %}@enduml
125
- {% enduml %}
126
-
127
- "
128
- `);
129
- });
130
- it("should not process math", () => {
131
- assert_1.default.equal(page.prepare("Hello $world$"), "Hello $world$\n\n");
132
- assert_1.default.equal(page.prepare("Hello $$world$$"), "Hello $$world$$\n\n");
133
- });
134
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=readme.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"readme.d.ts","sourceRoot":"","sources":["../../src/__tests__/readme.ts"],"names":[],"mappings":""}
@@ -1,28 +0,0 @@
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 assert_1 = __importDefault(require("assert"));
8
- const __1 = __importDefault(require("../"));
9
- const fs_1 = __importDefault(require("fs"));
10
- describe("Readme parsing", () => {
11
- let LEXED;
12
- beforeAll(() => {
13
- const CONTENT = fs_1.default.readFileSync(path_1.default.join(__dirname, "./fixtures/README.md"), "utf8");
14
- LEXED = __1.default.readme(CONTENT);
15
- });
16
- it("should contain a title", () => {
17
- (0, assert_1.default)(LEXED.title);
18
- });
19
- it("should contain a description", () => {
20
- (0, assert_1.default)(LEXED.description);
21
- });
22
- it("should extract the right title", () => {
23
- assert_1.default.equal(LEXED.title, "This is the title");
24
- });
25
- it("should extract the right description", () => {
26
- assert_1.default.equal(LEXED.description, "This is the book description.");
27
- });
28
- });
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=summary.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"summary.d.ts","sourceRoot":"","sources":["../../src/__tests__/summary.ts"],"names":[],"mappings":""}
@@ -1,60 +0,0 @@
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 assert_1 = __importDefault(require("assert"));
8
- const fs_1 = __importDefault(require("fs"));
9
- const __1 = __importDefault(require("../"));
10
- function lex(fixtureFile) {
11
- return __1.default.summary(fs_1.default.readFileSync(path_1.default.join(__dirname, "fixtures", fixtureFile), "utf8"));
12
- }
13
- describe("Summary parsing", () => {
14
- let LEXED, PART;
15
- beforeAll(() => {
16
- LEXED = lex("SUMMARY.md");
17
- PART = LEXED.parts[0];
18
- });
19
- it("should detect chapters", () => {
20
- assert_1.default.equal(PART.articles.length, 5);
21
- });
22
- it("should support articles", () => {
23
- assert_1.default.equal(PART.articles[0].articles.length, 2);
24
- assert_1.default.equal(PART.articles[1].articles.length, 0);
25
- assert_1.default.equal(PART.articles[2].articles.length, 0);
26
- });
27
- it("should detect paths and titles", () => {
28
- (0, assert_1.default)(PART.articles[0].ref);
29
- (0, assert_1.default)(PART.articles[1].ref);
30
- (0, assert_1.default)(PART.articles[2].ref);
31
- (0, assert_1.default)(PART.articles[3].ref);
32
- assert_1.default.equal(PART.articles[4].ref, null);
33
- (0, assert_1.default)(PART.articles[0].title);
34
- (0, assert_1.default)(PART.articles[1].title);
35
- (0, assert_1.default)(PART.articles[2].title);
36
- (0, assert_1.default)(PART.articles[3].title);
37
- (0, assert_1.default)(PART.articles[4].title);
38
- });
39
- it("should normalize paths from .md", () => {
40
- assert_1.default.equal(PART.articles[0].ref, "chapter-1/README.md");
41
- assert_1.default.equal(PART.articles[1].ref, "chapter-2/README.md");
42
- assert_1.default.equal(PART.articles[2].ref, "chapter-3/README.md");
43
- });
44
- it("should part parts", () => {
45
- const l = lex("SUMMARY_PARTS.md");
46
- assert_1.default.equal(l.parts.length, 3);
47
- });
48
- it("should allow lists separated by whitespace", () => {
49
- const l = lex("SUMMARY_WHITESPACE.md");
50
- assert_1.default.equal(l.parts[0].articles.length, 5);
51
- });
52
- it("should allow ignore empty entries", () => {
53
- const l = lex("SUMMARY_EMPTY.md");
54
- assert_1.default.equal(l.parts[0].articles.length, 1);
55
- });
56
- it("should correctly convert it to text", () => {
57
- const text = __1.default.summary.toText(LEXED);
58
- assert_1.default.deepEqual(__1.default.summary(text), LEXED);
59
- });
60
- });