Skip to content

Commit 282affe

Browse files
authored
fix: list continuation & crlf bug (#777)
* chore: adjust commit message rule * fix: paragraph after nested list incorrectly absorbed (fixes #776) Paragraphs following nested lists after blank lines were incorrectly being absorbed into the nested list item instead of being parsed as separate blocks. This fix ensures paragraphs are correctly separated from nested lists per CommonMark specification. * fix: lists don't render correctly with CRLF line endings (fixes #773) Lists and other markdown structures were incorrectly parsed when input had CRLF line endings. This fix ensures CRLF line endings are properly handled as line boundaries without requiring input normalization. * refactor: compress reference definition parsing Extract shared utilities to reduce code duplication in parseRefContent and parseFootnoteContent. New helpers (isBlockStartAt, isTitleDelimiter, parseQuotedTitle, parseParenTitle, scanFootnoteEnd) consolidate repeated patterns across reference and footnote parsing. - parseRefContent: 507→383 lines (-24%) - parseFootnoteContent: 185→123 lines (-34%) - Net reduction: 53 lines All tests passing, performance within 5% of baseline. * fix: handle CRLF in reference definition titles and footnote boundaries - parseQuotedTitle: detect CRLF blank lines to reject invalid titles - parseParenTitle: detect CRLF blank lines to reject invalid titles - scanFootnoteEnd: detect CRLF blank lines to stop absorbing content - Add CHAR_PAREN_OPEN/CLOSE constants - Remove unused scanToBlankLine function
1 parent 365948d commit 282affe

File tree

9 files changed

+679
-279
lines changed

9 files changed

+679
-279
lines changed
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+
Fix lists and other markdown structures not rendering correctly when input has CRLF line endings.
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+
Fix paragraph after nested list being incorrectly absorbed into the nested list item when followed by a blank line.

.cursor/rules/always.mdc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
alwaysApply: true
33
---
44

5+
- never git push code that is broken or failing tests, 100% passing tests are required as a quality gate before committing
56
- Use conventional commit syntax
67
- Do not create summary documents, deliver a concise summary in the chat when appropriate.
78
- Do not create helper functions unless there are at least two instances of the same pattern and overall LOC is reduced
@@ -20,8 +21,9 @@ alwaysApply: true
2021
- Parsing and Execution: Reduce code size via minification/tree-shaking, avoid eval(), and optimize regex patterns.
2122
- Dependency Management: Limit third-party libraries, use tree-shakable imports, and profile for bottlenecks.
2223
- Browser-Specific Quirks: Handle engine differences (e.g., V8 optimizations for hot paths), test on target environments.
24+
- When writing commit messages and changesets, speak in general terms, not specific implementation details. Keep language concise and to the point.
2325
- When writing commit messages on public code, focus on the user-facing change; how does this change benefit them? Ensure that noteworthy public changes and bugfixes have a changeset.
24-
- When writing commit messages on private/infra code, focus on the technical change; how does this change benefit the codebase? Keep it short.
26+
- When writing commit messages on private/infra code, focus on the technical change; how does this change benefit the codebase?
2527
- Optimize new rules for token efficiency: no bold/emphasis, headers, and stylistic formatting, concise/compact and highly-specific language
2628
- Remove examples unless critical for understanding
2729
- Prefer abbreviations and acronyms when unambiguous

scripts/metrics.baseline.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -254,10 +254,10 @@
254254
}
255255
},
256256
"parser": {
257-
"timestamp": "2025-12-16T05:00:42.963Z",
257+
"timestamp": "2026-01-10T06:07:46.257Z",
258258
"target": "parser",
259259
"inputSize": 173,
260-
"parseTime": 6.89,
260+
"parseTime": 4.6,
261261
"blockParsers": {
262262
"blockQuote": {
263263
"attempts": 70,
@@ -292,7 +292,7 @@
292292
"hits": 11
293293
},
294294
"htmlBlock": {
295-
"attempts": 58,
295+
"attempts": 88,
296296
"hits": 10
297297
},
298298
"htmlComment": {
@@ -375,9 +375,9 @@
375375
}
376376
},
377377
"operationCounts": {
378-
"totalOperations": 3297,
378+
"totalOperations": 3307,
379379
"blockParseIterations": 893,
380-
"inlineParseIterations": 1260
380+
"inlineParseIterations": 1270
381381
}
382382
},
383383
"react": {

src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ export const CHAR_PLUS = 43
4141
export const CHAR_PIPE = 124
4242
export const CHAR_BRACE_OPEN = 123 // {
4343
export const CHAR_BRACE_CLOSE = 125 // }
44+
export const CHAR_PAREN_OPEN = 40 // (
45+
export const CHAR_PAREN_CLOSE = 41 // )
4446
export const CHAR_x = 120
4547
export const CHAR_X = 88
4648
// Character code ranges for common character classes

0 commit comments

Comments
 (0)