Skip to content

Commit 4252da4

Browse files
Copilotquantizor
andauthored
Fix missing newlines between list item continuation lines at base indentation (#794)
* Initial plan * Fix inconsistent spacing between list item nodes depending on indentation Co-authored-by: quantizor <570070+quantizor@users.noreply.github.com> * Fix issue number in test description (#793) Co-authored-by: quantizor <570070+quantizor@users.noreply.github.com> * Flatten test blocks and add issue number to test names Co-authored-by: quantizor <570070+quantizor@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: quantizor <570070+quantizor@users.noreply.github.com>
1 parent c9322a8 commit 4252da4

File tree

8 files changed

+196
-22
lines changed

8 files changed

+196
-22
lines changed

.changeset/fix-list-spacing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"markdown-to-jsx": patch
3+
---
4+
5+
Fixed inconsistent spacing between list item nodes when continuation lines have indentation equal to the nested list marker. Previously, text nodes in list items were being concatenated without newlines when continuation lines matched the list's base indentation, causing missing line breaks in the rendered output.
Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import{r as c,j as de}from"./index-Bykw9UvX.js";function me(a){for(var n=[`fn map(pos: vec3f) -> f32 {
1+
import{r as c,j as de}from"./index-CqPqlK8n.js";function me(a){for(var n=[`fn map(pos: vec3f) -> f32 {
22
let k = u.elasticity;
33
let p0 = particles[0u];
44
let delta0 = pos - p0.position.xyz;

docs/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343

4444
gtag('config', 'G-T8TWRSBM1V')
4545
</script>
46-
<script type="module" crossorigin src="/assets/index-Bykw9UvX.js"></script>
46+
<script type="module" crossorigin src="/assets/index-CqPqlK8n.js"></script>
4747
<link rel="stylesheet" crossorigin href="/assets/index-D6QVjcGy.css">
4848
</head>
4949

docs/sitemap.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
33
<url>
44
<loc>https://markdown-to-jsx.quantizor.dev/</loc>
5-
<lastmod>2026-01-11</lastmod>
5+
<lastmod>2026-01-13</lastmod>
66
<changefreq>weekly</changefreq>
77
<priority>1.0</priority>
88
</url>
99
<url>
1010
<loc>https://markdown-to-jsx.quantizor.dev/llms.txt</loc>
11-
<lastmod>2026-01-11</lastmod>
11+
<lastmod>2026-01-13</lastmod>
1212
<changefreq>weekly</changefreq>
1313
<priority>0.8</priority>
1414
</url>

src/parse.spec.ts

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3343,6 +3343,174 @@ This is paragraph after.`
33433343
})
33443344
})
33453345

3346+
it('should preserve newline between list item text and continuation at same indentation (#793)', () => {
3347+
expect(
3348+
p.parser(`- Unordered list.
3349+
- Nested list.
3350+
Prefixed spaces equal to the nested list.`)
3351+
).toMatchInlineSnapshot(`
3352+
[
3353+
{
3354+
"endPos": 78,
3355+
"items": [
3356+
[
3357+
{
3358+
"text": "Unordered list.",
3359+
"type": "text",
3360+
},
3361+
{
3362+
"endPos": 78,
3363+
"items": [
3364+
[
3365+
{
3366+
"text": "Nested list.",
3367+
"type": "text",
3368+
},
3369+
{
3370+
"text":
3371+
"
3372+
"
3373+
,
3374+
"type": "text",
3375+
},
3376+
{
3377+
"text": "Prefixed spaces equal to the nested list.",
3378+
"type": "text",
3379+
},
3380+
],
3381+
],
3382+
"ordered": false,
3383+
"type": "unorderedList",
3384+
},
3385+
],
3386+
],
3387+
"ordered": false,
3388+
"type": "unorderedList",
3389+
},
3390+
]
3391+
`)
3392+
})
3393+
3394+
it('should preserve newlines between multiple continuation lines (#793)', () => {
3395+
expect(
3396+
p.parser(`- Unordered list.
3397+
- Nested list.
3398+
Prefixed spaces equal to the nested list.
3399+
And again.`)
3400+
).toMatchInlineSnapshot(`
3401+
[
3402+
{
3403+
"endPos": 91,
3404+
"items": [
3405+
[
3406+
{
3407+
"text": "Unordered list.",
3408+
"type": "text",
3409+
},
3410+
{
3411+
"endPos": 91,
3412+
"items": [
3413+
[
3414+
{
3415+
"text": "Nested list.",
3416+
"type": "text",
3417+
},
3418+
{
3419+
"text":
3420+
"
3421+
"
3422+
,
3423+
"type": "text",
3424+
},
3425+
{
3426+
"text": "Prefixed spaces equal to the nested list.",
3427+
"type": "text",
3428+
},
3429+
{
3430+
"text":
3431+
"
3432+
"
3433+
,
3434+
"type": "text",
3435+
},
3436+
{
3437+
"text": "And again.",
3438+
"type": "text",
3439+
},
3440+
],
3441+
],
3442+
"ordered": false,
3443+
"type": "unorderedList",
3444+
},
3445+
],
3446+
],
3447+
"ordered": false,
3448+
"type": "unorderedList",
3449+
},
3450+
]
3451+
`)
3452+
})
3453+
3454+
it('should preserve newline with lazy continuation then proper continuation (#793)', () => {
3455+
expect(
3456+
p.parser(`- Unordered list.
3457+
- Nested list.
3458+
Prefixed spaces not equal to the nested list.
3459+
But this line's are.`)
3460+
).toMatchInlineSnapshot(`
3461+
[
3462+
{
3463+
"endPos": 103,
3464+
"items": [
3465+
[
3466+
{
3467+
"text": "Unordered list.",
3468+
"type": "text",
3469+
},
3470+
{
3471+
"endPos": 103,
3472+
"items": [
3473+
[
3474+
{
3475+
"text": "Nested list.",
3476+
"type": "text",
3477+
},
3478+
{
3479+
"text":
3480+
"
3481+
"
3482+
,
3483+
"type": "text",
3484+
},
3485+
{
3486+
"text": "Prefixed spaces not equal to the nested list.",
3487+
"type": "text",
3488+
},
3489+
{
3490+
"text":
3491+
"
3492+
"
3493+
,
3494+
"type": "text",
3495+
},
3496+
{
3497+
"text": "But this line's are.",
3498+
"type": "text",
3499+
},
3500+
],
3501+
],
3502+
"ordered": false,
3503+
"type": "unorderedList",
3504+
},
3505+
],
3506+
],
3507+
"ordered": false,
3508+
"type": "unorderedList",
3509+
},
3510+
]
3511+
`)
3512+
})
3513+
33463514
describe('CRLF line endings', () => {
33473515
function toCRLF(text: string): string {
33483516
return text.replace(/\n/g, '\r\n')

src/parse.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5929,14 +5929,13 @@ function parseList(
59295929
}
59305930
const lastItem = getLastItem()
59315931
if (lastItem.length > 0 && !listItemHasBlockContent(lastItem)) {
5932-
// This is a lazy continuation line - continue the inline content
5933-
// Lazy continuation lines don't add a newline (no space in output)
5932+
// Continuation line at base indentation - add newline for proper spacing
59345933
appendListContinuation(
59355934
nextLineWithoutIndent,
59365935
lastItem,
59375936
state,
59385937
options,
5939-
false
5938+
true
59405939
)
59415940
prevLineWasBlank = false
59425941
currentPos = skipToNextLine(source, nextLineEnd)

src/react.spec.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3378,9 +3378,11 @@ it('should handle list item continuation properly without indentation', () => {
33783378
### h3 title
33793379
`)
33803380
)
3381-
expect(root.innerHTML).toMatchInlineSnapshot(
3382-
`"<div><ol start="1"><li><strong>A</strong>explanation about a</li><li><strong>B</strong>explanation about b</li></ol><h3 id="h3-title">h3 title</h3></div>"`
3383-
)
3381+
expect(root.innerHTML).toMatchInlineSnapshot(`
3382+
"<div><ol start="1"><li><strong>A</strong>
3383+
explanation about a</li><li><strong>B</strong>
3384+
explanation about b</li></ol><h3 id="h3-title">h3 title</h3></div>"
3385+
`)
33843386
})
33853387

33863388
describe('frontmatter', () => {

0 commit comments

Comments
 (0)