@honkit/markup-it 5.1.0 → 5.1.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/constants/blocks.js +1 -1
- package/lib/constants/defaultRules.js +4 -4
- package/lib/constants/entities.js +1 -1
- package/lib/constants/styles.js +1 -1
- package/lib/json/decode.js +1 -1
- package/lib/json/encode.js +2 -2
- package/lib/json/index.js +1 -1
- package/lib/models/content.js +2 -2
- package/lib/models/rule.js +2 -2
- package/lib/models/rules.js +2 -2
- package/lib/models/syntax.js +2 -2
- package/lib/models/token.js +6 -6
- package/lib/render/options.js +1 -1
- package/package.json +2 -2
- package/syntaxes/html/blocks.js +1 -1
- package/syntaxes/html/index.js +2 -2
- package/syntaxes/html/inline.js +2 -2
- package/syntaxes/html/list.js +1 -1
- package/syntaxes/html/parse.js +8 -8
- package/syntaxes/html/table.js +1 -1
- package/syntaxes/html/utils.js +1 -1
- package/syntaxes/markdown/blocks.js +13 -13
- package/syntaxes/markdown/code.js +5 -5
- package/syntaxes/markdown/document.js +1 -1
- package/syntaxes/markdown/heading.js +2 -2
- package/syntaxes/markdown/index.js +1 -1
- package/syntaxes/markdown/inline.js +28 -28
- package/syntaxes/markdown/isHTMLBlock.js +1 -1
- package/syntaxes/markdown/list.js +4 -4
- package/syntaxes/markdown/math.js +3 -3
- package/syntaxes/markdown/re/block.js +2 -2
- package/syntaxes/markdown/re/heading.js +1 -1
- package/syntaxes/markdown/re/inline.js +1 -1
- package/syntaxes/markdown/re/table.js +1 -1
- package/syntaxes/markdown/table.js +4 -4
- package/syntaxes/markdown/tableRow.js +4 -4
- package/syntaxes/markdown/utils.js +2 -2
package/lib/constants/blocks.js
CHANGED
|
@@ -9,7 +9,7 @@ const styles_1 = __importDefault(require("./styles"));
|
|
|
9
9
|
const defaultDocumentRule = (0, rule_1.default)(blocks_1.default.DOCUMENT)
|
|
10
10
|
.match((state, text) => {
|
|
11
11
|
return {
|
|
12
|
-
tokens: state.parseAsBlock(text)
|
|
12
|
+
tokens: state.parseAsBlock(text)
|
|
13
13
|
};
|
|
14
14
|
})
|
|
15
15
|
.toText((state, token) => {
|
|
@@ -18,19 +18,19 @@ const defaultDocumentRule = (0, rule_1.default)(blocks_1.default.DOCUMENT)
|
|
|
18
18
|
const defaultBlockRule = (0, rule_1.default)(blocks_1.default.TEXT)
|
|
19
19
|
.match((state, text) => {
|
|
20
20
|
return {
|
|
21
|
-
tokens: state.parseAsInline(text)
|
|
21
|
+
tokens: state.parseAsInline(text)
|
|
22
22
|
};
|
|
23
23
|
})
|
|
24
24
|
.toText("%s\n");
|
|
25
25
|
const defaultInlineRule = (0, rule_1.default)(styles_1.default.TEXT)
|
|
26
26
|
.match((state, text) => {
|
|
27
27
|
return {
|
|
28
|
-
text: text
|
|
28
|
+
text: text
|
|
29
29
|
};
|
|
30
30
|
})
|
|
31
31
|
.toText("%s");
|
|
32
32
|
exports.default = {
|
|
33
33
|
documentRule: defaultDocumentRule,
|
|
34
34
|
blockRule: defaultBlockRule,
|
|
35
|
-
inlineRule: defaultInlineRule
|
|
35
|
+
inlineRule: defaultInlineRule
|
|
36
36
|
};
|
package/lib/constants/styles.js
CHANGED
package/lib/json/decode.js
CHANGED
package/lib/json/encode.js
CHANGED
|
@@ -24,7 +24,7 @@ function encodeTokenToJSON(token) {
|
|
|
24
24
|
type: token.getType(),
|
|
25
25
|
text: token.getText(),
|
|
26
26
|
data: encodeDataToJSON(token.getData()),
|
|
27
|
-
tokens: encodeTokensToJSON(token.getTokens())
|
|
27
|
+
tokens: encodeTokensToJSON(token.getTokens())
|
|
28
28
|
};
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
@@ -45,7 +45,7 @@ function encodeTokensToJSON(tokens) {
|
|
|
45
45
|
function encodeContentToJSON(content) {
|
|
46
46
|
return {
|
|
47
47
|
syntax: content.getSyntax(),
|
|
48
|
-
token: encodeTokenToJSON(content.getToken())
|
|
48
|
+
token: encodeTokenToJSON(content.getToken())
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
51
|
exports.default = encodeContentToJSON;
|
package/lib/json/index.js
CHANGED
package/lib/models/content.js
CHANGED
|
@@ -11,7 +11,7 @@ const Content = immutable_1.default.Record({
|
|
|
11
11
|
syntax: String(),
|
|
12
12
|
// Entry token
|
|
13
13
|
// @ts-ignore
|
|
14
|
-
token: token_1.default.create(blocks_1.default.DOCUMENT)
|
|
14
|
+
token: token_1.default.create(blocks_1.default.DOCUMENT)
|
|
15
15
|
});
|
|
16
16
|
// ---- GETTERS ----
|
|
17
17
|
Content.prototype.getSyntax = function () {
|
|
@@ -31,7 +31,7 @@ Content.prototype.getToken = function () {
|
|
|
31
31
|
Content.createFromToken = function (syntax, token) {
|
|
32
32
|
return new Content({
|
|
33
33
|
syntax: syntax,
|
|
34
|
-
token: token
|
|
34
|
+
token: token
|
|
35
35
|
});
|
|
36
36
|
};
|
|
37
37
|
exports.default = Content;
|
package/lib/models/rule.js
CHANGED
|
@@ -11,7 +11,7 @@ const RuleRecord = immutable_1.default.Record({
|
|
|
11
11
|
// Type of the rule
|
|
12
12
|
type: new String(),
|
|
13
13
|
// Listener / Handlers {Map(<String,List<Function>)}
|
|
14
|
-
listeners: immutable_1.default.Map()
|
|
14
|
+
listeners: immutable_1.default.Map()
|
|
15
15
|
});
|
|
16
16
|
function Rule(type) {
|
|
17
17
|
if (!(this instanceof Rule)) {
|
|
@@ -19,7 +19,7 @@ function Rule(type) {
|
|
|
19
19
|
return new Rule(type);
|
|
20
20
|
}
|
|
21
21
|
RuleRecord.call(this, {
|
|
22
|
-
type: type
|
|
22
|
+
type: type
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
inherits(Rule, RuleRecord);
|
package/lib/models/rules.js
CHANGED
|
@@ -8,7 +8,7 @@ const is_1 = __importDefault(require("is"));
|
|
|
8
8
|
const rule_1 = __importDefault(require("./rule"));
|
|
9
9
|
const inherits = require("util").inherits;
|
|
10
10
|
const RulesSetRecord = immutable_1.default.Record({
|
|
11
|
-
rules: immutable_1.default.List()
|
|
11
|
+
rules: immutable_1.default.List()
|
|
12
12
|
});
|
|
13
13
|
function RulesSet(rules) {
|
|
14
14
|
if (!(this instanceof RulesSet)) {
|
|
@@ -18,7 +18,7 @@ function RulesSet(rules) {
|
|
|
18
18
|
// @ts-ignore
|
|
19
19
|
rules = new RulesList(rules);
|
|
20
20
|
RulesSetRecord.call(this, {
|
|
21
|
-
rules: rules
|
|
21
|
+
rules: rules
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
inherits(RulesSet, RulesSetRecord);
|
package/lib/models/syntax.js
CHANGED
|
@@ -15,7 +15,7 @@ const SyntaxSetRecord = immutable_1.default.Record({
|
|
|
15
15
|
// @ts-ignore
|
|
16
16
|
inline: new rules_1.default([]),
|
|
17
17
|
// @ts-ignore
|
|
18
|
-
blocks: new rules_1.default([])
|
|
18
|
+
blocks: new rules_1.default([])
|
|
19
19
|
});
|
|
20
20
|
function SyntaxSet(name, def) {
|
|
21
21
|
if (!(this instanceof SyntaxSet)) {
|
|
@@ -28,7 +28,7 @@ function SyntaxSet(name, def) {
|
|
|
28
28
|
// @ts-ignore
|
|
29
29
|
inline: new rules_1.default(def.inline),
|
|
30
30
|
// @ts-ignore
|
|
31
|
-
blocks: new rules_1.default(def.blocks)
|
|
31
|
+
blocks: new rules_1.default(def.blocks)
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
inherits(SyntaxSet, SyntaxSetRecord);
|
package/lib/models/token.js
CHANGED
|
@@ -20,7 +20,7 @@ const TokenRecord = immutable_1.default.Record({
|
|
|
20
20
|
// Can be use for annotating
|
|
21
21
|
raw: String(),
|
|
22
22
|
// List of children tokens (for block tokens)
|
|
23
|
-
tokens: immutable_1.default.List()
|
|
23
|
+
tokens: immutable_1.default.List()
|
|
24
24
|
});
|
|
25
25
|
function Token(def) {
|
|
26
26
|
if (!(this instanceof Token)) {
|
|
@@ -32,7 +32,7 @@ function Token(def) {
|
|
|
32
32
|
data: immutable_1.default.Map(def.data),
|
|
33
33
|
text: def.text,
|
|
34
34
|
raw: def.raw,
|
|
35
|
-
tokens: immutable_1.default.List(def.tokens)
|
|
35
|
+
tokens: immutable_1.default.List(def.tokens)
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
inherits(Token, TokenRecord);
|
|
@@ -91,7 +91,7 @@ Token.prototype.mergeWith = function (token) {
|
|
|
91
91
|
text: this.getText() + token.getText(),
|
|
92
92
|
raw: this.getRaw() + token.getRaw(),
|
|
93
93
|
data: this.getData().merge(token.getData()),
|
|
94
|
-
tokens: this.getTokens().concat(token.getTokens())
|
|
94
|
+
tokens: this.getTokens().concat(token.getTokens())
|
|
95
95
|
});
|
|
96
96
|
};
|
|
97
97
|
/**
|
|
@@ -101,7 +101,7 @@ Token.prototype.mergeWith = function (token) {
|
|
|
101
101
|
*/
|
|
102
102
|
Token.prototype.pushToken = function (token) {
|
|
103
103
|
return this.merge({
|
|
104
|
-
tokens: this.getTokens().push(token)
|
|
104
|
+
tokens: this.getTokens().push(token)
|
|
105
105
|
});
|
|
106
106
|
};
|
|
107
107
|
/**
|
|
@@ -145,7 +145,7 @@ Token.create = function (type, tok) {
|
|
|
145
145
|
text: text,
|
|
146
146
|
raw: tok.raw || "",
|
|
147
147
|
tokens: tokens,
|
|
148
|
-
data: data
|
|
148
|
+
data: data
|
|
149
149
|
});
|
|
150
150
|
};
|
|
151
151
|
/**
|
|
@@ -156,7 +156,7 @@ Token.create = function (type, tok) {
|
|
|
156
156
|
Token.createText = function (text) {
|
|
157
157
|
return Token.create(styles_1.default.TEXT, {
|
|
158
158
|
text: text,
|
|
159
|
-
raw: text
|
|
159
|
+
raw: text
|
|
160
160
|
});
|
|
161
161
|
};
|
|
162
162
|
exports.default = Token;
|
package/lib/render/options.js
CHANGED
|
@@ -8,7 +8,7 @@ const RenderOptions = immutable_1.default.Record({
|
|
|
8
8
|
// Transform the output of the render of a token
|
|
9
9
|
annotate: function (state, raw, token) {
|
|
10
10
|
return raw;
|
|
11
|
-
}
|
|
11
|
+
}
|
|
12
12
|
});
|
|
13
13
|
RenderOptions.prototype.getAnnotateFn = function () {
|
|
14
14
|
return this.get("annotate");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@honkit/markup-it",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.2",
|
|
4
4
|
"description": "Pipeline for working with markup input (for example Markdown)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"draft-js",
|
|
@@ -52,5 +52,5 @@
|
|
|
52
52
|
"publishConfig": {
|
|
53
53
|
"access": "public"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "1a64ab031dec8d305f080a29bda1f4970c37ecff"
|
|
56
56
|
}
|
package/syntaxes/html/blocks.js
CHANGED
package/syntaxes/html/index.js
CHANGED
|
@@ -4,7 +4,7 @@ const htmlToTokens = require("./parse");
|
|
|
4
4
|
const documentRule = MarkupIt.Rule(MarkupIt.BLOCKS.DOCUMENT)
|
|
5
5
|
.match((state, text) => {
|
|
6
6
|
return {
|
|
7
|
-
tokens: htmlToTokens(text)
|
|
7
|
+
tokens: htmlToTokens(text)
|
|
8
8
|
};
|
|
9
9
|
})
|
|
10
10
|
.toText((state, token) => {
|
|
@@ -18,5 +18,5 @@ module.exports = MarkupIt.Syntax("html", {
|
|
|
18
18
|
inline: require("./inline"),
|
|
19
19
|
|
|
20
20
|
// List of rules for parsing inline styles/entities
|
|
21
|
-
blocks: require("./blocks")
|
|
21
|
+
blocks: require("./blocks")
|
|
22
22
|
});
|
package/syntaxes/html/inline.js
CHANGED
|
@@ -30,7 +30,7 @@ module.exports = [
|
|
|
30
30
|
HTMLRule(markup.ENTITIES.LINK, "a", (data) => {
|
|
31
31
|
return {
|
|
32
32
|
title: data.title ? utils.escape(data.title) : undefined,
|
|
33
|
-
href: utils.escape(data.href || "")
|
|
33
|
+
href: utils.escape(data.href || "")
|
|
34
34
|
};
|
|
35
35
|
}),
|
|
36
36
|
|
|
@@ -43,5 +43,5 @@ module.exports = [
|
|
|
43
43
|
// ---- HTML ----
|
|
44
44
|
markup.Rule(markup.STYLES.HTML).toText((state, token) => {
|
|
45
45
|
return token.getAsPlainText();
|
|
46
|
-
})
|
|
46
|
+
})
|
|
47
47
|
];
|
package/syntaxes/html/list.js
CHANGED
package/syntaxes/html/parse.js
CHANGED
|
@@ -28,12 +28,12 @@ const TAGS_TO_TYPE = {
|
|
|
28
28
|
b: MarkupIt.STYLES.BOLD,
|
|
29
29
|
strike: MarkupIt.STYLES.STRIKETHROUGH,
|
|
30
30
|
em: MarkupIt.STYLES.ITALIC,
|
|
31
|
-
code: MarkupIt.STYLES.CODE
|
|
31
|
+
code: MarkupIt.STYLES.CODE
|
|
32
32
|
};
|
|
33
33
|
|
|
34
34
|
function resolveHeadingAttrs(attribs) {
|
|
35
35
|
return {
|
|
36
|
-
id: attribs.id
|
|
36
|
+
id: attribs.id
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
|
|
@@ -41,13 +41,13 @@ const TAGS_TO_DATA = {
|
|
|
41
41
|
a: function (attribs) {
|
|
42
42
|
return {
|
|
43
43
|
href: attribs.href,
|
|
44
|
-
title: attribs.alt || ""
|
|
44
|
+
title: attribs.alt || ""
|
|
45
45
|
};
|
|
46
46
|
},
|
|
47
47
|
img: function (attribs) {
|
|
48
48
|
return {
|
|
49
49
|
src: attribs.src,
|
|
50
|
-
title: attribs.alt || ""
|
|
50
|
+
title: attribs.alt || ""
|
|
51
51
|
};
|
|
52
52
|
},
|
|
53
53
|
h1: resolveHeadingAttrs,
|
|
@@ -55,7 +55,7 @@ const TAGS_TO_DATA = {
|
|
|
55
55
|
h3: resolveHeadingAttrs,
|
|
56
56
|
h4: resolveHeadingAttrs,
|
|
57
57
|
h5: resolveHeadingAttrs,
|
|
58
|
-
h6: resolveHeadingAttrs
|
|
58
|
+
h6: resolveHeadingAttrs
|
|
59
59
|
};
|
|
60
60
|
|
|
61
61
|
/**
|
|
@@ -86,7 +86,7 @@ function htmlToTokens(str) {
|
|
|
86
86
|
}
|
|
87
87
|
|
|
88
88
|
const token = MarkupIt.Token.create(type, {
|
|
89
|
-
data: dataResolver ? dataResolver(attribs) : {}
|
|
89
|
+
data: dataResolver ? dataResolver(attribs) : {}
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
stack.push(token);
|
|
@@ -107,10 +107,10 @@ function htmlToTokens(str) {
|
|
|
107
107
|
|
|
108
108
|
const lastToken = stack.pop();
|
|
109
109
|
pushToLast(lastToken);
|
|
110
|
-
}
|
|
110
|
+
}
|
|
111
111
|
},
|
|
112
112
|
{
|
|
113
|
-
decodeEntities: true
|
|
113
|
+
decodeEntities: true
|
|
114
114
|
}
|
|
115
115
|
);
|
|
116
116
|
|
package/syntaxes/html/table.js
CHANGED
package/syntaxes/html/utils.js
CHANGED
|
@@ -19,8 +19,8 @@ module.exports = MarkupIt.RulesSet([
|
|
|
19
19
|
return {
|
|
20
20
|
tokens: state.parseAsInline(text),
|
|
21
21
|
data: {
|
|
22
|
-
id: match[1]
|
|
23
|
-
}
|
|
22
|
+
id: match[1]
|
|
23
|
+
}
|
|
24
24
|
};
|
|
25
25
|
})
|
|
26
26
|
.toText((state, token) => {
|
|
@@ -58,7 +58,7 @@ module.exports = MarkupIt.RulesSet([
|
|
|
58
58
|
|
|
59
59
|
return state.toggle("blockquote", () => {
|
|
60
60
|
return {
|
|
61
|
-
tokens: state.parseAsBlock(inner)
|
|
61
|
+
tokens: state.parseAsBlock(inner)
|
|
62
62
|
};
|
|
63
63
|
});
|
|
64
64
|
})
|
|
@@ -82,7 +82,7 @@ module.exports = MarkupIt.RulesSet([
|
|
|
82
82
|
MarkupIt.Rule(MarkupIt.BLOCKS.HTML)
|
|
83
83
|
.regExp(reBlock.html, (state, match) => {
|
|
84
84
|
return {
|
|
85
|
-
text: match[0]
|
|
85
|
+
text: match[0]
|
|
86
86
|
};
|
|
87
87
|
})
|
|
88
88
|
.toText("%s"),
|
|
@@ -100,11 +100,11 @@ module.exports = MarkupIt.RulesSet([
|
|
|
100
100
|
state.refs = state.refs || {};
|
|
101
101
|
state.refs[id] = {
|
|
102
102
|
href: href,
|
|
103
|
-
title: title
|
|
103
|
+
title: title
|
|
104
104
|
};
|
|
105
105
|
|
|
106
106
|
return {
|
|
107
|
-
type: "definition"
|
|
107
|
+
type: "definition"
|
|
108
108
|
};
|
|
109
109
|
}),
|
|
110
110
|
|
|
@@ -121,10 +121,10 @@ module.exports = MarkupIt.RulesSet([
|
|
|
121
121
|
tokens: [
|
|
122
122
|
MarkupIt.Token.create(MarkupIt.ENTITIES.MATH, {
|
|
123
123
|
data: {
|
|
124
|
-
tex: text
|
|
125
|
-
}
|
|
126
|
-
})
|
|
127
|
-
]
|
|
124
|
+
tex: text
|
|
125
|
+
}
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
128
|
};
|
|
129
129
|
})
|
|
130
130
|
.regExp(reBlock.paragraph, (state, match) => {
|
|
@@ -138,7 +138,7 @@ module.exports = MarkupIt.RulesSet([
|
|
|
138
138
|
const text = match[1].trim();
|
|
139
139
|
|
|
140
140
|
return {
|
|
141
|
-
tokens: state.parseAsInline(text)
|
|
141
|
+
tokens: state.parseAsInline(text)
|
|
142
142
|
};
|
|
143
143
|
})
|
|
144
144
|
.toText("%s\n\n"),
|
|
@@ -150,8 +150,8 @@ module.exports = MarkupIt.RulesSet([
|
|
|
150
150
|
const text = match[0];
|
|
151
151
|
|
|
152
152
|
return {
|
|
153
|
-
tokens: state.parseAsInline(text)
|
|
153
|
+
tokens: state.parseAsInline(text)
|
|
154
154
|
};
|
|
155
155
|
})
|
|
156
|
-
.toText("%s\n")
|
|
156
|
+
.toText("%s\n")
|
|
157
157
|
]);
|
|
@@ -12,8 +12,8 @@ const blockRule = MarkupIt.Rule(MarkupIt.BLOCKS.CODE)
|
|
|
12
12
|
tokens: [MarkupIt.Token.createText(inner)],
|
|
13
13
|
data: {
|
|
14
14
|
syntax: match[2],
|
|
15
|
-
type: "fences"
|
|
16
|
-
}
|
|
15
|
+
type: "fences" // https://spec.commonmark.org/0.29/#fenced-code-blocks
|
|
16
|
+
}
|
|
17
17
|
};
|
|
18
18
|
})
|
|
19
19
|
|
|
@@ -28,8 +28,8 @@ const blockRule = MarkupIt.Rule(MarkupIt.BLOCKS.CODE)
|
|
|
28
28
|
tokens: [MarkupIt.Token.createText(inner)],
|
|
29
29
|
data: {
|
|
30
30
|
syntax: undefined,
|
|
31
|
-
type: "indented"
|
|
32
|
-
}
|
|
31
|
+
type: "indented" // https://spec.commonmark.org/0.29/#indented-code-blocks
|
|
32
|
+
}
|
|
33
33
|
};
|
|
34
34
|
})
|
|
35
35
|
|
|
@@ -60,5 +60,5 @@ const blockRule = MarkupIt.Rule(MarkupIt.BLOCKS.CODE)
|
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
module.exports = {
|
|
63
|
-
block: blockRule
|
|
63
|
+
block: blockRule
|
|
64
64
|
};
|
|
@@ -64,7 +64,7 @@ const documentRule = MarkupIt.Rule(MarkupIt.BLOCKS.DOCUMENT)
|
|
|
64
64
|
text = cleanupText(text);
|
|
65
65
|
|
|
66
66
|
const token = MarkupIt.Token.create(MarkupIt.BLOCKS.DOCUMENT, {
|
|
67
|
-
tokens: state.parseAsBlock(text)
|
|
67
|
+
tokens: state.parseAsBlock(text)
|
|
68
68
|
});
|
|
69
69
|
|
|
70
70
|
return MarkupIt.transform(token, resolveLink.bind(null, state));
|
|
@@ -12,7 +12,7 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
12
12
|
MarkupIt.Rule(MarkupIt.ENTITIES.FOOTNOTE_REF)
|
|
13
13
|
.regExp(reInline.reffn, (state, match) => {
|
|
14
14
|
return {
|
|
15
|
-
text: match[1]
|
|
15
|
+
text: match[1]
|
|
16
16
|
};
|
|
17
17
|
})
|
|
18
18
|
.toText((state, token) => {
|
|
@@ -29,7 +29,7 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
29
29
|
|
|
30
30
|
const imgData = {
|
|
31
31
|
alt: match[1],
|
|
32
|
-
src: match[2]
|
|
32
|
+
src: match[2]
|
|
33
33
|
};
|
|
34
34
|
|
|
35
35
|
const title = match[3];
|
|
@@ -38,7 +38,7 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
return {
|
|
41
|
-
data: imgData
|
|
41
|
+
data: imgData
|
|
42
42
|
};
|
|
43
43
|
})
|
|
44
44
|
.toText((state, token) => {
|
|
@@ -61,8 +61,8 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
61
61
|
tokens: state.parseAsInline(match[1]),
|
|
62
62
|
data: {
|
|
63
63
|
href: match[2],
|
|
64
|
-
title: match[3]
|
|
65
|
-
}
|
|
64
|
+
title: match[3]
|
|
65
|
+
}
|
|
66
66
|
};
|
|
67
67
|
});
|
|
68
68
|
})
|
|
@@ -71,8 +71,8 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
71
71
|
return {
|
|
72
72
|
tokens: state.parseAsInline(match[1]),
|
|
73
73
|
data: {
|
|
74
|
-
href: match[1]
|
|
75
|
-
}
|
|
74
|
+
href: match[1]
|
|
75
|
+
}
|
|
76
76
|
};
|
|
77
77
|
});
|
|
78
78
|
})
|
|
@@ -84,9 +84,9 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
84
84
|
|
|
85
85
|
return {
|
|
86
86
|
data: {
|
|
87
|
-
href: uri
|
|
87
|
+
href: uri
|
|
88
88
|
},
|
|
89
|
-
tokens: [MarkupIt.Token.createText(uri)]
|
|
89
|
+
tokens: [MarkupIt.Token.createText(uri)]
|
|
90
90
|
};
|
|
91
91
|
})
|
|
92
92
|
.regExp(reInline.reflink, (state, match) => {
|
|
@@ -97,9 +97,9 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
97
97
|
return {
|
|
98
98
|
type: MarkupIt.ENTITIES.LINK,
|
|
99
99
|
data: {
|
|
100
|
-
ref: refId
|
|
100
|
+
ref: refId
|
|
101
101
|
},
|
|
102
|
-
tokens: [MarkupIt.Token.createText(innerText)]
|
|
102
|
+
tokens: [MarkupIt.Token.createText(innerText)]
|
|
103
103
|
};
|
|
104
104
|
});
|
|
105
105
|
})
|
|
@@ -111,8 +111,8 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
111
111
|
type: MarkupIt.ENTITIES.LINK,
|
|
112
112
|
tokens: state.parseAsInline(match[1]),
|
|
113
113
|
data: {
|
|
114
|
-
ref: refId
|
|
115
|
-
}
|
|
114
|
+
ref: refId
|
|
115
|
+
}
|
|
116
116
|
};
|
|
117
117
|
});
|
|
118
118
|
})
|
|
@@ -123,8 +123,8 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
123
123
|
return {
|
|
124
124
|
tokens: state.parseAsInline(match[1]),
|
|
125
125
|
data: {
|
|
126
|
-
ref: refId
|
|
127
|
-
}
|
|
126
|
+
ref: refId
|
|
127
|
+
}
|
|
128
128
|
};
|
|
129
129
|
});
|
|
130
130
|
})
|
|
@@ -142,7 +142,7 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
142
142
|
MarkupIt.Rule(MarkupIt.STYLES.CODE)
|
|
143
143
|
.regExp(reInline.code, (state, match) => {
|
|
144
144
|
return {
|
|
145
|
-
tokens: [MarkupIt.Token.createText(match[2])]
|
|
145
|
+
tokens: [MarkupIt.Token.createText(match[2])]
|
|
146
146
|
};
|
|
147
147
|
})
|
|
148
148
|
.toText((state, token) => {
|
|
@@ -161,7 +161,7 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
161
161
|
MarkupIt.Rule(MarkupIt.STYLES.BOLD)
|
|
162
162
|
.regExp(reInline.strong, (state, match) => {
|
|
163
163
|
return {
|
|
164
|
-
tokens: state.parseAsInline(match[2] || match[1])
|
|
164
|
+
tokens: state.parseAsInline(match[2] || match[1])
|
|
165
165
|
};
|
|
166
166
|
})
|
|
167
167
|
.toText("**%s**"),
|
|
@@ -170,7 +170,7 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
170
170
|
MarkupIt.Rule(MarkupIt.STYLES.ITALIC)
|
|
171
171
|
.regExp(reInline.em, (state, match) => {
|
|
172
172
|
return {
|
|
173
|
-
tokens: state.parseAsInline(match[2] || match[1])
|
|
173
|
+
tokens: state.parseAsInline(match[2] || match[1])
|
|
174
174
|
};
|
|
175
175
|
})
|
|
176
176
|
.toText("_%s_"),
|
|
@@ -179,7 +179,7 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
179
179
|
MarkupIt.Rule(MarkupIt.STYLES.STRIKETHROUGH)
|
|
180
180
|
.regExp(reInline.del, (state, match) => {
|
|
181
181
|
return {
|
|
182
|
-
tokens: state.parseAsInline(match[1])
|
|
182
|
+
tokens: state.parseAsInline(match[1])
|
|
183
183
|
};
|
|
184
184
|
})
|
|
185
185
|
.toText("~~%s~~"),
|
|
@@ -212,15 +212,15 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
212
212
|
{
|
|
213
213
|
type: MarkupIt.STYLES.HTML,
|
|
214
214
|
text: innerText,
|
|
215
|
-
raw: innerText
|
|
216
|
-
}
|
|
215
|
+
raw: innerText
|
|
216
|
+
}
|
|
217
217
|
];
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
let result = Immutable.List().push({
|
|
221
221
|
type: MarkupIt.STYLES.HTML,
|
|
222
222
|
text: startTag,
|
|
223
|
-
raw: startTag
|
|
223
|
+
raw: startTag
|
|
224
224
|
});
|
|
225
225
|
|
|
226
226
|
result = result.concat(innerTokens);
|
|
@@ -229,7 +229,7 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
229
229
|
result = result.push({
|
|
230
230
|
type: MarkupIt.STYLES.HTML,
|
|
231
231
|
text: endTag,
|
|
232
|
-
raw: endTag
|
|
232
|
+
raw: endTag
|
|
233
233
|
});
|
|
234
234
|
}
|
|
235
235
|
|
|
@@ -258,9 +258,9 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
258
258
|
return {
|
|
259
259
|
text: "",
|
|
260
260
|
data: {
|
|
261
|
-
type: type
|
|
261
|
+
type: type
|
|
262
262
|
},
|
|
263
|
-
tokens: [MarkupIt.Token.createText(text)]
|
|
263
|
+
tokens: [MarkupIt.Token.createText(text)]
|
|
264
264
|
};
|
|
265
265
|
})
|
|
266
266
|
.toText((state, token) => {
|
|
@@ -279,18 +279,18 @@ const inlineRules = MarkupIt.RulesSet([
|
|
|
279
279
|
MarkupIt.Rule(MarkupIt.STYLES.TEXT)
|
|
280
280
|
.regExp(reInline.escape, (state, match) => {
|
|
281
281
|
return {
|
|
282
|
-
text: match[1]
|
|
282
|
+
text: match[1]
|
|
283
283
|
};
|
|
284
284
|
})
|
|
285
285
|
.regExp(reInline.text, (state, match) => {
|
|
286
286
|
return {
|
|
287
|
-
text: utils.unescape(match[0])
|
|
287
|
+
text: utils.unescape(match[0])
|
|
288
288
|
};
|
|
289
289
|
})
|
|
290
290
|
.toText((state, token) => {
|
|
291
291
|
const text = token.getAsPlainText();
|
|
292
292
|
return utils.escape(text, false);
|
|
293
|
-
})
|
|
293
|
+
})
|
|
294
294
|
]);
|
|
295
295
|
|
|
296
296
|
module.exports = inlineRules;
|
|
@@ -66,8 +66,8 @@ function listRule(type) {
|
|
|
66
66
|
raw: rawItem,
|
|
67
67
|
tokens: state.parseAsBlock(textItem),
|
|
68
68
|
data: {
|
|
69
|
-
loose: loose
|
|
70
|
-
}
|
|
69
|
+
loose: loose
|
|
70
|
+
}
|
|
71
71
|
});
|
|
72
72
|
};
|
|
73
73
|
|
|
@@ -75,7 +75,7 @@ function listRule(type) {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
return {
|
|
78
|
-
tokens: result
|
|
78
|
+
tokens: result
|
|
79
79
|
};
|
|
80
80
|
})
|
|
81
81
|
.toText((state, token) => {
|
|
@@ -109,5 +109,5 @@ function listRule(type) {
|
|
|
109
109
|
|
|
110
110
|
module.exports = {
|
|
111
111
|
ul: listRule(MarkupIt.BLOCKS.UL_LIST),
|
|
112
|
-
ol: listRule(MarkupIt.BLOCKS.OL_LIST)
|
|
112
|
+
ol: listRule(MarkupIt.BLOCKS.OL_LIST)
|
|
113
113
|
};
|
|
@@ -17,7 +17,7 @@ function isInlineTex(content) {
|
|
|
17
17
|
function normalizeTeX(content, isInline) {
|
|
18
18
|
// trim new line at start and end, but preserve spaces
|
|
19
19
|
content = content.replace(/^\n+/, "").replace(/\n+$/, "");
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
if (!isInline) {
|
|
22
22
|
content = `\n${content}\n`;
|
|
23
23
|
}
|
|
@@ -34,8 +34,8 @@ module.exports = MarkupIt.Rule(MarkupIt.ENTITIES.MATH)
|
|
|
34
34
|
|
|
35
35
|
return {
|
|
36
36
|
data: {
|
|
37
|
-
tex: text
|
|
38
|
-
}
|
|
37
|
+
tex: text
|
|
38
|
+
}
|
|
39
39
|
};
|
|
40
40
|
})
|
|
41
41
|
.toText((state, token) => {
|
|
@@ -16,7 +16,7 @@ const inline = {
|
|
|
16
16
|
del: /^~~(?=\S)([\s\S]*?\S)~~/,
|
|
17
17
|
text: /^[\s\S]+?(?=[\\<![_*`$]| {2,}\n|$)/,
|
|
18
18
|
math: /^\$\$([^$]+)\$\$/,
|
|
19
|
-
template: /^{([#%{])\s*(.*?)\s*(?=[#%}]})[#%}]}
|
|
19
|
+
template: /^{([#%{])\s*(.*?)\s*(?=[#%}]})[#%}]}/
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
inline._inside = /(?:\[[^\]]*]|[^[\]]|](?=[^[]*]))*/;
|
|
@@ -7,7 +7,7 @@ const tableRow = require("./tableRow");
|
|
|
7
7
|
const ALIGN = {
|
|
8
8
|
LEFT: "left",
|
|
9
9
|
RIGHT: "right",
|
|
10
|
-
CENTER: "center"
|
|
10
|
+
CENTER: "center"
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -27,9 +27,9 @@ function Table(state, header, align, rows) {
|
|
|
27
27
|
|
|
28
28
|
return {
|
|
29
29
|
data: {
|
|
30
|
-
align: align
|
|
30
|
+
align: align
|
|
31
31
|
},
|
|
32
|
-
tokens: Immutable.List([headerRow]).concat(rowTokens)
|
|
32
|
+
tokens: Immutable.List([headerRow]).concat(rowTokens)
|
|
33
33
|
};
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -135,5 +135,5 @@ const cellRule = MarkupIt.Rule(MarkupIt.BLOCKS.TABLE_CELL).toText((state, token)
|
|
|
135
135
|
module.exports = {
|
|
136
136
|
block: blockRule,
|
|
137
137
|
cell: cellRule,
|
|
138
|
-
row: rowRule
|
|
138
|
+
row: rowRule
|
|
139
139
|
};
|
|
@@ -13,7 +13,7 @@ const rowRules = inlineRules
|
|
|
13
13
|
.unshift(
|
|
14
14
|
MarkupIt.Rule(CELL_SEPARATOR).regExp(reTable.cellSeparation, (match) => {
|
|
15
15
|
return {
|
|
16
|
-
raw: match[0]
|
|
16
|
+
raw: match[0]
|
|
17
17
|
};
|
|
18
18
|
})
|
|
19
19
|
)
|
|
@@ -48,7 +48,7 @@ function parseRow(state, text) {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const cell = MarkupIt.Token.create(MarkupIt.BLOCKS.TABLE_CELL, {
|
|
51
|
-
tokens: accu
|
|
51
|
+
tokens: accu
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
cells.push(cell);
|
|
@@ -65,10 +65,10 @@ function parseRow(state, text) {
|
|
|
65
65
|
pushCell();
|
|
66
66
|
|
|
67
67
|
return MarkupIt.Token.create(MarkupIt.BLOCKS.TABLE_ROW, {
|
|
68
|
-
tokens: cells
|
|
68
|
+
tokens: cells
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
module.exports = {
|
|
73
|
-
parse: parseRow
|
|
73
|
+
parse: parseRow
|
|
74
74
|
};
|
|
@@ -18,7 +18,7 @@ const replacements = [
|
|
|
18
18
|
["<", "<"],
|
|
19
19
|
[">", ">"],
|
|
20
20
|
["_", "\\_"],
|
|
21
|
-
["|", "\\|"]
|
|
21
|
+
["|", "\\|"]
|
|
22
22
|
];
|
|
23
23
|
|
|
24
24
|
// Split a text into lines
|
|
@@ -105,5 +105,5 @@ module.exports = {
|
|
|
105
105
|
escape: escapeMarkdown,
|
|
106
106
|
unescape: unescapeMarkdown,
|
|
107
107
|
replace: replace,
|
|
108
|
-
indent: indent
|
|
108
|
+
indent: indent
|
|
109
109
|
};
|