@@ -49,15 +49,75 @@ describe("Markdown", () => {
4949 expect(h3.props.fgColor).toBe("green");
5050 });
5151
52- test("paragraph renders as wrapping Text", () => {
53- const nodes = Markdown("Hello **bold** world");
52+ test("plain paragraph renders as wrapping Text", () => {
53+ const nodes = Markdown("Hello world");
5454 expect(nodes).toHaveLength(1);
5555 const t = asText(nodes[0]!);
56- // Inline markers stripped, plain text content
57- expect(t.content).toBe("Hello bold world");
56+ expect(t.content).toBe("Hello world");
5857 expect(t.props.wrap).toBe("word");
5958 });
6059
60+ test("paragraph with bold renders as wrapping HStack", () => {
61+ const nodes = Markdown("Hello **bold** world");
62+ expect(nodes).toHaveLength(1);
63+ const hstack = asContainer(nodes[0]!);
64+ expect(hstack.type).toBe("hstack");
65+ expect(hstack.props.flexWrap).toBe("wrap");
66+ // Children: "Hello", " ", bold("bold"), " ", "world"
67+ expect(hstack.children).toHaveLength(5);
68+ expect(asText(hstack.children[0]!).content).toBe("Hello");
69+ expect(asText(hstack.children[1]!).content).toBe(" ");
70+ const boldNode = asText(hstack.children[2]!);
71+ expect(boldNode.content).toBe("bold");
72+ expect(boldNode.props.bold).toBe(true);
73+ expect(asText(hstack.children[3]!).content).toBe(" ");
74+ expect(asText(hstack.children[4]!).content).toBe("world");
75+ });
76+
77+ test("paragraph with italic renders styled nodes", () => {
78+ const nodes = Markdown("some *italic* text");
79+ const hstack = asContainer(nodes[0]!);
80+ expect(hstack.type).toBe("hstack");
81+ // "some", " ", italic("italic"), " ", "text"
82+ const italicNode = asText(hstack.children[2]!);
83+ expect(italicNode.content).toBe("italic");
84+ expect(italicNode.props.italic).toBe(true);
85+ });
86+
87+ test("paragraph with inline code keeps code span atomic", () => {
88+ const nodes = Markdown("use `foo bar` here");
89+ const hstack = asContainer(nodes[0]!);
90+ expect(hstack.type).toBe("hstack");
91+ // "use", " ", code("foo bar"), " ", "here"
92+ expect(hstack.children).toHaveLength(5);
93+ const codeNode = asText(hstack.children[2]!);
94+ expect(codeNode.content).toBe("foo bar");
95+ expect(codeNode.props.fgColor).toBe("yellow");
96+ });
97+
98+ test("paragraph with link keeps link text atomic", () => {
99+ const nodes = Markdown("see [the docs](https://example.com) here");
100+ const hstack = asContainer(nodes[0]!);
101+ // "see", " ", link("the docs"), " ", "here"
102+ expect(hstack.children).toHaveLength(5);
103+ const linkNode = asText(hstack.children[2]!);
104+ expect(linkNode.content).toBe("the docs");
105+ expect(linkNode.props.fgColor).toBe("cyan");
106+ expect(linkNode.props.underline).toBe(true);
107+ });
108+
109+ test("paragraph with mixed formatting", () => {
110+ const nodes = Markdown("Hello, **bold**!");
111+ const hstack = asContainer(nodes[0]!);
112+ // "Hello,", " ", bold("bold"), "!"
113+ expect(hstack.children).toHaveLength(4);
114+ expect(asText(hstack.children[0]!).content).toBe("Hello,");
115+ expect(asText(hstack.children[1]!).content).toBe(" ");
116+ expect(asText(hstack.children[2]!).props.bold).toBe(true);
117+ // No space before "!" — punctuation is adjacent
118+ expect(asText(hstack.children[3]!).content).toBe("!");
119+ });
120+
61121 test("code block renders as VStack with Text", () => {
62122 const nodes = Markdown("```js\nconst x = 1;\n```");
63123 expect(nodes).toHaveLength(1);
@@ -159,8 +219,16 @@ describe("Markdown", () => {
159219
160220 test("link text is used, url is stripped", () => {
161221 const nodes = Markdown("See [the docs](https://example.com) here.");
162- const t = asText(nodes[0]!);
163- expect(t.content).toBe("See the docs here.");
222+ const hstack = asContainer(nodes[0]!);
223+ expect(hstack.type).toBe("hstack");
224+ expect(hstack.props.flexWrap).toBe("wrap");
225+ // "See", " ", link("the docs"), " ", "here."
226+ expect(hstack.children).toHaveLength(5);
227+ expect(asText(hstack.children[0]!).content).toBe("See");
228+ const link = asText(hstack.children[2]!);
229+ expect(link.content).toBe("the docs");
230+ expect(link.props.fgColor).toBe("cyan");
231+ expect(asText(hstack.children[4]!).content).toBe("here.");
164232 });
165233
166234 test("streaming: unclosed code block renders as code", () => {
@@ -172,9 +240,49 @@ describe("Markdown", () => {
172240 });
173241
174242 test("streaming: unclosed bold appears as plain text", () => {
243+ // Unclosed ** is not parsed as bold — stays as text span
175244 const nodes = Markdown("hello **world");
176245 const t = asText(nodes[0]!);
177246 expect(t.content).toBe("hello **world");
247+ expect(t.props.wrap).toBe("word");
248+ });
249+
250+ test("list item with inline formatting", () => {
251+ const nodes = Markdown("- hello **bold** world");
252+ const row = asContainer(nodes[0]!);
253+ expect(row.type).toBe("hstack");
254+ const wrapper = asContainer(row.children[1]!);
255+ expect(wrapper.type).toBe("vstack");
256+ // Content is a wrapping HStack
257+ const content = asContainer(wrapper.children[0]!);
258+ expect(content.type).toBe("hstack");
259+ expect(content.props.flexWrap).toBe("wrap");
260+ // "hello", " ", bold("bold"), " ", "world"
261+ expect(content.children).toHaveLength(5);
262+ expect(asText(content.children[2]!).props.bold).toBe(true);
263+ });
264+
265+ test("blockquote with inline formatting", () => {
266+ const nodes = Markdown("> hello **bold** text");
267+ const row = asContainer(nodes[0]!);
268+ const wrapper = asContainer(row.children[1]!);
269+ const content = asContainer(wrapper.children[0]!);
270+ expect(content.type).toBe("hstack");
271+ expect(content.props.flexWrap).toBe("wrap");
272+ // blockquoteText style (italic) applied to the wrapping HStack
273+ expect(content.props.italic).toBe(true);
274+ // bold node inside inherits italic from parent, also has bold
275+ expect(asText(content.children[2]!).props.bold).toBe(true);
276+ });
277+
278+ test("inline code theme is customizable", () => {
279+ const nodes = Markdown("use `code` here", {
280+ theme: { inlineCode: { fgColor: "red", bgColor: "black" } },
281+ });
282+ const hstack = asContainer(nodes[0]!);
283+ const codeNode = asText(hstack.children[2]!);
284+ expect(codeNode.props.fgColor).toBe("red");
285+ expect(codeNode.props.bgColor).toBe("black");
178286 });
179287
180288 test("full document produces correct node sequence", () => {