fix(core): drop the leading space from PascalCase markdown table headers#28049
fix(core): drop the leading space from PascalCase markdown table headers#28049he-yufeng wants to merge 1 commit into
Conversation
Summary of ChangesHello, 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 Highlights
Using Gemini Code AssistThe 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
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 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
|
|
📊 PR Size: size/S
|
There was a problem hiding this comment.
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.
What
camelToSpace(used forjsonToMarkdownobject keys and table headers) leaves a stray leading space when the key starts with an uppercase letter:"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 likeID/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:
"userId"still maps to"User Id";"UserId"now also maps to"User Id".Test
Added a case to
markdownUtils.test.tsasserting that a PascalCase-keyed table renders| User Id | Name |(no leading space). It fails onmain('| User Id | Name |...') and passes with this change.vitest runon the file is green (14 tests); prettier and eslint are clean.