@yozora/tokenizer-image-reference 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 CHANGED
@@ -128,18 +128,28 @@ const match = function (api) {
128
128
 
129
129
  const parse = function (api) {
130
130
  return {
131
- parse: (token, children) => {
131
+ parse: tokens => tokens.map(token => {
132
132
  const { identifier, label, referenceType } = token;
133
+ const children = api.parseInlineTokens(token.children);
133
134
  const alt = tokenizerImage.calcImageAlt(children);
134
- const result = {
135
- type: ast.ImageReferenceType,
136
- identifier,
137
- label,
138
- referenceType,
139
- alt,
140
- };
141
- return result;
142
- },
135
+ const node = api.shouldReservePosition
136
+ ? {
137
+ type: ast.ImageReferenceType,
138
+ position: api.calcPosition(token),
139
+ identifier,
140
+ label,
141
+ referenceType,
142
+ alt,
143
+ }
144
+ : {
145
+ type: ast.ImageReferenceType,
146
+ identifier,
147
+ label,
148
+ referenceType,
149
+ alt,
150
+ };
151
+ return node;
152
+ }),
143
153
  };
144
154
  };
145
155
 
package/lib/esm/index.js CHANGED
@@ -124,18 +124,28 @@ const match = function (api) {
124
124
 
125
125
  const parse = function (api) {
126
126
  return {
127
- parse: (token, children) => {
127
+ parse: tokens => tokens.map(token => {
128
128
  const { identifier, label, referenceType } = token;
129
+ const children = api.parseInlineTokens(token.children);
129
130
  const alt = calcImageAlt(children);
130
- const result = {
131
- type: ImageReferenceType,
132
- identifier,
133
- label,
134
- referenceType,
135
- alt,
136
- };
137
- return result;
138
- },
131
+ const node = api.shouldReservePosition
132
+ ? {
133
+ type: ImageReferenceType,
134
+ position: api.calcPosition(token),
135
+ identifier,
136
+ label,
137
+ referenceType,
138
+ alt,
139
+ }
140
+ : {
141
+ type: ImageReferenceType,
142
+ identifier,
143
+ label,
144
+ referenceType,
145
+ alt,
146
+ };
147
+ return node;
148
+ }),
139
149
  };
140
150
  };
141
151
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yozora/tokenizer-image-reference",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.2",
4
4
  "author": {
5
5
  "name": "guanghechen",
6
6
  "url": "https://github.com/guanghechen/"
@@ -35,11 +35,11 @@
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.1",
39
- "@yozora/character": "^2.0.0-alpha.1",
40
- "@yozora/core-tokenizer": "^2.0.0-alpha.1",
41
- "@yozora/tokenizer-image": "^2.0.0-alpha.1",
42
- "@yozora/tokenizer-link": "^2.0.0-alpha.1"
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-image": "^2.0.0-alpha.2",
42
+ "@yozora/tokenizer-link": "^2.0.0-alpha.2"
43
43
  },
44
- "gitHead": "86202e1d2b03ccfc2ab030517d9d314f7aee7666"
44
+ "gitHead": "da59d85520455c59a117a35032ef1a035c10ea21"
45
45
  }