File tree 3 files changed +22
-17
lines changed
3 files changed +22
-17
lines changed Original file line number Diff line number Diff line change @@ -109,9 +109,13 @@ are two small differences with Pandoc's syntax:
109
109
* This plugin does not support list numbers enclosed in parentheses,
110
110
as the Commonmark spec does not support these either for lists
111
111
numbered with Arabic numerals.
112
- * Pandoc and Commonmark do not agree whether a list is allowed to
113
- interrupt a paragraph. It also depends on if that list is nested or not.
114
- This plugin always allows a paragraph to be interrupted.
112
+ * Pandoc does not allow any list to interrupt a paragraph. In the
113
+ spirit of the Commonmark spec (which allows only lists starting
114
+ with 1 to interrupt a paragraph), this plugins allows lists that
115
+ start with "A", "a", "I" or "i" (i.e. all 'first numerals') to
116
+ interrupt a paragraph. The same holds for the "#" generic numbered
117
+ list item marker.
118
+ For nested lists, any start number can interrupt a paragraph.
115
119
116
120
Configuration
117
121
-------------
Original file line number Diff line number Diff line change @@ -276,6 +276,12 @@ const createFancyList = (options: MarkdownItFancyListPluginOptions) => {
276
276
return false ;
277
277
}
278
278
279
+ // do not allow subsequent numbers to interrupt paragraphs in non-nested lists
280
+ const isNestedList = state . listIndent !== - 1 ;
281
+ if ( isTerminatingParagraph && marker . start !== 1 && isNestedList === false ) {
282
+ return false ;
283
+ }
284
+
279
285
// If we're starting a new unordered list right after
280
286
// a paragraph, first line should not be empty.
281
287
if ( isTerminatingParagraph ) {
Original file line number Diff line number Diff line change @@ -289,7 +289,7 @@ iii. a plane ticket
289
289
await assertHTML ( expectedHtml , markdown ) ;
290
290
} ) ;
291
291
292
- it ( "allows subsequent numbers to interrupt paragraphs" , async ( ) => {
292
+ it ( "does not allow subsequent numbers to interrupt paragraphs" , async ( ) => {
293
293
const markdown = `
294
294
I need to buy
295
295
b. new shoes
@@ -302,19 +302,14 @@ iii. a coat
302
302
iv. a plane ticket
303
303
` ;
304
304
const expectedHtml = `
305
- <p>I need to buy</p>
306
- <ol type="a" start="2">
307
- <li>new shoes</li>
308
- <li>a coat</li>
309
- <li>a plane ticket</li>
310
- </ol>
311
- <p>I also need to buy</p>
312
- <ol type="i" start="2">
313
- <li>new shoes</li>
314
- <li>a coat</li>
315
- <li>a plane ticket</li>
316
- </ol>
317
-
305
+ <p>I need to buy
306
+ b. new shoes
307
+ c. a coat
308
+ d. a plane ticket</p>
309
+ <p>I also need to buy
310
+ ii. new shoes
311
+ iii. a coat
312
+ iv. a plane ticket</p>
318
313
` ;
319
314
await assertHTML ( expectedHtml , markdown ) ;
320
315
} ) ;
You can’t perform that action at this time.
0 commit comments