@yozora/tokenizer-html-inline 1.3.0 → 2.0.0-alpha.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/cjs/index.js +63 -57
- package/lib/esm/index.js +63 -57
- package/lib/types/index.d.ts +2 -4
- package/lib/types/tokenizer.d.ts +6 -29
- package/lib/types/types.d.ts +12 -12
- package/lib/types/util/cdata.d.ts +6 -6
- package/lib/types/util/closing.d.ts +7 -7
- package/lib/types/util/comment.d.ts +6 -6
- package/lib/types/util/declaration.d.ts +7 -7
- package/lib/types/util/instruction.d.ts +6 -6
- package/lib/types/util/open.d.ts +7 -7
- package/package.json +6 -6
package/lib/cjs/index.js
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var ast = require('@yozora/ast');
|
|
6
5
|
var character = require('@yozora/character');
|
|
7
6
|
var coreTokenizer = require('@yozora/core-tokenizer');
|
|
8
7
|
var tokenizerHtmlBlock = require('@yozora/tokenizer-html-block');
|
|
9
|
-
|
|
10
|
-
const uniqueName = '@yozora/tokenizer-html-inline';
|
|
8
|
+
var ast = require('@yozora/ast');
|
|
11
9
|
|
|
12
10
|
function eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex) {
|
|
13
11
|
let i = startIndex;
|
|
@@ -108,8 +106,7 @@ function eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex) {
|
|
|
108
106
|
|
|
109
107
|
function eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex) {
|
|
110
108
|
let i = startIndex;
|
|
111
|
-
if (i + 4 >= endIndex ||
|
|
112
|
-
nodePoints[i + 1].codePoint !== character.AsciiCodePoint.EXCLAMATION_MARK)
|
|
109
|
+
if (i + 4 >= endIndex || nodePoints[i + 1].codePoint !== character.AsciiCodePoint.EXCLAMATION_MARK)
|
|
113
110
|
return null;
|
|
114
111
|
const tagNameStartIndex = i + 2;
|
|
115
112
|
for (i = tagNameStartIndex; i < endIndex; ++i) {
|
|
@@ -143,8 +140,7 @@ function eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex) {
|
|
|
143
140
|
|
|
144
141
|
function eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex) {
|
|
145
142
|
let i = startIndex;
|
|
146
|
-
if (i + 3 >= endIndex ||
|
|
147
|
-
nodePoints[i + 1].codePoint !== character.AsciiCodePoint.QUESTION_MARK)
|
|
143
|
+
if (i + 3 >= endIndex || nodePoints[i + 1].codePoint !== character.AsciiCodePoint.QUESTION_MARK)
|
|
148
144
|
return null;
|
|
149
145
|
const si = i + 2;
|
|
150
146
|
for (i = si; i < endIndex; ++i) {
|
|
@@ -207,6 +203,8 @@ function eatHtmlInlineTokenOpenDelimiter(nodePoints, startIndex, endIndex) {
|
|
|
207
203
|
return delimiter;
|
|
208
204
|
}
|
|
209
205
|
|
|
206
|
+
const uniqueName = '@yozora/tokenizer-html-inline';
|
|
207
|
+
|
|
210
208
|
class HtmlInlineTokenizer extends coreTokenizer.BaseInlineTokenizer {
|
|
211
209
|
constructor(props = {}) {
|
|
212
210
|
var _a, _b;
|
|
@@ -214,64 +212,72 @@ class HtmlInlineTokenizer extends coreTokenizer.BaseInlineTokenizer {
|
|
|
214
212
|
name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
|
|
215
213
|
priority: (_b = props.priority) !== null && _b !== void 0 ? _b : coreTokenizer.TokenizerPriority.ATOMIC,
|
|
216
214
|
});
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
215
|
+
this.match = api => {
|
|
216
|
+
return {
|
|
217
|
+
findDelimiter: () => coreTokenizer.genFindDelimiter(_findDelimiter),
|
|
218
|
+
processSingleDelimiter,
|
|
219
|
+
};
|
|
220
|
+
function _findDelimiter(startIndex, endIndex) {
|
|
221
|
+
const nodePoints = api.getNodePoints();
|
|
222
|
+
for (let i = startIndex; i < endIndex; ++i) {
|
|
223
|
+
i = coreTokenizer.eatOptionalWhitespaces(nodePoints, i, endIndex);
|
|
224
|
+
if (i >= endIndex)
|
|
225
|
+
break;
|
|
226
|
+
const c = nodePoints[i].codePoint;
|
|
227
|
+
switch (c) {
|
|
228
|
+
case character.AsciiCodePoint.BACKSLASH:
|
|
229
|
+
i += 1;
|
|
230
|
+
break;
|
|
231
|
+
case character.AsciiCodePoint.OPEN_ANGLE: {
|
|
232
|
+
const delimiter = tryToEatDelimiter(nodePoints, i, endIndex);
|
|
233
|
+
if (delimiter != null)
|
|
234
|
+
return delimiter;
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
234
238
|
}
|
|
239
|
+
return null;
|
|
235
240
|
}
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
241
|
+
function processSingleDelimiter(delimiter) {
|
|
242
|
+
const token = Object.assign(Object.assign({}, delimiter), { nodeType: ast.HtmlType });
|
|
243
|
+
return [token];
|
|
244
|
+
}
|
|
245
|
+
};
|
|
246
|
+
this.parse = api => ({
|
|
247
|
+
parse: token => {
|
|
248
|
+
const { startIndex, endIndex } = token;
|
|
249
|
+
const nodePoints = api.getNodePoints();
|
|
250
|
+
const value = character.calcStringFromNodePoints(nodePoints, startIndex, endIndex);
|
|
251
|
+
const result = { type: ast.HtmlType, value };
|
|
252
|
+
return result;
|
|
253
|
+
},
|
|
254
|
+
});
|
|
249
255
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
delimiter = eatHtmlInlineClosingDelimiter(nodePoints, startIndex, endIndex);
|
|
256
|
-
if (delimiter != null)
|
|
257
|
-
return delimiter;
|
|
258
|
-
delimiter = eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex);
|
|
259
|
-
if (delimiter != null)
|
|
260
|
-
return delimiter;
|
|
261
|
-
delimiter = eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex);
|
|
262
|
-
if (delimiter != null)
|
|
263
|
-
return delimiter;
|
|
264
|
-
delimiter = eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex);
|
|
265
|
-
if (delimiter != null)
|
|
266
|
-
return delimiter;
|
|
267
|
-
delimiter = eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex);
|
|
256
|
+
}
|
|
257
|
+
function tryToEatDelimiter(nodePoints, startIndex, endIndex) {
|
|
258
|
+
let delimiter = null;
|
|
259
|
+
delimiter = eatHtmlInlineTokenOpenDelimiter(nodePoints, startIndex, endIndex);
|
|
260
|
+
if (delimiter != null)
|
|
268
261
|
return delimiter;
|
|
269
|
-
|
|
262
|
+
delimiter = eatHtmlInlineClosingDelimiter(nodePoints, startIndex, endIndex);
|
|
263
|
+
if (delimiter != null)
|
|
264
|
+
return delimiter;
|
|
265
|
+
delimiter = eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex);
|
|
266
|
+
if (delimiter != null)
|
|
267
|
+
return delimiter;
|
|
268
|
+
delimiter = eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex);
|
|
269
|
+
if (delimiter != null)
|
|
270
|
+
return delimiter;
|
|
271
|
+
delimiter = eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex);
|
|
272
|
+
if (delimiter != null)
|
|
273
|
+
return delimiter;
|
|
274
|
+
delimiter = eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex);
|
|
275
|
+
return delimiter;
|
|
270
276
|
}
|
|
271
277
|
|
|
272
278
|
exports.HtmlInlineTokenizer = HtmlInlineTokenizer;
|
|
273
279
|
exports.HtmlInlineTokenizerName = uniqueName;
|
|
274
|
-
exports[
|
|
280
|
+
exports["default"] = HtmlInlineTokenizer;
|
|
275
281
|
exports.eatHtmlInlineCDataDelimiter = eatHtmlInlineCDataDelimiter;
|
|
276
282
|
exports.eatHtmlInlineClosingDelimiter = eatHtmlInlineClosingDelimiter;
|
|
277
283
|
exports.eatHtmlInlineCommentDelimiter = eatHtmlInlineCommentDelimiter;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { HtmlType } from '@yozora/ast';
|
|
2
1
|
import { AsciiCodePoint, isAsciiUpperLetter, isWhitespaceCharacter, calcStringFromNodePoints } from '@yozora/character';
|
|
3
|
-
import { eatOptionalWhitespaces, BaseInlineTokenizer, TokenizerPriority } from '@yozora/core-tokenizer';
|
|
2
|
+
import { eatOptionalWhitespaces, BaseInlineTokenizer, TokenizerPriority, genFindDelimiter } from '@yozora/core-tokenizer';
|
|
4
3
|
import { eatHTMLTagName, eatHTMLAttribute } from '@yozora/tokenizer-html-block';
|
|
5
|
-
|
|
6
|
-
const uniqueName = '@yozora/tokenizer-html-inline';
|
|
4
|
+
import { HtmlType } from '@yozora/ast';
|
|
7
5
|
|
|
8
6
|
function eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex) {
|
|
9
7
|
let i = startIndex;
|
|
@@ -104,8 +102,7 @@ function eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex) {
|
|
|
104
102
|
|
|
105
103
|
function eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex) {
|
|
106
104
|
let i = startIndex;
|
|
107
|
-
if (i + 4 >= endIndex ||
|
|
108
|
-
nodePoints[i + 1].codePoint !== AsciiCodePoint.EXCLAMATION_MARK)
|
|
105
|
+
if (i + 4 >= endIndex || nodePoints[i + 1].codePoint !== AsciiCodePoint.EXCLAMATION_MARK)
|
|
109
106
|
return null;
|
|
110
107
|
const tagNameStartIndex = i + 2;
|
|
111
108
|
for (i = tagNameStartIndex; i < endIndex; ++i) {
|
|
@@ -139,8 +136,7 @@ function eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex) {
|
|
|
139
136
|
|
|
140
137
|
function eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex) {
|
|
141
138
|
let i = startIndex;
|
|
142
|
-
if (i + 3 >= endIndex ||
|
|
143
|
-
nodePoints[i + 1].codePoint !== AsciiCodePoint.QUESTION_MARK)
|
|
139
|
+
if (i + 3 >= endIndex || nodePoints[i + 1].codePoint !== AsciiCodePoint.QUESTION_MARK)
|
|
144
140
|
return null;
|
|
145
141
|
const si = i + 2;
|
|
146
142
|
for (i = si; i < endIndex; ++i) {
|
|
@@ -203,6 +199,8 @@ function eatHtmlInlineTokenOpenDelimiter(nodePoints, startIndex, endIndex) {
|
|
|
203
199
|
return delimiter;
|
|
204
200
|
}
|
|
205
201
|
|
|
202
|
+
const uniqueName = '@yozora/tokenizer-html-inline';
|
|
203
|
+
|
|
206
204
|
class HtmlInlineTokenizer extends BaseInlineTokenizer {
|
|
207
205
|
constructor(props = {}) {
|
|
208
206
|
var _a, _b;
|
|
@@ -210,59 +208,67 @@ class HtmlInlineTokenizer extends BaseInlineTokenizer {
|
|
|
210
208
|
name: (_a = props.name) !== null && _a !== void 0 ? _a : uniqueName,
|
|
211
209
|
priority: (_b = props.priority) !== null && _b !== void 0 ? _b : TokenizerPriority.ATOMIC,
|
|
212
210
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
211
|
+
this.match = api => {
|
|
212
|
+
return {
|
|
213
|
+
findDelimiter: () => genFindDelimiter(_findDelimiter),
|
|
214
|
+
processSingleDelimiter,
|
|
215
|
+
};
|
|
216
|
+
function _findDelimiter(startIndex, endIndex) {
|
|
217
|
+
const nodePoints = api.getNodePoints();
|
|
218
|
+
for (let i = startIndex; i < endIndex; ++i) {
|
|
219
|
+
i = eatOptionalWhitespaces(nodePoints, i, endIndex);
|
|
220
|
+
if (i >= endIndex)
|
|
221
|
+
break;
|
|
222
|
+
const c = nodePoints[i].codePoint;
|
|
223
|
+
switch (c) {
|
|
224
|
+
case AsciiCodePoint.BACKSLASH:
|
|
225
|
+
i += 1;
|
|
226
|
+
break;
|
|
227
|
+
case AsciiCodePoint.OPEN_ANGLE: {
|
|
228
|
+
const delimiter = tryToEatDelimiter(nodePoints, i, endIndex);
|
|
229
|
+
if (delimiter != null)
|
|
230
|
+
return delimiter;
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
230
234
|
}
|
|
235
|
+
return null;
|
|
231
236
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
237
|
+
function processSingleDelimiter(delimiter) {
|
|
238
|
+
const token = Object.assign(Object.assign({}, delimiter), { nodeType: HtmlType });
|
|
239
|
+
return [token];
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
this.parse = api => ({
|
|
243
|
+
parse: token => {
|
|
244
|
+
const { startIndex, endIndex } = token;
|
|
245
|
+
const nodePoints = api.getNodePoints();
|
|
246
|
+
const value = calcStringFromNodePoints(nodePoints, startIndex, endIndex);
|
|
247
|
+
const result = { type: HtmlType, value };
|
|
248
|
+
return result;
|
|
249
|
+
},
|
|
250
|
+
});
|
|
245
251
|
}
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
delimiter = eatHtmlInlineClosingDelimiter(nodePoints, startIndex, endIndex);
|
|
252
|
-
if (delimiter != null)
|
|
253
|
-
return delimiter;
|
|
254
|
-
delimiter = eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex);
|
|
255
|
-
if (delimiter != null)
|
|
256
|
-
return delimiter;
|
|
257
|
-
delimiter = eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex);
|
|
258
|
-
if (delimiter != null)
|
|
259
|
-
return delimiter;
|
|
260
|
-
delimiter = eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex);
|
|
261
|
-
if (delimiter != null)
|
|
262
|
-
return delimiter;
|
|
263
|
-
delimiter = eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex);
|
|
252
|
+
}
|
|
253
|
+
function tryToEatDelimiter(nodePoints, startIndex, endIndex) {
|
|
254
|
+
let delimiter = null;
|
|
255
|
+
delimiter = eatHtmlInlineTokenOpenDelimiter(nodePoints, startIndex, endIndex);
|
|
256
|
+
if (delimiter != null)
|
|
264
257
|
return delimiter;
|
|
265
|
-
|
|
258
|
+
delimiter = eatHtmlInlineClosingDelimiter(nodePoints, startIndex, endIndex);
|
|
259
|
+
if (delimiter != null)
|
|
260
|
+
return delimiter;
|
|
261
|
+
delimiter = eatHtmlInlineCommentDelimiter(nodePoints, startIndex, endIndex);
|
|
262
|
+
if (delimiter != null)
|
|
263
|
+
return delimiter;
|
|
264
|
+
delimiter = eatHtmlInlineInstructionDelimiter(nodePoints, startIndex, endIndex);
|
|
265
|
+
if (delimiter != null)
|
|
266
|
+
return delimiter;
|
|
267
|
+
delimiter = eatHtmlInlineDeclarationDelimiter(nodePoints, startIndex, endIndex);
|
|
268
|
+
if (delimiter != null)
|
|
269
|
+
return delimiter;
|
|
270
|
+
delimiter = eatHtmlInlineCDataDelimiter(nodePoints, startIndex, endIndex);
|
|
271
|
+
return delimiter;
|
|
266
272
|
}
|
|
267
273
|
|
|
268
274
|
export { HtmlInlineTokenizer, uniqueName as HtmlInlineTokenizerName, HtmlInlineTokenizer as default, eatHtmlInlineCDataDelimiter, eatHtmlInlineClosingDelimiter, eatHtmlInlineCommentDelimiter, eatHtmlInlineDeclarationDelimiter, eatHtmlInlineInstructionDelimiter, eatHtmlInlineTokenOpenDelimiter };
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { HtmlInlineTokenizer } from './tokenizer';
|
|
2
1
|
export * from './util/cdata';
|
|
3
2
|
export * from './util/closing';
|
|
4
3
|
export * from './util/comment';
|
|
5
4
|
export * from './util/declaration';
|
|
6
5
|
export * from './util/instruction';
|
|
7
6
|
export * from './util/open';
|
|
8
|
-
export { HtmlInlineTokenizer } from './tokenizer';
|
|
7
|
+
export { HtmlInlineTokenizer, HtmlInlineTokenizer as default } from './tokenizer';
|
|
9
8
|
export { uniqueName as HtmlInlineTokenizerName } from './types';
|
|
10
|
-
export type {
|
|
11
|
-
export default HtmlInlineTokenizer;
|
|
9
|
+
export type { IToken as IHtmlInlineToken, ITokenizerProps as IHtmlInlineTokenizerProps, } from './types';
|
package/lib/types/tokenizer.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { NodePoint } from '@yozora/character';
|
|
3
|
-
import type { MatchInlinePhaseApi, ParseInlinePhaseApi, ResultOfProcessSingleDelimiter, Tokenizer, TokenizerMatchInlineHook, TokenizerParseInlineHook } from '@yozora/core-tokenizer';
|
|
1
|
+
import type { IInlineTokenizer, IMatchInlineHookCreator, IParseInlineHookCreator } from '@yozora/core-tokenizer';
|
|
4
2
|
import { BaseInlineTokenizer } from '@yozora/core-tokenizer';
|
|
5
|
-
import type {
|
|
3
|
+
import type { IDelimiter, INode, IToken, ITokenizerProps, T } from './types';
|
|
6
4
|
/**
|
|
7
5
|
* Lexical Analyzer for HtmlInline.
|
|
8
6
|
*
|
|
@@ -13,29 +11,8 @@ import type { Delimiter, Node, T, Token, TokenizerProps } from './types';
|
|
|
13
11
|
*
|
|
14
12
|
* @see https://github.github.com/gfm/#raw-html
|
|
15
13
|
*/
|
|
16
|
-
export declare class HtmlInlineTokenizer extends BaseInlineTokenizer<
|
|
17
|
-
constructor(props?:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* @see BaseInlineTokenizer
|
|
21
|
-
*/
|
|
22
|
-
protected _findDelimiter(startIndex: number, endIndex: number, api: Readonly<MatchInlinePhaseApi>): Delimiter | null;
|
|
23
|
-
/**
|
|
24
|
-
* @override
|
|
25
|
-
* @see TokenizerMatchInlineHook
|
|
26
|
-
*/
|
|
27
|
-
processSingleDelimiter(delimiter: Delimiter): ResultOfProcessSingleDelimiter<T, Token>;
|
|
28
|
-
/**
|
|
29
|
-
* @override
|
|
30
|
-
* @see TokenizerParseInlineHook
|
|
31
|
-
*/
|
|
32
|
-
parseInline(token: Token, children: YastNode[], api: Readonly<ParseInlinePhaseApi>): Node;
|
|
33
|
-
/**
|
|
34
|
-
* Try to eat a delimiter
|
|
35
|
-
*
|
|
36
|
-
* @param nodePoints
|
|
37
|
-
* @param startIndex
|
|
38
|
-
* @param endIndex
|
|
39
|
-
*/
|
|
40
|
-
protected tryToEatDelimiter(nodePoints: ReadonlyArray<NodePoint>, startIndex: number, endIndex: number): Delimiter | null;
|
|
14
|
+
export declare class HtmlInlineTokenizer extends BaseInlineTokenizer<T, IDelimiter, IToken, INode> implements IInlineTokenizer<T, IDelimiter, IToken, INode> {
|
|
15
|
+
constructor(props?: ITokenizerProps);
|
|
16
|
+
readonly match: IMatchInlineHookCreator<T, IDelimiter, IToken>;
|
|
17
|
+
readonly parse: IParseInlineHookCreator<T, IToken, INode>;
|
|
41
18
|
}
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
1
|
+
import type { HtmlType, IHtml } from '@yozora/ast';
|
|
2
|
+
import type { IBaseInlineTokenizerProps, IPartialYastInlineToken } from '@yozora/core-tokenizer';
|
|
3
|
+
import type { IHtmlInlineCDataDelimiter, IHtmlInlineCDataTokenData } from './util/cdata';
|
|
4
|
+
import type { IHtmlInlineClosingDelimiter, IHtmlInlineClosingTokenData } from './util/closing';
|
|
5
|
+
import type { IHtmlInlineCommentDelimiter, IHtmlInlineCommentTokenData } from './util/comment';
|
|
6
|
+
import type { IHtmlInlineDeclarationDelimiter, IHtmlInlineDeclarationTokenData } from './util/declaration';
|
|
7
|
+
import type { IHtmlInlineInstructionDelimiter, IHtmlInlineInstructionTokenData } from './util/instruction';
|
|
8
|
+
import type { IHtmlInlineOpenDelimiter, IHtmlInlineOpenTokenData as IHtmlInlineOpenTokenData } from './util/open';
|
|
9
9
|
export declare type T = HtmlType;
|
|
10
|
-
export declare type
|
|
10
|
+
export declare type INode = IHtml;
|
|
11
11
|
export declare const uniqueName = "@yozora/tokenizer-html-inline";
|
|
12
12
|
/**
|
|
13
13
|
* Text between '<' and '>' that looks like an HTML tag is parsed as a raw
|
|
@@ -17,6 +17,6 @@ export declare const uniqueName = "@yozora/tokenizer-html-inline";
|
|
|
17
17
|
*
|
|
18
18
|
* @see https://github.github.com/gfm/#raw-html
|
|
19
19
|
*/
|
|
20
|
-
export declare type
|
|
21
|
-
export declare type
|
|
22
|
-
export declare type
|
|
20
|
+
export declare type IToken = IPartialYastInlineToken<T> & (IHtmlInlineOpenTokenData | IHtmlInlineClosingTokenData | IHtmlInlineCommentTokenData | IHtmlInlineInstructionTokenData | IHtmlInlineDeclarationTokenData | IHtmlInlineCDataTokenData);
|
|
21
|
+
export declare type IDelimiter = IHtmlInlineOpenDelimiter | IHtmlInlineClosingDelimiter | IHtmlInlineCommentDelimiter | IHtmlInlineInstructionDelimiter | IHtmlInlineDeclarationDelimiter | IHtmlInlineCDataDelimiter;
|
|
22
|
+
export declare type ITokenizerProps = Partial<IBaseInlineTokenizerProps>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export interface
|
|
1
|
+
import type { INodePoint } from '@yozora/character';
|
|
2
|
+
import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
|
|
3
|
+
export interface IHtmlInlineCDataData {
|
|
4
4
|
htmlType: 'cdata';
|
|
5
5
|
}
|
|
6
|
-
export interface
|
|
6
|
+
export interface IHtmlInlineCDataTokenData {
|
|
7
7
|
htmlType: 'cdata';
|
|
8
8
|
}
|
|
9
|
-
export interface
|
|
9
|
+
export interface IHtmlInlineCDataDelimiter extends IYastTokenDelimiter, IHtmlInlineCDataTokenData {
|
|
10
10
|
type: 'full';
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -18,4 +18,4 @@ export interface HtmlInlineCDataDelimiter extends YastTokenDelimiter, HtmlInline
|
|
|
18
18
|
* @param endIndex
|
|
19
19
|
* @see https://github.github.com/gfm/#cdata-section
|
|
20
20
|
*/
|
|
21
|
-
export declare function eatHtmlInlineCDataDelimiter(nodePoints: ReadonlyArray<
|
|
21
|
+
export declare function eatHtmlInlineCDataDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineCDataDelimiter | null;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export interface
|
|
1
|
+
import type { INodeInterval, INodePoint } from '@yozora/character';
|
|
2
|
+
import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
|
|
3
|
+
export interface IHtmlInlineClosingTagData {
|
|
4
4
|
htmlType: 'closing';
|
|
5
5
|
tagName: string;
|
|
6
6
|
}
|
|
7
|
-
export interface
|
|
7
|
+
export interface IHtmlInlineClosingTokenData {
|
|
8
8
|
htmlType: 'closing';
|
|
9
|
-
tagName:
|
|
9
|
+
tagName: INodeInterval;
|
|
10
10
|
}
|
|
11
|
-
export interface
|
|
11
|
+
export interface IHtmlInlineClosingDelimiter extends IYastTokenDelimiter, IHtmlInlineClosingTokenData {
|
|
12
12
|
type: 'full';
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
@@ -20,4 +20,4 @@ export interface HtmlInlineClosingDelimiter extends YastTokenDelimiter, HtmlInli
|
|
|
20
20
|
* @param endIndex
|
|
21
21
|
* @see https://github.github.com/gfm/#closing-tag
|
|
22
22
|
*/
|
|
23
|
-
export declare function eatHtmlInlineClosingDelimiter(nodePoints: ReadonlyArray<
|
|
23
|
+
export declare function eatHtmlInlineClosingDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineClosingDelimiter | null;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export interface
|
|
1
|
+
import type { INodePoint } from '@yozora/character';
|
|
2
|
+
import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
|
|
3
|
+
export interface IHtmlInlineCommentData {
|
|
4
4
|
htmlType: 'comment';
|
|
5
5
|
}
|
|
6
|
-
export interface
|
|
6
|
+
export interface IHtmlInlineCommentTokenData {
|
|
7
7
|
htmlType: 'comment';
|
|
8
8
|
}
|
|
9
|
-
export interface
|
|
9
|
+
export interface IHtmlInlineCommentDelimiter extends IYastTokenDelimiter, IHtmlInlineCommentTokenData {
|
|
10
10
|
type: 'full';
|
|
11
11
|
}
|
|
12
12
|
/**
|
|
@@ -18,4 +18,4 @@ export interface HtmlInlineCommentDelimiter extends YastTokenDelimiter, HtmlInli
|
|
|
18
18
|
* @param endIndex
|
|
19
19
|
* @see https://github.github.com/gfm/#html-comment
|
|
20
20
|
*/
|
|
21
|
-
export declare function eatHtmlInlineCommentDelimiter(nodePoints: ReadonlyArray<
|
|
21
|
+
export declare function eatHtmlInlineCommentDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineCommentDelimiter | null;
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
export interface
|
|
1
|
+
import type { INodeInterval, INodePoint } from '@yozora/character';
|
|
2
|
+
import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
|
|
3
|
+
export interface IHtmlInlineDeclarationData {
|
|
4
4
|
htmlType: 'declaration';
|
|
5
5
|
}
|
|
6
|
-
export interface
|
|
6
|
+
export interface IHtmlInlineDeclarationTokenData {
|
|
7
7
|
htmlType: 'declaration';
|
|
8
|
-
tagName:
|
|
8
|
+
tagName: INodeInterval;
|
|
9
9
|
}
|
|
10
|
-
export interface
|
|
10
|
+
export interface IHtmlInlineDeclarationDelimiter extends IYastTokenDelimiter, IHtmlInlineDeclarationTokenData {
|
|
11
11
|
type: 'full';
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
@@ -20,4 +20,4 @@ export interface HtmlInlineDeclarationDelimiter extends YastTokenDelimiter, Html
|
|
|
20
20
|
* @param endIndex
|
|
21
21
|
* @see https://github.github.com/gfm/#declaration
|
|
22
22
|
*/
|
|
23
|
-
export declare function eatHtmlInlineDeclarationDelimiter(nodePoints: ReadonlyArray<
|
|
23
|
+
export declare function eatHtmlInlineDeclarationDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineDeclarationDelimiter | null;
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { INodePoint } from '@yozora/character';
|
|
2
|
+
import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
|
|
3
3
|
/**
|
|
4
4
|
*
|
|
5
5
|
* @see https://github.github.com/gfm/#processing-instruction
|
|
6
6
|
*/
|
|
7
|
-
export interface
|
|
7
|
+
export interface IHtmlInlineInstructionData {
|
|
8
8
|
htmlType: 'instruction';
|
|
9
9
|
}
|
|
10
|
-
export interface
|
|
10
|
+
export interface IHtmlInlineInstructionTokenData {
|
|
11
11
|
htmlType: 'instruction';
|
|
12
12
|
}
|
|
13
|
-
export interface
|
|
13
|
+
export interface IHtmlInlineInstructionDelimiter extends IYastTokenDelimiter, IHtmlInlineInstructionTokenData {
|
|
14
14
|
type: 'full';
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
@@ -22,4 +22,4 @@ export interface HtmlInlineInstructionDelimiter extends YastTokenDelimiter, Html
|
|
|
22
22
|
* @param endIndex
|
|
23
23
|
* @see https://github.github.com/gfm/#processing-instruction
|
|
24
24
|
*/
|
|
25
|
-
export declare function eatHtmlInlineInstructionDelimiter(nodePoints: ReadonlyArray<
|
|
25
|
+
export declare function eatHtmlInlineInstructionDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineInstructionDelimiter | null;
|
package/lib/types/util/open.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
1
|
+
import type { INodeInterval, INodePoint } from '@yozora/character';
|
|
2
|
+
import type { IYastTokenDelimiter } from '@yozora/core-tokenizer';
|
|
3
3
|
import type { RawHTMLAttribute } from '@yozora/tokenizer-html-block';
|
|
4
|
-
export interface
|
|
4
|
+
export interface IHtmlInlineOpenTagData {
|
|
5
5
|
htmlType: 'open';
|
|
6
6
|
/**
|
|
7
7
|
* HTML tag name.
|
|
@@ -19,13 +19,13 @@ export interface HtmlInlineOpenTagData {
|
|
|
19
19
|
*/
|
|
20
20
|
selfClosed: boolean;
|
|
21
21
|
}
|
|
22
|
-
export interface
|
|
22
|
+
export interface IHtmlInlineOpenTokenData {
|
|
23
23
|
htmlType: 'open';
|
|
24
|
-
tagName:
|
|
24
|
+
tagName: INodeInterval;
|
|
25
25
|
attributes: RawHTMLAttribute[];
|
|
26
26
|
selfClosed: boolean;
|
|
27
27
|
}
|
|
28
|
-
export interface
|
|
28
|
+
export interface IHtmlInlineOpenDelimiter extends IYastTokenDelimiter, IHtmlInlineOpenTokenData {
|
|
29
29
|
type: 'full';
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
@@ -37,4 +37,4 @@ export interface HtmlInlineOpenDelimiter extends YastTokenDelimiter, HtmlInlineO
|
|
|
37
37
|
* @param endIndex
|
|
38
38
|
* @see https://github.github.com/gfm/#open-tag
|
|
39
39
|
*/
|
|
40
|
-
export declare function eatHtmlInlineTokenOpenDelimiter(nodePoints: ReadonlyArray<
|
|
40
|
+
export declare function eatHtmlInlineTokenOpenDelimiter(nodePoints: ReadonlyArray<INodePoint>, startIndex: number, endIndex: number): IHtmlInlineOpenDelimiter | null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-html-inline",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-alpha.0",
|
|
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": "^
|
|
39
|
-
"@yozora/character": "^
|
|
40
|
-
"@yozora/core-tokenizer": "^
|
|
41
|
-
"@yozora/tokenizer-html-block": "^
|
|
38
|
+
"@yozora/ast": "^2.0.0-alpha.0",
|
|
39
|
+
"@yozora/character": "^2.0.0-alpha.0",
|
|
40
|
+
"@yozora/core-tokenizer": "^2.0.0-alpha.0",
|
|
41
|
+
"@yozora/tokenizer-html-block": "^2.0.0-alpha.0"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "0171501339c49ffd02ed16a63447fa20a47a29a7"
|
|
44
44
|
}
|