ai-read-over-pro 0.0.16 → 0.0.18
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/components/demo/src/read-over.vue +58 -47
- package/dist/ai-read-over-pro.common.js +2922 -34
- package/dist/ai-read-over-pro.common.js.map +1 -1
- package/dist/ai-read-over-pro.css +1 -1
- package/dist/ai-read-over-pro.umd.js +2924 -36
- package/dist/ai-read-over-pro.umd.js.map +1 -1
- package/dist/ai-read-over-pro.umd.min.js +4 -4
- package/dist/ai-read-over-pro.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -45,6 +45,7 @@
|
|
|
45
45
|
import ChatTools from "./chat-tools.vue";
|
|
46
46
|
import katex from 'katex';
|
|
47
47
|
import 'katex/dist/katex.min.css';
|
|
48
|
+
import 'katex/contrib/mhchem/mhchem.js';
|
|
48
49
|
export default {
|
|
49
50
|
name: 'ReadOver',
|
|
50
51
|
components: {
|
|
@@ -73,53 +74,63 @@ export default {
|
|
|
73
74
|
this.$emit('on-noty-apply', this.analyzeData, this.exercisesData);
|
|
74
75
|
},
|
|
75
76
|
renderFormulas(text) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
77
|
+
if (!text) return '';
|
|
78
|
+
text = text.replace(/>/g, '>')
|
|
79
|
+
.replace(/</g, '<')
|
|
80
|
+
.replace(/&/g, '&')
|
|
81
|
+
.replace(/"/g, '"')
|
|
82
|
+
.replace(/'/g, "'");
|
|
83
|
+
// 如果整个文本包含 LaTeX 命令且没有定界符,整体包裹
|
|
84
|
+
const hasDelimiter = /\$|\\\(|\\\[/.test(text);
|
|
85
|
+
if (!hasDelimiter) {
|
|
86
|
+
text = text.replace(
|
|
87
|
+
/(\\(?:frac|sqrt|sum|int|cdot|times|geq|leq|neq|pm|div|alpha|beta|gamma|theta|pi|sigma|omega|infty|log|sin|cos|tan|left|right|overline|hat|vec|bar|lim|in|notin|supset|subseteq|ln|Gamma|to)(?:\{[^{}]*(?:\{[^{}]*(?:\{[^{}]*\}[^{}]*)*\}[^{}]*)*\}|[^\s{},。?!、;:\u4e00-\u9fa5])*)/g,
|
|
88
|
+
(match) => `\\(${match}\\)`
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
const { renderToString } = katex;
|
|
92
|
+
return text
|
|
93
|
+
// $$ ... $$ 块级公式
|
|
94
|
+
.replace(/\$\$([\s\S]*?)\$\$/gs, function (_, formula) {
|
|
95
|
+
try {
|
|
96
|
+
const trimmedFormula = formula.trim()
|
|
97
|
+
return renderToString(trimmedFormula, { displayMode: true });
|
|
98
|
+
} catch (error) {
|
|
99
|
+
console.error('Error rendering block formula:', error);
|
|
100
|
+
return _;
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
// \(...\) 行内公式
|
|
104
|
+
.replace(/\\\((.*?)\\\)/gs, function (_, formula) {
|
|
105
|
+
try {
|
|
106
|
+
const trimmedFormula = formula.trim()
|
|
107
|
+
return renderToString(trimmedFormula, { displayMode: false });
|
|
108
|
+
} catch (error) {
|
|
109
|
+
console.error('Error rendering inline formula:', error);
|
|
110
|
+
return _;
|
|
111
|
+
}
|
|
112
|
+
})
|
|
113
|
+
// \[...\] 块级公式
|
|
114
|
+
.replace(/\\\[(.*?)\\\]/gs, function (_, formula) {
|
|
115
|
+
try {
|
|
116
|
+
const trimmedFormula = formula.trim()
|
|
117
|
+
return renderToString(trimmedFormula, { displayMode: true });
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error('Error rendering block formula:', error);
|
|
120
|
+
return _;
|
|
121
|
+
}
|
|
122
|
+
})
|
|
123
|
+
// $...$ 行内公式
|
|
124
|
+
.replace(/\$(.+?)\$/gs, function (_, formula) {
|
|
125
|
+
try {
|
|
126
|
+
const trimmedFormula = formula.trim()
|
|
127
|
+
return renderToString(trimmedFormula, { displayMode: false });
|
|
128
|
+
} catch (error) {
|
|
129
|
+
console.error('Error rendering inline formula with $...$:', error);
|
|
130
|
+
return _;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
},
|
|
123
134
|
},
|
|
124
135
|
}
|
|
125
136
|
</script>
|