[PR #24958] fix: preserve bracketed numbers in code blocks #131613

Open
opened 2026-05-21 17:19:06 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/24958
Author: @pragnyanramtha
Created: 5/20/2026
Status: 🔄 Open

Base: devHead: pragnyan/fix-code-block-citation-strip-24948


📝 Commits (2)

  • c525c41 fix: preserve bracketed numbers in code blocks
  • d524035 fix: preserve indented code citations

📊 Changes

1 file changed (+37 additions, -14 deletions)

View changed files

📝 src/lib/components/chat/Messages/ContentRenderer.svelte (+37 -14)

📄 Description

Pull Request Checklist

Before submitting, make sure you've checked the following:

  • Linked Issue/Discussion: Closes #24948.
  • Target branch: This pull request targets the dev branch.
  • Description: This fixes citation marker stripping so it no longer removes bracketed numbers from fenced or inline code.
  • Changelog: Included below.
  • Documentation: Not applicable; this is a rendering bug fix with no user-facing docs change.
  • Dependencies: No dependency changes.
  • Testing: Targeted lint, formatting, diff checks, and production build were run.
  • No Unchecked AI Code: The change was reviewed and tested locally before submission.
  • Self-Review: Self-review completed.
  • Architecture: Reuses the existing replaceOutsideCode utility instead of introducing new parsing behavior.
  • Git Hygiene: Atomic branch based on dev.
  • Title Prefix: Uses the fix: prefix.

Changelog Entry

Description

  • Preserve bracketed positive integers inside fenced and inline code blocks when citation markers are stripped for citation-disabled models.

Added

  • N/A

Changed

  • Reuses the existing code-aware replacement helper when removing citation markers.

Deprecated

  • N/A

Removed

  • N/A

Fixed

  • Code blocks like data = [0] no longer render or copy as data = when citation handling is disabled.

Security

  • N/A

Breaking Changes

  • N/A

Additional Information

Validation run:

  • npx prettier --plugin-search-dir --check src/lib/components/chat/Messages/ContentRenderer.svelte
  • npx eslint src/lib/components/chat/Messages/ContentRenderer.svelte
  • git diff --check
  • npm run build

I also verified the transform behavior directly: the previous replacement removed [0] from fenced code and [3] from inline code, while the updated path removes citation markers outside code and preserves both code examples.

Screenshots or Videos

  • Not attached; this is a text rendering transform regression and was validated with the deterministic transform check above plus a production build.

Contributor License Agreement


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/24958 **Author:** [@pragnyanramtha](https://github.com/pragnyanramtha) **Created:** 5/20/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `pragnyan/fix-code-block-citation-strip-24948` --- ### 📝 Commits (2) - [`c525c41`](https://github.com/open-webui/open-webui/commit/c525c41051512e2de4ab187c1e19e44c35a72f80) fix: preserve bracketed numbers in code blocks - [`d524035`](https://github.com/open-webui/open-webui/commit/d52403586382a0a4bdb3153ab1a4845b175df417) fix: preserve indented code citations ### 📊 Changes **1 file changed** (+37 additions, -14 deletions) <details> <summary>View changed files</summary> 📝 `src/lib/components/chat/Messages/ContentRenderer.svelte` (+37 -14) </details> ### 📄 Description # Pull Request Checklist **Before submitting, make sure you've checked the following:** - [x] **Linked Issue/Discussion:** Closes #24948. - [x] **Target branch:** This pull request targets the `dev` branch. - [x] **Description:** This fixes citation marker stripping so it no longer removes bracketed numbers from fenced or inline code. - [x] **Changelog:** Included below. - [x] **Documentation:** Not applicable; this is a rendering bug fix with no user-facing docs change. - [x] **Dependencies:** No dependency changes. - [x] **Testing:** Targeted lint, formatting, diff checks, and production build were run. - [x] **No Unchecked AI Code:** The change was reviewed and tested locally before submission. - [x] **Self-Review:** Self-review completed. - [x] **Architecture:** Reuses the existing `replaceOutsideCode` utility instead of introducing new parsing behavior. - [x] **Git Hygiene:** Atomic branch based on `dev`. - [x] **Title Prefix:** Uses the `fix:` prefix. # Changelog Entry ### Description - Preserve bracketed positive integers inside fenced and inline code blocks when citation markers are stripped for citation-disabled models. ### Added - N/A ### Changed - Reuses the existing code-aware replacement helper when removing citation markers. ### Deprecated - N/A ### Removed - N/A ### Fixed - Code blocks like `data = [0]` no longer render or copy as `data =` when citation handling is disabled. ### Security - N/A ### Breaking Changes - N/A --- ### Additional Information Validation run: - `npx prettier --plugin-search-dir --check src/lib/components/chat/Messages/ContentRenderer.svelte` - `npx eslint src/lib/components/chat/Messages/ContentRenderer.svelte` - `git diff --check` - `npm run build` I also verified the transform behavior directly: the previous replacement removed `[0]` from fenced code and `[3]` from inline code, while the updated path removes citation markers outside code and preserves both code examples. ### Screenshots or Videos - Not attached; this is a text rendering transform regression and was validated with the deterministic transform check above plus a production build. ### Contributor License Agreement <!-- DO NOT DELETE THE TEXT BELOW Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. Your PR will NOT be reviewed or merged until you check the box below confirming that you have read and agree to the terms of the CLA. --> - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-05-21 17:19:06 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#131613