Skip to content

fix(widget): drop the whole language tag from a code block - #579

Merged
anurag629 merged 2 commits into
codercops:devfrom
prakashNalla:fix/578-fence-language
Nov 10, 2026
Merged

anurag629 merged 2 commits into
codercops:devfrom
prakashNalla:fix/578-fence-language

Conversation

@prakashNalla

Copy link
Copy Markdown
Collaborator

What does this change?

renderMarkdown() matched a code block's language tag with \w*, so a tag with a symbol (c++, c#, objective-c) left the rest of the tag at the top of the block, and a one-line block like ```const x``` lost its first word as if it were the tag. The tag is now anything up to the end of the fence line, and only when a newline follows it. Patch changeset for @chatcops/widget.

Closes #578

How I tested this

Added cases to packages/widget/tests/markdown.test.ts for c++, c#, objective-c and ts tags and for a one-line block. The first three and the one-line case fail without the change. I also added a tag with a space after it (```ts) and a block that is still streaming with no closing fence; both render the same as on dev.

  • pnpm -r build and pnpm -r typecheck: pass
  • pnpm test: 2430 tests passed (65 skipped)
  • pnpm lint: passes
  • pnpm size: all bundles still under their limits, the chat panel is 18.89 of 19 kB

AI assistance

Claude helped me w/ understand the issue

Checklist

  • This PR targets dev
  • I was assigned the linked issue
  • pnpm -r build, pnpm test and pnpm -r typecheck pass locally
  • Tests added or updated where it makes sense
  • For a bug fix: the new test fails without my change
  • Changeset added (pnpm changeset) if this changes core, widget or server
  • Docs updated if behavior or options changed

@anurag629 anurag629 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @prakashNalla, the change is right. The new pattern at packages/widget/src/markdown.ts:45 takes everything up to the first newline as the tag, and only when a newline follows, so a c++, c# or objective-c tag is dropped whole and a one-line block keeps its first word. The tests cover each case from #578, and the tag with a space after it and the unclosed block expect the same output dev gives today.

@anurag629
anurag629 merged commit 5dbb63f into codercops:dev Nov 10, 2026
5 checks passed
@github-actions github-actions Bot added the codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com) label Nov 10, 2026
@anurag629

Copy link
Copy Markdown
Member

Merged, thanks @prakashNalla.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

codercops-accepted Merged PR that counts on the monthly leaderboard (oss.codercops.com)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants