diff --git a/src/components/elements/markdown/components.ts b/src/components/elements/markdown/components.ts index d641eaea..9fed24ac 100644 --- a/src/components/elements/markdown/components.ts +++ b/src/components/elements/markdown/components.ts @@ -6,7 +6,7 @@ import {renderLink} from './components/link'; import {renderListItem} from './components/listItem'; import {renderParagraph} from './components/paragraph'; import {renderStrong} from './components/strong'; -import {renderTable, renderTableCell, renderTableRow} from './components/table'; +import {renderTable, renderTableCell, renderTableHeader, renderTableRow} from './components/table'; // Key correspondences: @@ -25,6 +25,7 @@ export const components: Components = { h6: renderHeading, strong: renderStrong, table: renderTable, + th: renderTableHeader, tr: renderTableRow, td: renderTableCell, li: renderListItem, diff --git a/src/components/elements/markdown/components/table.tsx b/src/components/elements/markdown/components/table.tsx index 0304610b..b8f90cff 100644 --- a/src/components/elements/markdown/components/table.tsx +++ b/src/components/elements/markdown/components/table.tsx @@ -33,6 +33,14 @@ export const renderTable = ({children, node}: MarkdownComponentProps) => { return {children}
; }; +export const renderTableHeader = ({children}: MarkdownComponentProps) => ( + + + {children} + + +); + export const renderTableRow: TableRowComponent = ({children}) => { idxCounter = 0; diff --git a/src/components/elements/markdown/main.test.tsx b/src/components/elements/markdown/main.test.tsx index 15936e93..81eb5d43 100644 --- a/src/components/elements/markdown/main.test.tsx +++ b/src/components/elements/markdown/main.test.tsx @@ -143,6 +143,16 @@ describe('Markdown', () => { }); it('colors text in table', async () => { + const markdown = 'head | ::[red]col 2::\n:---: | :---:\nX | Y'; + + renderReact(() => {markdown}); + + const headCell = screen.getByText('col 2', {selector: 'span'}); + expect(headCell).toHaveStyle({color: 'red'}); + expect(headCell.parentElement?.tagName).toBe('TH'); + }); + + it('colors text in table header', async () => { const markdown = 'head | col 2\n:---: | :---:\nX | ::[red]Y::'; renderReact(() => {markdown});