marked-katex-extension 4.0.1 → 4.0.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/index.cjs +16 -9
- package/lib/index.umd.js +16 -9
- package/package.json +5 -2
- package/src/index.js +16 -9
package/lib/index.cjs
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
var katex = require('katex');
|
|
4
4
|
|
|
5
|
-
const inlineStartRule = /(\s|^)\${1,2}(?!\$)/;
|
|
6
5
|
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:]|$)/;
|
|
7
6
|
const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
|
|
8
7
|
|
|
@@ -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,7 +18419,6 @@
|
|
|
18419
18419
|
}
|
|
18420
18420
|
};
|
|
18421
18421
|
|
|
18422
|
-
const inlineStartRule = /(\s|^)\${1,2}(?!\$)/;
|
|
18423
18422
|
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:]|$)/;
|
|
18424
18423
|
const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
|
|
18425
18424
|
|
|
@@ -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.2",
|
|
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 .",
|
|
@@ -46,6 +48,7 @@
|
|
|
46
48
|
"devDependencies": {
|
|
47
49
|
"@babel/core": "^7.23.0",
|
|
48
50
|
"@babel/preset-env": "^7.22.20",
|
|
51
|
+
"@markedjs/testutils": "9.1.0-3",
|
|
49
52
|
"@rollup/plugin-node-resolve": "^15.2.1",
|
|
50
53
|
"@semantic-release/changelog": "^6.0.3",
|
|
51
54
|
"@semantic-release/commit-analyzer": "^11.0.0",
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import katex from 'katex';
|
|
2
2
|
|
|
3
|
-
const inlineStartRule = /(\s|^)\${1,2}(?!\$)/;
|
|
4
3
|
const inlineRule = /^(\${1,2})(?!\$)((?:\\.|[^\\\n])*?(?:\\.|[^\\\n\$]))\1(?=[\s?!\.,:]|$)/;
|
|
5
4
|
const blockRule = /^(\${1,2})\n((?:\\[^]|[^\\])+?)\n\1(?:\n|$)/;
|
|
6
5
|
|
|
@@ -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) {
|