Skip to content

Commit 5012c8c

Browse files
committed
Markdown: unicode dashes in table syntax
1 parent e3f8b6e commit 5012c8c

File tree

4 files changed

+69
-11
lines changed

4 files changed

+69
-11
lines changed

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,34 +56,34 @@
5656
},
5757
"dependencies": {
5858
"hightable": "0.17.2",
59-
"hyparquet": "1.16.2",
59+
"hyparquet": "1.17.1",
6060
"hyparquet-compressors": "1.1.1",
6161
"icebird": "0.3.0",
6262
"react": "18.3.1",
6363
"react-dom": "18.3.1"
6464
},
6565
"devDependencies": {
66-
"@eslint/js": "9.29.0",
67-
"@storybook/react-vite": "9.0.13",
66+
"@eslint/js": "9.30.1",
67+
"@storybook/react-vite": "9.0.15",
6868
"@testing-library/react": "16.3.0",
69-
"@types/node": "24.0.4",
69+
"@types/node": "24.0.10",
7070
"@types/react": "19.1.8",
7171
"@types/react-dom": "19.1.6",
7272
"@vitejs/plugin-react": "4.6.0",
7373
"@vitest/coverage-v8": "3.2.4",
74-
"eslint": "9.29.0",
74+
"eslint": "9.30.1",
7575
"eslint-plugin-react": "7.37.5",
7676
"eslint-plugin-react-hooks": "5.2.0",
7777
"eslint-plugin-react-refresh": "0.4.20",
78-
"eslint-plugin-storybook": "9.0.13",
79-
"globals": "16.2.0",
78+
"eslint-plugin-storybook": "9.0.15",
79+
"globals": "16.3.0",
8080
"jsdom": "26.1.0",
8181
"nodemon": "3.1.10",
8282
"npm-run-all": "4.1.5",
83-
"storybook": "9.0.13",
83+
"storybook": "9.0.15",
8484
"typescript": "5.8.3",
85-
"typescript-eslint": "8.35.0",
86-
"vite": "6.3.5",
85+
"typescript-eslint": "8.35.1",
86+
"vite": "7.0.1",
8787
"vitest": "3.2.4"
8888
},
8989
"eslintConfig": {

src/components/Markdown/Markdown.test.tsx

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,4 +512,28 @@ describe('Markdown with tables', () => {
512512
expect(getByText('Cell with | escaped pipe')).toBeDefined()
513513
expect(getByText('Normal cell')).toBeDefined()
514514
})
515+
516+
it('renders a table even with unicode en dash', () => {
517+
const text = 'Header 1 | Header 2\n–|–\nRow 1 | Data 1\nRow 2 | Data 2'
518+
const { getByText, getByRole } = render(<Markdown text={text} />)
519+
expect(getByRole('table')).toBeDefined()
520+
expect(getByText('Header 1')).toBeDefined()
521+
expect(getByText('Header 2')).toBeDefined()
522+
expect(getByText('Row 1')).toBeDefined()
523+
expect(getByText('Data 1')).toBeDefined()
524+
expect(getByText('Row 2')).toBeDefined()
525+
expect(getByText('Data 2')).toBeDefined()
526+
})
527+
528+
it('renders a table even with unicode em dash', () => {
529+
const text = 'Header 1 | Header 2\n—|—\nRow 1 | Data 1\nRow 2 | Data 2'
530+
const { getByText, getByRole } = render(<Markdown text={text} />)
531+
expect(getByRole('table')).toBeDefined()
532+
expect(getByText('Header 1')).toBeDefined()
533+
expect(getByText('Header 2')).toBeDefined()
534+
expect(getByText('Row 1')).toBeDefined()
535+
expect(getByText('Data 1')).toBeDefined()
536+
expect(getByText('Row 2')).toBeDefined()
537+
expect(getByText('Data 2')).toBeDefined()
538+
})
515539
})

src/components/Markdown/Markdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ function parseMarkdown(text: string): Token[] {
118118
const sepLine = lines[i + 1] ?? ''
119119
// Check if the next line is a valid table separator
120120
// Extended markdown alignment syntax: |:--|, |:--:|, |--:|
121-
const tableSepRegex = /^\s*\|?\s*:?-+:?\s*(\|\s*:?-+:?\s*)*\|?\s*$/
121+
const tableSepRegex = /^\s*\|?\s*:?[-]+:?\s*(\|\s*:?[-]+:?\s*)*\|?\s*$/
122122
if (sepLine.includes('|') && tableSepRegex.test(sepLine)) {
123123
// collect header cells
124124
const headerCells = splitTableRow(line)

table.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
2+
# Test Tables with Unicode Dashes
3+
4+
## Regular dash table
5+
Header 1 | Header 2
6+
-|-
7+
Row 1 | Data 1
8+
Row 2 | Data 2
9+
10+
## En dash table (–)
11+
Header 1 | Header 2
12+
–|–
13+
Row 1 | Data 1
14+
Row 2 | Data 2
15+
16+
## Em dash table (—)
17+
Header 1 | Header 2
18+
—|—
19+
Row 1 | Data 1
20+
Row 2 | Data 2
21+
22+
## Mixed dashes table
23+
Header 1 | Header 2 | Header 3
24+
-|–|—
25+
Row 1 | Data 1 | Data 1
26+
Row 2 | Data 2 | Data 2
27+
28+
## Original Table
29+
30+
| Name | Age | Occupation |
31+
|----------|-----|----------------|
32+
| Alice | 30 | Engineer |
33+
| Bob | 25 | Designer |
34+
| Charlie | 35 | Product Manager|

0 commit comments

Comments
 (0)