mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 22:21:22 -07:00
Removed getPlainTextLength (#18848)
This commit is contained in:
@@ -1,25 +0,0 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2025 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { getPlainTextLength } from './InlineMarkdownRenderer.js';
|
||||
import { describe, it, expect } from 'vitest';
|
||||
|
||||
describe('getPlainTextLength', () => {
|
||||
it.each([
|
||||
['**Primary Go', 12],
|
||||
['*Primary Go', 11],
|
||||
['**Primary Go**', 10],
|
||||
['*Primary Go*', 10],
|
||||
['**', 2],
|
||||
['*', 1],
|
||||
['compile-time**', 14],
|
||||
])(
|
||||
'should measure markdown text length correctly for "%s"',
|
||||
(input, expected) => {
|
||||
expect(getPlainTextLength(input)).toBe(expected);
|
||||
},
|
||||
);
|
||||
});
|
||||
@@ -7,7 +7,6 @@
|
||||
import React from 'react';
|
||||
import { Text } from 'ink';
|
||||
import { theme } from '../semantic-colors.js';
|
||||
import stringWidth from 'string-width';
|
||||
import { debugLogger } from '@google/gemini-cli-core';
|
||||
|
||||
// Constants for Markdown parsing
|
||||
@@ -171,19 +170,3 @@ const RenderInlineInternal: React.FC<RenderInlineProps> = ({
|
||||
};
|
||||
|
||||
export const RenderInline = React.memo(RenderInlineInternal);
|
||||
|
||||
/**
|
||||
* Utility function to get the plain text length of a string with markdown formatting
|
||||
* This is useful for calculating column widths in tables
|
||||
*/
|
||||
export const getPlainTextLength = (text: string): number => {
|
||||
const cleanText = text
|
||||
.replace(/\*\*(.*?)\*\*/g, '$1')
|
||||
.replace(/\*(.+?)\*/g, '$1')
|
||||
.replace(/_(.*?)_/g, '$1')
|
||||
.replace(/~~(.*?)~~/g, '$1')
|
||||
.replace(/`(.*?)`/g, '$1')
|
||||
.replace(/<u>(.*?)<\/u>/g, '$1')
|
||||
.replace(/.*\[(.*?)\]\(.*\)/g, '$1');
|
||||
return stringWidth(cleanText);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user