@yozora/tokenizer-inline-math 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
@@ -119,7 +119,7 @@ const match = function (api) {
119
119
 
120
120
  const parse = function (api) {
121
121
  return {
122
- parse: token => {
122
+ parse: tokens => tokens.map(token => {
123
123
  const nodePoints = api.getNodePoints();
124
124
  let startIndex = token.startIndex + token.thickness;
125
125
  let endIndex = token.endIndex - token.thickness;
@@ -138,12 +138,12 @@ const parse = function (api) {
138
138
  endIndex -= 1;
139
139
  }
140
140
  }
141
- const result = {
142
- type: ast.InlineMathType,
143
- value: character.calcStringFromNodePoints(nodePoints, startIndex, endIndex).replace(/\n/, ' '),
144
- };
145
- return result;
146
- },
141
+ const value = character.calcStringFromNodePoints(nodePoints, startIndex, endIndex).replace(/\n/, ' ');
142
+ const node = api.shouldReservePosition
143
+ ? { type: ast.InlineMathType, position: api.calcPosition(token), value }
144
+ : { type: ast.InlineMathType, value };
145
+ return node;
146
+ }),
147
147
  };
148
148
  };
149
149
 
package/lib/esm/index.js CHANGED
@@ -115,7 +115,7 @@ const match = function (api) {
115
115
 
116
116
  const parse = function (api) {
117
117
  return {
118
- parse: token => {
118
+ parse: tokens => tokens.map(token => {
119
119
  const nodePoints = api.getNodePoints();
120
120
  let startIndex = token.startIndex + token.thickness;
121
121
  let endIndex = token.endIndex - token.thickness;
@@ -134,12 +134,12 @@ const parse = function (api) {
134
134
  endIndex -= 1;
135
135
  }
136
136
  }
137
- const result = {
138
- type: InlineMathType,
139
- value: calcStringFromNodePoints(nodePoints, startIndex, endIndex).replace(/\n/, ' '),
140
- };
141
- return result;
142
- },
137
+ const value = calcStringFromNodePoints(nodePoints, startIndex, endIndex).replace(/\n/, ' ');
138
+ const node = api.shouldReservePosition
139
+ ? { type: InlineMathType, position: api.calcPosition(token), value }
140
+ : { type: InlineMathType, value };
141
+ return node;
142
+ }),
143
143
  };
144
144
  };
145
145
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yozora/tokenizer-inline-math",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.2",
4
4
  "description": "Tokenizer for processing inline math (formulas)",
5
5
  "author": {
6
6
  "name": "guanghechen",
@@ -45,12 +45,12 @@
45
45
  "test": "cross-env TS_NODE_FILES=true jest --config ../../jest.config.js --rootDir ."
46
46
  },
47
47
  "dependencies": {
48
- "@yozora/ast": "^2.0.0-alpha.1",
49
- "@yozora/character": "^2.0.0-alpha.1",
50
- "@yozora/core-tokenizer": "^2.0.0-alpha.1"
48
+ "@yozora/ast": "^2.0.0-alpha.2",
49
+ "@yozora/character": "^2.0.0-alpha.2",
50
+ "@yozora/core-tokenizer": "^2.0.0-alpha.2"
51
51
  },
52
52
  "devDependencies": {
53
- "@yozora/tokenizer-inline-code": "^2.0.0-alpha.1"
53
+ "@yozora/tokenizer-inline-code": "^2.0.0-alpha.2"
54
54
  },
55
- "gitHead": "86202e1d2b03ccfc2ab030517d9d314f7aee7666"
55
+ "gitHead": "da59d85520455c59a117a35032ef1a035c10ea21"
56
56
  }