book-source 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -675,12 +675,13 @@ function parseOrderedListItem( str , ctx , indent ) {
675
675
  var lastPart = ctx.parts[ ctx.parts.length - 1 ] ;
676
676
 
677
677
  if ( ! lastPart || lastPart.type !== 'orderedList' ) {
678
- ctx.parts.push( new documentParts.OrderedList( indent ) ) ;
678
+ lastPart = new documentParts.OrderedList( indent ) ;
679
+ ctx.parts.push( lastPart ) ;
679
680
  }
680
681
 
681
682
  stack( ctx ) ;
682
683
 
683
- ctx.parts.push( new documentParts.OrderedListItem( indent , order ) ) ;
684
+ ctx.parts.push( new documentParts.OrderedListItem( indent , order , lastPart.autoIndex ++ ) ) ;
684
685
 
685
686
  var blockEnd = detectBlockEnd( str , ctx.i , ctx.parent?.indent , LIST_ITEM_END_PARAMS ) ;
686
687
  parseInlineChildren( str , ctx , blockEnd ) ;
@@ -247,6 +247,7 @@ documentParts.ListItem = ListItem ;
247
247
  function OrderedList( indent ) {
248
248
  this.type = 'orderedList' ;
249
249
  this.indent = indent ;
250
+ this.autoIndex = 1 ;
250
251
  BlockPart.call( this ) ;
251
252
  }
252
253
 
@@ -256,10 +257,11 @@ documentParts.OrderedList = OrderedList ;
256
257
 
257
258
 
258
259
 
259
- function OrderedListItem( indent , order ) {
260
+ function OrderedListItem( indent , order , index ) {
260
261
  this.type = 'orderedListItem' ;
261
262
  this.indent = indent ;
262
- this.order = order ;
263
+ this.order = order ; // User order value
264
+ this.index = index ; // Real index, starting at 1, and auto-incrementing
263
265
  BlockPart.call( this ) ;
264
266
  }
265
267
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "book-source",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "A lightweight markup language, inspired by Markdown.",
5
5
  "main": "lib/book-source.js",
6
6
  "directories": {