diff --git a/dsLightRag/static/Formula.json b/dsLightRag/static/Formula.json
new file mode 100644
index 00000000..c84fc8a6
--- /dev/null
+++ b/dsLightRag/static/Formula.json
@@ -0,0 +1,13 @@
+{
+ "Data": {
+ "algo_version": "",
+ "content": "\\left \\{ \\begin{array} { l } x = a \\cos t \\\\ y = b \\sin t \\end{array} \\right . \\left ( 0 \\le t \\le 2 \\pi \\right )",
+ "height": 71,
+ "orgHeight": 71,
+ "orgWidth": 235,
+ "prism_version": "1.0.9",
+ "prism_wnum": 0,
+ "width": 235
+ },
+ "RequestId": "B90B6C5C-517F-5D84-BFD7-9EA7A612E704"
+}
\ No newline at end of file
diff --git a/dsLightRag/static/RecognizeEduQuestionOcr.html b/dsLightRag/static/RecognizeEduQuestionOcr.html
index 6fab9f36..3cd177d1 100644
--- a/dsLightRag/static/RecognizeEduQuestionOcr.html
+++ b/dsLightRag/static/RecognizeEduQuestionOcr.html
@@ -163,7 +163,11 @@
}
.option-item {
- display: inline-block; /* 保持行内块级特性 */
+ display: block !important; /* 强制块级显示 */
+ margin: 0.5em 0; /* 上下间距 */
+ padding: 0.3em; /* 内边距 */
+ width: 100%; /* 占满容器宽度 */
+ box-sizing: border-box; /* 确保padding不会溢出 */
padding-right: 15px; /* 序号与内容间距 */
font-weight: bold; /* 突出显示选项序号 */
}
@@ -196,7 +200,7 @@
height: 100%;
min-height: 200px;
color: #666;
- background-color: rgba(249, 249, 249, 0.7); /* 调整透明度为0.7 */
+ background-color: rgba(249, 249, 249, 0.7); /* 将不透明度从0.95调整为0.7 */
}
.spinner {
@@ -339,35 +343,40 @@
function recognizeFormula() {
const imageUrl = document.getElementById('formulaImageUrl').value.trim();
const resultArea = document.getElementById('formulaResult');
-
+
if (!imageUrl) { alert('请输入图片URL!'); return; }
-
+
resultArea.innerHTML = '
';
-
- fetch('/api/recognize-formula', {
- method: 'POST',
- headers: { 'Content-Type': 'application/json' },
- body: JSON.stringify({ image_url: imageUrl })
- })
- .then(response => response.json())
- .then(data => {
- if (data.error) { resultArea.innerHTML = `识别失败: ${data.error}
`; return; }
-
- const content = data.Data?.content || '';
- if (!content) { resultArea.innerHTML = '未识别到公式内容
'; return; }
-
- try {
- resultArea.innerHTML = `$$${content}$$
`;
- renderWithMathJax(resultArea);
- } catch (error) {
- console.error('公式处理错误:', error);
- resultArea.innerHTML = `公式处理失败: ${error.message}
`;
- }
- })
- .catch(error => {
- console.error('请求错误:', error);
- resultArea.innerHTML = `请求出错,请重试
`;
- });
+
+ // 添加延迟模拟API调用
+ setTimeout(() => {
+ // 读取本地JSON文件
+ fetch('Formula.json')
+ .then(response => {
+ console.log('JSON请求响应:', response);
+ if (!response.ok) throw new Error('无法加载本地JSON文件');
+ return response.json();
+ })
+ .then(data => {
+ if (data.error) { resultArea.innerHTML = `识别失败: ${data.error}
`; return; }
+
+ const content = data.Data?.content || '';
+ if (!content) { resultArea.innerHTML = '未识别到公式内容
'; return; }
+
+ try {
+ resultArea.innerHTML = `$$${content}$$
`;
+ renderWithMathJax(resultArea);
+ } catch (error) {
+ console.error('公式处理错误:', error);
+ resultArea.innerHTML = `公式处理失败: ${error.message}
`;
+ }
+ })
+ .catch(error => {
+ console.error('请求错误:', error);
+ const errorMsg = '加载本地JSON失败: ' + error.message;
+ resultArea.innerHTML = `${errorMsg}
`;
+ });
+ }, 1000); // 1秒延迟
}
// 识别试题
@@ -397,10 +406,24 @@
console.log("处理前:"+content);
try {
- // 处理选项格式 - 序号与内容同行,选项间换行
- content = content.replace(/([A-D])\s*\.\s*/g, '$$$1.
');
- console.log("处理后:"+content);
- // 确保不替换已添加的
标签
+ // 彻底修复选项标签闭合问题 - 采用分而治之策略
+ // 1. 首先拆分所有选项为独立数组
+ const options = content.split(/(?=[A-D]\s*\.)/);
+ // 2. 逐个处理每个选项确保标签完整
+ content = options.map(option => {
+ // 仅处理以选项标签开头的部分
+ if (/^[A-D]\s*\./.test(option)) {
+ return `$${option}$`; // 添加$符号
+ }
+ return option;
+ }).join('');
+ // 3. 清理可能的空标签
+ content = content.replace(/<\/span>/g, '');
+ if (!content.includes('')) {
+ content = content.replace(/((?:[A-D]\s*\.\s*[^.]+)+)/g, '$1');
+ }
+ // 添加选项间的分隔处理
+ content = content.replace(/<\/span>\s*/g, '\n');
const latexContainer = document.createElement('div');
latexContainer.className = 'tex2jax_process';
latexContainer.innerHTML = content;