Skip to content

Commit

Permalink
🔧 Bump version to 1.9.4 and improve LaTeX list formatting
Browse files Browse the repository at this point in the history
- Updated version number in manifest.json to 1.9.4.
- Enhanced LaTeX processing in latex.js to adjust list indentation, ensuring consistent formatting by using 4 spaces for all list levels.
  • Loading branch information
yym68686 committed Jan 16, 2025
1 parent 8b42307 commit 9e61f91
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Cerebr",
"version": "1.9.3",
"version": "1.9.4",
"description": "Cerebr - 智能AI聊天助手",
"content_security_policy": {
"extension_pages": "script-src 'self' 'wasm-unsafe-eval'; object-src 'self'"
Expand Down
25 changes: 19 additions & 6 deletions src/utils/latex.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,32 @@ export function processMathAndMarkdown(text) {
**2. 主要贡献:**
* **开源:** Xmodel-2 是开源的
**第一封邮件(7月22日)**是
即 **a** ⊗ **b** ≠ **b** ⊗ **a**。
**3. A 和 B 矩阵的生成**
* **A**:
* R
* Q
* K
*/

// 处理第一级列表(确保使用3个空格)
text = text.replace(/^\s{3,4}\*\s+/mg, ' * ');

// 处理列表缩进,保持层级关系但使用4个空格
text = text.replace(/^(\s{4,})\*(\s+)/mg, (match, spaces, trailing) => {
// 计算缩进层级(每4个空格算一级)
const level = Math.floor(spaces.length / 4);
// 找出所有列表项的最小缩进空格数
const minIndent = Math.min(...text.match(/^(\s*)\*/mg).map(s => s.length - 1));
// 计算当前项相对于最小缩进的层级(每4个空格算一级)
const relativeLevel = Math.floor((spaces.length - minIndent) / 4);
// 根据最小缩进确定最大允许层级
const maxLevel = minIndent === 0 ? 2 : (minIndent === 4 ? 3 : 4);
// 限制最终层级
const level = Math.min(relativeLevel, maxLevel - Math.floor(minIndent / 4));
// 为每一级添加4个空格
return ' '.repeat(level) + '*' + trailing;
return ' '.repeat(level) + '* ';
});

// // 处理第一级列表(确保使用3个空格)
// text = text.replace(/^(\s{0,2})\*(\s+)/mg, ' *$2');

// 渲染 Markdown
let html = marked.parse(text);

Expand Down

0 comments on commit 9e61f91

Please sign in to comment.