@honkit/markdown 5.1.5 → 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/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.5",
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.5",
42
- "@honkit/markup-it": "^5.1.5",
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": "d75ed67c85e3fc6976e837b56402f84e860886c7"
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,137 +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 handle line breaks appropriately", () => {
25
- assert_1.default.equal(page("Line one. \nLine two.").content, "<p>Line one.<br>Line two.</p>");
26
- });
27
- it("should escape codeblocks in preparation (1)", () => {
28
- assert_1.default.equal(page.prepare("Hello `world`"), "Hello {% raw %}`world`{% endraw %}\n\n");
29
- assert_1.default.equal(page.prepare("Hello `world test`"), "Hello {% raw %}`world test`{% endraw %}\n\n");
30
- assert_1.default.equal(page.prepare("Hello ```world test```"), "Hello {% raw %}`world test`{% endraw %}\n\n");
31
- assert_1.default.equal(page.prepare("Hello\n```js\nworld test\n```\n"), "Hello\n\n{% raw %}```js\nworld test\n```\n\n{% endraw %}");
32
- expect(page.prepare("Hello\n```\ntest\n\tworld\n\ttest\n```")).toMatchInlineSnapshot(`
33
- "Hello
34
-
35
- {% raw %}\`\`\`
36
- test
37
- world
38
- test
39
- \`\`\`
40
-
41
- {% endraw %}"
42
- `);
43
- // preserve \t in CodeBlock
44
- expect(page.prepare("Hello\n```js\n\tvar a = 1;\n\tconsole.log(a);\n```")).toMatchInlineSnapshot(`
45
- "Hello
46
-
47
- {% raw %}\`\`\`js
48
- var a = 1;
49
- console.log(a);
50
- \`\`\`
51
-
52
- {% endraw %}"
53
- `);
54
- });
55
- it("should escape codeblocks in preparation (2)", () => {
56
- expect(page.prepare(`Hello
57
-
58
-
59
- \tworld
60
- \thello
61
-
62
-
63
- test`)).toMatchInlineSnapshot(`
64
- "Hello
65
-
66
- {% raw %} world
67
- hello
68
-
69
- {% endraw %}test
70
-
71
- "
72
- `);
73
- expect(page.prepare(`Hello
74
-
75
-
76
- \tworld
77
- \thello
78
-
79
-
80
- `)).toMatchInlineSnapshot(`
81
- "Hello
82
-
83
- {% raw %} world
84
- hello
85
-
86
- {% endraw %}"
87
- `);
88
- });
89
- it("should escape codeblocks with nunjucks tags", () => {
90
- assert_1.default.equal(page.prepare('Hello {{ "Bonjour" }} ```test```'), 'Hello {{ "Bonjour" }} {% raw %}`test`{% endraw %}\n\n');
91
- });
92
- it("should escape codeblocks with nunjucks tags in {% raw %} tags", () => {
93
- assert_1.default.equal(page.prepare('{% raw %}Hello {{ "Bonjour" }} ```test```{% endraw %}'), '{% raw %}Hello {{ "Bonjour" }} `test`{% endraw %}\n\n');
94
- assert_1.default.equal(page.prepare('{% raw %}Hello {{ "Bonjour" }} {% raw %}{% endraw %}```test```'), '{% raw %}Hello {{ "Bonjour" }} {% raw %}{% endraw %}{% raw %}`test`{% endraw %}\n\n');
95
- assert_1.default.equal(page.prepare('```{% raw %}Hello {{ "Bonjour" }} {% raw %}```'), '{% raw %}`{% raw %}Hello {{ "Bonjour" }} {% raw %}`{% endraw %}\n\n');
96
- assert_1.default.equal(page.prepare("```\ntest\n```\n\n\n### Test"), "{% raw %}```\ntest\n```\n\n{% endraw %}### Test\n\n");
97
- });
98
- it("escape {% uml %} block tags + Indented code block", () => {
99
- const code = `{% uml %}
100
- @startuml
101
-
102
- \tClass Stage
103
- \tClass Timeout {
104
- \t\t+constructor:function(cfg)
105
- \t\t+timeout:function(ctx)
106
- \t\t+overdue:function(ctx)
107
- \t\t+stage: Stage
108
- \t}
109
- \tStage <|-- Timeout
110
-
111
- @enduml
112
- {% enduml %}
113
- `;
114
- expect(page.prepare(code)).toMatchInlineSnapshot(`
115
- "{% uml %}
116
- @startuml
117
-
118
- {% raw %} Class Stage
119
- Class Timeout {
120
- +constructor:function(cfg)
121
- +timeout:function(ctx)
122
- +overdue:function(ctx)
123
- +stage: Stage
124
- }
125
- Stage <|-- Timeout
126
-
127
- {% endraw %}@enduml
128
- {% enduml %}
129
-
130
- "
131
- `);
132
- });
133
- it("should not process math", () => {
134
- assert_1.default.equal(page.prepare("Hello $world$"), "Hello $world$\n\n");
135
- assert_1.default.equal(page.prepare("Hello $$world$$"), "Hello $$world$$\n\n");
136
- });
137
- });
@@ -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
- });