coai/app
Hobo12 7a57d86894 Update Markdown.tsx
###  Add Math Preprocessing for Markdown Component

#### Summary
This PR introduces preprocessing for math expressions within the Markdown component. The component now transforms inline math (e.g., `\(...\)`) to use the `$ ... $` format and block math (e.g., `\[...\]`) to use the `$$ ... $$` format. This enhancement helps in standardizing the math syntax before it’s processed by the Markdown renderer.

#### Changes
- **Enhanced Markdown Component:**
  - Added a `useMemo` hook in the `Markdown` function to preprocess the `children` content.
  - **Inline Math:** Replaces `\(...\)` with `$ ... $`.
  - **Block Math:** Replaces `\[...\]` with `\n$$\n ... \n$$\n`, ensuring that block math expressions are placed on separate lines.
- **Refactoring:**
  - The processed content is then passed to the existing `MarkdownContent` component, preserving all existing functionalities like code highlighting, link rendering, and file block handling.

#### Rationale
Previously, the Markdown component did not handle the conversion of LaTeX-style math delimiters, which could lead to inconsistent rendering of math expressions. By preprocessing the content, we ensure a more robust and flexible handling of both inline and block math expressions.

#### Possible Drawbacks
- **Non-Mathematical Content Interference:**  
  The preprocessing approach targets `\(...\)` and `\[...\]` delimiters universally. This means that any non-mathematical content using these delimiters for other purposes might be unintentionally transformed, potentially leading to unexpected formatting issues.

#### How to Test
1. **Inline Math:**  
   - Input: `This is inline math: \(a^2 + b^2 = c^2\)`
   - Expected Transformation: `This is inline math: $ a^2 + b^2 = c^2 $`
2. **Block Math:**  
   - Input: `Here is block math: \[ \int_0^\infty e^{-x} dx \]`
   - Expected Transformation:  
     ```
     Here is block math: 
     $$
     \int_0^\infty e^{-x} dx
     $$
     ```
3. **Non-Mathematical Content:**  
   - Ensure that content not intended as math that might incidentally use these delimiters is reviewed to avoid unexpected changes.
4. **Overall Rendering:**  
   - Verify that the Markdown renders as expected with both math expressions and other markdown elements (e.g., code blocks, links).

#### Additional Notes
- The changes maintain backwards compatibility. If there are no math delimiters present, the content remains unaffected.
- The updated component still supports HTML rendering based on the `acceptHtml` prop.
- No changes were made to the auxiliary components (`Label`, `Link`, `Code`), ensuring that the overall markdown styling and functionalities remain consistent.
2025-02-18 20:19:37 +08:00
..
public feat: add gemini pro, gemini pro vision models 2023-12-28 09:32:14 +08:00
src Update Markdown.tsx 2025-02-18 20:19:37 +08:00
src-tauri feat: Add support of gpt-4o-mini 2024-07-19 20:38:56 +08:00
.env.deeptrain update buffer and vision image counter 2023-11-21 21:58:44 +08:00
.eslintrc.cjs v2 moved 2023-09-06 11:21:10 +08:00
.gitignore feat: update auto translation tool 2023-12-21 12:48:26 +08:00
.prettierrc.json v2 moved 2023-09-06 11:21:10 +08:00
components.json feat: charge alpha 2023-12-08 10:15:45 +08:00
index.html feat: update meta viewport (ios support) 2024-02-25 20:57:13 +08:00
package.json feat: better admin user subscription management ui 2024-07-06 15:32:41 +08:00
pnpm-lock.yaml feat: 火山V3接口 2025-02-13 18:33:48 +08:00
postcss.config.js v2 moved 2023-09-06 11:21:10 +08:00
qodana.yaml v2 moved 2023-09-06 11:21:10 +08:00
tailwind.config.js feat: add market land feature 2024-03-18 11:45:34 +08:00
tsconfig.json fix: build error & 2025-02-08 20:38:00 +08:00
tsconfig.node.json feat: add japanese language support 2023-12-21 17:33:24 +08:00
vite.config.ts feat: support function calling (alpha) 2024-02-16 21:21:27 +08:00