@yozora/tokenizer-fenced-code 2.0.0-alpha.2 → 2.0.1
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 +13 -8
- package/lib/esm/index.js +13 -8
- package/lib/types/types.d.ts +2 -2
- package/package.json +6 -6
package/lib/cjs/index.js
CHANGED
|
@@ -21,28 +21,33 @@ const parse = function (api) {
|
|
|
21
21
|
parse: tokens => tokens.map(token => {
|
|
22
22
|
const infoString = token.infoString;
|
|
23
23
|
let i = 0;
|
|
24
|
-
const
|
|
24
|
+
const langInfo = [];
|
|
25
25
|
for (; i < infoString.length; ++i) {
|
|
26
26
|
const p = infoString[i];
|
|
27
27
|
if (character.isUnicodeWhitespaceCharacter(p.codePoint))
|
|
28
28
|
break;
|
|
29
|
-
|
|
29
|
+
langInfo.push(p);
|
|
30
30
|
}
|
|
31
|
+
const lang = character.calcEscapedStringFromNodePoints(langInfo, 0, langInfo.length, true);
|
|
31
32
|
i = coreTokenizer.eatOptionalWhitespaces(infoString, i, infoString.length);
|
|
33
|
+
const meta = character.calcEscapedStringFromNodePoints(infoString, i, infoString.length, true);
|
|
32
34
|
const contents = coreTokenizer.mergeContentLinesFaithfully(token.lines);
|
|
35
|
+
let value = character.calcStringFromNodePoints(contents);
|
|
36
|
+
if (!/\n$/.test(value))
|
|
37
|
+
value += '\n';
|
|
33
38
|
const node = api.shouldReservePosition
|
|
34
39
|
? {
|
|
35
40
|
type: ast.CodeType,
|
|
36
41
|
position: token.position,
|
|
37
|
-
lang:
|
|
38
|
-
meta:
|
|
39
|
-
value
|
|
42
|
+
lang: lang.length > 0 ? lang : null,
|
|
43
|
+
meta: meta.length > 0 ? meta : null,
|
|
44
|
+
value,
|
|
40
45
|
}
|
|
41
46
|
: {
|
|
42
47
|
type: ast.CodeType,
|
|
43
|
-
lang:
|
|
44
|
-
meta:
|
|
45
|
-
value
|
|
48
|
+
lang: lang.length > 0 ? lang : null,
|
|
49
|
+
meta: meta.length > 0 ? meta : null,
|
|
50
|
+
value,
|
|
46
51
|
};
|
|
47
52
|
return node;
|
|
48
53
|
}),
|
package/lib/esm/index.js
CHANGED
|
@@ -13,28 +13,33 @@ const parse = function (api) {
|
|
|
13
13
|
parse: tokens => tokens.map(token => {
|
|
14
14
|
const infoString = token.infoString;
|
|
15
15
|
let i = 0;
|
|
16
|
-
const
|
|
16
|
+
const langInfo = [];
|
|
17
17
|
for (; i < infoString.length; ++i) {
|
|
18
18
|
const p = infoString[i];
|
|
19
19
|
if (isUnicodeWhitespaceCharacter(p.codePoint))
|
|
20
20
|
break;
|
|
21
|
-
|
|
21
|
+
langInfo.push(p);
|
|
22
22
|
}
|
|
23
|
+
const lang = calcEscapedStringFromNodePoints(langInfo, 0, langInfo.length, true);
|
|
23
24
|
i = eatOptionalWhitespaces(infoString, i, infoString.length);
|
|
25
|
+
const meta = calcEscapedStringFromNodePoints(infoString, i, infoString.length, true);
|
|
24
26
|
const contents = mergeContentLinesFaithfully(token.lines);
|
|
27
|
+
let value = calcStringFromNodePoints(contents);
|
|
28
|
+
if (!/\n$/.test(value))
|
|
29
|
+
value += '\n';
|
|
25
30
|
const node = api.shouldReservePosition
|
|
26
31
|
? {
|
|
27
32
|
type: CodeType,
|
|
28
33
|
position: token.position,
|
|
29
|
-
lang:
|
|
30
|
-
meta:
|
|
31
|
-
value
|
|
34
|
+
lang: lang.length > 0 ? lang : null,
|
|
35
|
+
meta: meta.length > 0 ? meta : null,
|
|
36
|
+
value,
|
|
32
37
|
}
|
|
33
38
|
: {
|
|
34
39
|
type: CodeType,
|
|
35
|
-
lang:
|
|
36
|
-
meta:
|
|
37
|
-
value
|
|
40
|
+
lang: lang.length > 0 ? lang : null,
|
|
41
|
+
meta: meta.length > 0 ? meta : null,
|
|
42
|
+
value,
|
|
38
43
|
};
|
|
39
44
|
return node;
|
|
40
45
|
}),
|
package/lib/types/types.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Code, CodeType } from '@yozora/ast';
|
|
2
2
|
import type { IBaseBlockTokenizerProps } from '@yozora/core-tokenizer';
|
|
3
3
|
import type { IFencedBlockHookContext, IFencedBlockToken } from '@yozora/tokenizer-fenced-block';
|
|
4
4
|
export declare type T = CodeType;
|
|
5
|
-
export declare type INode =
|
|
5
|
+
export declare type INode = Code;
|
|
6
6
|
export declare const uniqueName = "@yozora/tokenizer-fenced-code";
|
|
7
7
|
export declare type IToken = IFencedBlockToken<T>;
|
|
8
8
|
export declare type IThis = IFencedBlockHookContext<T>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yozora/tokenizer-fenced-code",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
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.
|
|
39
|
-
"@yozora/character": "^2.0.
|
|
40
|
-
"@yozora/core-tokenizer": "^2.0.
|
|
41
|
-
"@yozora/tokenizer-fenced-block": "^2.0.
|
|
38
|
+
"@yozora/ast": "^2.0.1",
|
|
39
|
+
"@yozora/character": "^2.0.1",
|
|
40
|
+
"@yozora/core-tokenizer": "^2.0.1",
|
|
41
|
+
"@yozora/tokenizer-fenced-block": "^2.0.1"
|
|
42
42
|
},
|
|
43
|
-
"gitHead": "
|
|
43
|
+
"gitHead": "3aea33091e402bd6c7754d91d549e8d648475073"
|
|
44
44
|
}
|