Skip to content

[BUG] 代码块解析有问题,内容显示不完整 #1601

@MUKAPP

Description

@MUKAPP

System details / 系统信息

E5 2666v3,Windows 11 24H2,DeepChat v1.0.4-beta.6

What's wrong? / 出了什么问题?

markdown 代码块解析有问题,好多都显示不全
例如:
Image

AI原文:

下面多输出一些 Markdown 代码块示例:

## JavaScript

```javascript
const users = [
  { id: 1, name: "Alice", active: true },
  { id: 2, name: "Bob", active: false },
  { id: 3, name: "Charlie", active: true }
];

const activeUsers = users.filter(user => user.active);

console.log(activeUsers);
```

## TypeScript

```typescript
type User = {
  id: number;
  name: string;
  email?: string;
};

function formatUser(user: User): string {
  return `${user.id}: ${user.name}`;
}

const user: User = {
  id: 1,
  name: "DeepChat"
};

console.log(formatUser(user));
```

## Python

```python
from dataclasses import dataclass

@dataclass
class Task:
    title: str
    done: bool = False

tasks = [
    Task("Write markdown"),
    Task("Test code blocks", True),
]

for task in tasks:
    status = "done" if task.done else "pending"
    print(f"{task.title}: {status}")
```

## Java

```java
public class Main {
    public static void main(String[] args) {
        String name = "DeepChat";
        System.out.println("Hello, " + name + "!");
    }
}
```

## Kotlin

```kotlin
data class User(
    val id: Int,
    val name: String
)

fun main() {
    val user = User(1, "DeepChat")
    println("Hello, ${user.name}")
}
```

## Go

```go
package main

import "fmt"

type User struct {
	ID   int
	Name string
}

func main() {
	user := User{ID: 1, Name: "DeepChat"}
	fmt.Printf("Hello, %s!\n", user.Name)
}
```

## Rust

```rust
#[derive(Debug)]
struct User {
    id: u32,
    name: String,
}

fn main() {
    let user = User {
        id: 1,
        name: String::from("DeepChat"),
    };

    println!("{:?}", user);
}
```

## C

```c
#include <stdio.h>

int main(void) {
    const char *name = "DeepChat";
    printf("Hello, %s!\n", name);
    return 0;
}
```

## C++

```cpp
#include <iostream>
#include <string>

struct User {
    int id;
    std::string name;
};

int main() {
    User user{1, "DeepChat"};
    std::cout << "Hello, " << user.name << "!" << std::endl;
    return 0;
}
```

## HTML

```html
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8" />
  <title>Markdown 测试</title>
</head>
<body>
  <h1>Hello DeepChat</h1>
  <p>这是一个 HTML 代码块。</p>
</body>
</html>
```

## CSS

```css
.card {
  max-width: 420px;
  padding: 24px;
  border-radius: 16px;
  background: linear-gradient(135deg, #1e293b, #0f172a);
  color: #f8fafc;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.35);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 24px;
}
```

## SQL

```sql
CREATE TABLE users (
  id INTEGER PRIMARY KEY,
  name TEXT NOT NULL,
  email TEXT UNIQUE,
  created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

SELECT id, name, email
FROM users
WHERE email IS NOT NULL
ORDER BY created_at DESC;
```

## JSON

```json
{
  "name": "DeepChat",
  "version": "1.0.0",
  "features": ["markdown", "code-block", "table"],
  "enabled": true
}
```

## YAML

```yaml
app:
  name: DeepChat
  environment: development
  features:
    markdown: true
    codeBlocks: true
    tables: true
```

## Bash

```bash
#!/usr/bin/env bash

set -euo pipefail

echo "Testing markdown code blocks..."

for file in *.md; do
  echo "Found markdown file: $file"
done
```

## PowerShell

```powershell
$Name = "DeepChat"

Write-Host "Hello, $Name!"

Get-ChildItem -Filter "*.md" | ForEach-Object {
    Write-Host "Markdown file:" $_.Name
}
```

## Markdown 原文示例

````markdown
# 标题

这是一段包含 **加粗**`行内代码` 的 Markdown。

```js
console.log("nested code block");
```
````

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions