book-source 0.3.7 → 0.3.8

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.
package/brainstorming CHANGED
@@ -40,7 +40,7 @@
40
40
  (where style can be a color like red, green, black, or other style like bold, italic, oblique, separated by comma ",")
41
41
  (generate a <span>)
42
42
 
43
- ✅ Title tooltip: [text][title text]
43
+ ✅ Title/Hint tooltip: [text][title text]
44
44
 
45
45
  ✅ Link: [link text](href)
46
46
  ✅ Link+Title: [link text][title text](href)
@@ -747,41 +747,26 @@ function parseMedia( str , ctx , float = null ) {
747
747
 
748
748
  ctx.i = end ;
749
749
  ctx.iStartOfInlineChunk = ctx.i + 1 ;
750
+
750
751
  var data = parseDataMark( str , ctx , MEDIA_DATA_MARK ) ;
751
752
  if ( ! data ) { return ; }
752
753
 
753
754
  if ( ! data.href?.[ 0 ] ) { return ; }
754
755
 
755
- var type = 'imageBlock' ;
756
-
757
- if ( data.href[ 1 ] ) {
758
- switch ( data.href[ 1 ] ) {
759
- case 'image' :
760
- type = 'imageBlock' ;
761
- break ;
762
- case 'audio' :
763
- type = 'audioBlock' ;
764
- break ;
765
- case 'video' :
766
- type = 'videoBlock' ;
767
- break ;
768
- default :
769
- return ;
770
- }
771
- }
772
-
773
- var params = { type , altText: text , href: data.href[ 0 ] } ;
774
-
775
- if ( float ) { params.float = float ; }
776
-
777
- if ( data.text?.length ) {
778
- params.caption = data.text[ 0 ] ;
779
- if ( data.text[ 1 ] ) { params.title = data.text[ 1 ] ; }
756
+ switch ( data.href[ 1 ] || 'image' ) {
757
+ case 'image' :
758
+ ctx.parts.push( new documentParts.ImageBlock( data.href[ 0 ] , text , float , data.text?.[ 0 ] , data.text?.[ 1 ] ) ) ;
759
+ break ;
760
+ case 'audio' :
761
+ ctx.parts.push( new documentParts.AudioBlock( data.href[ 0 ] , text , float , data.text?.[ 0 ] , data.text?.[ 1 ] ) ) ;
762
+ break ;
763
+ case 'video' :
764
+ ctx.parts.push( new documentParts.VideoBlock( data.href[ 0 ] , text , float , data.text?.[ 0 ] , data.text?.[ 1 ] ) ) ;
765
+ break ;
766
+ default :
767
+ break ;
780
768
  }
781
769
 
782
- //if ( data.extra?.length ) { params.title = data.extra[ 0 ] ; }
783
-
784
- ctx.parts.push( params ) ;
785
770
  ctx.i ++ ;
786
771
  }
787
772
 
@@ -1607,13 +1592,13 @@ function parseStyledText( str , ctx , scanEnd ) {
1607
1592
 
1608
1593
  var href = data.href?.[ 0 ] ,
1609
1594
  style = data.style?.[ 0 ] ,
1610
- title = data.text?.[ 0 ] ;
1595
+ hint = data.text?.[ 0 ] ;
1611
1596
 
1612
1597
  if ( href ) {
1613
- ctx.parts.push( new documentParts.Link( href , style , title ) ) ;
1598
+ ctx.parts.push( new documentParts.Link( href , style , hint ) ) ;
1614
1599
  }
1615
- else if ( style || title ) {
1616
- ctx.parts.push( new documentParts.StyledText( style , title ) ) ;
1600
+ else if ( style || hint ) {
1601
+ ctx.parts.push( new documentParts.StyledText( style , hint ) ) ;
1617
1602
  }
1618
1603
  else {
1619
1604
  return ;
@@ -67,9 +67,7 @@ documentParts.InlineTextPart = InlineTextPart ;
67
67
 
68
68
 
69
69
 
70
- function BlockPart() {
71
- this.parts = [] ;
72
- }
70
+ function BlockPart() {}
73
71
 
74
72
  BlockPart.prototype = Object.create( Part.prototype ) ;
75
73
  BlockPart.prototype.constructor = BlockPart ;
@@ -77,6 +75,16 @@ documentParts.BlockPart = BlockPart ;
77
75
 
78
76
 
79
77
 
78
+ function BlockContainerPart() {
79
+ this.parts = [] ;
80
+ }
81
+
82
+ BlockContainerPart.prototype = Object.create( Part.prototype ) ;
83
+ BlockContainerPart.prototype.constructor = BlockContainerPart ;
84
+ documentParts.BlockContainerPart = BlockContainerPart ;
85
+
86
+
87
+
80
88
  // Inline Parts
81
89
 
82
90
  function Text( text ) {
@@ -126,12 +134,12 @@ documentParts.Code = Code ;
126
134
 
127
135
 
128
136
 
129
- function Link( href , style , title ) {
137
+ function Link( href , style , hint ) {
130
138
  this.type = 'link' ;
131
139
  this.href = href ;
132
140
  this.style = style || undefined ;
133
141
  InlineContainerPart.call( this ) ;
134
- this.title = title || undefined ;
142
+ this.hint = hint || undefined ;
135
143
  }
136
144
 
137
145
  Link.prototype = Object.create( InlineContainerPart.prototype ) ;
@@ -140,11 +148,11 @@ documentParts.Link = Link ;
140
148
 
141
149
 
142
150
 
143
- function StyledText( style , title ) {
151
+ function StyledText( style , hint ) {
144
152
  this.type = 'styledText' ;
145
153
  this.style = style || undefined ;
146
154
  InlineContainerPart.call( this ) ;
147
- this.title = title || undefined ;
155
+ this.hint = hint || undefined ;
148
156
  }
149
157
 
150
158
  StyledText.prototype = Object.create( InlineContainerPart.prototype ) ;
@@ -153,11 +161,11 @@ documentParts.StyledText = StyledText ;
153
161
 
154
162
 
155
163
 
156
- function Image( href , altText , title ) {
164
+ function Image( href , altText , hint ) {
157
165
  this.type = 'image' ;
158
166
  this.href = href ;
159
167
  this.altText = altText ;
160
- this.title = title || undefined ;
168
+ this.hint = hint || undefined ;
161
169
  InlinePart.call( this ) ;
162
170
  }
163
171
 
@@ -169,7 +177,7 @@ documentParts.Image = Image ;
169
177
 
170
178
  const emoji = require( 'string-kit/lib/emoji.js' ) ;
171
179
 
172
- function Pictogram( code , altText , title ) {
180
+ function Pictogram( code , altText , hint ) {
173
181
  this.type = 'pictogram' ;
174
182
  this.code = code ;
175
183
 
@@ -181,7 +189,7 @@ function Pictogram( code , altText , title ) {
181
189
  emojiChar ? emoji.getCanonicalName( emojiChar ) :
182
190
  undefined ;
183
191
 
184
- this.title = title || undefined ;
192
+ this.hint = hint || undefined ;
185
193
 
186
194
  InlinePart.call( this ) ;
187
195
  }
@@ -196,10 +204,10 @@ documentParts.Pictogram = Pictogram ;
196
204
 
197
205
  function Paragraph() {
198
206
  this.type = 'paragraph' ;
199
- BlockPart.call( this ) ;
207
+ BlockContainerPart.call( this ) ;
200
208
  }
201
209
 
202
- Paragraph.prototype = Object.create( BlockPart.prototype ) ;
210
+ Paragraph.prototype = Object.create( BlockContainerPart.prototype ) ;
203
211
  Paragraph.prototype.constructor = Paragraph ;
204
212
  documentParts.Paragraph = Paragraph ;
205
213
 
@@ -208,10 +216,10 @@ documentParts.Paragraph = Paragraph ;
208
216
  function Header( level ) {
209
217
  this.type = 'header' ;
210
218
  this.level = level ;
211
- BlockPart.call( this ) ;
219
+ BlockContainerPart.call( this ) ;
212
220
  }
213
221
 
214
- Header.prototype = Object.create( BlockPart.prototype ) ;
222
+ Header.prototype = Object.create( BlockContainerPart.prototype ) ;
215
223
  Header.prototype.constructor = Header ;
216
224
  documentParts.Header = Header ;
217
225
 
@@ -219,10 +227,10 @@ documentParts.Header = Header ;
219
227
 
220
228
  function Cite() {
221
229
  this.type = 'cite' ;
222
- BlockPart.call( this ) ;
230
+ BlockContainerPart.call( this ) ;
223
231
  }
224
232
 
225
- Cite.prototype = Object.create( BlockPart.prototype ) ;
233
+ Cite.prototype = Object.create( BlockContainerPart.prototype ) ;
226
234
  Cite.prototype.constructor = Cite ;
227
235
  documentParts.Cite = Cite ;
228
236
 
@@ -231,10 +239,10 @@ documentParts.Cite = Cite ;
231
239
  function List( indent ) {
232
240
  this.type = 'list' ;
233
241
  this.indent = indent ;
234
- BlockPart.call( this ) ;
242
+ BlockContainerPart.call( this ) ;
235
243
  }
236
244
 
237
- List.prototype = Object.create( BlockPart.prototype ) ;
245
+ List.prototype = Object.create( BlockContainerPart.prototype ) ;
238
246
  List.prototype.constructor = List ;
239
247
  documentParts.List = List ;
240
248
 
@@ -243,10 +251,10 @@ documentParts.List = List ;
243
251
  function ListItem( indent ) {
244
252
  this.type = 'listItem' ;
245
253
  this.indent = indent ;
246
- BlockPart.call( this ) ;
254
+ BlockContainerPart.call( this ) ;
247
255
  }
248
256
 
249
- ListItem.prototype = Object.create( BlockPart.prototype ) ;
257
+ ListItem.prototype = Object.create( BlockContainerPart.prototype ) ;
250
258
  ListItem.prototype.constructor = ListItem ;
251
259
  documentParts.ListItem = ListItem ;
252
260
 
@@ -256,10 +264,10 @@ function OrderedList( indent ) {
256
264
  this.type = 'orderedList' ;
257
265
  this.indent = indent ;
258
266
  this.autoIndex = 1 ;
259
- BlockPart.call( this ) ;
267
+ BlockContainerPart.call( this ) ;
260
268
  }
261
269
 
262
- OrderedList.prototype = Object.create( BlockPart.prototype ) ;
270
+ OrderedList.prototype = Object.create( BlockContainerPart.prototype ) ;
263
271
  OrderedList.prototype.constructor = OrderedList ;
264
272
  documentParts.OrderedList = OrderedList ;
265
273
 
@@ -270,10 +278,10 @@ function OrderedListItem( indent , order , index ) {
270
278
  this.indent = indent ;
271
279
  this.order = order ; // User order value
272
280
  this.index = index ; // Real index, starting at 1, and auto-incrementing
273
- BlockPart.call( this ) ;
281
+ BlockContainerPart.call( this ) ;
274
282
  }
275
283
 
276
- OrderedListItem.prototype = Object.create( BlockPart.prototype ) ;
284
+ OrderedListItem.prototype = Object.create( BlockContainerPart.prototype ) ;
277
285
  OrderedListItem.prototype.constructor = OrderedListItem ;
278
286
  documentParts.OrderedListItem = OrderedListItem ;
279
287
 
@@ -282,10 +290,10 @@ documentParts.OrderedListItem = OrderedListItem ;
282
290
  function Quote( indent ) {
283
291
  this.type = 'quote' ;
284
292
  this.indent = indent ;
285
- BlockPart.call( this ) ;
293
+ BlockContainerPart.call( this ) ;
286
294
  }
287
295
 
288
- Quote.prototype = Object.create( BlockPart.prototype ) ;
296
+ Quote.prototype = Object.create( BlockContainerPart.prototype ) ;
289
297
  Quote.prototype.constructor = Quote ;
290
298
  documentParts.Quote = Quote ;
291
299
 
@@ -294,10 +302,10 @@ documentParts.Quote = Quote ;
294
302
  function HorizontalRule( clearFloat ) {
295
303
  this.type = 'horizontalRule' ;
296
304
  this.clearFloat = clearFloat ;
297
- BlockPart.call( this ) ;
305
+ BlockContainerPart.call( this ) ;
298
306
  }
299
307
 
300
- HorizontalRule.prototype = Object.create( BlockPart.prototype ) ;
308
+ HorizontalRule.prototype = Object.create( BlockContainerPart.prototype ) ;
301
309
  HorizontalRule.prototype.constructor = HorizontalRule ;
302
310
  documentParts.HorizontalRule = HorizontalRule ;
303
311
 
@@ -305,10 +313,10 @@ documentParts.HorizontalRule = HorizontalRule ;
305
313
 
306
314
  function ClearFloat() {
307
315
  this.type = 'clearFloat' ;
308
- BlockPart.call( this ) ;
316
+ BlockContainerPart.call( this ) ;
309
317
  }
310
318
 
311
- ClearFloat.prototype = Object.create( BlockPart.prototype ) ;
319
+ ClearFloat.prototype = Object.create( BlockContainerPart.prototype ) ;
312
320
  ClearFloat.prototype.constructor = ClearFloat ;
313
321
  documentParts.ClearFloat = ClearFloat ;
314
322
 
@@ -318,10 +326,10 @@ function CodeBlock( text , lang ) {
318
326
  this.type = 'codeBlock' ;
319
327
  this.lang = lang || undefined ;
320
328
  this.text = text ;
321
- BlockPart.call( this ) ;
329
+ BlockContainerPart.call( this ) ;
322
330
  }
323
331
 
324
- CodeBlock.prototype = Object.create( BlockPart.prototype ) ;
332
+ CodeBlock.prototype = Object.create( BlockContainerPart.prototype ) ;
325
333
  CodeBlock.prototype.constructor = CodeBlock ;
326
334
  documentParts.CodeBlock = CodeBlock ;
327
335
 
@@ -330,15 +338,63 @@ documentParts.CodeBlock = CodeBlock ;
330
338
  function Anchor( href ) {
331
339
  this.type = 'anchor' ;
332
340
  this.href = href ;
333
- BlockPart.call( this ) ;
341
+ BlockContainerPart.call( this ) ;
334
342
  }
335
343
 
336
- Anchor.prototype = Object.create( BlockPart.prototype ) ;
344
+ Anchor.prototype = Object.create( BlockContainerPart.prototype ) ;
337
345
  Anchor.prototype.constructor = Anchor ;
338
346
  documentParts.Anchor = Anchor ;
339
347
 
340
348
 
341
349
 
350
+ function ImageBlock( href , altText , float , caption , hint ) {
351
+ this.type = 'imageBlock' ;
352
+ this.href = href ;
353
+ this.altText = altText ;
354
+ this.float = float || undefined ;
355
+ this.caption = caption || undefined ;
356
+ this.hint = hint || undefined ;
357
+ BlockPart.call( this ) ;
358
+ }
359
+
360
+ ImageBlock.prototype = Object.create( BlockPart.prototype ) ;
361
+ ImageBlock.prototype.constructor = ImageBlock ;
362
+ documentParts.ImageBlock = ImageBlock ;
363
+
364
+
365
+
366
+ function AudioBlock( href , altText , float , caption , hint ) {
367
+ this.type = 'audioBlock' ;
368
+ this.href = href ;
369
+ this.altText = altText ;
370
+ this.float = float || undefined ;
371
+ this.caption = caption || undefined ;
372
+ this.hint = hint || undefined ;
373
+ BlockPart.call( this ) ;
374
+ }
375
+
376
+ AudioBlock.prototype = Object.create( BlockPart.prototype ) ;
377
+ AudioBlock.prototype.constructor = AudioBlock ;
378
+ documentParts.AudioBlock = AudioBlock ;
379
+
380
+
381
+
382
+ function VideoBlock( href , altText , float , caption , hint ) {
383
+ this.type = 'videoBlock' ;
384
+ this.href = href ;
385
+ this.altText = altText ;
386
+ this.float = float || undefined ;
387
+ this.caption = caption || undefined ;
388
+ this.hint = hint || undefined ;
389
+ BlockPart.call( this ) ;
390
+ }
391
+
392
+ VideoBlock.prototype = Object.create( BlockPart.prototype ) ;
393
+ VideoBlock.prototype.constructor = VideoBlock ;
394
+ documentParts.VideoBlock = VideoBlock ;
395
+
396
+
397
+
342
398
  function Table() {
343
399
  this.type = 'table' ;
344
400
  this.columns = [] ;
@@ -346,10 +402,10 @@ function Table() {
346
402
  this.hasHeadSeparator = false ;
347
403
  this.hasRowSeparator = false ;
348
404
  this.hasRowSpan = false ; // Useful to disable background colors based on odd/even rows
349
- BlockPart.call( this ) ;
405
+ BlockContainerPart.call( this ) ;
350
406
  }
351
407
 
352
- Table.prototype = Object.create( BlockPart.prototype ) ;
408
+ Table.prototype = Object.create( BlockContainerPart.prototype ) ;
353
409
  Table.prototype.constructor = Table ;
354
410
  documentParts.Table = Table ;
355
411
 
@@ -358,10 +414,10 @@ documentParts.Table = Table ;
358
414
  function TableCaption( style ) {
359
415
  this.type = 'tableCaption' ;
360
416
  this.style = style || undefined ;
361
- BlockPart.call( this ) ;
417
+ BlockContainerPart.call( this ) ;
362
418
  }
363
419
 
364
- TableCaption.prototype = Object.create( BlockPart.prototype ) ;
420
+ TableCaption.prototype = Object.create( BlockContainerPart.prototype ) ;
365
421
  TableCaption.prototype.constructor = TableCaption ;
366
422
  documentParts.TableCaption = TableCaption ;
367
423
 
@@ -372,10 +428,10 @@ function TableRow( style ) {
372
428
  this.style = style || undefined ;
373
429
  this.rowSeparator = false ;
374
430
  this.continueRowSpan = undefined ;
375
- BlockPart.call( this ) ;
431
+ BlockContainerPart.call( this ) ;
376
432
  }
377
433
 
378
- TableRow.prototype = Object.create( BlockPart.prototype ) ;
434
+ TableRow.prototype = Object.create( BlockContainerPart.prototype ) ;
379
435
  TableRow.prototype.constructor = TableRow ;
380
436
  documentParts.TableRow = TableRow ;
381
437
 
@@ -394,10 +450,10 @@ function TableHeadRow( style ) {
394
450
  this.style = style || undefined ;
395
451
  this.rowSeparator = false ;
396
452
  this.continueRowSpan = undefined ;
397
- BlockPart.call( this ) ;
453
+ BlockContainerPart.call( this ) ;
398
454
  }
399
455
 
400
- TableHeadRow.prototype = Object.create( BlockPart.prototype ) ;
456
+ TableHeadRow.prototype = Object.create( BlockContainerPart.prototype ) ;
401
457
  TableHeadRow.prototype.constructor = TableHeadRow ;
402
458
  documentParts.TableHeadRow = TableHeadRow ;
403
459
 
@@ -413,10 +469,10 @@ function TableCell( style ) {
413
469
  this.sx = - 1 ;
414
470
  this.ex = - 1 ;
415
471
  this.masterCell = undefined ;
416
- BlockPart.call( this ) ;
472
+ BlockContainerPart.call( this ) ;
417
473
  }
418
474
 
419
- TableCell.prototype = Object.create( BlockPart.prototype ) ;
475
+ TableCell.prototype = Object.create( BlockContainerPart.prototype ) ;
420
476
  TableCell.prototype.constructor = TableCell ;
421
477
  documentParts.TableCell = TableCell ;
422
478
 
@@ -447,10 +503,10 @@ function TableHeadCell( style ) {
447
503
  this.masterCell = undefined ;
448
504
  this.isColumnHead = false ;
449
505
  this.isRowHead = false ;
450
- BlockPart.call( this ) ;
506
+ BlockContainerPart.call( this ) ;
451
507
  }
452
508
 
453
- TableHeadCell.prototype = Object.create( BlockPart.prototype ) ;
509
+ TableHeadCell.prototype = Object.create( BlockContainerPart.prototype ) ;
454
510
  TableHeadCell.prototype.constructor = TableHeadCell ;
455
511
  documentParts.TableHeadCell = TableHeadCell ;
456
512
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "book-source",
3
- "version": "0.3.7",
3
+ "version": "0.3.8",
4
4
  "description": "A lightweight markup language, inspired by Markdown.",
5
5
  "main": "lib/book-source.js",
6
6
  "directories": {