Skip to content

fix(core): drop the leading space from PascalCase markdown table headers#28049

Open
he-yufeng wants to merge 1 commit into
google-gemini:mainfrom
he-yufeng:fix/camel-to-space-leading-space
Open

fix(core): drop the leading space from PascalCase markdown table headers#28049
he-yufeng wants to merge 1 commit into
google-gemini:mainfrom
he-yufeng:fix/camel-to-space-leading-space

Conversation

@he-yufeng

Copy link
Copy Markdown

What

camelToSpace (used for jsonToMarkdown object keys and table headers) leaves a stray leading space when the key starts with an uppercase letter:

const result = text.replace(/([A-Z])/g, ' $1'); // "UserId" -> " User Id"
return result.charAt(0).toUpperCase() + result.slice(1).trim();
// charAt(0) is the leading space, so it survives -> " User Id"

"userId""User Id" (fine), but "UserId"" User Id", "Name"" Name", "ID"" I D". JSON whose keys are PascalCase or acronyms (common for .NET/Pascal-style APIs and keys like ID/URL) then renders table headers as | User Id | (double space) instead of | User Id |.

Fix

Trim before capitalizing, so the first real character is the one that gets upper-cased:

const result = text.replace(/([A-Z])/g, ' $1').trim();
return result.charAt(0).toUpperCase() + result.slice(1);

"userId" still maps to "User Id"; "UserId" now also maps to "User Id".

Test

Added a case to markdownUtils.test.ts asserting that a PascalCase-keyed table renders | User Id | Name | (no leading space). It fails on main ('| User Id | Name |...') and passes with this change. vitest run on the file is green (14 tests); prettier and eslint are clean.

@he-yufeng he-yufeng requested a review from a team as a code owner June 19, 2026 20:05
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a formatting issue in markdown table generation where PascalCase object keys resulted in extra leading spaces in table headers. By adjusting the string processing logic in the camelToSpace utility, the output is now correctly formatted for various casing styles, including PascalCase and acronyms.

Highlights

  • Fixing stray leading spaces: Updated the camelToSpace utility function to trim the string before capitalization, ensuring that PascalCase keys do not result in unintended leading spaces in markdown table headers.
  • Regression testing: Added a new test case in markdownUtils.test.ts to verify that PascalCase keys like 'UserId' are correctly formatted without leading spaces.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the size/s A small PR label Jun 19, 2026
@github-actions

Copy link
Copy Markdown

📊 PR Size: size/S

  • Lines changed: 10
  • Additions: +8
  • Deletions: -2
  • Files changed: 2

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request fixes an issue in the camelToSpace utility function where PascalCase keys (which start with an uppercase letter) would result in a leading space in the formatted output. The fix trims the intermediate string before capitalizing the first character. A corresponding unit test has been added to verify this behavior. There are no review comments, so I have no feedback to provide.

@gemini-cli gemini-cli Bot added the status/need-issue Pull requests that need to have an associated issue. label Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/s A small PR status/need-issue Pull requests that need to have an associated issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant