Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,33 +56,33 @@
},
"dependencies": {
"hightable": "0.26.0",
"hyparquet": "1.24.0",
"hyparquet": "1.24.1",
"hyparquet-compressors": "1.1.1",
"icebird": "0.3.1",
"squirreling": "0.7.9"
},
"devDependencies": {
"@storybook/react-vite": "10.2.0",
"@storybook/react-vite": "10.2.2",
"@testing-library/react": "16.3.2",
"@types/node": "25.0.10",
"@types/react": "19.2.9",
"@types/node": "25.1.0",
"@types/react": "19.2.10",
"@types/react-dom": "19.2.3",
"@vitejs/plugin-react": "5.1.2",
"@vitest/coverage-v8": "4.0.18",
"eslint": "9.39.2",
"eslint-plugin-react": "7.37.5",
"eslint-plugin-react-hooks": "7.0.1",
"eslint-plugin-react-refresh": "0.4.26",
"eslint-plugin-storybook": "10.2.0",
"globals": "17.1.0",
"eslint-plugin-storybook": "10.2.2",
"globals": "17.2.0",
"jsdom": "27.4.0",
"nodemon": "3.1.11",
"npm-run-all": "4.1.5",
"react": "19.2.3",
"react-dom": "19.2.3",
"storybook": "10.2.0",
"react": "19.2.4",
"react-dom": "19.2.4",
"storybook": "10.2.2",
"typescript": "5.9.3",
"typescript-eslint": "8.53.1",
"typescript-eslint": "8.54.0",
"vite": "7.3.1",
"vitest": "4.0.18"
},
Expand Down
23 changes: 16 additions & 7 deletions src/components/Markdown/Markdown.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,25 @@ describe('Markdown lists', () => {
})

it('nested code block within a list item', () => {
const text = `- List item with code:
\`\`\`js
console.log("Nested code")
\`\`\``
const text = `- Item 1
- Item 2 code:

\`\`\`bash
./doStuff
\`\`\`

- Item 3`
const { container, getByText } = render(<Markdown text={text} />)
getByText('List item with code:')
getByText('console.log("Nested code")')
getByText('Item 1')
getByText('Item 2 code:')
getByText('Item 3')
const codeBlock = container.querySelector('pre')
expect(codeBlock).toBeTruthy()
expect(codeBlock?.textContent).toContain('console.log("Nested code")')
// Leading spaces should be stripped
expect(codeBlock?.textContent).toBe('./doStuff')
// All items should be in the same list
expect(container.querySelectorAll('ul').length).toBe(1)
expect(container.querySelectorAll('li').length).toBe(3)
})

it('list with unicode dash –', () => {
Expand Down
6 changes: 4 additions & 2 deletions src/components/Markdown/Markdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,16 +212,18 @@ function parseList(lines: string[], start: number, baseIndent: number): [Token[]
if (subIndent > baseIndent) {
const trimmed = subline.trimStart()
if (trimmed.startsWith('```')) {
// If it’s a fenced code block, parse until closing fence
// Fenced code block, parse until closing fence
const language = trimmed.slice(3).trim() || undefined
const indentRegex = new RegExp(`^ {0,${subIndent}}`)
i++
const codeLines: string[] = []
while (i < lines.length && !lines[i]?.trimStart().startsWith('```')) {
const line = lines[i]
if (line === undefined) {
throw new Error(`Line is undefined at index ${i}`)
}
codeLines.push(line)
// Strip spaces to match the fence indent
codeLines.push(line.replace(indentRegex, ''))
i++
}
i++ // skip the closing ```
Expand Down