Skip to content

Commit 70a48a3

Browse files
fix(ui): misaligned markdown table rendering (#8336)
Co-authored-by: Tommaso Sciortino <[email protected]>
1 parent 5fa6d87 commit 70a48a3

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/**
2+
* @license
3+
* Copyright 2025 Google LLC
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
import { getPlainTextLength } from './InlineMarkdownRenderer.js';
8+
import { describe, it, expect } from 'vitest';
9+
10+
describe('getPlainTextLength', () => {
11+
it.each([
12+
['**Primary Go', 12],
13+
['*Primary Go', 11],
14+
['**Primary Go**', 10],
15+
['*Primary Go*', 10],
16+
['**', 2],
17+
['*', 1],
18+
['compile-time**', 14],
19+
])(
20+
'should measure markdown text length correctly for "%s"',
21+
(input, expected) => {
22+
expect(getPlainTextLength(input)).toBe(expected);
23+
},
24+
);
25+
});

packages/cli/src/ui/utils/InlineMarkdownRenderer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ export const RenderInline = React.memo(RenderInlineInternal);
178178
export const getPlainTextLength = (text: string): number => {
179179
const cleanText = text
180180
.replace(/\*\*(.*?)\*\*/g, '$1')
181-
.replace(/\*(.*?)\*/g, '$1')
181+
.replace(/\*(.+?)\*/g, '$1')
182182
.replace(/_(.*?)_/g, '$1')
183183
.replace(/~~(.*?)~~/g, '$1')
184184
.replace(/`(.*?)`/g, '$1')

0 commit comments

Comments
 (0)