@honkit/markdown 3.6.17 → 3.7.2
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/__tests__/glossary.js +23 -0
- package/lib/__tests__/inline.js +9 -0
- package/lib/__tests__/langs.js +22 -0
- package/lib/__tests__/page.js +128 -0
- package/lib/__tests__/readme.js +23 -0
- package/lib/__tests__/summary.js +55 -0
- package/lib/toMarkdown.js +1 -1
- package/package.json +3 -3
- package/CHANGELOG.md +0 -159
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const assert = require("assert");
|
|
4
|
+
const glossary = require("../").glossary;
|
|
5
|
+
describe("Glossary parsing", () => {
|
|
6
|
+
let LEXED;
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
const CONTENT = fs.readFileSync(path.join(__dirname, "./fixtures/GLOSSARY.md"), "utf8");
|
|
9
|
+
LEXED = glossary(CONTENT);
|
|
10
|
+
});
|
|
11
|
+
it("should only get heading + paragraph pairs", () => {
|
|
12
|
+
assert.equal(LEXED.length, 4);
|
|
13
|
+
});
|
|
14
|
+
it("should output simple name/description objects", () => {
|
|
15
|
+
assert.equal(true, !LEXED.some((e) => {
|
|
16
|
+
return !(e.name && e.description);
|
|
17
|
+
}));
|
|
18
|
+
});
|
|
19
|
+
it("should correctly convert it to text", () => {
|
|
20
|
+
const text = glossary.toText(LEXED);
|
|
21
|
+
assert.deepEqual(glossary(text), LEXED);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const assert = require("assert");
|
|
4
|
+
const inline = require("../").inline;
|
|
5
|
+
describe("Inline", () => {
|
|
6
|
+
it("should render inline markdown", () => {
|
|
7
|
+
assert.equal(inline("Hello **World**").content, "Hello <strong>World</strong>");
|
|
8
|
+
});
|
|
9
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const assert = require("assert");
|
|
4
|
+
const langs = require("../").langs;
|
|
5
|
+
describe("Languages parsing", () => {
|
|
6
|
+
let LEXED;
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
const CONTENT = fs.readFileSync(path.join(__dirname, "./fixtures/LANGS.md"), "utf8");
|
|
9
|
+
LEXED = langs(CONTENT);
|
|
10
|
+
});
|
|
11
|
+
it("should detect paths and titles", () => {
|
|
12
|
+
assert.equal(LEXED.length, 2);
|
|
13
|
+
assert.equal(LEXED[0].ref, "en/");
|
|
14
|
+
assert.equal(LEXED[0].title, "English");
|
|
15
|
+
assert.equal(LEXED[1].ref, "fr/");
|
|
16
|
+
assert.equal(LEXED[1].title, "French");
|
|
17
|
+
});
|
|
18
|
+
it("should correctly convert it to text", () => {
|
|
19
|
+
const text = langs.toText(LEXED);
|
|
20
|
+
assert.deepEqual(langs(text), LEXED);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const assert = require("assert");
|
|
4
|
+
const page = require("../").page;
|
|
5
|
+
describe("Page parsing", () => {
|
|
6
|
+
let LEXED;
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
const CONTENT = fs.readFileSync(path.join(__dirname, "./fixtures/PAGE.md"), "utf8");
|
|
9
|
+
LEXED = page(CONTENT);
|
|
10
|
+
});
|
|
11
|
+
it("should gen content", () => {
|
|
12
|
+
assert(LEXED.content);
|
|
13
|
+
});
|
|
14
|
+
it("should not add id to headings", () => {
|
|
15
|
+
assert.equal(page("# Hello").content, "<h1>Hello</h1>");
|
|
16
|
+
assert.equal(page("# Hello {#test}").content, '<h1 id="test">Hello</h1>');
|
|
17
|
+
});
|
|
18
|
+
it("should escape codeblocks in preparation (1)", () => {
|
|
19
|
+
assert.equal(page.prepare("Hello `world`"), "Hello {% raw %}`world`{% endraw %}\n\n");
|
|
20
|
+
assert.equal(page.prepare("Hello `world test`"), "Hello {% raw %}`world test`{% endraw %}\n\n");
|
|
21
|
+
assert.equal(page.prepare("Hello ```world test```"), "Hello {% raw %}`world test`{% endraw %}\n\n");
|
|
22
|
+
assert.equal(page.prepare("Hello\n```js\nworld test\n```\n"), "Hello\n\n{% raw %}```js\nworld test\n```\n\n{% endraw %}");
|
|
23
|
+
expect(page.prepare("Hello\n```\ntest\n\tworld\n\ttest\n```")).toMatchInlineSnapshot(`
|
|
24
|
+
"Hello
|
|
25
|
+
|
|
26
|
+
{% raw %}\`\`\`
|
|
27
|
+
test
|
|
28
|
+
world
|
|
29
|
+
test
|
|
30
|
+
\`\`\`
|
|
31
|
+
|
|
32
|
+
{% endraw %}"
|
|
33
|
+
`);
|
|
34
|
+
// preserve \t in CodeBlock
|
|
35
|
+
expect(page.prepare("Hello\n```js\n\tvar a = 1;\n\tconsole.log(a);\n```")).toMatchInlineSnapshot(`
|
|
36
|
+
"Hello
|
|
37
|
+
|
|
38
|
+
{% raw %}\`\`\`js
|
|
39
|
+
var a = 1;
|
|
40
|
+
console.log(a);
|
|
41
|
+
\`\`\`
|
|
42
|
+
|
|
43
|
+
{% endraw %}"
|
|
44
|
+
`);
|
|
45
|
+
});
|
|
46
|
+
it("should escape codeblocks in preparation (2)", () => {
|
|
47
|
+
expect(page.prepare(`Hello
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
\tworld
|
|
51
|
+
\thello
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
test`)).toMatchInlineSnapshot(`
|
|
55
|
+
"Hello
|
|
56
|
+
|
|
57
|
+
{% raw %} world
|
|
58
|
+
hello
|
|
59
|
+
|
|
60
|
+
{% endraw %}test
|
|
61
|
+
|
|
62
|
+
"
|
|
63
|
+
`);
|
|
64
|
+
expect(page.prepare(`Hello
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
\tworld
|
|
68
|
+
\thello
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
`)).toMatchInlineSnapshot(`
|
|
72
|
+
"Hello
|
|
73
|
+
|
|
74
|
+
{% raw %} world
|
|
75
|
+
hello
|
|
76
|
+
|
|
77
|
+
{% endraw %}"
|
|
78
|
+
`);
|
|
79
|
+
});
|
|
80
|
+
it("should escape codeblocks with nunjucks tags", () => {
|
|
81
|
+
assert.equal(page.prepare('Hello {{ "Bonjour" }} ```test```'), 'Hello {{ "Bonjour" }} {% raw %}`test`{% endraw %}\n\n');
|
|
82
|
+
});
|
|
83
|
+
it("should escape codeblocks with nunjucks tags in {% raw %} tags", () => {
|
|
84
|
+
assert.equal(page.prepare('{% raw %}Hello {{ "Bonjour" }} ```test```{% endraw %}'), '{% raw %}Hello {{ "Bonjour" }} `test`{% endraw %}\n\n');
|
|
85
|
+
assert.equal(page.prepare('{% raw %}Hello {{ "Bonjour" }} {% raw %}{% endraw %}```test```'), '{% raw %}Hello {{ "Bonjour" }} {% raw %}{% endraw %}{% raw %}`test`{% endraw %}\n\n');
|
|
86
|
+
assert.equal(page.prepare('```{% raw %}Hello {{ "Bonjour" }} {% raw %}```'), '{% raw %}`{% raw %}Hello {{ "Bonjour" }} {% raw %}`{% endraw %}\n\n');
|
|
87
|
+
assert.equal(page.prepare("```\ntest\n```\n\n\n### Test"), "{% raw %}```\ntest\n```\n\n{% endraw %}### Test\n\n");
|
|
88
|
+
});
|
|
89
|
+
it("escape {% uml %} block tags + Indented code block", () => {
|
|
90
|
+
const code = `{% uml %}
|
|
91
|
+
@startuml
|
|
92
|
+
|
|
93
|
+
\tClass Stage
|
|
94
|
+
\tClass Timeout {
|
|
95
|
+
\t\t+constructor:function(cfg)
|
|
96
|
+
\t\t+timeout:function(ctx)
|
|
97
|
+
\t\t+overdue:function(ctx)
|
|
98
|
+
\t\t+stage: Stage
|
|
99
|
+
\t}
|
|
100
|
+
\tStage <|-- Timeout
|
|
101
|
+
|
|
102
|
+
@enduml
|
|
103
|
+
{% enduml %}
|
|
104
|
+
`;
|
|
105
|
+
expect(page.prepare(code)).toMatchInlineSnapshot(`
|
|
106
|
+
"{% uml %}
|
|
107
|
+
@startuml
|
|
108
|
+
|
|
109
|
+
{% raw %} Class Stage
|
|
110
|
+
Class Timeout {
|
|
111
|
+
+constructor:function(cfg)
|
|
112
|
+
+timeout:function(ctx)
|
|
113
|
+
+overdue:function(ctx)
|
|
114
|
+
+stage: Stage
|
|
115
|
+
}
|
|
116
|
+
Stage <|-- Timeout
|
|
117
|
+
|
|
118
|
+
{% endraw %}@enduml
|
|
119
|
+
{% enduml %}
|
|
120
|
+
|
|
121
|
+
"
|
|
122
|
+
`);
|
|
123
|
+
});
|
|
124
|
+
it("should not process math", () => {
|
|
125
|
+
assert.equal(page.prepare("Hello $world$"), "Hello $world$\n\n");
|
|
126
|
+
assert.equal(page.prepare("Hello $$world$$"), "Hello $$world$$\n\n");
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const assert = require("assert");
|
|
4
|
+
const readme = require("../").readme;
|
|
5
|
+
describe("Readme parsing", () => {
|
|
6
|
+
let LEXED;
|
|
7
|
+
beforeAll(() => {
|
|
8
|
+
const CONTENT = fs.readFileSync(path.join(__dirname, "./fixtures/README.md"), "utf8");
|
|
9
|
+
LEXED = readme(CONTENT);
|
|
10
|
+
});
|
|
11
|
+
it("should contain a title", () => {
|
|
12
|
+
assert(LEXED.title);
|
|
13
|
+
});
|
|
14
|
+
it("should contain a description", () => {
|
|
15
|
+
assert(LEXED.description);
|
|
16
|
+
});
|
|
17
|
+
it("should extract the right title", () => {
|
|
18
|
+
assert.equal(LEXED.title, "This is the title");
|
|
19
|
+
});
|
|
20
|
+
it("should extract the right description", () => {
|
|
21
|
+
assert.equal(LEXED.description, "This is the book description.");
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const fs = require("fs");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const assert = require("assert");
|
|
4
|
+
const summary = require("../").summary;
|
|
5
|
+
function lex(fixtureFile) {
|
|
6
|
+
return summary(fs.readFileSync(path.join(__dirname, "fixtures", fixtureFile), "utf8"));
|
|
7
|
+
}
|
|
8
|
+
describe("Summary parsing", () => {
|
|
9
|
+
let LEXED;
|
|
10
|
+
beforeAll(() => {
|
|
11
|
+
LEXED = lex("SUMMARY.md");
|
|
12
|
+
PART = LEXED.parts[0];
|
|
13
|
+
});
|
|
14
|
+
it("should detect chapters", () => {
|
|
15
|
+
assert.equal(PART.articles.length, 5);
|
|
16
|
+
});
|
|
17
|
+
it("should support articles", () => {
|
|
18
|
+
assert.equal(PART.articles[0].articles.length, 2);
|
|
19
|
+
assert.equal(PART.articles[1].articles.length, 0);
|
|
20
|
+
assert.equal(PART.articles[2].articles.length, 0);
|
|
21
|
+
});
|
|
22
|
+
it("should detect paths and titles", () => {
|
|
23
|
+
assert(PART.articles[0].ref);
|
|
24
|
+
assert(PART.articles[1].ref);
|
|
25
|
+
assert(PART.articles[2].ref);
|
|
26
|
+
assert(PART.articles[3].ref);
|
|
27
|
+
assert.equal(PART.articles[4].ref, null);
|
|
28
|
+
assert(PART.articles[0].title);
|
|
29
|
+
assert(PART.articles[1].title);
|
|
30
|
+
assert(PART.articles[2].title);
|
|
31
|
+
assert(PART.articles[3].title);
|
|
32
|
+
assert(PART.articles[4].title);
|
|
33
|
+
});
|
|
34
|
+
it("should normalize paths from .md", () => {
|
|
35
|
+
assert.equal(PART.articles[0].ref, "chapter-1/README.md");
|
|
36
|
+
assert.equal(PART.articles[1].ref, "chapter-2/README.md");
|
|
37
|
+
assert.equal(PART.articles[2].ref, "chapter-3/README.md");
|
|
38
|
+
});
|
|
39
|
+
it("should part parts", () => {
|
|
40
|
+
const l = lex("SUMMARY_PARTS.md");
|
|
41
|
+
assert.equal(l.parts.length, 3);
|
|
42
|
+
});
|
|
43
|
+
it("should allow lists separated by whitespace", () => {
|
|
44
|
+
const l = lex("SUMMARY_WHITESPACE.md");
|
|
45
|
+
assert.equal(l.parts[0].articles.length, 5);
|
|
46
|
+
});
|
|
47
|
+
it("should allow ignore empty entries", () => {
|
|
48
|
+
const l = lex("SUMMARY_EMPTY.md");
|
|
49
|
+
assert.equal(l.parts[0].articles.length, 1);
|
|
50
|
+
});
|
|
51
|
+
it("should correctly convert it to text", () => {
|
|
52
|
+
const text = summary.toText(LEXED);
|
|
53
|
+
assert.deepEqual(summary(text), LEXED);
|
|
54
|
+
});
|
|
55
|
+
});
|
package/lib/toMarkdown.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honkit/markdown",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.7.2",
|
|
4
4
|
"description": "Parse markdown content for honkit",
|
|
5
5
|
"homepage": "https://github.com/honkit/honkit",
|
|
6
6
|
"bugs": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@honkit/html": "^3.6.17",
|
|
42
|
-
"@honkit/markup-it": "^3.
|
|
42
|
+
"@honkit/markup-it": "^3.7.2",
|
|
43
43
|
"markdown-escape": "^1.0.1"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
@@ -49,5 +49,5 @@
|
|
|
49
49
|
"publishConfig": {
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
|
-
"gitHead": "
|
|
52
|
+
"gitHead": "89e4ff9d86596d7c650c5e83e2d768435d6eef20"
|
|
53
53
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
-
|
|
6
|
-
## [3.6.17](https://github.com/honkit/honkit/compare/v3.6.16...v3.6.17) (2021-02-15)
|
|
7
|
-
|
|
8
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
## 3.6.16 (2020-12-15)
|
|
15
|
-
|
|
16
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
## 3.6.15 (2020-12-05)
|
|
23
|
-
|
|
24
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## 3.6.14 (2020-11-29)
|
|
31
|
-
|
|
32
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
## 3.6.13 (2020-11-17)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
### Bug Fixes
|
|
42
|
-
|
|
43
|
-
* **honkit:** browser print layout in default theme ([#159](https://github.com/honkit/honkit/issues/159)) ([672cb9c](https://github.com/honkit/honkit/commit/672cb9c92f90dd154793b7a36d4dbf2654e7aec4))
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
## 3.6.12 (2020-11-13)
|
|
50
|
-
|
|
51
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
## [3.5.5](https://github.com/honkit/honkit/compare/v3.5.4...v3.5.5) (2020-08-02)
|
|
58
|
-
|
|
59
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
## [3.5.4](https://github.com/honkit/honkit/compare/v3.5.3...v3.5.4) (2020-08-01)
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
### Bug Fixes
|
|
69
|
-
|
|
70
|
-
* add prepublish script ([810fcc7](https://github.com/honkit/honkit/commit/810fcc7f45f3b1ab8d9527e8738f9861fdbe2c31))
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
## [3.5.1](https://github.com/honkit/honkit/compare/v3.5.0...v3.5.1) (2020-07-04)
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
### Bug Fixes
|
|
80
|
-
|
|
81
|
-
* **honkit:** use @honkit/markdown-legacy instead of @honkit/markdown ([e8549d5](https://github.com/honkit/honkit/commit/e8549d573603becc9f145a7c9cef5fd4ff013262))
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
## [3.4.1](https://github.com/honkit/honkit/compare/v3.4.0...v3.4.1) (2020-06-29)
|
|
88
|
-
|
|
89
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
## [3.3.11](https://github.com/honkit/honkit/compare/v3.3.10...v3.3.11) (2020-06-27)
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
### Bug Fixes
|
|
99
|
-
|
|
100
|
-
* **markdown:** Do not force convert Indented CodeBlock to Fenced code blocks ([#60](https://github.com/honkit/honkit/issues/60)) ([ef55687](https://github.com/honkit/honkit/commit/ef556874f42d27a4d7b323acbc92fcadd579d034))
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
## [3.3.8](https://github.com/honkit/honkit/compare/v3.3.7...v3.3.8) (2020-06-18)
|
|
107
|
-
|
|
108
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
## [3.3.7](https://github.com/honkit/honkit/compare/v3.3.6...v3.3.7) (2020-06-18)
|
|
115
|
-
|
|
116
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
## [3.3.6](https://github.com/honkit/honkit/compare/v3.3.5...v3.3.6) (2020-06-18)
|
|
123
|
-
|
|
124
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
## [3.3.5](https://github.com/honkit/honkit/compare/v3.3.4...v3.3.5) (2020-06-18)
|
|
131
|
-
|
|
132
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
## [3.3.4](https://github.com/honkit/honkit/compare/v3.3.3...v3.3.4) (2020-06-17)
|
|
139
|
-
|
|
140
|
-
**Note:** Version bump only for package @honkit/markdown
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
## [3.3.1](https://github.com/honkit/honkit/compare/v3.3.0...v3.3.1) (2020-06-15)
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
### Bug Fixes
|
|
150
|
-
|
|
151
|
-
* **markdown:** fix markdown parser ([2a1d670](https://github.com/honkit/honkit/commit/2a1d6705521da848233b3518b5adab871a8dc5fb))
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
# 3.3.0 (2020-06-14)
|
|
158
|
-
|
|
159
|
-
**Note:** Version bump only for package @honkit/markdown
|