Skip to content

Commit 42cd530

Browse files
committed
fix(core): drop the leading space from PascalCase markdown table headers
1 parent c22137e commit 42cd530

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

packages/core/src/utils/markdownUtils.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ describe('markdownUtils', () => {
6464
);
6565
});
6666

67+
it('does not prefix table headers with a stray space for PascalCase keys', () => {
68+
const data = [{ UserId: 1, Name: 'Alice' }];
69+
const result = jsonToMarkdown(data);
70+
expect(result).toBe('| User Id | Name |\n| --- | --- |\n| 1 | Alice |');
71+
});
72+
6773
it('should handle pipe characters, backslashes, and newlines in table data', () => {
6874
const data = [
6975
{ colInfo: 'val|ue', otherInfo: 'line\nbreak', pathInfo: 'C:\\test' },

packages/core/src/utils/markdownUtils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
* e.g., "camelCaseString" -> "Camel Case String"
1010
*/
1111
function camelToSpace(text: string): string {
12-
const result = text.replace(/([A-Z])/g, ' $1');
13-
return result.charAt(0).toUpperCase() + result.slice(1).trim();
12+
const result = text.replace(/([A-Z])/g, ' $1').trim();
13+
return result.charAt(0).toUpperCase() + result.slice(1);
1414
}
1515

1616
/**

0 commit comments

Comments
 (0)