Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

fix([issue-7269]): keep intraword underscores literal in MarkdownOutput

[._.]/ Adam Eivyd9d042d19b7f
diff --git a/client/src/components/cos/MarkdownOutput.jsx b/client/src/components/cos/MarkdownOutput.jsx
index be452e4d02..dd2f59bb2e 100644
--- a/client/src/components/cos/MarkdownOutput.jsx
+++ b/client/src/components/cos/MarkdownOutput.jsx
@@ -3,7 +3,10 @@
// `![alt](url)` image embeds are matched BEFORE the `[text](url)` link form so
// the leading `!` isn't dropped. A same-origin (`/…`) or http(s) src is allowed;
// anything else (data:, javascript:, etc.) renders as the alt text only.
-const INLINE_RE = /(!\[[^\]]*\]\([^)]+\)|`[^`]*`|\*\*[^*]+\*\*|\*[^*]+\*|_[^_]+_|\[[^\]]+\]\([^)]+\))/g;
+// Unlike `*emphasis*`, GFM only opens/closes `_emphasis_` at a word boundary, so
+// the lookarounds keep intraword underscores (QUALITY_AUDIT_JSON, SOME_ENV_VAR,
+// snake_case) literal instead of being consumed as emphasis delimiters.
+const INLINE_RE = /(!\[[^\]]*\]\([^)]+\)|`[^`]*`|\*\*[^*]+\*\*|\*[^*]+\*|(?<!\w)_(?!\s)[^_]+(?<!\s)_(?!\w)|\[[^\]]+\]\([^)]+\))/g;
const safeSrc = (url) => (/^(https?:\/\/|\/[^/])/.test(url) ? url : null);
diff --git a/client/src/components/cos/MarkdownOutput.test.jsx b/client/src/components/cos/MarkdownOutput.test.jsx
new file mode 100644
index 0000000000..9cf81ae490
--- /dev/null
+++ b/client/src/components/cos/MarkdownOutput.test.jsx
@@ -0,0 +1,15 @@
+import { it, expect } from 'vitest';
+import { render, screen } from '@testing-library/react';
+import MarkdownOutput from './MarkdownOutput';
+
+it('keeps intraword underscores literal instead of consuming them as emphasis', () => {
+ render(<MarkdownOutput content="QUALITY_AUDIT_JSON: done" />);
+ expect(screen.getByText('QUALITY_AUDIT_JSON: done')).toBeInTheDocument();
+});
+
+it('still renders a genuine word-boundary _emphasis_ span as italic', () => {
+ render(<MarkdownOutput content="this is _important_ text" />);
+ const em = screen.getByText('important');
+ expect(em.tagName).toBe('EM');
+ expect(screen.getByText(/this is/)).toBeInTheDocument();
+});