@yozora/tokenizer-inline-math 2.0.6 → 2.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/LICENSE +1 -1
- package/lib/types/index.d.ts +3 -3
- package/package.json +6 -6
- package/src/match.ts +5 -5
- package/src/types.ts +4 -4
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2020-
|
|
3
|
+
Copyright (c) 2020-2023 guanghechen (https://github.com/guanghechen)
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/lib/types/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { IPartialInlineToken, ITokenizer, IBaseInlineTokenizerProps, ITokenDelimiter, IMatchInlineHookCreator, IParseInlineHookCreator, BaseInlineTokenizer, IInlineTokenizer } from '@yozora/core-tokenizer';
|
|
2
2
|
import { InlineMathType, InlineMath } from '@yozora/ast';
|
|
3
3
|
|
|
4
4
|
type T = InlineMathType;
|
|
5
5
|
type INode = InlineMath;
|
|
6
6
|
declare const uniqueName = "@yozora/tokenizer-inline-math";
|
|
7
|
-
interface IToken extends
|
|
7
|
+
interface IToken extends IPartialInlineToken<T> {
|
|
8
8
|
/**
|
|
9
9
|
* Thickness of the InlineMathDelimiter
|
|
10
10
|
*/
|
|
@@ -13,7 +13,7 @@ interface IToken extends IPartialYastInlineToken<T> {
|
|
|
13
13
|
/**
|
|
14
14
|
* IDelimiter of InlineMathToken.
|
|
15
15
|
*/
|
|
16
|
-
interface IDelimiter extends
|
|
16
|
+
interface IDelimiter extends ITokenDelimiter {
|
|
17
17
|
type: 'full';
|
|
18
18
|
/**
|
|
19
19
|
* Thickness of the InlineMathDelimiter
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-inline-math",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "Tokenizer for processing inline math (formulas)",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "guanghechen",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"test": "cross-env TS_NODE_FILES=true NODE_OPTIONS=--experimental-vm-modules jest --config ../../jest.config.mjs --rootDir ."
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@yozora/ast": "^2.
|
|
53
|
-
"@yozora/character": "^2.
|
|
54
|
-
"@yozora/core-tokenizer": "^2.
|
|
52
|
+
"@yozora/ast": "^2.1.2",
|
|
53
|
+
"@yozora/character": "^2.1.2",
|
|
54
|
+
"@yozora/core-tokenizer": "^2.1.2"
|
|
55
55
|
},
|
|
56
56
|
"devDependencies": {
|
|
57
|
-
"@yozora/tokenizer-inline-code": "^2.
|
|
57
|
+
"@yozora/tokenizer-inline-code": "^2.1.2"
|
|
58
58
|
},
|
|
59
|
-
"gitHead": "
|
|
59
|
+
"gitHead": "992bacafd173e7788e99fed34ce8b45f6ed24cfe"
|
|
60
60
|
}
|
package/src/match.ts
CHANGED
|
@@ -5,7 +5,7 @@ import type {
|
|
|
5
5
|
IMatchInlineHookCreator,
|
|
6
6
|
IResultOfFindDelimiters,
|
|
7
7
|
IResultOfProcessSingleDelimiter,
|
|
8
|
-
|
|
8
|
+
ITokenDelimiter,
|
|
9
9
|
} from '@yozora/core-tokenizer'
|
|
10
10
|
import { eatOptionalCharacters } from '@yozora/core-tokenizer'
|
|
11
11
|
import type { IDelimiter, IThis, IToken, T } from './types'
|
|
@@ -19,7 +19,7 @@ export const match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis> = func
|
|
|
19
19
|
const blockStartIndex: number = api.getBlockStartIndex()
|
|
20
20
|
const blockEndIndex: number = api.getBlockEndIndex()
|
|
21
21
|
|
|
22
|
-
const potentialDelimiters:
|
|
22
|
+
const potentialDelimiters: ITokenDelimiter[] = []
|
|
23
23
|
for (let i = blockStartIndex; i < blockEndIndex; ++i) {
|
|
24
24
|
const c = nodePoints[i].codePoint
|
|
25
25
|
switch (c) {
|
|
@@ -56,7 +56,7 @@ export const match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis> = func
|
|
|
56
56
|
break
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const delimiter:
|
|
59
|
+
const delimiter: ITokenDelimiter = {
|
|
60
60
|
type: 'opener',
|
|
61
61
|
startIndex: _startIndex,
|
|
62
62
|
endIndex: i + 1,
|
|
@@ -88,7 +88,7 @@ export const match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis> = func
|
|
|
88
88
|
// No backtick character found after dollar
|
|
89
89
|
if (thickness <= 1) {
|
|
90
90
|
if (backtickRequired) break
|
|
91
|
-
const delimiter:
|
|
91
|
+
const delimiter: ITokenDelimiter = {
|
|
92
92
|
type: 'both',
|
|
93
93
|
startIndex: _startIndex,
|
|
94
94
|
endIndex: i,
|
|
@@ -97,7 +97,7 @@ export const match: IMatchInlineHookCreator<T, IDelimiter, IToken, IThis> = func
|
|
|
97
97
|
break
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
const delimiter:
|
|
100
|
+
const delimiter: ITokenDelimiter = {
|
|
101
101
|
type: 'closer',
|
|
102
102
|
startIndex: _startIndex,
|
|
103
103
|
endIndex: i,
|
package/src/types.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type { InlineMath, InlineMathType } from '@yozora/ast'
|
|
2
2
|
import type {
|
|
3
3
|
IBaseInlineTokenizerProps,
|
|
4
|
-
|
|
4
|
+
IPartialInlineToken,
|
|
5
|
+
ITokenDelimiter,
|
|
5
6
|
ITokenizer,
|
|
6
|
-
IYastTokenDelimiter,
|
|
7
7
|
} from '@yozora/core-tokenizer'
|
|
8
8
|
|
|
9
9
|
export type T = InlineMathType
|
|
10
10
|
export type INode = InlineMath
|
|
11
11
|
export const uniqueName = '@yozora/tokenizer-inline-math'
|
|
12
12
|
|
|
13
|
-
export interface IToken extends
|
|
13
|
+
export interface IToken extends IPartialInlineToken<T> {
|
|
14
14
|
/**
|
|
15
15
|
* Thickness of the InlineMathDelimiter
|
|
16
16
|
*/
|
|
@@ -20,7 +20,7 @@ export interface IToken extends IPartialYastInlineToken<T> {
|
|
|
20
20
|
/**
|
|
21
21
|
* IDelimiter of InlineMathToken.
|
|
22
22
|
*/
|
|
23
|
-
export interface IDelimiter extends
|
|
23
|
+
export interface IDelimiter extends ITokenDelimiter {
|
|
24
24
|
type: 'full'
|
|
25
25
|
/**
|
|
26
26
|
* Thickness of the InlineMathDelimiter
|