@yozora/tokenizer-image 2.0.0-alpha.1 → 2.0.0-alpha.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/cjs/index.js +7 -4
- package/lib/esm/index.js +7 -4
- package/package.json +6 -6
package/lib/cjs/index.js
CHANGED
|
@@ -111,7 +111,7 @@ const match = function (api) {
|
|
|
111
111
|
|
|
112
112
|
const parse = function (api) {
|
|
113
113
|
return {
|
|
114
|
-
parse: (token
|
|
114
|
+
parse: tokens => tokens.map(token => {
|
|
115
115
|
const nodePoints = api.getNodePoints();
|
|
116
116
|
let url = '';
|
|
117
117
|
if (token.destinationContent != null) {
|
|
@@ -123,15 +123,18 @@ const parse = function (api) {
|
|
|
123
123
|
const destination = character.calcEscapedStringFromNodePoints(nodePoints, startIndex, endIndex, true);
|
|
124
124
|
url = coreTokenizer.encodeLinkDestination(destination);
|
|
125
125
|
}
|
|
126
|
+
const children = api.parseInlineTokens(token.children);
|
|
126
127
|
const alt = calcImageAlt(children);
|
|
127
128
|
let title;
|
|
128
129
|
if (token.titleContent != null) {
|
|
129
130
|
const { startIndex, endIndex } = token.titleContent;
|
|
130
131
|
title = character.calcEscapedStringFromNodePoints(nodePoints, startIndex + 1, endIndex - 1);
|
|
131
132
|
}
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
const node = api.shouldReservePosition
|
|
134
|
+
? { type: ast.ImageType, position: api.calcPosition(token), url, alt, title }
|
|
135
|
+
: { type: ast.ImageType, url, alt, title };
|
|
136
|
+
return node;
|
|
137
|
+
}),
|
|
135
138
|
};
|
|
136
139
|
};
|
|
137
140
|
|
package/lib/esm/index.js
CHANGED
|
@@ -107,7 +107,7 @@ const match = function (api) {
|
|
|
107
107
|
|
|
108
108
|
const parse = function (api) {
|
|
109
109
|
return {
|
|
110
|
-
parse: (token
|
|
110
|
+
parse: tokens => tokens.map(token => {
|
|
111
111
|
const nodePoints = api.getNodePoints();
|
|
112
112
|
let url = '';
|
|
113
113
|
if (token.destinationContent != null) {
|
|
@@ -119,15 +119,18 @@ const parse = function (api) {
|
|
|
119
119
|
const destination = calcEscapedStringFromNodePoints(nodePoints, startIndex, endIndex, true);
|
|
120
120
|
url = encodeLinkDestination(destination);
|
|
121
121
|
}
|
|
122
|
+
const children = api.parseInlineTokens(token.children);
|
|
122
123
|
const alt = calcImageAlt(children);
|
|
123
124
|
let title;
|
|
124
125
|
if (token.titleContent != null) {
|
|
125
126
|
const { startIndex, endIndex } = token.titleContent;
|
|
126
127
|
title = calcEscapedStringFromNodePoints(nodePoints, startIndex + 1, endIndex - 1);
|
|
127
128
|
}
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
|
|
129
|
+
const node = api.shouldReservePosition
|
|
130
|
+
? { type: ImageType, position: api.calcPosition(token), url, alt, title }
|
|
131
|
+
: { type: ImageType, url, alt, title };
|
|
132
|
+
return node;
|
|
133
|
+
}),
|
|
131
134
|
};
|
|
132
135
|
};
|
|
133
136
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-image",
|
|
3
|
-
"version": "2.0.0-alpha.
|
|
3
|
+
"version": "2.0.0-alpha.2",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "guanghechen",
|
|
6
6
|
"url": "https://github.com/guanghechen/"
|
|
@@ -35,10 +35,10 @@
|
|
|
35
35
|
"test": "cross-env TS_NODE_FILES=true jest --config ../../jest.config.js --rootDir ."
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@yozora/ast": "^2.0.0-alpha.
|
|
39
|
-
"@yozora/character": "^2.0.0-alpha.
|
|
40
|
-
"@yozora/core-tokenizer": "^2.0.0-alpha.
|
|
41
|
-
"@yozora/tokenizer-link": "^2.0.0-alpha.
|
|
38
|
+
"@yozora/ast": "^2.0.0-alpha.2",
|
|
39
|
+
"@yozora/character": "^2.0.0-alpha.2",
|
|
40
|
+
"@yozora/core-tokenizer": "^2.0.0-alpha.2",
|
|
41
|
+
"@yozora/tokenizer-link": "^2.0.0-alpha.2"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "da59d85520455c59a117a35032ef1a035c10ea21"
|
|
44
44
|
}
|