Widget: a code block tagged `c++`, `c#` or `objective-c` shows part of the tag as code

Đang mở
#578 2 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@prakashNalla đang làm issue này rồi.

Từ ngày 2/11/2026.

  • #579 của @prakashNalla — đang mở

Đánh giá

Issue này chưa được đánh giá.

Mô tả

bug widget
Which part?

@chatcops/widget

Package version

dev

What happened?

A code block whose language tag has a symbol in it shows part of the tag as code. renderMarkdown() in packages/widget/src/markdown.ts (line 45) matches the tag with \w*, which stops at the first non-word character, so the rest of the tag ends up inside the block:

renderMarkdown('```c++\nint x;\n```')
// <pre><code>++
// int x;</code></pre>

The same happens with c# (a stray #) and objective-c (a stray -c). Models tag C++ and C# code this way all the time, so these replies start with a junk line.

The tag is also taken from a one-line fence, so ```const x``` renders as <pre><code>x</code></pre> and loses its first word.

What did you expect?

<pre><code>int x;</code></pre>, with the whole tag dropped. I'd match the tag as anything up to the end of the fence line, only when a newline follows it, so a one-line fence keeps all its text, with cases in packages/widget/tests/markdown.test.ts.

How can we reproduce it?

On dev, call renderMarkdown('```c++\nint x;\n```') from packages/widget/src/markdown.ts. The code block starts with ++.

Environment

Node 22, renderMarkdown() run directly on dev

Ngôn ngữ chính
TypeScript
Star
13
Fork
7
Merge trung bình
3 giờ 15 phút
Pull request đã merge (30 ngày)
330

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của codercops/chatcops

Tất cả issue của codercops/chatcops

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.