Skip to content

Commit 96ae8ca

Browse files
committed
fix: restore list styles for markdown lists in chat interface
- Add list-style-type for ol (decimal) and ul (disc) elements - Add nested list styles for better visual hierarchy - Add comprehensive tests for list rendering - Fixes #6094
1 parent 2411c8f commit 96ae8ca

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

webview-ui/src/components/common/MarkdownBlock.tsx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,31 @@ const StyledMarkdown = styled.div`
151151
margin-left: 0;
152152
}
153153
154+
ol {
155+
list-style-type: decimal;
156+
}
157+
158+
ul {
159+
list-style-type: disc;
160+
}
161+
162+
/* Nested list styles */
163+
ul ul {
164+
list-style-type: circle;
165+
}
166+
167+
ul ul ul {
168+
list-style-type: square;
169+
}
170+
171+
ol ol {
172+
list-style-type: lower-alpha;
173+
}
174+
175+
ol ol ol {
176+
list-style-type: lower-roman;
177+
}
178+
154179
p {
155180
white-space: pre-wrap;
156181
}

webview-ui/src/components/common/__tests__/MarkdownBlock.spec.tsx

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,84 @@ describe("MarkdownBlock", () => {
3636
const paragraph = container.querySelector("p")
3737
expect(paragraph?.textContent).toBe("Check out this link: https://example.com.")
3838
})
39+
40+
it("should render unordered lists with proper styling", async () => {
41+
const markdown = `Here are some items:
42+
- First item
43+
- Second item
44+
- Nested item
45+
- Another nested item`
46+
47+
const { container } = render(<MarkdownBlock markdown={markdown} />)
48+
49+
// Wait for the content to be processed
50+
await screen.findByText(/Here are some items/, { exact: false })
51+
52+
// Check that ul elements exist
53+
const ulElements = container.querySelectorAll("ul")
54+
expect(ulElements.length).toBeGreaterThan(0)
55+
56+
// Check that list items exist
57+
const liElements = container.querySelectorAll("li")
58+
expect(liElements.length).toBe(4)
59+
60+
// Verify the text content
61+
expect(screen.getByText("First item")).toBeInTheDocument()
62+
expect(screen.getByText("Second item")).toBeInTheDocument()
63+
expect(screen.getByText("Nested item")).toBeInTheDocument()
64+
expect(screen.getByText("Another nested item")).toBeInTheDocument()
65+
})
66+
67+
it("should render ordered lists with proper styling", async () => {
68+
const markdown = `And a numbered list:
69+
1. Step one
70+
2. Step two
71+
3. Step three`
72+
73+
const { container } = render(<MarkdownBlock markdown={markdown} />)
74+
75+
// Wait for the content to be processed
76+
await screen.findByText(/And a numbered list/, { exact: false })
77+
78+
// Check that ol elements exist
79+
const olElements = container.querySelectorAll("ol")
80+
expect(olElements.length).toBe(1)
81+
82+
// Check that list items exist
83+
const liElements = container.querySelectorAll("li")
84+
expect(liElements.length).toBe(3)
85+
86+
// Verify the text content
87+
expect(screen.getByText("Step one")).toBeInTheDocument()
88+
expect(screen.getByText("Step two")).toBeInTheDocument()
89+
expect(screen.getByText("Step three")).toBeInTheDocument()
90+
})
91+
92+
it("should render nested lists with proper hierarchy", async () => {
93+
const markdown = `Complex list:
94+
1. First level ordered
95+
- Second level unordered
96+
- Another second level
97+
1. Third level ordered
98+
2. Another third level
99+
2. Back to first level`
100+
101+
const { container } = render(<MarkdownBlock markdown={markdown} />)
102+
103+
// Wait for the content to be processed
104+
await screen.findByText(/Complex list/, { exact: false })
105+
106+
// Check nested structure
107+
const olElements = container.querySelectorAll("ol")
108+
const ulElements = container.querySelectorAll("ul")
109+
110+
expect(olElements.length).toBeGreaterThan(0)
111+
expect(ulElements.length).toBeGreaterThan(0)
112+
113+
// Verify all text is rendered
114+
expect(screen.getByText("First level ordered")).toBeInTheDocument()
115+
expect(screen.getByText("Second level unordered")).toBeInTheDocument()
116+
expect(screen.getByText("Third level ordered")).toBeInTheDocument()
117+
expect(screen.getByText("Back to first level")).toBeInTheDocument()
118+
})
39119
})

0 commit comments

Comments
 (0)