@@ -436,6 +436,32 @@ End of list.`;
436436 expect ( chunks [ 4 ] ) . toBe ( 'End of list.' ) ;
437437 } ) ;
438438
439+ it ( 'should preserve ordered list numbering when splitting' , ( ) => {
440+ const splitter = chunkdown ( {
441+ chunkSize : 50 ,
442+ maxOverflowRatio : 1.0 ,
443+ } ) ;
444+ const text = `Instructions:
445+
446+ 1. First step with some content
447+ 2. Second step with some content
448+ 3. Third step with some content
449+ 4. Fourth step with some content
450+ 5. Fifth step with some content
451+ 6. Sixth step with some content
452+
453+ End of instructions.` ;
454+ const chunks = splitter . splitText ( text ) ;
455+
456+ // Find the chunks containing ordered list items
457+ const listChunks = chunks . filter ( ( chunk ) => / ^ \d + \. / . test ( chunk . trim ( ) ) ) ;
458+
459+ expect ( listChunks . length ) . toBe ( 6 ) ;
460+ for ( let i = 1 ; i < listChunks . length ; i ++ ) {
461+ expect ( listChunks [ i ] ) . toMatch ( new RegExp ( `^[${ i + 1 } ]\.` ) ) ;
462+ }
463+ } ) ;
464+
439465 it ( 'should keep tables together if possible' , ( ) => {
440466 const splitter = chunkdown ( {
441467 chunkSize : 50 ,
@@ -1077,7 +1103,7 @@ Here's a sentence with a footnote[^1].
10771103 // Code block in list item
10781104 const example = true;
10791105 \`\`\`",
1080- "1 . Third item with blockquote:
1106+ "3 . Third item with blockquote:
10811107 > This is a blockquote inside a list item
10821108 > with multiple lines",
10831109 "### Table with Complex Content
0 commit comments