Commit Graph

5 Commits

Author SHA1 Message Date
Willem Jiang
1d71f8910e fix: react key warnings from duplicate message IDs + establish jest testing framework (#655)
* fix: resolve issue #588 - react key warnings from duplicate message IDs + establish jest testing framework

* Update the makefile and workflow with the js test

* Apply suggestions from code review

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-10-25 20:46:43 +08:00
Willem Jiang
1a16677d1a fix: unescape markdown-escaped characters in math formulas to fix #608 (#637)
When editing reports, tiptap-markdown escapes special characters (*, _, [, ])
which corrupts LaTeX formulas. This fix:

1. Adds unescapeLatexInMath() function to reverse markdown escaping within
   math delimiters ($...$ and 94410...94410)
2. Applies the unescape function in the editor's onChange callback to clean
   the markdown before storing it
3. Adds comprehensive tests covering edge cases and round-trip scenarios

The fix ensures formulas like $(f * g)[n]$ remain unescaped when editing,
preventing display errors after save/reload.
2025-10-21 10:06:31 +08:00
Willem Jiang
497a2a39cf fix:the formual display error after report editing (#627) 2025-10-17 15:34:43 +08:00
Willem Jiang
58c1743ed5 fix: resolve math formula display abnormal after editing report
This fix addresses the issue where math formulas become corrupted or
incorrectly displayed after editing the generated report in the editor.

**Root Cause:**
The issue occurred due to incompatibility between markdown processing
in the display component and the Tiptap editor:
1. Display component used \[\] and \(\) LaTeX delimiters
2. Tiptap Mathematics extension expects $ and 70868 delimiters
3. tiptap-markdown didn't have built-in math node serialization
4. Math syntax was lost/corrupted during editor save operations

**Solution Implemented:**
1. Created MathematicsWithMarkdown extension that adds markdown
   serialization support to Tiptap's Mathematics nodes
2. Added math delimiter normalization functions:
   - normalizeMathForEditor(): Converts LaTeX delimiters to $/70868
   - normalizeMathForDisplay(): Standardizes all delimiters to 70868
3. Updated Markdown component to use new normalization
4. Updated ReportEditor to normalize content before loading

**Changes:**
- web/src/components/editor/math-serializer.ts (new)
- web/src/components/editor/extensions.tsx
- web/src/components/editor/index.tsx
- web/src/components/deer-flow/markdown.tsx
- web/src/core/utils/markdown.ts
- web/tests/markdown-math-editor.test.ts (new)
- web/tests/markdown-katex.test.ts

**Testing:**
- Added 15 comprehensive tests for math normalization round-trip
- All tests passing (math editor + existing katex tests)
- Verified TypeScript compilation and linting

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
2025-10-15 08:52:50 +08:00
Willem Jiang
2a6455c436 feature: add formula rander in the markdown (#611)
* feature: add formula rander in the markdown

* fixed the lint errors
2025-10-11 23:05:09 +08:00