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

Offen
#578 2 Kommentare 0 Reaktionen 1 zugewiesene Person Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

@prakashNalla arbeitet bereits daran.

Seit 02.11.2026.

  • #579 von @prakashNalla — offen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Beschreibung

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

Vorherrschende Sprache
TypeScript
Sterne
13
Forks
7
Ø Merge
3 Std. 11 Min.
Gemergte PRs (30 T.)
330

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus codercops/chatcops

Alle Issues in codercops/chatcops

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.