File tree Expand file tree Collapse file tree 3 files changed +26
-7
lines changed
Expand file tree Collapse file tree 3 files changed +26
-7
lines changed Original file line number Diff line number Diff line change 5656 },
5757 "dependencies" : {
5858 "hightable" : " 0.18.5" ,
59- "hyparquet" : " 1.17.7 " ,
59+ "hyparquet" : " 1.17.8 " ,
6060 "hyparquet-compressors" : " 1.1.1" ,
6161 "icebird" : " 0.3.0" ,
6262 "react" : " 18.3.1" ,
6666 "@eslint/js" : " 9.35.0" ,
6767 "@storybook/react-vite" : " 9.1.5" ,
6868 "@testing-library/react" : " 16.3.0" ,
69- "@types/node" : " 24.3.1 " ,
70- "@types/react" : " 19.1.12 " ,
69+ "@types/node" : " 24.4.0 " ,
70+ "@types/react" : " 19.1.13 " ,
7171 "@types/react-dom" : " 19.1.9" ,
7272 "@vitejs/plugin-react" : " 5.0.2" ,
7373 "@vitest/coverage-v8" : " 3.2.4" ,
7676 "eslint-plugin-react-hooks" : " 5.2.0" ,
7777 "eslint-plugin-react-refresh" : " 0.4.20" ,
7878 "eslint-plugin-storybook" : " 9.1.5" ,
79- "globals" : " 16.3 .0" ,
80- "jsdom" : " 26.1 .0" ,
79+ "globals" : " 16.4 .0" ,
80+ "jsdom" : " 27.0 .0" ,
8181 "nodemon" : " 3.1.10" ,
8282 "npm-run-all" : " 4.1.5" ,
8383 "storybook" : " 9.1.5" ,
8484 "typescript" : " 5.8.3" ,
85- "typescript-eslint" : " 8.42 .0" ,
86- "vite" : " 7.1.4 " ,
85+ "typescript-eslint" : " 8.43 .0" ,
86+ "vite" : " 7.1.5 " ,
8787 "vitest" : " 3.2.4"
8888 },
8989 "eslintConfig" : {
Original file line number Diff line number Diff line change @@ -536,4 +536,17 @@ describe('Markdown with tables', () => {
536536 expect ( getByText ( 'Row 2' ) ) . toBeDefined ( )
537537 expect ( getByText ( 'Data 2' ) ) . toBeDefined ( )
538538 } )
539+
540+ it ( 'renders a table without preceding newline' , ( ) => {
541+ const text = 'Oldest houses:\n| id | year |\n|---|---|\n| 83 | 1920 |\n| 19 | 1951 |'
542+ const { getByText, getByRole } = render ( < Markdown text = { text } /> )
543+ expect ( getByRole ( 'table' ) ) . toBeDefined ( )
544+ expect ( getByText ( 'id' ) ) . toBeDefined ( )
545+ expect ( getByText ( 'year' ) ) . toBeDefined ( )
546+ expect ( getByText ( '83' ) ) . toBeDefined ( )
547+ expect ( getByText ( '1920' ) ) . toBeDefined ( )
548+ expect ( getByText ( '19' ) ) . toBeDefined ( )
549+ expect ( getByText ( '1951' ) ) . toBeDefined ( )
550+ expect ( getByText ( 'Oldest houses:' ) ) . toBeDefined ( )
551+ } )
539552} )
Original file line number Diff line number Diff line change @@ -152,6 +152,12 @@ function parseMarkdown(text: string): Token[] {
152152 if ( / ^ ( # { 1 , 6 } ) \s + / . test ( ln ) ) break // heading
153153 if ( / ^ ( \s * ) ( [ - * + – • ‣ ◦ ○ ⚬ ] | \d + \. ) \s + / . test ( ln ) ) break // list item
154154 if ( / ^ - - - + $ / . test ( ln . trim ( ) ) ) break // horizontal rule
155+ // table start: a header row followed by a separator row
156+ if ( ln . includes ( '|' ) && i + 1 < lines . length ) {
157+ const sepLine = lines [ i + 1 ] ?? ''
158+ const tableSepRegex = / ^ \s * \| ? \s * : ? [ - – — ] + : ? \s * ( \| \s * : ? [ - – — ] + : ? \s * ) * \| ? \s * $ /
159+ if ( sepLine . includes ( '|' ) && tableSepRegex . test ( sepLine ) ) break
160+ }
155161
156162 paraLines . push ( ln )
157163 i ++
You can’t perform that action at this time.
0 commit comments