marked-katex-extension 4.0.1 → 4.0.3
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/index.cjs +17 -10
- package/lib/index.umd.js +17 -10
- package/package.json +14 -11
- package/src/index.js +17 -10
package/lib/index.cjs
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var katex = require('katex');
|
|
4
4
|
|
|
5
|
-
const
|
|
6
|
-
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:]|$)/;
|
|
5
|
+
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/;
|
|
7
6
|
const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
|
|
8
7
|
|
|
9
8
|
function index(options = {}) {
|
|
@@ -24,16 +23,24 @@ function inlineKatex(options, renderer) {
|
|
|
24
23
|
name: 'inlineKatex',
|
|
25
24
|
level: 'inline',
|
|
26
25
|
start(src) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
26
|
+
let index;
|
|
27
|
+
let indexSrc = src;
|
|
28
|
+
|
|
29
|
+
while (indexSrc) {
|
|
30
|
+
index = indexSrc.indexOf('$');
|
|
31
|
+
if (index === -1) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (index === 0 || indexSrc.charAt(index - 1) === ' ') {
|
|
36
|
+
const possibleKatex = indexSrc.substring(index);
|
|
31
37
|
|
|
32
|
-
|
|
33
|
-
|
|
38
|
+
if (possibleKatex.match(inlineRule)) {
|
|
39
|
+
return index;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
return index;
|
|
43
|
+
indexSrc = indexSrc.substring(index + 1).replace(/^\$+/, '');
|
|
37
44
|
}
|
|
38
45
|
},
|
|
39
46
|
tokenizer(src, tokens) {
|
package/lib/index.umd.js
CHANGED
|
@@ -18419,8 +18419,7 @@
|
|
|
18419
18419
|
}
|
|
18420
18420
|
};
|
|
18421
18421
|
|
|
18422
|
-
const
|
|
18423
|
-
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:]|$)/;
|
|
18422
|
+
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/;
|
|
18424
18423
|
const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
|
|
18425
18424
|
|
|
18426
18425
|
function index(options = {}) {
|
|
@@ -18441,16 +18440,24 @@
|
|
|
18441
18440
|
name: 'inlineKatex',
|
|
18442
18441
|
level: 'inline',
|
|
18443
18442
|
start(src) {
|
|
18444
|
-
|
|
18445
|
-
|
|
18446
|
-
|
|
18447
|
-
|
|
18443
|
+
let index;
|
|
18444
|
+
let indexSrc = src;
|
|
18445
|
+
|
|
18446
|
+
while (indexSrc) {
|
|
18447
|
+
index = indexSrc.indexOf('$');
|
|
18448
|
+
if (index === -1) {
|
|
18449
|
+
return;
|
|
18450
|
+
}
|
|
18448
18451
|
|
|
18449
|
-
|
|
18450
|
-
|
|
18452
|
+
if (index === 0 || indexSrc.charAt(index - 1) === ' ') {
|
|
18453
|
+
const possibleKatex = indexSrc.substring(index);
|
|
18454
|
+
|
|
18455
|
+
if (possibleKatex.match(inlineRule)) {
|
|
18456
|
+
return index;
|
|
18457
|
+
}
|
|
18458
|
+
}
|
|
18451
18459
|
|
|
18452
|
-
|
|
18453
|
-
return index;
|
|
18460
|
+
indexSrc = indexSrc.substring(index + 1).replace(/^\$+/, '');
|
|
18454
18461
|
}
|
|
18455
18462
|
},
|
|
18456
18463
|
tokenizer(src, tokens) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marked-katex-extension",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "MarkedJS extesion to render katex",
|
|
5
5
|
"main": "./lib/index.cjs",
|
|
6
6
|
"module": "./src/index.js",
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"scripts": {
|
|
26
|
-
"test": "
|
|
26
|
+
"test": "npm run build && npm run test:cover && npm run test:spec && npm run test:types && npm run lint",
|
|
27
|
+
"test:katex": "jest --verbose",
|
|
28
|
+
"test:spec": "node --test spec/marked-tests.js",
|
|
27
29
|
"test:cover": "jest --coverage",
|
|
28
30
|
"test:types": "tsd -f spec/index.test-d.ts -t src/index.d.ts",
|
|
29
31
|
"lint": "eslint .",
|
|
@@ -44,9 +46,10 @@
|
|
|
44
46
|
"marked": ">=4 <10"
|
|
45
47
|
},
|
|
46
48
|
"devDependencies": {
|
|
47
|
-
"@babel/core": "^7.23.
|
|
48
|
-
"@babel/preset-env": "^7.
|
|
49
|
-
"@
|
|
49
|
+
"@babel/core": "^7.23.2",
|
|
50
|
+
"@babel/preset-env": "^7.23.2",
|
|
51
|
+
"@markedjs/testutils": "9.1.0-3",
|
|
52
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
50
53
|
"@semantic-release/changelog": "^6.0.3",
|
|
51
54
|
"@semantic-release/commit-analyzer": "^11.0.0",
|
|
52
55
|
"@semantic-release/git": "^10.0.1",
|
|
@@ -55,20 +58,20 @@
|
|
|
55
58
|
"@semantic-release/release-notes-generator": "^12.0.0",
|
|
56
59
|
"babel-jest": "^29.7.0",
|
|
57
60
|
"cheerio": "^1.0.0-rc.12",
|
|
58
|
-
"eslint": "^8.
|
|
61
|
+
"eslint": "^8.52.0",
|
|
59
62
|
"eslint-config-standard": "^17.1.0",
|
|
60
|
-
"eslint-plugin-import": "^2.
|
|
61
|
-
"eslint-plugin-n": "^16.
|
|
63
|
+
"eslint-plugin-import": "^2.29.0",
|
|
64
|
+
"eslint-plugin-n": "^16.2.0",
|
|
62
65
|
"eslint-plugin-promise": "^6.1.1",
|
|
63
66
|
"jest-cli": "^29.7.0",
|
|
64
|
-
"marked": "^9.
|
|
67
|
+
"marked": "^9.1.2",
|
|
65
68
|
"node-fetch": "^3.3.2",
|
|
66
|
-
"rollup": "^
|
|
69
|
+
"rollup": "^4.1.4",
|
|
67
70
|
"semantic-release": "^22.0.5",
|
|
68
71
|
"tsd": "^0.29.0"
|
|
69
72
|
},
|
|
70
73
|
"dependencies": {
|
|
71
|
-
"@types/katex": "^0.16.
|
|
74
|
+
"@types/katex": "^0.16.5",
|
|
72
75
|
"katex": "^0.16.9"
|
|
73
76
|
}
|
|
74
77
|
}
|
package/src/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import katex from 'katex';
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:]|$)/;
|
|
3
|
+
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:?!。,:]|$)/;
|
|
5
4
|
const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
|
|
6
5
|
|
|
7
6
|
export default function(options = {}) {
|
|
@@ -22,16 +21,24 @@ function inlineKatex(options, renderer) {
|
|
|
22
21
|
name: 'inlineKatex',
|
|
23
22
|
level: 'inline',
|
|
24
23
|
start(src) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
let index;
|
|
25
|
+
let indexSrc = src;
|
|
26
|
+
|
|
27
|
+
while (indexSrc) {
|
|
28
|
+
index = indexSrc.indexOf('$');
|
|
29
|
+
if (index === -1) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (index === 0 || indexSrc.charAt(index - 1) === ' ') {
|
|
34
|
+
const possibleKatex = indexSrc.substring(index);
|
|
29
35
|
|
|
30
|
-
|
|
31
|
-
|
|
36
|
+
if (possibleKatex.match(inlineRule)) {
|
|
37
|
+
return index;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
32
40
|
|
|
33
|
-
|
|
34
|
-
return index;
|
|
41
|
+
indexSrc = indexSrc.substring(index + 1).replace(/^\$+/, '');
|
|
35
42
|
}
|
|
36
43
|
},
|
|
37
44
|
tokenizer(src, tokens) {
|