@honkit/markup-it 6.0.4 → 6.1.5
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__/syntax.d.ts +2 -0
- package/lib/__tests__/syntax.d.ts.map +1 -0
- package/lib/__tests__/syntax.js +92 -0
- package/lib/json/__tests__/decode.d.ts +2 -0
- package/lib/json/__tests__/decode.d.ts.map +1 -0
- package/lib/json/__tests__/decode.js +38 -0
- package/lib/json/__tests__/encode.d.ts +2 -0
- package/lib/json/__tests__/encode.d.ts.map +1 -0
- package/lib/json/__tests__/encode.js +26 -0
- package/lib/models/__tests__/token.d.ts +2 -0
- package/lib/models/__tests__/token.d.ts.map +1 -0
- package/lib/models/__tests__/token.js +18 -0
- package/lib/parse/__tests__/mergeTokens.d.ts +2 -0
- package/lib/parse/__tests__/mergeTokens.d.ts.map +1 -0
- package/lib/parse/__tests__/mergeTokens.js +51 -0
- package/lib/parse/textToUnstyledTokens.d.ts.map +1 -1
- package/package.json +14 -15
- package/syntaxes/markdown/__tests__/normalizeTeX.spec.js +34 -0
- package/syntaxes/markdown/__tests__/specs/amps_and_angles_encoding.html +17 -0
- package/syntaxes/markdown/__tests__/specs/amps_and_angles_encoding.md +21 -0
- package/syntaxes/markdown/__tests__/specs/auto_links.html +18 -0
- package/syntaxes/markdown/__tests__/specs/auto_links.md +13 -0
- package/syntaxes/markdown/__tests__/specs/autolink_lines.html +3 -0
- package/syntaxes/markdown/__tests__/specs/autolink_lines.md +2 -0
- package/syntaxes/markdown/__tests__/specs/backslash_escapes.html +118 -0
- package/syntaxes/markdown/__tests__/specs/backslash_escapes.md +120 -0
- package/syntaxes/markdown/__tests__/specs/blockquote_list_item.html +3 -0
- package/syntaxes/markdown/__tests__/specs/blockquote_list_item.md +4 -0
- package/syntaxes/markdown/__tests__/specs/blockquotes_with_code_blocks.html +15 -0
- package/syntaxes/markdown/__tests__/specs/blockquotes_with_code_blocks.md +11 -0
- package/syntaxes/markdown/__tests__/specs/case_insensitive_refs.html +1 -0
- package/syntaxes/markdown/__tests__/specs/case_insensitive_refs.md +3 -0
- package/syntaxes/markdown/__tests__/specs/code_blocks.html +18 -0
- package/syntaxes/markdown/__tests__/specs/code_blocks.md +14 -0
- package/syntaxes/markdown/__tests__/specs/code_blocks_indent.html +13 -0
- package/syntaxes/markdown/__tests__/specs/code_blocks_indent.md +14 -0
- package/syntaxes/markdown/__tests__/specs/code_spans.html +6 -0
- package/syntaxes/markdown/__tests__/specs/code_spans.md +6 -0
- package/syntaxes/markdown/__tests__/specs/def_blocks.html +30 -0
- package/syntaxes/markdown/__tests__/specs/def_blocks.md +21 -0
- package/syntaxes/markdown/__tests__/specs/double_link.html +5 -0
- package/syntaxes/markdown/__tests__/specs/double_link.md +5 -0
- package/syntaxes/markdown/__tests__/specs/escaped_angles.html +1 -0
- package/syntaxes/markdown/__tests__/specs/escaped_angles.md +1 -0
- package/syntaxes/markdown/__tests__/specs/footnotes.html +4 -0
- package/syntaxes/markdown/__tests__/specs/footnotes.md +3 -0
- package/syntaxes/markdown/__tests__/specs/gfm_break.breaks.html +3 -0
- package/syntaxes/markdown/__tests__/specs/gfm_break.breaks.md +3 -0
- package/syntaxes/markdown/__tests__/specs/gfm_code.html +5 -0
- package/syntaxes/markdown/__tests__/specs/gfm_code.md +16 -0
- package/syntaxes/markdown/__tests__/specs/gfm_code_hr_list.html +52 -0
- package/syntaxes/markdown/__tests__/specs/gfm_code_hr_list.md +53 -0
- package/syntaxes/markdown/__tests__/specs/gfm_del.html +1 -0
- package/syntaxes/markdown/__tests__/specs/gfm_del.md +1 -0
- package/syntaxes/markdown/__tests__/specs/gfm_em.html +1 -0
- package/syntaxes/markdown/__tests__/specs/gfm_em.md +1 -0
- package/syntaxes/markdown/__tests__/specs/gfm_links.html +2 -0
- package/syntaxes/markdown/__tests__/specs/gfm_links.md +1 -0
- package/syntaxes/markdown/__tests__/specs/gfm_tables.html +37 -0
- package/syntaxes/markdown/__tests__/specs/gfm_tables.md +21 -0
- package/syntaxes/markdown/__tests__/specs/hard_wrapped_paragraphs_with_list_like_lines.nogfm.html +10 -0
- package/syntaxes/markdown/__tests__/specs/hard_wrapped_paragraphs_with_list_like_lines.nogfm.md +8 -0
- package/syntaxes/markdown/__tests__/specs/horizontal_rules.html +71 -0
- package/syntaxes/markdown/__tests__/specs/horizontal_rules.md +67 -0
- package/syntaxes/markdown/__tests__/specs/hr_list_break.html +10 -0
- package/syntaxes/markdown/__tests__/specs/hr_list_break.md +6 -0
- package/syntaxes/markdown/__tests__/specs/image.html +5 -0
- package/syntaxes/markdown/__tests__/specs/image.md +3 -0
- package/syntaxes/markdown/__tests__/specs/inline_html.html +6 -0
- package/syntaxes/markdown/__tests__/specs/inline_html.md +6 -0
- package/syntaxes/markdown/__tests__/specs/inline_html_advanced.html +15 -0
- package/syntaxes/markdown/__tests__/specs/inline_html_advanced.md +15 -0
- package/syntaxes/markdown/__tests__/specs/inline_html_comments.html +13 -0
- package/syntaxes/markdown/__tests__/specs/inline_html_comments.md +13 -0
- package/syntaxes/markdown/__tests__/specs/inline_html_script.html +3 -0
- package/syntaxes/markdown/__tests__/specs/inline_html_script.md +3 -0
- package/syntaxes/markdown/__tests__/specs/inline_html_simple.html +72 -0
- package/syntaxes/markdown/__tests__/specs/inline_html_simple.md +69 -0
- package/syntaxes/markdown/__tests__/specs/lazy_blockquotes.html +4 -0
- package/syntaxes/markdown/__tests__/specs/lazy_blockquotes.md +2 -0
- package/syntaxes/markdown/__tests__/specs/links_inline_style.html +15 -0
- package/syntaxes/markdown/__tests__/specs/links_inline_style.md +15 -0
- package/syntaxes/markdown/__tests__/specs/links_reference_style.html +52 -0
- package/syntaxes/markdown/__tests__/specs/links_reference_style.md +71 -0
- package/syntaxes/markdown/__tests__/specs/links_shortcut_references.html +9 -0
- package/syntaxes/markdown/__tests__/specs/links_shortcut_references.md +20 -0
- package/syntaxes/markdown/__tests__/specs/list_item_text.html +1 -0
- package/syntaxes/markdown/__tests__/specs/list_item_text.md +5 -0
- package/syntaxes/markdown/__tests__/specs/literal_quotes_in_titles.html +3 -0
- package/syntaxes/markdown/__tests__/specs/literal_quotes_in_titles.md +7 -0
- package/syntaxes/markdown/__tests__/specs/loose_lists.html +62 -0
- package/syntaxes/markdown/__tests__/specs/loose_lists.md +59 -0
- package/syntaxes/markdown/__tests__/specs/main.html +71 -0
- package/syntaxes/markdown/__tests__/specs/main.md +58 -0
- package/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.html +314 -0
- package/syntaxes/markdown/__tests__/specs/markdown_documentation_basics.md +306 -0
- package/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.html +942 -0
- package/syntaxes/markdown/__tests__/specs/markdown_documentation_syntax.md +888 -0
- package/syntaxes/markdown/__tests__/specs/nested_blockquotes.html +9 -0
- package/syntaxes/markdown/__tests__/specs/nested_blockquotes.md +5 -0
- package/syntaxes/markdown/__tests__/specs/nested_code.html +1 -0
- package/syntaxes/markdown/__tests__/specs/nested_code.md +1 -0
- package/syntaxes/markdown/__tests__/specs/nested_em.html +3 -0
- package/syntaxes/markdown/__tests__/specs/nested_em.md +3 -0
- package/syntaxes/markdown/__tests__/specs/nested_square_link.html +1 -0
- package/syntaxes/markdown/__tests__/specs/nested_square_link.md +1 -0
- package/syntaxes/markdown/__tests__/specs/not_a_link.html +1 -0
- package/syntaxes/markdown/__tests__/specs/not_a_link.md +1 -0
- package/syntaxes/markdown/__tests__/specs/ordered_and_unordered_lists.html +148 -0
- package/syntaxes/markdown/__tests__/specs/ordered_and_unordered_lists.md +131 -0
- package/syntaxes/markdown/__tests__/specs/ref_paren.html +1 -0
- package/syntaxes/markdown/__tests__/specs/ref_paren.md +3 -0
- package/syntaxes/markdown/__tests__/specs/same_bullet.html +5 -0
- package/syntaxes/markdown/__tests__/specs/same_bullet.md +3 -0
- package/syntaxes/markdown/__tests__/specs/simple_paragraph.html +1 -0
- package/syntaxes/markdown/__tests__/specs/simple_paragraph.md +1 -0
- package/syntaxes/markdown/__tests__/specs/strong_and_em_together.html +7 -0
- package/syntaxes/markdown/__tests__/specs/strong_and_em_together.md +7 -0
- package/syntaxes/markdown/__tests__/specs/table_pipe.html +5 -0
- package/syntaxes/markdown/__tests__/specs/table_pipe.md +4 -0
- package/syntaxes/markdown/__tests__/specs/tabs.html +25 -0
- package/syntaxes/markdown/__tests__/specs/tabs.md +21 -0
- package/syntaxes/markdown/__tests__/specs/tidyness.html +8 -0
- package/syntaxes/markdown/__tests__/specs/tidyness.md +5 -0
- package/syntaxes/markdown/__tests__/specs/toplevel_paragraphs.gfm.html +34 -0
- package/syntaxes/markdown/__tests__/specs/toplevel_paragraphs.gfm.md +37 -0
- package/syntaxes/markdown/__tests__/specs/tricky_list.html +23 -0
- package/syntaxes/markdown/__tests__/specs/tricky_list.md +15 -0
- package/syntaxes/markdown/__tests__/specs.js +74 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syntax.d.ts","sourceRoot":"","sources":["../../src/__tests__/syntax.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
const MarkupIt = __importStar(require(".."));
|
|
28
|
+
describe("Custom Syntax", () => {
|
|
29
|
+
const syntax = MarkupIt.Syntax("mysyntax", {
|
|
30
|
+
inline: [
|
|
31
|
+
MarkupIt.Rule(MarkupIt.STYLES.BOLD)
|
|
32
|
+
.regExp(/^\*\*([\s\S]+?)\*\*/, (state, match) => {
|
|
33
|
+
return {
|
|
34
|
+
text: match[1],
|
|
35
|
+
};
|
|
36
|
+
})
|
|
37
|
+
.toText("**%s**"),
|
|
38
|
+
],
|
|
39
|
+
});
|
|
40
|
+
const markup = new MarkupIt.Markup(syntax);
|
|
41
|
+
describe(".toContent", () => {
|
|
42
|
+
it("should return correct syntax name", () => {
|
|
43
|
+
const content = markup.toContent("Hello");
|
|
44
|
+
content.getSyntax().should.equal("mysyntax");
|
|
45
|
+
});
|
|
46
|
+
it("should parse as unstyled", () => {
|
|
47
|
+
const content = markup.toContent("Hello World");
|
|
48
|
+
const doc = content.getToken();
|
|
49
|
+
const blocks = doc.getTokens();
|
|
50
|
+
blocks.size.should.equal(1);
|
|
51
|
+
const p = blocks.get(0);
|
|
52
|
+
p.getType().should.equal(MarkupIt.BLOCKS.TEXT);
|
|
53
|
+
p.getAsPlainText().should.equal("Hello World");
|
|
54
|
+
});
|
|
55
|
+
it("should parse inline", () => {
|
|
56
|
+
const content = markup.toContent("Hello **World**");
|
|
57
|
+
const doc = content.getToken();
|
|
58
|
+
const blocks = doc.getTokens();
|
|
59
|
+
blocks.size.should.equal(1);
|
|
60
|
+
const p = blocks.get(0);
|
|
61
|
+
p.getType().should.equal(MarkupIt.BLOCKS.TEXT);
|
|
62
|
+
p.getAsPlainText().should.equal("Hello World");
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe(".toText", () => {
|
|
66
|
+
it("should output correct string", () => {
|
|
67
|
+
const content = MarkupIt.JSONUtils.decode({
|
|
68
|
+
syntax: "mysyntax",
|
|
69
|
+
token: {
|
|
70
|
+
type: MarkupIt.BLOCKS.DOCUMENT,
|
|
71
|
+
tokens: [
|
|
72
|
+
{
|
|
73
|
+
type: MarkupIt.BLOCKS.PARAGRAPH,
|
|
74
|
+
tokens: [
|
|
75
|
+
{
|
|
76
|
+
type: MarkupIt.STYLES.TEXT,
|
|
77
|
+
text: "Hello ",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
type: MarkupIt.STYLES.BOLD,
|
|
81
|
+
text: "World",
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
const text = markup.toText(content);
|
|
89
|
+
text.should.equal("Hello **World**\n");
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../src/json/__tests__/decode.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
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 decode_1 = __importDefault(require("../decode"));
|
|
7
|
+
const blocks_1 = __importDefault(require("../../constants/blocks"));
|
|
8
|
+
describe("decode", () => {
|
|
9
|
+
let content;
|
|
10
|
+
beforeAll(() => {
|
|
11
|
+
content = (0, decode_1.default)({
|
|
12
|
+
syntax: "mysyntax",
|
|
13
|
+
token: {
|
|
14
|
+
type: blocks_1.default.DOCUMENT,
|
|
15
|
+
tokens: [
|
|
16
|
+
{
|
|
17
|
+
type: blocks_1.default.PARAGRAPH,
|
|
18
|
+
text: "Hello World",
|
|
19
|
+
raw: "Hello World",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
it("should decode syntax name", () => {
|
|
26
|
+
content.getSyntax().should.equal("mysyntax");
|
|
27
|
+
});
|
|
28
|
+
it("should decode tokens tree", () => {
|
|
29
|
+
const doc = content.getToken();
|
|
30
|
+
const tokens = doc.getTokens();
|
|
31
|
+
tokens.size.should.equal(1);
|
|
32
|
+
const p = tokens.get(0);
|
|
33
|
+
p.getType().should.equal(blocks_1.default.PARAGRAPH);
|
|
34
|
+
p.getText().should.equal("Hello World");
|
|
35
|
+
p.getRaw().should.equal("Hello World");
|
|
36
|
+
p.getTokens().size.should.equal(0);
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../src/json/__tests__/encode.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 encode_1 = __importDefault(require("../encode"));
|
|
7
|
+
const blocks_1 = __importDefault(require("../../constants/blocks"));
|
|
8
|
+
describe("encode", () => {
|
|
9
|
+
let json;
|
|
10
|
+
beforeAll(() => {
|
|
11
|
+
// @ts-expect-error
|
|
12
|
+
json = (0, encode_1.default)(mock.paragraph);
|
|
13
|
+
});
|
|
14
|
+
it("should encode syntax name", () => {
|
|
15
|
+
json.syntax.should.equal("mysyntax");
|
|
16
|
+
});
|
|
17
|
+
it("should encode tokens", () => {
|
|
18
|
+
json.should.have.property("token");
|
|
19
|
+
const doc = json.token;
|
|
20
|
+
doc.tokens.should.have.lengthOf(1);
|
|
21
|
+
const p = doc.tokens[0];
|
|
22
|
+
p.type.should.equal(blocks_1.default.PARAGRAPH);
|
|
23
|
+
p.text.should.equal("Hello World");
|
|
24
|
+
p.tokens.should.be.an.Array().with.lengthOf(2);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/models/__tests__/token.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
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 token_1 = __importDefault(require("../token"));
|
|
7
|
+
const styles_1 = __importDefault(require("../../constants/styles"));
|
|
8
|
+
describe("Token", () => {
|
|
9
|
+
describe(".mergeWith", () => {
|
|
10
|
+
it("should merge text and raw", () => {
|
|
11
|
+
const base = token_1.default.createText("Hello ");
|
|
12
|
+
const other = token_1.default.createText("world");
|
|
13
|
+
const token = base.mergeWith(other);
|
|
14
|
+
token.getType().should.equal(styles_1.default.TEXT);
|
|
15
|
+
token.getText().should.equal("Hello world");
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeTokens.d.ts","sourceRoot":"","sources":["../../../src/parse/__tests__/mergeTokens.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
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 token_1 = __importDefault(require("../../models/token"));
|
|
8
|
+
const styles_1 = __importDefault(require("../../constants/styles"));
|
|
9
|
+
const mergeTokens_1 = __importDefault(require("../mergeTokens"));
|
|
10
|
+
describe("mergeTokens", () => {
|
|
11
|
+
it("should merge two tokens", () => {
|
|
12
|
+
const tokens = immutable_1.default.List([token_1.default.createText("Hello "), token_1.default.createText("world")]);
|
|
13
|
+
const merged = (0, mergeTokens_1.default)(tokens, [styles_1.default.TEXT]);
|
|
14
|
+
merged.size.should.equal(1);
|
|
15
|
+
const resultToken = merged.get(0);
|
|
16
|
+
resultToken.getType().should.equal(styles_1.default.TEXT);
|
|
17
|
+
resultToken.getText().should.equal("Hello world");
|
|
18
|
+
});
|
|
19
|
+
it("should merge three tokens", () => {
|
|
20
|
+
const tokens = immutable_1.default.List([token_1.default.createText("Hello "), token_1.default.createText("world"), token_1.default.createText("!")]);
|
|
21
|
+
const merged = (0, mergeTokens_1.default)(tokens, [styles_1.default.TEXT]);
|
|
22
|
+
merged.size.should.equal(1);
|
|
23
|
+
const resultToken = merged.get(0);
|
|
24
|
+
resultToken.getType().should.equal(styles_1.default.TEXT);
|
|
25
|
+
resultToken.getText().should.equal("Hello world!");
|
|
26
|
+
});
|
|
27
|
+
it("should merge 2x2 tokens", () => {
|
|
28
|
+
const tokens = immutable_1.default.List([
|
|
29
|
+
token_1.default.createText("Hello "),
|
|
30
|
+
token_1.default.createText("world"),
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
new token_1.default({
|
|
33
|
+
type: styles_1.default.BOLD,
|
|
34
|
+
text: ", right?",
|
|
35
|
+
}),
|
|
36
|
+
token_1.default.createText("!"),
|
|
37
|
+
token_1.default.createText("!"),
|
|
38
|
+
]);
|
|
39
|
+
const merged = (0, mergeTokens_1.default)(tokens, [styles_1.default.TEXT]);
|
|
40
|
+
merged.size.should.equal(3);
|
|
41
|
+
const first = merged.get(0);
|
|
42
|
+
const bold = merged.get(1);
|
|
43
|
+
const second = merged.get(2);
|
|
44
|
+
first.getType().should.equal(styles_1.default.TEXT);
|
|
45
|
+
first.getText().should.equal("Hello world");
|
|
46
|
+
bold.getType().should.equal(styles_1.default.BOLD);
|
|
47
|
+
bold.getText().should.equal(", right?");
|
|
48
|
+
second.getType().should.equal(styles_1.default.TEXT);
|
|
49
|
+
second.getText().should.equal("!!");
|
|
50
|
+
});
|
|
51
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textToUnstyledTokens.d.ts","sourceRoot":"","sources":["../../src/parse/textToUnstyledTokens.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAkBlC;;;;;;;GAOG;AACH,iBAAS,oBAAoB,CAAC,KAAK,KAAA,EAAE,QAAQ,KAAA,EAAE,IAAI,KAAA,
|
|
1
|
+
{"version":3,"file":"textToUnstyledTokens.d.ts","sourceRoot":"","sources":["../../src/parse/textToUnstyledTokens.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAkBlC;;;;;;;GAOG;AACH,iBAAS,oBAAoB,CAAC,KAAK,KAAA,EAAE,QAAQ,KAAA,EAAE,IAAI,KAAA,uBAgClD;AAED,eAAe,oBAAoB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honkit/markup-it",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.1.5",
|
|
4
4
|
"description": "Pipeline for working with markup input (for example Markdown)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"draft-js",
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"asciidoc",
|
|
9
9
|
"gitbook"
|
|
10
10
|
],
|
|
11
|
-
"homepage": "https://github.com/
|
|
11
|
+
"homepage": "https://github.com/honkit/honkit#readme",
|
|
12
12
|
"bugs": {
|
|
13
|
-
"url": "https://github.com/
|
|
13
|
+
"url": "https://github.com/honkit/honkit/issues"
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
|
17
|
-
"url": "
|
|
17
|
+
"url": "https://github.com/honkit/honkit.git"
|
|
18
18
|
},
|
|
19
19
|
"license": "Apache-2.0",
|
|
20
20
|
"author": "azu",
|
|
@@ -24,13 +24,6 @@
|
|
|
24
24
|
"syntaxes",
|
|
25
25
|
"!__tests__"
|
|
26
26
|
],
|
|
27
|
-
"scripts": {
|
|
28
|
-
"build": "tsc -p .",
|
|
29
|
-
"clean": "rimraf lib/",
|
|
30
|
-
"lint": "eslint .",
|
|
31
|
-
"test": "jest",
|
|
32
|
-
"prepublish": "npm run --if-present build"
|
|
33
|
-
},
|
|
34
27
|
"dependencies": {
|
|
35
28
|
"escape-string-regexp": "^4.0.0",
|
|
36
29
|
"html-entities": "^1.4.0",
|
|
@@ -41,7 +34,6 @@
|
|
|
41
34
|
"range-utils": "^1.1.0"
|
|
42
35
|
},
|
|
43
36
|
"devDependencies": {
|
|
44
|
-
"@honkit/cleaning-tools": "6.0.4",
|
|
45
37
|
"@types/jest": "^29.5.13",
|
|
46
38
|
"@types/node": "^22.7.4",
|
|
47
39
|
"eslint": "^9.12.0",
|
|
@@ -49,10 +41,17 @@
|
|
|
49
41
|
"jsdom": "^20.0.3",
|
|
50
42
|
"rimraf": "^6.0.1",
|
|
51
43
|
"should": "^13.2.3",
|
|
52
|
-
"ts-jest": "^29.2.5"
|
|
44
|
+
"ts-jest": "^29.2.5",
|
|
45
|
+
"@honkit/cleaning-tools": "6.1.5"
|
|
53
46
|
},
|
|
54
47
|
"publishConfig": {
|
|
55
48
|
"access": "public"
|
|
56
49
|
},
|
|
57
|
-
"
|
|
58
|
-
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsc -p .",
|
|
52
|
+
"clean": "rimraf lib/",
|
|
53
|
+
"lint": "eslint .",
|
|
54
|
+
"test": "jest",
|
|
55
|
+
"prepublish": "npm run --if-present build"
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const { normalizeTeX } = require("../math.js");
|
|
2
|
+
|
|
3
|
+
describe("normalizeTeX", () => {
|
|
4
|
+
it(`should normalize`, () => {
|
|
5
|
+
expect(normalizeTeX("$a$", true)).toMatchInlineSnapshot(`"$a$"`);
|
|
6
|
+
expect(normalizeTeX("$$a$$", true)).toMatchInlineSnapshot(`"$$a$$"`);
|
|
7
|
+
expect(normalizeTeX("$a$ $b$", true)).toMatchInlineSnapshot(`"$a$ $b$"`);
|
|
8
|
+
expect(normalizeTeX("$a$ $b$ $c$", true)).toMatchInlineSnapshot(`"$a$ $b$ $c$"`);
|
|
9
|
+
expect(normalizeTeX("$a$\n$b$", true)).toMatchInlineSnapshot(`
|
|
10
|
+
"$a$
|
|
11
|
+
$b$"
|
|
12
|
+
`);
|
|
13
|
+
expect(normalizeTeX("$a$\n\n$b$", true)).toMatchInlineSnapshot(`
|
|
14
|
+
"$a$
|
|
15
|
+
|
|
16
|
+
$b$"
|
|
17
|
+
`);
|
|
18
|
+
expect(normalizeTeX("$a$ $b$\n", true)).toMatchInlineSnapshot(`"$a$ $b$"`);
|
|
19
|
+
expect(normalizeTeX("$a$ $b$\n\n", true)).toMatchInlineSnapshot(`"$a$ $b$"`);
|
|
20
|
+
expect(normalizeTeX("$a$\n$b$\n", true)).toMatchInlineSnapshot(`
|
|
21
|
+
"$a$
|
|
22
|
+
$b$"
|
|
23
|
+
`);
|
|
24
|
+
expect(normalizeTeX("$a$\n\n$b$\n\n", true)).toMatchInlineSnapshot(`
|
|
25
|
+
"$a$
|
|
26
|
+
|
|
27
|
+
$b$"
|
|
28
|
+
`);
|
|
29
|
+
expect(normalizeTeX("$a$ $b$", true)).toMatchInlineSnapshot(`"$a$ $b$"`);
|
|
30
|
+
expect(normalizeTeX("$a$ $b$", true)).toMatchInlineSnapshot(`"$a$ $b$"`);
|
|
31
|
+
expect(normalizeTeX("$a$ $b$ $c$", true)).toMatchInlineSnapshot(`"$a$ $b$ $c$"`);
|
|
32
|
+
expect(normalizeTeX("$a$ $b$ $c$", true)).toMatchInlineSnapshot(`"$a$ $b$ $c$"`);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<p>AT&T has an ampersand in their name.</p>
|
|
2
|
+
|
|
3
|
+
<p>AT&T is another way to write it.</p>
|
|
4
|
+
|
|
5
|
+
<p>This & that.</p>
|
|
6
|
+
|
|
7
|
+
<p>4 < 5.</p>
|
|
8
|
+
|
|
9
|
+
<p>6 > 5.</p>
|
|
10
|
+
|
|
11
|
+
<p>Here's a <a href="http://example.com/?foo=1&bar=2">link</a> with an ampersand in the URL.</p>
|
|
12
|
+
|
|
13
|
+
<p>Here's a link with an amersand in the link text: <a href="http://att.com/" title="AT&T">AT&T</a>.</p>
|
|
14
|
+
|
|
15
|
+
<p>Here's an inline <a href="/script?foo=1&bar=2">link</a>.</p>
|
|
16
|
+
|
|
17
|
+
<p>Here's an inline <a href="/script?foo=1&bar=2">link</a>.</p>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
AT&T has an ampersand in their name.
|
|
2
|
+
|
|
3
|
+
AT&T is another way to write it.
|
|
4
|
+
|
|
5
|
+
This & that.
|
|
6
|
+
|
|
7
|
+
4 < 5.
|
|
8
|
+
|
|
9
|
+
6 > 5.
|
|
10
|
+
|
|
11
|
+
Here's a [link] [1] with an ampersand in the URL.
|
|
12
|
+
|
|
13
|
+
Here's a link with an amersand in the link text: [AT&T] [2].
|
|
14
|
+
|
|
15
|
+
Here's an inline [link](/script?foo=1&bar=2).
|
|
16
|
+
|
|
17
|
+
Here's an inline [link](</script?foo=1&bar=2>).
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
[1]: http://example.com/?foo=1&bar=2
|
|
21
|
+
[2]: http://att.com/ "AT&T"
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<p>Link: <a href="http://example.com/">http://example.com/</a>.</p>
|
|
2
|
+
|
|
3
|
+
<p>With an ampersand: <a href="http://example.com/?foo=1&bar=2">http://example.com/?foo=1&bar=2</a></p>
|
|
4
|
+
|
|
5
|
+
<ul>
|
|
6
|
+
<li>In a list?</li>
|
|
7
|
+
<li><a href="http://example.com/">http://example.com/</a></li>
|
|
8
|
+
<li>It should.</li>
|
|
9
|
+
</ul>
|
|
10
|
+
|
|
11
|
+
<blockquote>
|
|
12
|
+
<p>Blockquoted: <a href="http://example.com/">http://example.com/</a></p>
|
|
13
|
+
</blockquote>
|
|
14
|
+
|
|
15
|
+
<p>Auto-links should not occur here: <code><http://example.com/></code></p>
|
|
16
|
+
|
|
17
|
+
<pre><code>or here: <http://example.com/>
|
|
18
|
+
</code></pre>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
Link: <http://example.com/>.
|
|
2
|
+
|
|
3
|
+
With an ampersand: <http://example.com/?foo=1&bar=2>
|
|
4
|
+
|
|
5
|
+
* In a list?
|
|
6
|
+
* <http://example.com/>
|
|
7
|
+
* It should.
|
|
8
|
+
|
|
9
|
+
> Blockquoted: <http://example.com/>
|
|
10
|
+
|
|
11
|
+
Auto-links should not occur here: `<http://example.com/>`
|
|
12
|
+
|
|
13
|
+
or here: <http://example.com/>
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
<p>These should all get escaped:</p>
|
|
2
|
+
|
|
3
|
+
<p>Backslash: \</p>
|
|
4
|
+
|
|
5
|
+
<p>Backtick: `</p>
|
|
6
|
+
|
|
7
|
+
<p>Asterisk: *</p>
|
|
8
|
+
|
|
9
|
+
<p>Underscore: _</p>
|
|
10
|
+
|
|
11
|
+
<p>Left brace: {</p>
|
|
12
|
+
|
|
13
|
+
<p>Right brace: }</p>
|
|
14
|
+
|
|
15
|
+
<p>Left bracket: [</p>
|
|
16
|
+
|
|
17
|
+
<p>Right bracket: ]</p>
|
|
18
|
+
|
|
19
|
+
<p>Left paren: (</p>
|
|
20
|
+
|
|
21
|
+
<p>Right paren: )</p>
|
|
22
|
+
|
|
23
|
+
<p>Greater-than: ></p>
|
|
24
|
+
|
|
25
|
+
<p>Hash: #</p>
|
|
26
|
+
|
|
27
|
+
<p>Period: .</p>
|
|
28
|
+
|
|
29
|
+
<p>Bang: !</p>
|
|
30
|
+
|
|
31
|
+
<p>Plus: +</p>
|
|
32
|
+
|
|
33
|
+
<p>Minus: -</p>
|
|
34
|
+
|
|
35
|
+
<p>These should not, because they occur within a code block:</p>
|
|
36
|
+
|
|
37
|
+
<pre><code>Backslash: \\
|
|
38
|
+
|
|
39
|
+
Backtick: \`
|
|
40
|
+
|
|
41
|
+
Asterisk: \*
|
|
42
|
+
|
|
43
|
+
Underscore: \_
|
|
44
|
+
|
|
45
|
+
Left brace: \{
|
|
46
|
+
|
|
47
|
+
Right brace: \}
|
|
48
|
+
|
|
49
|
+
Left bracket: \[
|
|
50
|
+
|
|
51
|
+
Right bracket: \]
|
|
52
|
+
|
|
53
|
+
Left paren: \(
|
|
54
|
+
|
|
55
|
+
Right paren: \)
|
|
56
|
+
|
|
57
|
+
Greater-than: \>
|
|
58
|
+
|
|
59
|
+
Hash: \#
|
|
60
|
+
|
|
61
|
+
Period: \.
|
|
62
|
+
|
|
63
|
+
Bang: \!
|
|
64
|
+
|
|
65
|
+
Plus: \+
|
|
66
|
+
|
|
67
|
+
Minus: \-
|
|
68
|
+
</code></pre>
|
|
69
|
+
|
|
70
|
+
<p>Nor should these, which occur in code spans:</p>
|
|
71
|
+
|
|
72
|
+
<p>Backslash: <code>\\</code></p>
|
|
73
|
+
|
|
74
|
+
<p>Backtick: <code>\`</code></p>
|
|
75
|
+
|
|
76
|
+
<p>Asterisk: <code>\*</code></p>
|
|
77
|
+
|
|
78
|
+
<p>Underscore: <code>\_</code></p>
|
|
79
|
+
|
|
80
|
+
<p>Left brace: <code>\{</code></p>
|
|
81
|
+
|
|
82
|
+
<p>Right brace: <code>\}</code></p>
|
|
83
|
+
|
|
84
|
+
<p>Left bracket: <code>\[</code></p>
|
|
85
|
+
|
|
86
|
+
<p>Right bracket: <code>\]</code></p>
|
|
87
|
+
|
|
88
|
+
<p>Left paren: <code>\(</code></p>
|
|
89
|
+
|
|
90
|
+
<p>Right paren: <code>\)</code></p>
|
|
91
|
+
|
|
92
|
+
<p>Greater-than: <code>\></code></p>
|
|
93
|
+
|
|
94
|
+
<p>Hash: <code>\#</code></p>
|
|
95
|
+
|
|
96
|
+
<p>Period: <code>\.</code></p>
|
|
97
|
+
|
|
98
|
+
<p>Bang: <code>\!</code></p>
|
|
99
|
+
|
|
100
|
+
<p>Plus: <code>\+</code></p>
|
|
101
|
+
|
|
102
|
+
<p>Minus: <code>\-</code></p>
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
<p>These should get escaped, even though they're matching pairs for
|
|
106
|
+
other Markdown constructs:</p>
|
|
107
|
+
|
|
108
|
+
<p>*asterisks*</p>
|
|
109
|
+
|
|
110
|
+
<p>_underscores_</p>
|
|
111
|
+
|
|
112
|
+
<p>`backticks`</p>
|
|
113
|
+
|
|
114
|
+
<p>This is a code span with a literal backslash-backtick sequence: <code>\`</code></p>
|
|
115
|
+
|
|
116
|
+
<p>This is a tag with unescaped backticks <span attr='`ticks`'>bar</span>.</p>
|
|
117
|
+
|
|
118
|
+
<p>This is a tag with backslashes <span attr='\\backslashes\\'>bar</span>.</p>
|