@honkit/markup-it 4.0.7 → 5.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/__tests__/syntax.d.ts +2 -0
- package/lib/__tests__/syntax.d.ts.map +1 -0
- package/lib/__tests__/syntax.js +33 -13
- package/lib/constants/blocks.d.ts +24 -0
- package/lib/constants/blocks.d.ts.map +1 -0
- package/lib/constants/defaultRules.d.ts +7 -0
- package/lib/constants/defaultRules.d.ts.map +1 -0
- package/lib/constants/entities.d.ts +9 -0
- package/lib/constants/entities.d.ts.map +1 -0
- package/lib/constants/styles.d.ts +10 -0
- package/lib/constants/styles.d.ts.map +1 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +16 -18
- package/lib/json/__tests__/decode.d.ts +2 -0
- package/lib/json/__tests__/decode.d.ts.map +1 -0
- package/lib/json/__tests__/encode.d.ts +2 -0
- package/lib/json/__tests__/encode.d.ts.map +1 -0
- package/lib/json/decode.d.ts +9 -0
- package/lib/json/decode.d.ts.map +1 -0
- package/lib/json/encode.d.ts +17 -0
- package/lib/json/encode.d.ts.map +1 -0
- package/lib/json/index.d.ts +8 -0
- package/lib/json/index.d.ts.map +1 -0
- package/lib/markup.d.ts +36 -0
- package/lib/markup.d.ts.map +1 -0
- package/lib/markup.js +41 -43
- package/lib/models/__tests__/token.d.ts +2 -0
- package/lib/models/__tests__/token.d.ts.map +1 -0
- package/lib/models/content.d.ts +3 -0
- package/lib/models/content.d.ts.map +1 -0
- package/lib/models/rule.d.ts +3 -0
- package/lib/models/rule.d.ts.map +1 -0
- package/lib/models/rules.d.ts +3 -0
- package/lib/models/rules.d.ts.map +1 -0
- package/lib/models/syntax.d.ts +3 -0
- package/lib/models/syntax.d.ts.map +1 -0
- package/lib/models/token.d.ts +7 -0
- package/lib/models/token.d.ts.map +1 -0
- package/lib/parse/__tests__/mergeTokens.d.ts +2 -0
- package/lib/parse/__tests__/mergeTokens.d.ts.map +1 -0
- package/lib/parse/index.d.ts +19 -0
- package/lib/parse/index.d.ts.map +1 -0
- package/lib/parse/lex.d.ts +13 -0
- package/lib/parse/lex.d.ts.map +1 -0
- package/lib/parse/matchRule.d.ts +11 -0
- package/lib/parse/matchRule.d.ts.map +1 -0
- package/lib/parse/mergeTokens.d.ts +10 -0
- package/lib/parse/mergeTokens.d.ts.map +1 -0
- package/lib/parse/state.d.ts +3 -0
- package/lib/parse/state.d.ts.map +1 -0
- package/lib/parse/textToUnstyledTokens.d.ts +12 -0
- package/lib/parse/textToUnstyledTokens.d.ts.map +1 -0
- package/lib/render/index.d.ts +19 -0
- package/lib/render/index.d.ts.map +1 -0
- package/lib/render/options.d.ts +4 -0
- package/lib/render/options.d.ts.map +1 -0
- package/lib/render/state.d.ts +3 -0
- package/lib/render/state.d.ts.map +1 -0
- package/lib/utils/genKey.d.ts +8 -0
- package/lib/utils/genKey.d.ts.map +1 -0
- package/lib/utils/identity.d.ts +2 -0
- package/lib/utils/identity.d.ts.map +1 -0
- package/lib/utils/isBlock.d.ts +9 -0
- package/lib/utils/isBlock.d.ts.map +1 -0
- package/lib/utils/isEntity.d.ts +9 -0
- package/lib/utils/isEntity.d.ts.map +1 -0
- package/lib/utils/isStyle.d.ts +9 -0
- package/lib/utils/isStyle.d.ts.map +1 -0
- package/lib/utils/transform.d.ts +9 -0
- package/lib/utils/transform.d.ts.map +1 -0
- package/lib/utils/walk.d.ts +3 -0
- package/lib/utils/walk.d.ts.map +1 -0
- package/package.json +3 -2
- package/syntaxes/markdown/__tests__/specs.js +1 -1
- package/syntaxes/text/index.js +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syntax.d.ts","sourceRoot":"","sources":["../../src/__tests__/syntax.ts"],"names":[],"mappings":""}
|
package/lib/__tests__/syntax.js
CHANGED
|
@@ -1,14 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
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;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
26
|
// @ts-ignore
|
|
7
|
-
const
|
|
27
|
+
const MarkupIt = __importStar(require(".."));
|
|
8
28
|
describe("Custom Syntax", () => {
|
|
9
|
-
const syntax =
|
|
29
|
+
const syntax = MarkupIt.Syntax("mysyntax", {
|
|
10
30
|
inline: [
|
|
11
|
-
|
|
31
|
+
MarkupIt.Rule(MarkupIt.STYLES.BOLD)
|
|
12
32
|
.regExp(/^\*\*([\s\S]+?)\*\*/, (state, match) => {
|
|
13
33
|
return {
|
|
14
34
|
text: match[1],
|
|
@@ -17,7 +37,7 @@ describe("Custom Syntax", () => {
|
|
|
17
37
|
.toText("**%s**"),
|
|
18
38
|
],
|
|
19
39
|
});
|
|
20
|
-
const markup = new
|
|
40
|
+
const markup = new MarkupIt.Markup(syntax);
|
|
21
41
|
describe(".toContent", () => {
|
|
22
42
|
it("should return correct syntax name", () => {
|
|
23
43
|
const content = markup.toContent("Hello");
|
|
@@ -29,7 +49,7 @@ describe("Custom Syntax", () => {
|
|
|
29
49
|
const blocks = doc.getTokens();
|
|
30
50
|
blocks.size.should.equal(1);
|
|
31
51
|
const p = blocks.get(0);
|
|
32
|
-
p.getType().should.equal(
|
|
52
|
+
p.getType().should.equal(MarkupIt.BLOCKS.TEXT);
|
|
33
53
|
p.getAsPlainText().should.equal("Hello World");
|
|
34
54
|
});
|
|
35
55
|
it("should parse inline", () => {
|
|
@@ -38,26 +58,26 @@ describe("Custom Syntax", () => {
|
|
|
38
58
|
const blocks = doc.getTokens();
|
|
39
59
|
blocks.size.should.equal(1);
|
|
40
60
|
const p = blocks.get(0);
|
|
41
|
-
p.getType().should.equal(
|
|
61
|
+
p.getType().should.equal(MarkupIt.BLOCKS.TEXT);
|
|
42
62
|
p.getAsPlainText().should.equal("Hello World");
|
|
43
63
|
});
|
|
44
64
|
});
|
|
45
65
|
describe(".toText", () => {
|
|
46
66
|
it("should output correct string", () => {
|
|
47
|
-
const content =
|
|
67
|
+
const content = MarkupIt.JSONUtils.decode({
|
|
48
68
|
syntax: "mysyntax",
|
|
49
69
|
token: {
|
|
50
|
-
type:
|
|
70
|
+
type: MarkupIt.BLOCKS.DOCUMENT,
|
|
51
71
|
tokens: [
|
|
52
72
|
{
|
|
53
|
-
type:
|
|
73
|
+
type: MarkupIt.BLOCKS.PARAGRAPH,
|
|
54
74
|
tokens: [
|
|
55
75
|
{
|
|
56
|
-
type:
|
|
76
|
+
type: MarkupIt.STYLES.TEXT,
|
|
57
77
|
text: "Hello ",
|
|
58
78
|
},
|
|
59
79
|
{
|
|
60
|
-
type:
|
|
80
|
+
type: MarkupIt.STYLES.BOLD,
|
|
61
81
|
text: "World",
|
|
62
82
|
},
|
|
63
83
|
],
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
declare const _default: {
|
|
2
|
+
DOCUMENT: string;
|
|
3
|
+
TEXT: string;
|
|
4
|
+
CODE: string;
|
|
5
|
+
BLOCKQUOTE: string;
|
|
6
|
+
PARAGRAPH: string;
|
|
7
|
+
FOOTNOTE: string;
|
|
8
|
+
HTML: string;
|
|
9
|
+
HR: string;
|
|
10
|
+
HEADING_1: string;
|
|
11
|
+
HEADING_2: string;
|
|
12
|
+
HEADING_3: string;
|
|
13
|
+
HEADING_4: string;
|
|
14
|
+
HEADING_5: string;
|
|
15
|
+
HEADING_6: string;
|
|
16
|
+
TABLE: string;
|
|
17
|
+
TABLE_ROW: string;
|
|
18
|
+
TABLE_CELL: string;
|
|
19
|
+
OL_LIST: string;
|
|
20
|
+
UL_LIST: string;
|
|
21
|
+
LIST_ITEM: string;
|
|
22
|
+
};
|
|
23
|
+
export default _default;
|
|
24
|
+
//# sourceMappingURL=blocks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"blocks.d.ts","sourceRoot":"","sources":["../../src/constants/blocks.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,wBA0BE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaultRules.d.ts","sourceRoot":"","sources":["../../src/constants/defaultRules.ts"],"names":[],"mappings":";;;;;AA+BA,wBAIE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entities.d.ts","sourceRoot":"","sources":["../../src/constants/entities.ts"],"names":[],"mappings":";;;;;;;AAAA,wBAQE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../src/constants/styles.ts"],"names":[],"mappings":";;;;;;;;AAAA,wBAOE"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Markup from "./markup";
|
|
2
|
+
import BLOCKS from "./constants/blocks";
|
|
3
|
+
import STYLES from "./constants/styles";
|
|
4
|
+
import ENTITIES from "./constants/entities";
|
|
5
|
+
import Content from "./models/content";
|
|
6
|
+
import Syntax from "./models/syntax";
|
|
7
|
+
import Rule from "./models/rule";
|
|
8
|
+
import RulesSet from "./models/rules";
|
|
9
|
+
import Token from "./models/token";
|
|
10
|
+
import parse from "./parse";
|
|
11
|
+
import render from "./render";
|
|
12
|
+
import JSONUtils from "./json";
|
|
13
|
+
import genKey from "./utils/genKey";
|
|
14
|
+
import transform from "./utils/transform";
|
|
15
|
+
export default Markup;
|
|
16
|
+
export { Markup };
|
|
17
|
+
export { parse };
|
|
18
|
+
export { render };
|
|
19
|
+
export { Content };
|
|
20
|
+
export { Token };
|
|
21
|
+
export { Syntax };
|
|
22
|
+
export { Rule };
|
|
23
|
+
export { RulesSet };
|
|
24
|
+
export { JSONUtils };
|
|
25
|
+
export { genKey };
|
|
26
|
+
export { transform };
|
|
27
|
+
export { STYLES };
|
|
28
|
+
export { ENTITIES };
|
|
29
|
+
export { BLOCKS };
|
|
30
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAE5C,OAAO,OAAO,MAAM,kBAAkB,CAAC;AACvC,OAAO,MAAM,MAAM,iBAAiB,CAAC;AACrC,OAAO,IAAI,MAAM,eAAe,CAAC;AACjC,OAAO,QAAQ,MAAM,gBAAgB,CAAC;AACtC,OAAO,KAAK,MAAM,gBAAgB,CAAC;AAEnC,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,SAAS,MAAM,QAAQ,CAAC;AAE/B,OAAO,MAAM,MAAM,gBAAgB,CAAC;AACpC,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAE1C,eAAe,MAAM,CAAC;AACtB,OAAO,EAAE,MAAM,EAAE,CAAC;AAGlB,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,CAAC;AAGlB,OAAO,EAAE,OAAO,EAAE,CAAC;AACnB,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,OAAO,EAAE,IAAI,EAAE,CAAC;AAChB,OAAO,EAAE,QAAQ,EAAE,CAAC;AAGpB,OAAO,EAAE,SAAS,EAAE,CAAC;AACrB,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,CAAC;AAGrB,OAAO,EAAE,MAAM,EAAE,CAAC;AAClB,OAAO,EAAE,QAAQ,EAAE,CAAC;AACpB,OAAO,EAAE,MAAM,EAAE,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -3,35 +3,33 @@ 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
|
+
exports.BLOCKS = exports.ENTITIES = exports.STYLES = exports.transform = exports.genKey = exports.JSONUtils = exports.RulesSet = exports.Rule = exports.Syntax = exports.Token = exports.Content = exports.render = exports.parse = exports.Markup = void 0;
|
|
6
7
|
const markup_1 = __importDefault(require("./markup"));
|
|
8
|
+
exports.Markup = markup_1.default;
|
|
7
9
|
const blocks_1 = __importDefault(require("./constants/blocks"));
|
|
10
|
+
exports.BLOCKS = blocks_1.default;
|
|
8
11
|
const styles_1 = __importDefault(require("./constants/styles"));
|
|
12
|
+
exports.STYLES = styles_1.default;
|
|
9
13
|
const entities_1 = __importDefault(require("./constants/entities"));
|
|
14
|
+
exports.ENTITIES = entities_1.default;
|
|
10
15
|
const content_1 = __importDefault(require("./models/content"));
|
|
16
|
+
exports.Content = content_1.default;
|
|
11
17
|
const syntax_1 = __importDefault(require("./models/syntax"));
|
|
18
|
+
exports.Syntax = syntax_1.default;
|
|
12
19
|
const rule_1 = __importDefault(require("./models/rule"));
|
|
20
|
+
exports.Rule = rule_1.default;
|
|
13
21
|
const rules_1 = __importDefault(require("./models/rules"));
|
|
22
|
+
exports.RulesSet = rules_1.default;
|
|
14
23
|
const token_1 = __importDefault(require("./models/token"));
|
|
24
|
+
exports.Token = token_1.default;
|
|
15
25
|
const parse_1 = __importDefault(require("./parse"));
|
|
26
|
+
exports.parse = parse_1.default;
|
|
16
27
|
const render_1 = __importDefault(require("./render"));
|
|
28
|
+
exports.render = render_1.default;
|
|
17
29
|
const json_1 = __importDefault(require("./json"));
|
|
30
|
+
exports.JSONUtils = json_1.default;
|
|
18
31
|
const genKey_1 = __importDefault(require("./utils/genKey"));
|
|
32
|
+
exports.genKey = genKey_1.default;
|
|
19
33
|
const transform_1 = __importDefault(require("./utils/transform"));
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
module.exports.parse = parse_1.default;
|
|
23
|
-
module.exports.render = render_1.default;
|
|
24
|
-
// Models
|
|
25
|
-
module.exports.Content = content_1.default;
|
|
26
|
-
module.exports.Token = token_1.default;
|
|
27
|
-
module.exports.Syntax = syntax_1.default;
|
|
28
|
-
module.exports.Rule = rule_1.default;
|
|
29
|
-
module.exports.RulesSet = rules_1.default;
|
|
30
|
-
// Utils
|
|
31
|
-
module.exports.JSONUtils = json_1.default;
|
|
32
|
-
module.exports.genKey = genKey_1.default;
|
|
33
|
-
module.exports.transform = transform_1.default;
|
|
34
|
-
// Constants
|
|
35
|
-
module.exports.STYLES = styles_1.default;
|
|
36
|
-
module.exports.ENTITIES = entities_1.default;
|
|
37
|
-
module.exports.BLOCKS = blocks_1.default;
|
|
34
|
+
exports.transform = transform_1.default;
|
|
35
|
+
exports.default = markup_1.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../src/json/__tests__/decode.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../src/json/__tests__/encode.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../src/json/decode.ts"],"names":[],"mappings":"AAiCA;;;;;GAKG;AACH,iBAAS,qBAAqB,CAAC,IAAI,KAAA,OAElC;AAED,eAAe,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encode a Content into a JSON object
|
|
3
|
+
*
|
|
4
|
+
* @paran {Content} content
|
|
5
|
+
* @return {Object}
|
|
6
|
+
*/
|
|
7
|
+
declare function encodeContentToJSON(content: any): {
|
|
8
|
+
syntax: any;
|
|
9
|
+
token: {
|
|
10
|
+
type: any;
|
|
11
|
+
text: any;
|
|
12
|
+
data: any;
|
|
13
|
+
tokens: any;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export default encodeContentToJSON;
|
|
17
|
+
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../src/json/encode.ts"],"names":[],"mappings":"AAuCA;;;;;GAKG;AACH,iBAAS,mBAAmB,CAAC,OAAO,KAAA;;;;;;;;EAKnC;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/json/index.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,MAAM,MAAM,UAAU,CAAC;;;;;AAE9B,wBAGE"}
|
package/lib/markup.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
declare class DraftMarkup {
|
|
2
|
+
private syntax;
|
|
3
|
+
/**
|
|
4
|
+
* Create an instance using a set of rules
|
|
5
|
+
* @param {Syntax} syntax
|
|
6
|
+
*/
|
|
7
|
+
constructor(syntax: any);
|
|
8
|
+
/**
|
|
9
|
+
* Convert a text into an inline parsed content
|
|
10
|
+
* @param {string} text
|
|
11
|
+
* @return {List<Tokens>}
|
|
12
|
+
*/
|
|
13
|
+
toInlineText(tokens: any): any;
|
|
14
|
+
/**
|
|
15
|
+
* Convert a content to text
|
|
16
|
+
* @param {ContentState} content
|
|
17
|
+
* @param {Object} options
|
|
18
|
+
* @return {string}
|
|
19
|
+
*/
|
|
20
|
+
toContent(text: any, options?: {}): any;
|
|
21
|
+
/**
|
|
22
|
+
* Convert a text into an inline parsed content
|
|
23
|
+
* @param {string} text
|
|
24
|
+
* @return {List<Tokens>}
|
|
25
|
+
*/
|
|
26
|
+
toInlineContent(text: any): any;
|
|
27
|
+
/**
|
|
28
|
+
* Convert a content to text
|
|
29
|
+
* @param {ContentState} content
|
|
30
|
+
* @param {Object} options
|
|
31
|
+
* @return {string}
|
|
32
|
+
*/
|
|
33
|
+
toText(content: any, options?: {}): any;
|
|
34
|
+
}
|
|
35
|
+
export default DraftMarkup;
|
|
36
|
+
//# sourceMappingURL=markup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"markup.d.ts","sourceRoot":"","sources":["../src/markup.ts"],"names":[],"mappings":"AAGA,cAAM,WAAW;IACb,OAAO,CAAC,MAAM,CAAM;IAEpB;;;OAGG;gBACS,MAAM,EAAE,GAAG;IAIvB;;;;OAIG;IACH,YAAY,CAAC,MAAM,KAAA;IAInB;;;;;OAKG;IACH,SAAS,CAAC,IAAI,KAAA,EAAE,OAAO,CAAC,EAAE,EAAE;IAI5B;;;;OAIG;IACH,eAAe,CAAC,IAAI,KAAA;IAIpB;;;;;OAKG;IACH,MAAM,CAAC,OAAO,KAAA,EAAE,OAAO,CAAC,EAAE,EAAE;CAG/B;AAED,eAAe,WAAW,CAAC"}
|
package/lib/markup.js
CHANGED
|
@@ -5,49 +5,47 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const parse_1 = __importDefault(require("./parse"));
|
|
7
7
|
const render_1 = __importDefault(require("./render"));
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
class DraftMarkup {
|
|
9
|
+
/**
|
|
10
|
+
* Create an instance using a set of rules
|
|
11
|
+
* @param {Syntax} syntax
|
|
12
|
+
*/
|
|
13
|
+
constructor(syntax) {
|
|
14
|
+
this.syntax = syntax;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Convert a text into an inline parsed content
|
|
18
|
+
* @param {string} text
|
|
19
|
+
* @return {List<Tokens>}
|
|
20
|
+
*/
|
|
21
|
+
toInlineText(tokens) {
|
|
22
|
+
return render_1.default.asInline(this.syntax, tokens);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Convert a content to text
|
|
26
|
+
* @param {ContentState} content
|
|
27
|
+
* @param {Object} options
|
|
28
|
+
* @return {string}
|
|
29
|
+
*/
|
|
30
|
+
toContent(text, options) {
|
|
31
|
+
return (0, parse_1.default)(this.syntax, text, options);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Convert a text into an inline parsed content
|
|
35
|
+
* @param {string} text
|
|
36
|
+
* @return {List<Tokens>}
|
|
37
|
+
*/
|
|
38
|
+
toInlineContent(text) {
|
|
39
|
+
return parse_1.default.asInline(this.syntax, text);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Convert a content to text
|
|
43
|
+
* @param {ContentState} content
|
|
44
|
+
* @param {Object} options
|
|
45
|
+
* @return {string}
|
|
46
|
+
*/
|
|
47
|
+
toText(content, options) {
|
|
48
|
+
return (0, render_1.default)(this.syntax, content, options);
|
|
16
49
|
}
|
|
17
|
-
this.syntax = syntax;
|
|
18
50
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Convert a text into a parsed content
|
|
21
|
-
* @param {string} text
|
|
22
|
-
* @return {ContentState}
|
|
23
|
-
*/
|
|
24
|
-
DraftMarkup.prototype.toContent = function toContent(text, options) {
|
|
25
|
-
return (0, parse_1.default)(this.syntax, text, options);
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Convert a text into an inline parsed content
|
|
29
|
-
* @param {string} text
|
|
30
|
-
* @return {List<Tokens>}
|
|
31
|
-
*/
|
|
32
|
-
DraftMarkup.prototype.toInlineContent = function toInlineContent(text) {
|
|
33
|
-
// @ts-ignore
|
|
34
|
-
return parse_1.default.asInline(this.syntax, text);
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Convert a content to text
|
|
38
|
-
* @param {ContentState} content
|
|
39
|
-
* @param {Object} options
|
|
40
|
-
* @return {string}
|
|
41
|
-
*/
|
|
42
|
-
DraftMarkup.prototype.toText = function toText(content, options) {
|
|
43
|
-
return (0, render_1.default)(this.syntax, content, options);
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* Convert a content to text
|
|
47
|
-
* @param {List<Tokens>}
|
|
48
|
-
* @return {string}
|
|
49
|
-
*/
|
|
50
|
-
DraftMarkup.prototype.toInlineText = function toInlineText(tokens) {
|
|
51
|
-
return render_1.default.asInline(this.syntax, tokens);
|
|
52
|
-
};
|
|
53
51
|
exports.default = DraftMarkup;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../src/models/__tests__/token.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.d.ts","sourceRoot":"","sources":["../../src/models/content.ts"],"names":[],"mappings":"AAIA,QAAA,MAAM,OAAO,EAAE,GAOb,CAAC;AA2BH,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rule.d.ts","sourceRoot":"","sources":["../../src/models/rule.ts"],"names":[],"mappings":"AAaA,iBAAS,IAAI,CAAC,IAAI,CAAC,KAAA,OASlB;AAmID,eAAe,IAAI,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/models/rules.ts"],"names":[],"mappings":"AAQA,iBAAS,QAAQ,CAAC,KAAK,KAAA,OAYtB;AA0GD,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"syntax.d.ts","sourceRoot":"","sources":["../../src/models/syntax.ts"],"names":[],"mappings":"AAgBA,iBAAS,SAAS,CAAC,IAAI,KAAA,EAAE,GAAG,KAAA,OAc3B;AAgED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/models/token.ts"],"names":[],"mappings":"AA2BA,iBAAS,KAAK,CAAC,GAAG,KAAA,OAajB;kBAbQ,KAAK;;;;AAgKd,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeTokens.d.ts","sourceRoot":"","sources":["../../../src/parse/__tests__/mergeTokens.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parse a text using a syntax
|
|
3
|
+
* @param {Syntax} syntax
|
|
4
|
+
* @param {string} text
|
|
5
|
+
* @return {Content}
|
|
6
|
+
*/
|
|
7
|
+
declare function parse(syntax: any, text: any, options?: {}): any;
|
|
8
|
+
declare namespace parse {
|
|
9
|
+
var asInline: typeof parseAsInline;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse a text using a syntax as inline content
|
|
13
|
+
* @param {Syntax} syntax
|
|
14
|
+
* @param {string} text
|
|
15
|
+
* @return {List<Token>}
|
|
16
|
+
*/
|
|
17
|
+
declare function parseAsInline(syntax: any, text: any, options?: {}): any;
|
|
18
|
+
export default parse;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parse/index.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,iBAAS,KAAK,CAAC,MAAM,KAAA,EAAE,IAAI,KAAA,EAAE,OAAO,CAAC,EAAE,EAAE,OAOxC;kBAPQ,KAAK;;;AASd;;;;;GAKG;AACH,iBAAS,aAAa,CAAC,MAAM,KAAA,EAAE,IAAI,KAAA,EAAE,OAAO,CAAC,EAAE,EAAE,OAIhD;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Process a text using a set of rules
|
|
3
|
+
* to return a flat list of tokens
|
|
4
|
+
*
|
|
5
|
+
* @param {ParsingState} state
|
|
6
|
+
* @param {List<Rule>} rules
|
|
7
|
+
* @param {boolean} isInline
|
|
8
|
+
* @param {string} text
|
|
9
|
+
* @return {List<Token>}
|
|
10
|
+
*/
|
|
11
|
+
declare function lex(state: any, rules: any, isInline: any, text: any, nonParsed: any): any;
|
|
12
|
+
export default lex;
|
|
13
|
+
//# sourceMappingURL=lex.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lex.d.ts","sourceRoot":"","sources":["../../src/parse/lex.ts"],"names":[],"mappings":"AAKA;;;;;;;;;GASG;AACH,iBAAS,GAAG,CAAC,KAAK,KAAA,EAAE,KAAK,KAAA,EAAE,QAAQ,KAAA,EAAE,IAAI,KAAA,EAAE,SAAS,KAAA,OAqCnD;AAED,eAAe,GAAG,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import Immutable from "immutable";
|
|
2
|
+
/**
|
|
3
|
+
* Match a text using a rule
|
|
4
|
+
* @param {ParsingState} state
|
|
5
|
+
* @param {Rule} rule
|
|
6
|
+
* @param {string} text
|
|
7
|
+
* @return {List<Token>|null}
|
|
8
|
+
*/
|
|
9
|
+
declare function matchRule(state: any, rule: any, text: any): Immutable.Iterable<number, any>;
|
|
10
|
+
export default matchRule;
|
|
11
|
+
//# sourceMappingURL=matchRule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matchRule.d.ts","sourceRoot":"","sources":["../../src/parse/matchRule.ts"],"names":[],"mappings":"AACA,OAAO,SAAS,MAAM,WAAW,CAAC;AAIlC;;;;;;GAMG;AACH,iBAAS,SAAS,CAAC,KAAK,KAAA,EAAE,IAAI,KAAA,EAAE,IAAI,KAAA,mCAenC;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Merge tokens of a specific type
|
|
3
|
+
*
|
|
4
|
+
* @param {List<Token>} tokens
|
|
5
|
+
* @param {Array<String>} types
|
|
6
|
+
* @return {List<Token>}
|
|
7
|
+
*/
|
|
8
|
+
declare function mergeTokens(tokens: any, types: any): any;
|
|
9
|
+
export default mergeTokens;
|
|
10
|
+
//# sourceMappingURL=mergeTokens.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mergeTokens.d.ts","sourceRoot":"","sources":["../../src/parse/mergeTokens.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,iBAAS,WAAW,CAAC,MAAM,KAAA,EAAE,KAAK,KAAA,OAqBjC;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/parse/state.ts"],"names":[],"mappings":"AAMA,iBAAS,YAAY,CAAC,MAAM,KAAA,EAAE,OAAO,KAAA,OAUpC;AA6GD,eAAe,YAAY,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import Immutable from "immutable";
|
|
2
|
+
/**
|
|
3
|
+
* Convert a normal text into a list of unstyled tokens (block or inline)
|
|
4
|
+
*
|
|
5
|
+
* @param {ParsingState} state
|
|
6
|
+
* @param {boolean} isInline
|
|
7
|
+
* @param {string} text
|
|
8
|
+
* @return {List<Token>}
|
|
9
|
+
*/
|
|
10
|
+
declare function textToUnstyledTokens(state: any, isInline: any, text: any): Immutable.List<unknown>;
|
|
11
|
+
export default textToUnstyledTokens;
|
|
12
|
+
//# sourceMappingURL=textToUnstyledTokens.d.ts.map
|
|
@@ -0,0 +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,2BAkClD;AAED,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render a Content instance using a syntax
|
|
3
|
+
* @param {Content}
|
|
4
|
+
* @param {Object} options
|
|
5
|
+
* @return {string}
|
|
6
|
+
*/
|
|
7
|
+
declare function render(syntax: any, content: any, options: any): any;
|
|
8
|
+
declare namespace render {
|
|
9
|
+
var asInline: typeof renderAsInline;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Parse a text using a syntax as inline content
|
|
13
|
+
* @param {Syntax} syntax
|
|
14
|
+
* @param {List<Token>} tokens
|
|
15
|
+
* @return {string}
|
|
16
|
+
*/
|
|
17
|
+
declare function renderAsInline(syntax: any, tokens: any): any;
|
|
18
|
+
export default render;
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/render/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,iBAAS,MAAM,CAAC,MAAM,KAAA,EAAE,OAAO,KAAA,EAAE,OAAO,KAAA,OAOvC;kBAPQ,MAAM;;;AASf;;;;;GAKG;AACH,iBAAS,cAAc,CAAC,MAAM,KAAA,EAAE,MAAM,KAAA,OAIrC;AAGD,eAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/render/options.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAElC,QAAA,MAAM,aAAa,wBAKjB,CAAC;AAMH,eAAe,aAAa,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/render/state.ts"],"names":[],"mappings":"AAGA,iBAAS,cAAc,CAAC,MAAM,KAAA,EAAE,OAAO,KAAA,OAQtC;AA+CD,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genKey.d.ts","sourceRoot":"","sources":["../../src/utils/genKey.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,iBAAS,WAAW,WAInB;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../src/utils/identity.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,QAAQ,CAAC,KAAK,KAAA,OAErC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isBlock.d.ts","sourceRoot":"","sources":["../../src/utils/isBlock.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,iBAAS,OAAO,CAAC,KAAK,KAAA,WAErB;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isEntity.d.ts","sourceRoot":"","sources":["../../src/utils/isEntity.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,iBAAS,QAAQ,CAAC,KAAK,KAAA,WAEtB;AAED,eAAe,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isStyle.d.ts","sourceRoot":"","sources":["../../src/utils/isStyle.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,iBAAS,OAAO,CAAC,KAAK,KAAA,WAErB;AAED,eAAe,OAAO,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transform that works on token or list of tokens
|
|
3
|
+
* @param {Token|List<Token>|Content} base
|
|
4
|
+
* @param {Function} iter
|
|
5
|
+
* @return {Token|List<Token>|Content}
|
|
6
|
+
*/
|
|
7
|
+
declare function transform(base: any, iter: any): any;
|
|
8
|
+
export default transform;
|
|
9
|
+
//# sourceMappingURL=transform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform.d.ts","sourceRoot":"","sources":["../../src/utils/transform.ts"],"names":[],"mappings":"AA2CA;;;;;GAKG;AACH,iBAAS,SAAS,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,OAM5B;AAED,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../src/utils/walk.ts"],"names":[],"mappings":"AAYA,iBAAS,IAAI,CAAC,IAAI,KAAA,EAAE,IAAI,KAAA,OAyBvB;AAED,eAAe,IAAI,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honkit/markup-it",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Pipeline for working with markup input (for example Markdown)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"draft-js",
|
|
@@ -41,6 +41,7 @@
|
|
|
41
41
|
"range-utils": "^1.1.0"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
+
"@types/jest": "^29.5.3",
|
|
44
45
|
"eslint": "^8.23.1",
|
|
45
46
|
"jest": "^29.0.3",
|
|
46
47
|
"jsdom": "^20.0.0",
|
|
@@ -51,5 +52,5 @@
|
|
|
51
52
|
"publishConfig": {
|
|
52
53
|
"access": "public"
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "9feb7e251f1d305c2cd521f78f0a275b847a6e1b"
|
|
55
56
|
}
|
|
@@ -3,7 +3,7 @@ const path = require("path");
|
|
|
3
3
|
const JSDOM = require("jsdom").JSDOM;
|
|
4
4
|
const assert = require("assert");
|
|
5
5
|
|
|
6
|
-
const MarkupIt = require("../../..");
|
|
6
|
+
const MarkupIt = require("../../..").Markup;
|
|
7
7
|
const markdownSyntax = require("../");
|
|
8
8
|
const htmlSyntax = require("../../html");
|
|
9
9
|
|
package/syntaxes/text/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const MarkupIt = require("../../");
|
|
1
|
+
const MarkupIt = require("../../").Markup;
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
This syntax uses the default rules (UNSTYLED)
|
|
@@ -6,5 +6,5 @@ const MarkupIt = require("../../");
|
|
|
6
6
|
*/
|
|
7
7
|
module.exports = MarkupIt.Syntax("markdown", {
|
|
8
8
|
inline: [],
|
|
9
|
-
blocks: [MarkupIt.Rule(MarkupIt.BLOCKS.PARAGRAPH).toText("%s\n\n")]
|
|
9
|
+
blocks: [MarkupIt.Rule(MarkupIt.BLOCKS.PARAGRAPH).toText("%s\n\n")]
|
|
10
10
|
});
|