total5 0.0.1 → 0.0.2

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/markdown.js ADDED
@@ -0,0 +1,762 @@
1
+ // Total.js Markdown
2
+ // The MIT License
3
+ // Copyright 2018-2023 (c) Peter Širka <petersirka@gmail.com>
4
+
5
+ const REG_DASH = /-{2,}/g;
6
+ const REG_TAGS = /<[^>]*>/g;
7
+ const REG_EMPTYCHAR = /\s|\W/;
8
+ const REG_ICONS = /(^|[^\w]):((fab|far|fas|fal|fad|fa|ti)\s(fa|ti)-)?[a-z-]+:([^\w]|$)/g;
9
+ const REG_KEYWORDS = /\{.*?\}\(.*?\)/g;
10
+ const REG_LINKEXTERNAL = /(https|http):\/\//;
11
+ const REG_FORMAT = /__.*?__|_.*?_|\*\*.*?\*\*|\*.*?\*|~~.*?~~|~.*?~/g;
12
+ const REG_ORDERED = /^[a-z|0-9]{1,3}\.\s|^-\s/i;
13
+ const REG_ORDEREDSIZE = /^(\s|\t)+/;
14
+ const REG_CODE = /`.*?`/g;
15
+ const REG_ENCODETAGS = /<|>/g;
16
+ const ENCODE = val => '&' + (val === '<' ? 'lt' : 'gt') + ';';
17
+ const REG_NIL = /\0/g;
18
+
19
+ function markdown_code(value) {
20
+ return value ? ('<code>' + value.substring(1, value.length - 1) + '</code>') : '';
21
+ }
22
+
23
+ function markdown_imagelinks(value) {
24
+
25
+ if (!value)
26
+ return '';
27
+
28
+ var end = value.lastIndexOf(')') + 1;
29
+ var img = value.substring(0, end);
30
+ var url = value.substring(end + 2, value.length - 1);
31
+ var label = markdown_links(img);
32
+ var footnote = label.substring(0, 13);
33
+
34
+ if (footnote === '<sup data-id=' || footnote === '<span data-id' || label.substring(0, 9) === '<a href="')
35
+ return label;
36
+
37
+ return '<a href="' + url + '"' + (REG_LINKEXTERNAL.test(url) ? ' target="_blank"' : '') + '>' + label + '</a>';
38
+ }
39
+
40
+ function markdown_table(value, align, ishead) {
41
+
42
+ var columns = value.substring(1, value.length - 1).split('|');
43
+ var builder = '';
44
+
45
+ for (var i = 0; i < columns.length; i++) {
46
+ var column = columns[i].trim();
47
+ if (column.charAt(0) != '-') {
48
+ var a = align[i];
49
+ builder += '<' + (ishead ? 'th' : 'td') + (a && a !== 'left' ? (' class="' + a + '"') : '') + '>' + column + '</' + (ishead ? 'th' : 'td') + '>';
50
+ }
51
+ }
52
+
53
+ return '<tr>' + builder + '</tr>';
54
+ }
55
+
56
+ function markdown_links(value) {
57
+
58
+ if (!value)
59
+ return '';
60
+
61
+ var end = value.lastIndexOf(']');
62
+ var img = value.charAt(0) === '!';
63
+ var text = value.substring(img ? 2 : 1, end);
64
+ var link = value.substring(end + 2, value.length - 1);
65
+
66
+ // footnotes
67
+ if ((/^#\d+$/).test(link)) {
68
+ return (/^\d+$/).test(text) ? '<sup data-id="{0}" class="markdown-footnote">{1}</sup>'.format(link.substring(1), text) : '<span data-id="{0}" class="markdown-footnote">{1}</span>'.format(link.substring(1), text);
69
+ }
70
+
71
+ if (link.substring(0, 4) === 'www.')
72
+ link = 'https://' + link;
73
+
74
+ var nofollow = link.charAt(0) === '@' ? ' rel="nofollow"' : REG_LINKEXTERNAL.test(link) ? ' target="_blank"' : '';
75
+ return '<a href="' + link + '"' + nofollow + '>' + text + '</a>';
76
+ }
77
+
78
+ function markdown_image(value) {
79
+
80
+ var end = value.lastIndexOf(']');
81
+ var text = value.substring(2, end);
82
+ var link = value.substring(end + 2, value.length - 1);
83
+ var responsive = 1;
84
+ var f = text.charAt(0);
85
+
86
+ if (f === '+') {
87
+ responsive = 2;
88
+ text = text.substring(1);
89
+ } else if (f === '-') {
90
+ // gallery
91
+ responsive = 3;
92
+ text = text.substring(1);
93
+ }
94
+
95
+ return '<img src="' + link + '" alt="' + text + '"' + (responsive === 1 ? ' class="img-responsive"' : responsive === 3 ? ' class="markdown-gallery"' : '') + ' border="0" loading="lazy" />';
96
+ }
97
+
98
+ function markdown_keywords(value) {
99
+ var keyword = value.substring(1, value.indexOf('}'));
100
+ var type = value.substring(value.lastIndexOf('(') + 1, value.lastIndexOf(')'));
101
+ return '<span class="markdown-keyword" data-type="{0}">{1}</span>'.format(type, keyword);
102
+ }
103
+
104
+ function markdown_links2(value) {
105
+ value = value.substring(4, value.length - 4);
106
+ return '<a href="' + (value.isEmail() ? 'mailto:' : REG_LINKEXTERNAL.test(value) ? '' : 'http://') + value + '" target="_blank">' + value + '</a>';
107
+ }
108
+
109
+ function markdown_format(value, index, text) {
110
+
111
+ var p = text.charAt(index - 1);
112
+ var n = text.charAt(index + value.length);
113
+
114
+ if ((!p || REG_EMPTYCHAR.test(p)) && (!n || REG_EMPTYCHAR.test(n))) {
115
+
116
+ var beg = '';
117
+ var end = '';
118
+ var tag;
119
+
120
+ if (value.indexOf('*') !== -1) {
121
+ tag = value.indexOf('**') === -1 ? 'em' : 'strong';
122
+ beg += '<' + tag + '>';
123
+ end = '</' + tag + '>' + end;
124
+ }
125
+
126
+ if (value.indexOf('_') !== -1) {
127
+ tag = value.indexOf('__') === -1 ? 'u' : 'b';
128
+ beg += '<' + tag + '>';
129
+ end = '</' + tag + '>' + end;
130
+ }
131
+
132
+ if (value.indexOf('~') !== -1) {
133
+ beg += '<strike>';
134
+ end = '</strike>' + end;
135
+ }
136
+
137
+ var count = value.charAt(1) === value.charAt(0) ? 2 : 1;
138
+ return beg + value.substring(count, value.length - count) + end;
139
+ }
140
+
141
+ return value;
142
+ }
143
+
144
+ function markdown_id(prefix, value) {
145
+ value = value.replace(REG_TAGS, '');
146
+ return prefix + value.slug().replace(REG_DASH, '-');
147
+ }
148
+
149
+ function markdown_icon(value) {
150
+
151
+ var beg = -1;
152
+ var end = -1;
153
+
154
+ for (var i = 0; i < value.length; i++) {
155
+ var code = value.charCodeAt(i);
156
+ if (code === 58) {
157
+ if (beg === -1)
158
+ beg = i + 1;
159
+ else
160
+ end = i;
161
+ }
162
+ }
163
+
164
+ var icon = value.substring(beg, end);
165
+ if (icon.indexOf(' ') === -1)
166
+ icon = 'ti ti-' + icon;
167
+ return value.substring(0, beg - 1) + '<i class="' + icon + '"></i>' + value.substring(end + 1);
168
+ }
169
+
170
+ function markdown_urlify(str) {
171
+ return str.replace(/(^|\s)+(((https?:\/\/)|(www\.))[^\s]+)/g, function(url, b, c) {
172
+ var len = url.length;
173
+ var l = url.charAt(len - 1);
174
+ var f = url.charAt(0);
175
+ if (l === '.' || l === ',')
176
+ url = url.substring(0, len - 1);
177
+ else
178
+ l = '';
179
+ url = (c === 'www.' ? 'http://' + url : url).trim();
180
+ return (f.charCodeAt(0) < 40 ? f : '') + '[' + url + '](' + url + ')' + l;
181
+ });
182
+ }
183
+
184
+ function parseul(builder) {
185
+
186
+ var ul = {};
187
+ var is = false;
188
+ var currentindex = -1;
189
+ var output = [];
190
+
191
+ for (var i = 0; i < builder.length; i++) {
192
+
193
+ var line = builder[i];
194
+
195
+ if (line.charAt(0) === '\0') {
196
+
197
+ if (!is)
198
+ currentindex = output.push('<ul />') - 1;
199
+
200
+ var key = currentindex + '';
201
+ is = true;
202
+
203
+ var tmp = line.substring(1);
204
+ var index = tmp.indexOf('<');
205
+ var obj = {};
206
+ obj.index = i;
207
+ obj.type = tmp.substring(0, 2);
208
+ obj.offset = +tmp.substring(2, index).trim();
209
+ obj.line = line.substring(index + 1);
210
+
211
+ if (ul[key])
212
+ ul[key].push(obj);
213
+ else
214
+ ul[key] = [obj];
215
+
216
+ } else {
217
+ output.push(line);
218
+ is = false;
219
+ }
220
+ }
221
+
222
+ for (var key in ul) {
223
+
224
+ var line = +key;
225
+ var arr = ul[key];
226
+ var lines = [];
227
+ var tags = [];
228
+ var prev = null;
229
+ var diff = null;
230
+ var init = false;
231
+ var tmp = null;
232
+
233
+ for (var i = 0; i < arr.length; i++) {
234
+
235
+ var li = arr[i];
236
+ var beg = li.type === 'ul' ? '<ul>' : li.type === 'o1' ? '<ol type="1">' : '<ol type="a">';
237
+ var end = li.type === 'ul' ? '</ul>' : '</ol>';
238
+
239
+ var diff = li.offset - (prev ? prev.offset : 0);
240
+
241
+ // Init
242
+ if (!init) {
243
+ init = true;
244
+ lines.push(beg);
245
+ tags.push(end);
246
+ }
247
+
248
+ if (diff > 0) {
249
+ var last = lines[lines.length - 1];
250
+ last = last.replace(/<\/li>$/, '');
251
+ lines[lines.length - 1] = last;
252
+ tags.push(end + '</li>');
253
+ lines.push(beg);
254
+ lines.push(li.line);
255
+ } else if (diff < 0) {
256
+ while (diff < 0) {
257
+ tmp = tags.pop();
258
+ lines.push(tmp);
259
+ diff++;
260
+ }
261
+ lines.push(li.line);
262
+ } else {
263
+ lines.push(li.line);
264
+ }
265
+
266
+ prev = li;
267
+
268
+ }
269
+
270
+ while (tags.length)
271
+ lines.push(tags.pop());
272
+
273
+ output[line] = lines.join('\n');
274
+ }
275
+
276
+ return output;
277
+ }
278
+
279
+ function formatline(line) {
280
+ var tmp = [];
281
+ return line.replace(REG_CODE, function(text) {
282
+ tmp.push(text);
283
+ return '\0';
284
+ }).replace(REG_FORMAT, markdown_format).replace(REG_NIL, () => markdown_code(tmp.shift()));
285
+ }
286
+
287
+ function imagescope(val) {
288
+
289
+ var beg = -1;
290
+ var can = false;
291
+ var n;
292
+
293
+ for (var i = 0; i < val.length; i++) {
294
+ var c = val.charAt(i);
295
+
296
+ if (c === '[') {
297
+ beg = i;
298
+ can = false;
299
+ continue;
300
+ }
301
+
302
+ if (c === ']') {
303
+
304
+ can = false;
305
+
306
+ if (beg === -1)
307
+ continue;
308
+
309
+ n = val.charAt(i + 1);
310
+
311
+ // maybe a link mistake
312
+ if (n === ' ')
313
+ n = val.charAt(i + 2);
314
+
315
+ // maybe a link
316
+ can = n === '(';
317
+ }
318
+
319
+ if (beg > -1 && can && c === ')') {
320
+ n = val.charAt(beg - 1);
321
+ var tmp = val.substring(beg - (n === '!' ? 1 : 0), i + 1);
322
+ if (tmp.charAt(0) === '!')
323
+ val = val.replace(tmp, markdown_image(tmp));
324
+ can = false;
325
+ beg = -1;
326
+ }
327
+ }
328
+
329
+ return val;
330
+ }
331
+
332
+ function linkscope(val, index, callback) {
333
+
334
+ var beg = -1;
335
+ var beg2 = -1;
336
+ var can = false;
337
+ var skip = false;
338
+ var find = false;
339
+ var n;
340
+
341
+ for (var i = index; i < val.length; i++) {
342
+ var c = val.charAt(i);
343
+
344
+ if (c === '[') {
345
+ beg = i;
346
+ can = false;
347
+ find = true;
348
+ continue;
349
+ }
350
+
351
+ var codescope = val.substring(i, i + 6);
352
+
353
+ if (skip && codescope === '</code') {
354
+ skip = false;
355
+ i += 7;
356
+ continue;
357
+ }
358
+
359
+ if (skip)
360
+ continue;
361
+
362
+ if (!find && codescope === '<code>') {
363
+ skip = true;
364
+ continue;
365
+ }
366
+
367
+ var il = val.substring(i, i + 4);
368
+
369
+ if (il === '&lt;') {
370
+ beg2 = i;
371
+ continue;
372
+ } else if (beg2 > -1 && il === '&gt;') {
373
+ callback(val.substring(beg2, i + 4), true);
374
+ beg2 = -1;
375
+ continue;
376
+ }
377
+
378
+ if (c === ']') {
379
+
380
+ can = false;
381
+ find = false;
382
+
383
+ if (beg === -1)
384
+ continue;
385
+
386
+ n = val.charAt(i + 1);
387
+
388
+ // maybe a link mistake
389
+ if (n === ' ')
390
+ n = val.charAt(i + 2);
391
+
392
+ // maybe a link
393
+ can = n === '(';
394
+ }
395
+
396
+ if (beg > -1 && can && c === ')') {
397
+ n = val.charAt(beg - 1);
398
+ callback(val.substring(beg - (n === '!' ? 1 : 0), i + 1));
399
+ can = false;
400
+ find = false;
401
+ beg = -1;
402
+ }
403
+ }
404
+ }
405
+
406
+ String.prototype.markdown = function(opt, nested) {
407
+
408
+ // opt.wrap = true;
409
+ // opt.linetag = 'p';
410
+ // opt.ul = true;
411
+ // opt.code = true;
412
+ // opt.images = true;
413
+ // opt.links = true;
414
+ // opt.formatting = true;
415
+ // opt.icons = true;
416
+ // opt.tables = true;
417
+ // opt.br = true;
418
+ // opt.headlines = true;
419
+ // opt.hr = true;
420
+ // opt.blockquotes = true;
421
+ // opt.sections = true;
422
+ // opt.custom
423
+ // opt.footnotes = true;
424
+ // opt.urlify = true;
425
+ // opt.keywords = true;
426
+ // opt.emptynewline = true;
427
+ // opt.bookmarks = true;
428
+ // opt.prefix = '';
429
+
430
+ var str = this;
431
+
432
+ if (!opt)
433
+ opt = {};
434
+
435
+ if (opt.bookmarks == null)
436
+ opt.bookmarks = true;
437
+
438
+ var lines = str.split('\n');
439
+ var builder = [];
440
+ var ul = [];
441
+ var table = false;
442
+ var iscode = false;
443
+ var isblock = false;
444
+ var ishead = 0;
445
+ var isprevblock = false;
446
+ var headline = '<{0}' + (opt.bookmarks ? ' id="{3}"' : '') + ' class="markdown-line" data-index="{1}">{2}</{0}>';
447
+ var line;
448
+ var tmp;
449
+ var prefix = opt.prefix || '';
450
+
451
+ if (opt.wrap == null)
452
+ opt.wrap = true;
453
+
454
+ if (opt.linetag == null)
455
+ opt.linetag = 'p';
456
+
457
+ var closeul = function() {
458
+ while (ul.length) {
459
+ var text = ul.pop();
460
+ builder.push('</' + text + '>');
461
+ }
462
+ };
463
+
464
+ var linkreplace = function(text, inline) {
465
+ if (inline)
466
+ opt.$line = opt.$line.replace(text, markdown_links2);
467
+ else if (opt.images !== false)
468
+ opt.$line = opt.$line.replace(text, markdown_imagelinks);
469
+ else
470
+ opt.$line = opt.$line.replace(text, text => markdown_links(text, opt.images));
471
+ };
472
+
473
+ for (var i = 0; i < lines.length; i++) {
474
+
475
+ lines[i] = lines[i].replace(REG_ENCODETAGS, ENCODE);
476
+
477
+ if (!lines[i]) {
478
+ builder.push('');
479
+ continue;
480
+ }
481
+
482
+ var three = lines[i].substring(0, 3);
483
+
484
+ if (!iscode && (three === ':::' || (three === '==='))) {
485
+
486
+ if (isblock) {
487
+ if (opt.blocks !== false)
488
+ builder[builder.length - 1] += '</div></div>';
489
+ isblock = false;
490
+ isprevblock = true;
491
+ continue;
492
+ }
493
+
494
+ closeul();
495
+ isblock = true;
496
+ if (opt.blocks !== false) {
497
+ line = lines[i].substring(3).trim();
498
+ if (opt.formatting !== false)
499
+ line = formatline(line);
500
+ if (opt.custom)
501
+ line = opt.custom(line);
502
+ if (opt.html)
503
+ line = opt.html(line, 'block');
504
+ builder.push('<div class="markdown-block markdown-line" data-line="{0}"><span class="markdown-showblock"><i class="ti ti-plus"></i>{1}</span><div class="hidden">'.format(i, line));
505
+ }
506
+ continue;
507
+ }
508
+
509
+ if (!isblock && lines[i] && isprevblock) {
510
+ builder.push('<br />');
511
+ isprevblock = false;
512
+ }
513
+
514
+ if (three === '```') {
515
+
516
+ if (iscode) {
517
+ if (opt.code !== false)
518
+ builder[builder.length - 1] += '</code></pre></div>';
519
+ iscode = false;
520
+ continue;
521
+ }
522
+
523
+ closeul();
524
+ iscode = true;
525
+ if (opt.code !== false)
526
+ tmp = '<div class="markdown-code markdown-line hidden"><pre class="noscrollbar"><code class="lang-{0}">'.format(lines[i].substring(3));
527
+ continue;
528
+ }
529
+
530
+ if (iscode) {
531
+ if (opt.code !== false)
532
+ builder.push(tmp + lines[i]);
533
+ if (tmp)
534
+ tmp = '';
535
+ continue;
536
+ }
537
+
538
+ line = lines[i];
539
+
540
+ if (opt.br !== false)
541
+ line = line.replace(/&lt;br(\s\/)?&gt;/g, '<br />');
542
+
543
+ if (line.length > 10 && opt.urlify !== false && opt.links !== false)
544
+ line = markdown_urlify(line);
545
+
546
+ if (opt.custom)
547
+ line = opt.custom(line);
548
+
549
+ if (line.length > 2 && line !== '***' && line !== '---') {
550
+
551
+ if (opt.formatting !== false)
552
+ line = formatline(line);
553
+
554
+ if (opt.images !== false)
555
+ line = imagescope(line);
556
+
557
+ if (opt.links !== false) {
558
+ opt.$line = line;
559
+ linkscope(line, 0, linkreplace);
560
+ line = opt.$line;
561
+ }
562
+
563
+ if (opt.keywords !== false)
564
+ line = line.replace(REG_KEYWORDS, markdown_keywords);
565
+
566
+ if (opt.icons !== false)
567
+ line = line.replace(REG_ICONS, markdown_icon);
568
+ }
569
+
570
+ if (!line) {
571
+ if (table) {
572
+ table = null;
573
+ if (opt.tables !== false)
574
+ builder.push('</tbody></table>');
575
+ }
576
+ }
577
+
578
+ if (line === '' && lines[i - 1] === '') {
579
+ closeul();
580
+ if (opt.emptynewline !== false)
581
+ builder.push('<br />');
582
+ continue;
583
+ }
584
+
585
+ if (line[0] === '|') {
586
+ closeul();
587
+
588
+ if (!table) {
589
+ var next = lines[i + 1];
590
+ if (next[0] === '|') {
591
+ if (next.indexOf('--') === -1) {
592
+ if (opt.tables !== false)
593
+ builder.push('<table class="table table-bordered"><thead>');
594
+ table = [];
595
+ ishead = 2;
596
+ } else {
597
+ table = [];
598
+ var columns = next.substring(1, next.length - 1).split('|');
599
+ for (var j = 0; j < columns.length; j++) {
600
+ var column = columns[j].trim();
601
+ var align = 'left';
602
+ if (column.charAt(column.length - 1) === ':')
603
+ align = column[0] === ':' ? 'center' : 'right';
604
+ table.push(align);
605
+ }
606
+ if (opt.tables !== false)
607
+ builder.push('<table class="table table-bordered"><thead>');
608
+ ishead = 1;
609
+ i++;
610
+ }
611
+ } else
612
+ continue;
613
+ }
614
+
615
+ if (opt.tables !== false) {
616
+ if (ishead === 1)
617
+ builder.push(markdown_table(line, table, true) + '</thead><tbody>');
618
+ else if (ishead === 2)
619
+ builder.push('<tbody>' + markdown_table(line, table));
620
+ else
621
+ builder.push(markdown_table(line, table));
622
+ }
623
+
624
+ ishead = 0;
625
+ continue;
626
+ }
627
+
628
+ if (line.charAt(0) === '#') {
629
+
630
+ closeul();
631
+
632
+ if (line.substring(0, 2) === '# ') {
633
+ tmp = line.substring(2).trim();
634
+ if (opt.headlines !== false) {
635
+ if (opt.html)
636
+ tmp = opt.html(tmp, '#');
637
+ builder.push(headline.format('h1', i, tmp, opt.bookmarks ? markdown_id(prefix, tmp) : ''));
638
+ }
639
+ continue;
640
+ }
641
+
642
+ if (line.substring(0, 3) === '## ') {
643
+ tmp = line.substring(3).trim();
644
+ if (opt.headlines !== false) {
645
+ if (opt.html)
646
+ tmp = opt.html(tmp, '##');
647
+ builder.push(headline.format('h2', i, tmp, opt.bookmarks ? markdown_id(prefix, tmp) : ''));
648
+ }
649
+ continue;
650
+ }
651
+
652
+ if (line.substring(0, 4) === '### ') {
653
+ tmp = line.substring(4).trim();
654
+ if (opt.headlines !== false) {
655
+ if (opt.html)
656
+ tmp = opt.html(tmp, '###');
657
+ builder.push(headline.format('h3', i, tmp, opt.bookmarks ? markdown_id(prefix, tmp) : ''));
658
+ }
659
+ continue;
660
+ }
661
+
662
+ if (line.substring(0, 5) === '#### ') {
663
+ tmp = line.substring(5).trim();
664
+ if (opt.headlines !== false) {
665
+ if (opt.html)
666
+ tmp = opt.html(tmp, '####');
667
+ builder.push(headline.format('h4', i, tmp, opt.bookmarks ? markdown_id(prefix, tmp) : ''));
668
+ }
669
+ continue;
670
+ }
671
+
672
+ if (line.substring(0, 6) === '##### ') {
673
+ tmp = line.substring(6).trim();
674
+ if (opt.headlines !== false) {
675
+ if (opt.html)
676
+ tmp = opt.html(tmp, '#####');
677
+ builder.push(headline.format('h5', i, tmp, opt.bookmarks ? markdown_id(prefix, tmp) : ''));
678
+ }
679
+ continue;
680
+ }
681
+ }
682
+
683
+ tmp = line.substring(0, 3);
684
+
685
+ if (tmp === '---' || tmp === '***') {
686
+ if (opt.hr !== false)
687
+ builder.push('<hr class="markdown-line' + (tmp.charAt(0) === '-' ? '1' : '2') + ' markdown-line" data-line="' + i + '" />');
688
+ continue;
689
+ }
690
+
691
+ // footnotes
692
+ if ((/^#\d+:(\s)+/).test(line)) {
693
+ if (opt.footnotes !== false) {
694
+ tmp = line.indexOf(':');
695
+ builder.push('<div class="markdown-footnotebody" data-id="{0}"><span>{0}:</span> {1}</div>'.format(line.substring(1, tmp).trim(), line.substring(tmp + 1).trim()));
696
+ }
697
+ continue;
698
+ }
699
+
700
+ if (line.substring(0, 5) === '&gt; ') {
701
+ if (opt.blockquotes !== false) {
702
+ line = line.substring(5).trim();
703
+ if (opt.html)
704
+ line = opt.html(line, 'blockquote');
705
+ builder.push('<blockquote class="markdown-line" data-line="' + i + '">' + line + '</blockquote>');
706
+ }
707
+ continue;
708
+ }
709
+
710
+ if (line.substring(0, 5) === '&lt; ') {
711
+ if (opt.sections !== false) {
712
+ line = line.substring(5).trim();
713
+ if (opt.html)
714
+ line = opt.html(line, 'section');
715
+ builder.push('<section class="markdown-line" data-line="' + i + '">' + line + '</section>');
716
+ }
717
+ continue;
718
+ }
719
+
720
+ var tmpline = line.trim();
721
+
722
+ if (opt.ul !== false && REG_ORDERED.test(tmpline)) {
723
+
724
+ var size = line.match(REG_ORDEREDSIZE);
725
+ if (size)
726
+ size = size[0].length;
727
+ else
728
+ size = 0;
729
+
730
+ var ultype = tmpline.charAt(0) === '-' ? 'ul' : 'ol';
731
+ var tmpstr = (ultype === 'ol' ? tmpline.substring(tmpline.indexOf('.') + 1) : tmpline.substring(2));
732
+ var istask = false;
733
+
734
+ var tt = tmpstr.trim().substring(0, 3);
735
+ istask = tt === '[ ]' || tt === '[x]';
736
+
737
+ var tmpval = tmpstr.trim();
738
+
739
+ if (opt.html)
740
+ tmpval = opt.html(tmpval, 'li');
741
+
742
+ builder.push('\0' + (ultype === 'ol' ? ('o' + ((/\d+\./).test(tmpline) ? '1' : 'a')) : 'ul') + size + '<li data-line="{0}" class="markdown-line{1}">'.format(i, istask ? ' markdown-task' : '') + tmpval.replace(/\[x\]/g, '<i class="ti ti-check-square green"></i>').replace(/\[\s\]/g, '<i class="ti ti-square"></i>') + '</li>');
743
+
744
+ } else {
745
+ closeul();
746
+ if (line) {
747
+ line = line.trim();
748
+ if (opt.html)
749
+ line = opt.html(line, opt.linetag);
750
+ }
751
+ line && builder.push((opt.linetag ? ('<' + opt.linetag + ' class="markdown-line" data-line="' + i + '">') : '') + line.trim() + (opt.linetag ? ('</' + opt.linetag + '>') : ''));
752
+ }
753
+ }
754
+
755
+ closeul();
756
+
757
+ table && opt.tables !== false && builder.push('</tbody></table>');
758
+ iscode && opt.code !== false && builder.push('</code></pre>');
759
+
760
+ builder = parseul(builder);
761
+ return (opt.wrap ? ('<div class="markdown' + (nested ? '' : ' markdown-container') + '">') : '') + builder.join('\n').replace(/\t/g, ' ') + (opt.wrap ? '</div>' : '');
762
+ };