mathpix-markdown-it 1.0.92 → 1.0.94

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.
@@ -193,6 +193,7 @@ var menclose = function (handlerApi) {
193
193
  ascii: '',
194
194
  ascii_tsv: '',
195
195
  ascii_csv: '',
196
+ ascii_md: '',
196
197
  };
197
198
  try {
198
199
  var atr = exports.getAttributes(node);
@@ -204,7 +205,7 @@ var menclose = function (handlerApi) {
204
205
  }
205
206
  res = common_1.AddToAsciiData(res, [isLeft ? '[' : '']);
206
207
  var data = handlerApi.handleAll(node, serialize);
207
- res = common_1.AddToAsciiData(res, [data.ascii, data.ascii_tsv, data.ascii_csv]);
208
+ res = common_1.AddToAsciiData(res, [data.ascii, data.ascii_tsv, data.ascii_csv, data.ascii_md]);
208
209
  if (atr && atr.lcm) {
209
210
  res = common_1.AddToAsciiData(res, ['']);
210
211
  }
@@ -278,10 +279,11 @@ var getDataForVerticalMath = function (serialize, node, rowNumber) {
278
279
  };
279
280
  var mtable = function () {
280
281
  return function (node, serialize) {
281
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
282
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0;
282
283
  var mml = '';
283
284
  var mml_tsv = '';
284
285
  var mml_csv = '';
286
+ var mml_md = '';
285
287
  try {
286
288
  /** MathJax: <mrow> came from \left...\right
287
289
  * so treat as subexpression (TeX class INNER). */
@@ -290,20 +292,24 @@ var mtable = function () {
290
292
  var countRow = node.childNodes.length;
291
293
  var toTsv = serialize.options.tableToTsv && !serialize.options.isSubTable
292
294
  && (((_c = node.Parent) === null || _c === void 0 ? void 0 : _c.kind) === 'math' || (parentIsMenclose && ((_d = node.Parent.Parent) === null || _d === void 0 ? void 0 : _d.kind) === 'math'));
293
- var toCsv = (serialize.options.tableToCsv || serialize.options.tableToCsv) && !serialize.options.isSubTable
295
+ var toCsv = serialize.options.tableToCsv && !serialize.options.isSubTable
294
296
  && (((_e = node.Parent) === null || _e === void 0 ? void 0 : _e.kind) === 'math' || (parentIsMenclose && ((_f = node.Parent.Parent) === null || _f === void 0 ? void 0 : _f.kind) === 'math'));
297
+ var toMd = serialize.options.tableToMd && !serialize.options.isSubTable
298
+ && (((_g = node.Parent) === null || _g === void 0 ? void 0 : _g.kind) === 'math' || (parentIsMenclose && ((_h = node.Parent.Parent) === null || _h === void 0 ? void 0 : _h.kind) === 'math'));
299
+ node.attributes.setInherited('toTsv', toTsv);
295
300
  node.attributes.setInherited('toCsv', toCsv);
301
+ node.attributes.setInherited('toMd', toMd);
296
302
  var columnAlign = node.attributes.get('columnalign');
297
303
  var arrRowLines = node.attributes.isSet('rowlines') ? node.attributes.get('rowlines').split(' ') : [];
298
304
  var envName = node.attributes.get('name');
299
305
  /** Check if a table is enclosed in brackets */
300
- var isHasBranchOpen = node.parent && node.parent.kind === 'mrow' && ((_g = node.parent.properties) === null || _g === void 0 ? void 0 : _g.hasOwnProperty('open'));
301
- var isHasBranchClose = node.parent && node.parent.kind === 'mrow' && ((_h = node.parent.properties) === null || _h === void 0 ? void 0 : _h.hasOwnProperty('close'));
306
+ var isHasBranchOpen = node.parent && node.parent.kind === 'mrow' && ((_j = node.parent.properties) === null || _j === void 0 ? void 0 : _j.hasOwnProperty('open'));
307
+ var isHasBranchClose = node.parent && node.parent.kind === 'mrow' && ((_k = node.parent.properties) === null || _k === void 0 ? void 0 : _k.hasOwnProperty('close'));
302
308
  var thereAreBracketsIn_parent = (isHasBranchOpen && node.parent.properties['open'])
303
309
  || (isHasBranchClose && node.parent.properties['close']);
304
- var thereAreBracketsIn_Parent = parentIsMenclose && ((_j = node.Parent.Parent) === null || _j === void 0 ? void 0 : _j.isKind('mrow'))
305
- && ((((_k = node.Parent.Parent.properties) === null || _k === void 0 ? void 0 : _k.hasOwnProperty('open')) && node.Parent.Parent.properties['open'])
306
- || (((_l = node.Parent.Parent.properties) === null || _l === void 0 ? void 0 : _l.hasOwnProperty('close')) && node.Parent.Parent.properties['close']));
310
+ var thereAreBracketsIn_Parent = parentIsMenclose && ((_l = node.Parent.Parent) === null || _l === void 0 ? void 0 : _l.isKind('mrow'))
311
+ && ((((_m = node.Parent.Parent.properties) === null || _m === void 0 ? void 0 : _m.hasOwnProperty('open')) && node.Parent.Parent.properties['open'])
312
+ || (((_o = node.Parent.Parent.properties) === null || _o === void 0 ? void 0 : _o.hasOwnProperty('close')) && node.Parent.Parent.properties['close']));
307
313
  /** It is a matrix or system of equations with brackets */
308
314
  var isMatrixOrSystemOfEquations = thereAreBracketsIn_parent || thereAreBracketsIn_Parent;
309
315
  var itShouldBeFlatten = consts_1.envArraysShouldBeFlattenInTSV.includes(envName)
@@ -317,24 +323,27 @@ var mtable = function () {
317
323
  var mtrNode = node.childNodes[i];
318
324
  mtrNode.attributes.setInherited('toTsv', toTsv);
319
325
  mtrNode.attributes.setInherited('toCsv', toCsv);
326
+ mtrNode.attributes.setInherited('toMd', toMd);
320
327
  mtrNode.attributes.setInherited('itShouldBeFlatten', itShouldBeFlatten);
321
328
  var mmlRow = '';
322
329
  var mmlRow_tsv = '';
323
330
  var mmlRow_csv = '';
331
+ var mmlRow_md = '';
324
332
  var mmlRowVerticalMath = '';
325
333
  var mathOperation = '';
326
- var countColl = (_m = mtrNode.childNodes) === null || _m === void 0 ? void 0 : _m.length;
334
+ var countColl = (_p = mtrNode.childNodes) === null || _p === void 0 ? void 0 : _p.length;
327
335
  /** It's EqnArray or AmsEqnArray or AlignAt.
328
336
  * eqnarray*, align, align*, split, gather, gather*, aligned, gathered, alignat, alignat*, alignedat */
329
337
  var isEqnArrayRow = mtrNode.attributes.get('displaystyle');
330
338
  for (var j = 0; j < countColl; j++) {
331
339
  if (j > 0 && !isEqnArrayRow) {
332
340
  mmlRow += ',';
333
- mmlRow_tsv += toTsv ? ((_o = serialize.options.tsv_separators) === null || _o === void 0 ? void 0 : _o.column) || '\t' : itShouldBeFlatten ? ', ' : ',';
334
- mmlRow_csv += toCsv ? ((_p = serialize.options.csv_separators) === null || _p === void 0 ? void 0 : _p.column) || ',' : itShouldBeFlatten ? ', ' : ',';
341
+ mmlRow_tsv += toTsv ? ((_q = serialize.options.tsv_separators) === null || _q === void 0 ? void 0 : _q.column) || '\t' : itShouldBeFlatten ? ', ' : ',';
342
+ mmlRow_csv += toCsv ? ((_r = serialize.options.csv_separators) === null || _r === void 0 ? void 0 : _r.column) || ',' : itShouldBeFlatten ? ', ' : ',';
343
+ mmlRow_md += toMd ? ((_s = serialize.options.md_separators) === null || _s === void 0 ? void 0 : _s.column) || ' ' : itShouldBeFlatten ? ', ' : ',';
335
344
  }
336
345
  var mtdNode = mtrNode.childNodes[j];
337
- var _x = serialize.visitNode(mtdNode, ''), _y = _x.ascii, ascii = _y === void 0 ? '' : _y, _z = _x.ascii_tsv, ascii_tsv = _z === void 0 ? '' : _z, _0 = _x.ascii_csv, ascii_csv = _0 === void 0 ? '' : _0;
346
+ var _1 = serialize.visitNode(mtdNode, ''), _2 = _1.ascii, ascii = _2 === void 0 ? '' : _2, _3 = _1.ascii_tsv, ascii_tsv = _3 === void 0 ? '' : _3, _4 = _1.ascii_csv, ascii_csv = _4 === void 0 ? '' : _4, _5 = _1.ascii_md, ascii_md = _5 === void 0 ? '' : _5;
338
347
  var mmlCollVerticalMath = '';
339
348
  if (isVerticalMath) {
340
349
  var dataColl = getDataForVerticalMath(serialize, mtdNode, i);
@@ -350,6 +359,7 @@ var mtable = function () {
350
359
  mmlRow += ascii;
351
360
  mmlRow_tsv += !toTsv && itShouldBeFlatten ? ascii_tsv.trimEnd() : ascii_tsv;
352
361
  mmlRow_csv += !toCsv && itShouldBeFlatten ? ascii_csv.trimEnd() : ascii_csv;
362
+ mmlRow_md += !toMd && itShouldBeFlatten ? ascii_md.trimEnd() : ascii_md;
353
363
  mmlRowVerticalMath += mmlCollVerticalMath;
354
364
  }
355
365
  /** For vertical math, if the horizontal line is in front of the answer, then replace it with an equals sign */
@@ -358,16 +368,18 @@ var mtable = function () {
358
368
  }
359
369
  /** It's EqnArray or AmsEqnArray or AlignAt.
360
370
  * eqnarray*, align, align*, split, gather, gather*, aligned, gathered, alignat, alignat*, alignedat */
361
- var isEqnArray = (_q = mtrNode.attributes) === null || _q === void 0 ? void 0 : _q.get('displaystyle');
371
+ var isEqnArray = (_t = mtrNode.attributes) === null || _t === void 0 ? void 0 : _t.get('displaystyle');
362
372
  arrRows.push({
363
373
  mmlRow: mmlRow,
364
374
  mmlRow_tsv: mmlRow_tsv,
365
375
  mmlRow_csv: mmlRow_csv,
376
+ mmlRow_md: mmlRow_md,
366
377
  mmlRowVerticalMath: mmlRowVerticalMath,
367
378
  mathOperation: mathOperation,
368
379
  encloseToSquareBrackets: countRow > 1 || isSubExpression || (countColl > 1 && !isEqnArray),
369
380
  toTsv: toTsv,
370
381
  toCsv: toCsv,
382
+ toMd: toMd,
371
383
  itShouldBeFlatten: itShouldBeFlatten
372
384
  });
373
385
  }
@@ -392,19 +404,24 @@ var mtable = function () {
392
404
  var mmlTableContent = '';
393
405
  var mmlTableContent_tsv = '';
394
406
  var mmlTableContent_csv = '';
407
+ var mmlTableContent_md = '';
395
408
  for (var i = 0; i < arrRows.length; i++) {
396
409
  if (i > 0 && !isVerticalMath) {
397
410
  mmlTableContent += ',';
398
411
  mmlTableContent_tsv += toTsv
399
- ? ((_r = serialize.options.tsv_separators) === null || _r === void 0 ? void 0 : _r.row) || '\n'
412
+ ? ((_u = serialize.options.tsv_separators) === null || _u === void 0 ? void 0 : _u.row) || '\n'
400
413
  : itShouldBeFlatten ? ', ' : ',';
401
414
  mmlTableContent_csv += toCsv
402
- ? ((_s = serialize.options.csv_separators) === null || _s === void 0 ? void 0 : _s.row) || '\n'
415
+ ? ((_v = serialize.options.csv_separators) === null || _v === void 0 ? void 0 : _v.row) || '\n'
416
+ : itShouldBeFlatten ? ', ' : ',';
417
+ mmlTableContent_md += toMd
418
+ ? ((_w = serialize.options.md_separators) === null || _w === void 0 ? void 0 : _w.row) || ' <br> '
403
419
  : itShouldBeFlatten ? ', ' : ',';
404
420
  }
405
421
  var mmlRow = isVerticalMath ? arrRows[i].mmlRowVerticalMath : arrRows[i].mmlRow;
406
422
  var mmlRow_tsv = isVerticalMath ? arrRows[i].mmlRowVerticalMath : arrRows[i].mmlRow_tsv;
407
423
  var mmlRow_csv = isVerticalMath ? arrRows[i].mmlRowVerticalMath : arrRows[i].mmlRow_csv;
424
+ var mmlRow_md = isVerticalMath ? arrRows[i].mmlRowVerticalMath : arrRows[i].mmlRow_md;
408
425
  mmlTableContent += arrRows[i].encloseToSquareBrackets && !isVerticalMath
409
426
  ? '[' + mmlRow + ']'
410
427
  : mmlRow;
@@ -416,12 +433,16 @@ var mtable = function () {
416
433
  && !arrRows[i].itShouldBeFlatten && !arrRows[i].toCsv && !isVerticalMath
417
434
  ? '[' + mmlRow_csv + ']'
418
435
  : mmlRow_csv;
436
+ mmlTableContent_md += arrRows[i].encloseToSquareBrackets
437
+ && !arrRows[i].itShouldBeFlatten && !arrRows[i].toMd && !isVerticalMath
438
+ ? '[' + mmlRow_md + ']'
439
+ : mmlRow_md;
419
440
  }
420
441
  if (isVerticalMath) {
421
- if ((_t = node.Parent) === null || _t === void 0 ? void 0 : _t.isKind('mrow')) {
442
+ if ((_x = node.Parent) === null || _x === void 0 ? void 0 : _x.isKind('mrow')) {
422
443
  node.Parent.attributes.setInherited('isVerticalMath', true);
423
444
  }
424
- if (((_u = node.Parent) === null || _u === void 0 ? void 0 : _u.isKind('menclose')) && ((_w = (_v = node.Parent) === null || _v === void 0 ? void 0 : _v.Parent) === null || _w === void 0 ? void 0 : _w.isKind('mrow'))) {
445
+ if (((_y = node.Parent) === null || _y === void 0 ? void 0 : _y.isKind('menclose')) && ((_0 = (_z = node.Parent) === null || _z === void 0 ? void 0 : _z.Parent) === null || _0 === void 0 ? void 0 : _0.isKind('mrow'))) {
425
446
  node.Parent.Parent.attributes.setInherited('isVerticalMath', true);
426
447
  }
427
448
  }
@@ -451,6 +472,19 @@ var mtable = function () {
451
472
  mml_csv += isHasBranchClose || parentIsMenclose ? '' : ':}';
452
473
  }
453
474
  }
475
+ if (toMd) {
476
+ mml_md += mmlTableContent_md;
477
+ }
478
+ else {
479
+ if (itShouldBeFlatten || isVerticalMath) {
480
+ mml_md += mmlTableContent_md;
481
+ }
482
+ else {
483
+ mml_md += isHasBranchOpen || parentIsMenclose ? '' : '{:';
484
+ mml_md += mmlTableContent_md;
485
+ mml_md += isHasBranchClose || parentIsMenclose ? '' : ':}';
486
+ }
487
+ }
454
488
  if (isVerticalMath) {
455
489
  mml += mmlTableContent;
456
490
  }
@@ -463,6 +497,7 @@ var mtable = function () {
463
497
  ascii: mml,
464
498
  ascii_tsv: mml_tsv,
465
499
  ascii_csv: mml_csv,
500
+ ascii_md: mml_md,
466
501
  };
467
502
  }
468
503
  catch (e) {
@@ -471,6 +506,7 @@ var mtable = function () {
471
506
  ascii: mml,
472
507
  ascii_tsv: mml_tsv,
473
508
  ascii_csv: mml_csv,
509
+ ascii_md: mml_md,
474
510
  };
475
511
  }
476
512
  };
@@ -487,11 +523,13 @@ var mrow = function () {
487
523
  var mmlContent = '';
488
524
  var mmlContent_tsv = '';
489
525
  var mmlContent_csv = '';
526
+ var mmlContent_md = '';
490
527
  for (var i = 0; i < node.childNodes.length; i++) {
491
528
  var data = serialize.visitNode(node.childNodes[i], '');
492
529
  mmlContent += data.ascii;
493
530
  mmlContent_tsv += data.ascii_tsv;
494
531
  mmlContent_csv += data.ascii_csv;
532
+ mmlContent_md += data.ascii_md;
495
533
  }
496
534
  var isVerticalMath = node.attributes.get('isVerticalMath');
497
535
  var open_1 = isTexClass7 && needBranchOpen && !isVerticalMath ? '{:' : '';
@@ -500,6 +538,7 @@ var mrow = function () {
500
538
  ascii: open_1 + mmlContent + close_1,
501
539
  ascii_tsv: open_1 + mmlContent_tsv + close_1,
502
540
  ascii_csv: open_1 + mmlContent_csv + close_1,
541
+ ascii_md: open_1 + mmlContent_md + close_1,
503
542
  };
504
543
  }
505
544
  catch (e) {
@@ -508,17 +547,19 @@ var mrow = function () {
508
547
  ascii: '',
509
548
  ascii_tsv: '',
510
549
  ascii_csv: '',
550
+ ascii_md: '',
511
551
  };
512
552
  }
513
553
  };
514
554
  };
515
555
  var mtr = function () {
516
556
  return function (node, serialize) {
517
- var _a, _b;
557
+ var _a, _b, _c;
518
558
  var res = {
519
559
  ascii: '',
520
560
  ascii_tsv: '',
521
561
  ascii_csv: '',
562
+ ascii_md: '',
522
563
  };
523
564
  try {
524
565
  /** It's EqnArray or AmsEqnArray or AlignAt.
@@ -526,20 +567,23 @@ var mtr = function () {
526
567
  var isEqnArray = node.attributes.get('displaystyle');
527
568
  var toTsv = node.attributes.get('toTsv');
528
569
  var toCsv = node.attributes.get('toCsv');
570
+ var toMd = node.attributes.get('toMd');
529
571
  var itShouldBeFlatten = node.attributes.get('itShouldBeFlatten');
530
572
  for (var i = 0; i < node.childNodes.length; i++) {
531
573
  if (i > 0 && !isEqnArray) {
532
574
  res = common_1.AddToAsciiData(res, [
533
575
  ',',
534
576
  toTsv ? ((_a = serialize.options.tsv_separators) === null || _a === void 0 ? void 0 : _a.column) || '\t' : itShouldBeFlatten ? ', ' : ',',
535
- toCsv ? ((_b = serialize.options.csv_separators) === null || _b === void 0 ? void 0 : _b.column) || ',' : itShouldBeFlatten ? ', ' : ','
577
+ toCsv ? ((_b = serialize.options.csv_separators) === null || _b === void 0 ? void 0 : _b.column) || ',' : itShouldBeFlatten ? ', ' : ',',
578
+ toMd ? ((_c = serialize.options.md_separators) === null || _c === void 0 ? void 0 : _c.column) || ' ' : itShouldBeFlatten ? ', ' : ',',
536
579
  ]);
537
580
  }
538
- var _c = serialize.visitNode(node.childNodes[i], ''), _d = _c.ascii, ascii = _d === void 0 ? '' : _d, _e = _c.ascii_tsv, ascii_tsv = _e === void 0 ? '' : _e, _f = _c.ascii_csv, ascii_csv = _f === void 0 ? '' : _f;
581
+ var _d = serialize.visitNode(node.childNodes[i], ''), _e = _d.ascii, ascii = _e === void 0 ? '' : _e, _f = _d.ascii_tsv, ascii_tsv = _f === void 0 ? '' : _f, _g = _d.ascii_csv, ascii_csv = _g === void 0 ? '' : _g, _h = _d.ascii_md, ascii_md = _h === void 0 ? '' : _h;
539
582
  res = common_1.AddToAsciiData(res, [
540
583
  ascii,
541
584
  !toTsv && itShouldBeFlatten ? ascii_tsv === null || ascii_tsv === void 0 ? void 0 : ascii_tsv.trimEnd() : ascii_tsv,
542
- !toCsv && itShouldBeFlatten ? ascii_csv === null || ascii_csv === void 0 ? void 0 : ascii_csv.trimEnd() : ascii_csv
585
+ !toCsv && itShouldBeFlatten ? ascii_csv === null || ascii_csv === void 0 ? void 0 : ascii_csv.trimEnd() : ascii_csv,
586
+ !toMd && itShouldBeFlatten ? ascii_md === null || ascii_md === void 0 ? void 0 : ascii_md.trimEnd() : ascii_md,
543
587
  ]);
544
588
  }
545
589
  return res;
@@ -555,7 +599,8 @@ var mpadded = function (handlerApi) {
555
599
  var res = {
556
600
  ascii: '',
557
601
  ascii_tsv: '',
558
- ascii_csv: ''
602
+ ascii_csv: '',
603
+ ascii_md: ''
559
604
  };
560
605
  try {
561
606
  var mmlAdd = handlerApi.handleAll(node, serialize);
@@ -573,12 +618,14 @@ var mpadded = function (handlerApi) {
573
618
  res = common_1.AddToAsciiData(res, [
574
619
  '"',
575
620
  serialize.options.tableToTsv ? '' : '"',
621
+ '',
576
622
  ''
577
623
  ]);
578
- res = common_1.AddToAsciiData(res, [mmlAdd.ascii, mmlAdd.ascii_tsv, mmlAdd.ascii_csv]);
624
+ res = common_1.AddToAsciiData(res, [mmlAdd.ascii, mmlAdd.ascii_tsv, mmlAdd.ascii_csv, mmlAdd.ascii_md]);
579
625
  res = common_1.AddToAsciiData(res, [
580
626
  '"',
581
627
  serialize.options.tableToTsv ? '' : '"',
628
+ '',
582
629
  ''
583
630
  ]);
584
631
  return res;
@@ -594,7 +641,8 @@ var mover = function (handlerApi) {
594
641
  var res = {
595
642
  ascii: '',
596
643
  ascii_tsv: '',
597
- ascii_csv: ''
644
+ ascii_csv: '',
645
+ ascii_md: ''
598
646
  };
599
647
  try {
600
648
  var firstChild = node.childNodes[0] ? node.childNodes[0] : '';
@@ -610,6 +658,7 @@ var mover = function (handlerApi) {
610
658
  dataFirstChild ? dataFirstChild.ascii ? dataFirstChild.ascii.trim() : dataFirstChild.ascii : '',
611
659
  dataFirstChild ? dataFirstChild.ascii_tsv ? dataFirstChild.ascii_tsv.trim() : dataFirstChild.ascii_tsv : '',
612
660
  dataFirstChild ? dataFirstChild.ascii_csv ? dataFirstChild.ascii_csv.trim() : dataFirstChild.ascii_csv : '',
661
+ dataFirstChild ? dataFirstChild.ascii_md ? dataFirstChild.ascii_md.trim() : dataFirstChild.ascii_md : '',
613
662
  ]);
614
663
  res = common_1.AddToAsciiData(res, [')']);
615
664
  }
@@ -617,21 +666,23 @@ var mover = function (handlerApi) {
617
666
  res = common_1.AddToAsciiData(res, [
618
667
  dataFirstChild ? dataFirstChild.ascii : '',
619
668
  dataFirstChild ? dataFirstChild.ascii_tsv : '',
620
- dataFirstChild ? dataFirstChild.ascii_csv : ''
669
+ dataFirstChild ? dataFirstChild.ascii_csv : '',
670
+ dataFirstChild ? dataFirstChild.ascii_md : ''
621
671
  ]);
622
672
  res = common_1.AddToAsciiData(res, ['^']);
623
673
  res = common_1.AddToAsciiData(res, [serialize.options.extraBrackets ? '(' : '']);
624
674
  res = common_1.AddToAsciiData(res, [
625
675
  dataSecondChild ? dataSecondChild.ascii : '',
626
676
  dataSecondChild ? dataSecondChild.ascii_tsv : '',
627
- dataSecondChild ? dataSecondChild.ascii_csv : ''
677
+ dataSecondChild ? dataSecondChild.ascii_csv : '',
678
+ dataSecondChild ? dataSecondChild.ascii_md : ''
628
679
  ]);
629
680
  res = common_1.AddToAsciiData(res, [serialize.options.extraBrackets ? ')' : '']);
630
681
  }
631
682
  }
632
683
  else {
633
684
  var data = handlerApi.handleAll(node, serialize);
634
- res = common_1.AddToAsciiData(res, [data.ascii, data.ascii_tsv, data.ascii_csv]);
685
+ res = common_1.AddToAsciiData(res, [data.ascii, data.ascii_tsv, data.ascii_csv, data.ascii_md]);
635
686
  }
636
687
  return res;
637
688
  }
@@ -646,7 +697,8 @@ var munder = function (handlerApi) {
646
697
  var res = {
647
698
  ascii: '',
648
699
  ascii_tsv: '',
649
- ascii_csv: ''
700
+ ascii_csv: '',
701
+ ascii_md: ''
650
702
  };
651
703
  try {
652
704
  var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
@@ -661,27 +713,30 @@ var munder = function (handlerApi) {
661
713
  res = common_1.AddToAsciiData(res, [
662
714
  dataFirstChild ? dataFirstChild.ascii : '',
663
715
  dataFirstChild ? dataFirstChild.ascii_tsv : '',
664
- dataFirstChild ? dataFirstChild.ascii_csv : ''
716
+ dataFirstChild ? dataFirstChild.ascii_csv : '',
717
+ dataFirstChild ? dataFirstChild.ascii_md : ''
665
718
  ]);
666
719
  res = common_1.AddToAsciiData(res, [asc + ')']);
667
720
  }
668
721
  else {
669
722
  var data = handlerApi.handleAll(node, serialize);
670
- res = common_1.AddToAsciiData(res, [data.ascii, data.ascii_tsv, data.ascii_csv]);
723
+ res = common_1.AddToAsciiData(res, [data.ascii, data.ascii_tsv, data.ascii_csv, data.ascii_md]);
671
724
  }
672
725
  }
673
726
  else {
674
727
  res = common_1.AddToAsciiData(res, [
675
728
  dataFirstChild ? dataFirstChild.ascii : '',
676
729
  dataFirstChild ? dataFirstChild.ascii_tsv : '',
677
- dataFirstChild ? dataFirstChild.ascii_csv : ''
730
+ dataFirstChild ? dataFirstChild.ascii_csv : '',
731
+ dataFirstChild ? dataFirstChild.ascii_md : ''
678
732
  ]);
679
733
  res = common_1.AddToAsciiData(res, ['_']);
680
734
  res = common_1.AddToAsciiData(res, [serialize.options.extraBrackets ? '(' : '']);
681
735
  res = common_1.AddToAsciiData(res, [
682
736
  dataSecondChild ? dataSecondChild.ascii : '',
683
737
  dataSecondChild ? dataSecondChild.ascii_tsv : '',
684
- dataSecondChild ? dataSecondChild.ascii_csv : ''
738
+ dataSecondChild ? dataSecondChild.ascii_csv : '',
739
+ dataSecondChild ? dataSecondChild.ascii_md : ''
685
740
  ]);
686
741
  res = common_1.AddToAsciiData(res, [serialize.options.extraBrackets ? ')' : '']);
687
742
  }
@@ -698,7 +753,8 @@ var munderover = function () {
698
753
  var res = {
699
754
  ascii: '',
700
755
  ascii_tsv: '',
701
- ascii_csv: ''
756
+ ascii_csv: '',
757
+ ascii_md: ''
702
758
  };
703
759
  try {
704
760
  var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
@@ -711,6 +767,7 @@ var munderover = function () {
711
767
  dataFirstChild.ascii ? dataFirstChild.ascii : '',
712
768
  dataFirstChild.ascii_tsv ? dataFirstChild.ascii_tsv : '',
713
769
  dataFirstChild.ascii_csv ? dataFirstChild.ascii_csv : '',
770
+ dataFirstChild.ascii_md ? dataFirstChild.ascii_md : ''
714
771
  ]);
715
772
  res = common_1.AddToAsciiData(res, ['_']);
716
773
  res = common_1.AddToAsciiData(res, [serialize.options.extraBrackets ? '(' : '']);
@@ -718,6 +775,7 @@ var munderover = function () {
718
775
  dataSecondChild.ascii ? dataSecondChild.ascii : '',
719
776
  dataSecondChild.ascii_tsv ? dataSecondChild.ascii_tsv : '',
720
777
  dataSecondChild.ascii_csv ? dataSecondChild.ascii_csv : '',
778
+ dataSecondChild.ascii_md ? dataSecondChild.ascii_md : ''
721
779
  ]);
722
780
  res = common_1.AddToAsciiData(res, [serialize.options.extraBrackets ? ')' : '']);
723
781
  res = common_1.AddToAsciiData(res, ['^']);
@@ -726,6 +784,7 @@ var munderover = function () {
726
784
  dataThirdChild.ascii ? dataThirdChild.ascii : '',
727
785
  dataThirdChild.ascii_tsv ? dataThirdChild.ascii_tsv : '',
728
786
  dataThirdChild.ascii_csv ? dataThirdChild.ascii_csv : '',
787
+ dataThirdChild.ascii_md ? dataThirdChild.ascii_md : ''
729
788
  ]);
730
789
  res = common_1.AddToAsciiData(res, [serialize.options.extraBrackets ? ')' : '']);
731
790
  return res;
@@ -741,7 +800,8 @@ var msub = function () {
741
800
  var res = {
742
801
  ascii: '',
743
802
  ascii_tsv: '',
744
- ascii_csv: ''
803
+ ascii_csv: '',
804
+ ascii_md: ''
745
805
  };
746
806
  try {
747
807
  var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
@@ -751,14 +811,16 @@ var msub = function () {
751
811
  res = common_1.AddToAsciiData(res, [
752
812
  dataFirstChild ? dataFirstChild.ascii : '',
753
813
  dataFirstChild ? dataFirstChild.ascii_tsv : '',
754
- dataFirstChild ? dataFirstChild.ascii_csv : ''
814
+ dataFirstChild ? dataFirstChild.ascii_csv : '',
815
+ dataFirstChild ? dataFirstChild.ascii_md : ''
755
816
  ]);
756
817
  res = common_1.AddToAsciiData(res, ['_']);
757
818
  res = common_1.AddToAsciiData(res, [serialize.options.extraBrackets ? '(' : '']);
758
819
  res = common_1.AddToAsciiData(res, [
759
820
  dataSecondChild ? dataSecondChild.ascii : '',
760
821
  dataSecondChild ? dataSecondChild.ascii_tsv : '',
761
- dataSecondChild ? dataSecondChild.ascii_csv : ''
822
+ dataSecondChild ? dataSecondChild.ascii_csv : '',
823
+ dataSecondChild ? dataSecondChild.ascii_md : ''
762
824
  ]);
763
825
  res = common_1.AddToAsciiData(res, [serialize.options.extraBrackets ? ')' : '']);
764
826
  return res;
@@ -775,6 +837,7 @@ var msup = function () {
775
837
  ascii: '',
776
838
  ascii_tsv: '',
777
839
  ascii_csv: '',
840
+ ascii_md: ''
778
841
  };
779
842
  try {
780
843
  var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
@@ -785,6 +848,7 @@ var msup = function () {
785
848
  dataFirstChild ? dataFirstChild.ascii : '',
786
849
  dataFirstChild ? dataFirstChild.ascii_tsv : '',
787
850
  dataFirstChild ? dataFirstChild.ascii_csv : '',
851
+ dataFirstChild ? dataFirstChild.ascii_md : ''
788
852
  ]);
789
853
  res = common_1.AddToAsciiData(res, ['^']);
790
854
  res = common_1.AddToAsciiData(res, [serialize.options.extraBrackets ? '(' : '']);
@@ -792,6 +856,7 @@ var msup = function () {
792
856
  dataSecondChild ? dataSecondChild.ascii : '',
793
857
  dataSecondChild ? dataSecondChild.ascii_tsv : '',
794
858
  dataSecondChild ? dataSecondChild.ascii_csv : '',
859
+ dataSecondChild ? dataSecondChild.ascii_md : ''
795
860
  ]);
796
861
  res = common_1.AddToAsciiData(res, [serialize.options.extraBrackets ? ')' : '']);
797
862
  return res;
@@ -807,7 +872,8 @@ var msubsup = function () {
807
872
  var res = {
808
873
  ascii: '',
809
874
  ascii_tsv: '',
810
- ascii_csv: ''
875
+ ascii_csv: '',
876
+ ascii_md: ''
811
877
  };
812
878
  try {
813
879
  var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
@@ -820,6 +886,7 @@ var msubsup = function () {
820
886
  dataFirstChild ? dataFirstChild.ascii : '',
821
887
  dataFirstChild ? dataFirstChild.ascii_tsv : '',
822
888
  dataFirstChild ? dataFirstChild.ascii_csv : '',
889
+ dataFirstChild ? dataFirstChild.ascii_md : ''
823
890
  ]);
824
891
  res = common_1.AddToAsciiData(res, ['_']);
825
892
  res = common_1.AddToAsciiData(res, ['(']);
@@ -827,6 +894,7 @@ var msubsup = function () {
827
894
  dataSecondChild ? dataSecondChild.ascii : '',
828
895
  dataSecondChild ? dataSecondChild.ascii_tsv : '',
829
896
  dataSecondChild ? dataSecondChild.ascii_csv : '',
897
+ dataSecondChild ? dataSecondChild.ascii_md : ''
830
898
  ]);
831
899
  res = common_1.AddToAsciiData(res, [')']);
832
900
  res = common_1.AddToAsciiData(res, ['^']);
@@ -835,6 +903,7 @@ var msubsup = function () {
835
903
  dataThirdChild ? dataThirdChild.ascii : '',
836
904
  dataThirdChild ? dataThirdChild.ascii_tsv : '',
837
905
  dataThirdChild ? dataThirdChild.ascii_csv : '',
906
+ dataThirdChild ? dataThirdChild.ascii_md : ''
838
907
  ]);
839
908
  res = common_1.AddToAsciiData(res, [')']);
840
909
  return res;
@@ -851,6 +920,7 @@ var msqrt = function () {
851
920
  ascii: '',
852
921
  ascii_tsv: '',
853
922
  ascii_csv: '',
923
+ ascii_md: ''
854
924
  };
855
925
  try {
856
926
  var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
@@ -859,7 +929,8 @@ var msqrt = function () {
859
929
  res = common_1.AddToAsciiData(res, [
860
930
  dataFirstChild ? dataFirstChild.ascii : '',
861
931
  dataFirstChild ? dataFirstChild.ascii_tsv : '',
862
- dataFirstChild ? dataFirstChild.ascii_csv : ''
932
+ dataFirstChild ? dataFirstChild.ascii_csv : '',
933
+ dataFirstChild ? dataFirstChild.ascii_md : ''
863
934
  ]);
864
935
  return res;
865
936
  }
@@ -875,6 +946,7 @@ var mroot = function () {
875
946
  ascii: '',
876
947
  ascii_tsv: '',
877
948
  ascii_csv: '',
949
+ ascii_md: ''
878
950
  };
879
951
  try {
880
952
  var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
@@ -886,14 +958,16 @@ var mroot = function () {
886
958
  res = common_1.AddToAsciiData(res, [
887
959
  dataSecondChild ? dataSecondChild.ascii : '',
888
960
  dataSecondChild ? dataSecondChild.ascii_tsv : '',
889
- dataSecondChild ? dataSecondChild.ascii_csv : ''
961
+ dataSecondChild ? dataSecondChild.ascii_csv : '',
962
+ dataSecondChild ? dataSecondChild.ascii_md : ''
890
963
  ]);
891
964
  res = common_1.AddToAsciiData(res, [secondChild ? ')' : '']);
892
965
  res = common_1.AddToAsciiData(res, [firstChild ? '(' : '']);
893
966
  res = common_1.AddToAsciiData(res, [
894
967
  dataFirstChild ? dataFirstChild.ascii : '',
895
968
  dataFirstChild ? dataFirstChild.ascii_tsv : '',
896
- dataFirstChild ? dataFirstChild.ascii_csv : ''
969
+ dataFirstChild ? dataFirstChild.ascii_csv : '',
970
+ dataFirstChild ? dataFirstChild.ascii_md : ''
897
971
  ]);
898
972
  res = common_1.AddToAsciiData(res, [firstChild ? ')' : '']);
899
973
  return res;
@@ -910,6 +984,7 @@ var mfrac = function () {
910
984
  ascii: '',
911
985
  ascii_tsv: '',
912
986
  ascii_csv: '',
987
+ ascii_md: ''
913
988
  };
914
989
  try {
915
990
  var firstChild = node.childNodes[0] ? node.childNodes[0] : null;
@@ -922,6 +997,7 @@ var mfrac = function () {
922
997
  dataFirstChild ? dataFirstChild.ascii : '',
923
998
  dataFirstChild ? dataFirstChild.ascii_tsv : '',
924
999
  dataFirstChild ? dataFirstChild.ascii_csv : '',
1000
+ dataFirstChild ? dataFirstChild.ascii_md : ''
925
1001
  ]);
926
1002
  res = common_1.AddToAsciiData(res, [')']);
927
1003
  }
@@ -930,6 +1006,7 @@ var mfrac = function () {
930
1006
  dataFirstChild ? dataFirstChild.ascii : '',
931
1007
  dataFirstChild ? dataFirstChild.ascii_tsv : '',
932
1008
  dataFirstChild ? dataFirstChild.ascii_csv : '',
1009
+ dataFirstChild ? dataFirstChild.ascii_md : ''
933
1010
  ]);
934
1011
  }
935
1012
  res = common_1.AddToAsciiData(res, ['/']);
@@ -939,6 +1016,7 @@ var mfrac = function () {
939
1016
  dataSecondChild ? dataSecondChild.ascii : '',
940
1017
  dataSecondChild ? dataSecondChild.ascii_tsv : '',
941
1018
  dataSecondChild ? dataSecondChild.ascii_csv : '',
1019
+ dataSecondChild ? dataSecondChild.ascii_md : ''
942
1020
  ]);
943
1021
  res = common_1.AddToAsciiData(res, [')']);
944
1022
  }
@@ -947,6 +1025,7 @@ var mfrac = function () {
947
1025
  dataSecondChild ? dataSecondChild.ascii : '',
948
1026
  dataSecondChild ? dataSecondChild.ascii_tsv : '',
949
1027
  dataSecondChild ? dataSecondChild.ascii_csv : '',
1028
+ dataSecondChild ? dataSecondChild.ascii_md : ''
950
1029
  ]);
951
1030
  }
952
1031
  return res;
@@ -962,7 +1041,8 @@ var mtext = function () {
962
1041
  var res = {
963
1042
  ascii: '',
964
1043
  ascii_tsv: '',
965
- ascii_csv: ''
1044
+ ascii_csv: '',
1045
+ ascii_md: ''
966
1046
  };
967
1047
  try {
968
1048
  if (!node.childNodes || node.childNodes.length === 0) {
@@ -977,11 +1057,13 @@ var mtext = function () {
977
1057
  }
978
1058
  var toTsv = node.attributes.get('toTsv');
979
1059
  var toCsv = node.attributes.get('toCsv');
980
- if (value[0] === '(' || toTsv || toCsv) {
1060
+ var toMd = node.attributes.get('toMd');
1061
+ if (value[0] === '(' || toTsv || toCsv || toMd) {
981
1062
  res = common_1.AddToAsciiData(res, [
982
1063
  value[0] === '(' ? value.replace(/"/g, '') : value,
983
1064
  toTsv ? value.replace(/"/g, '') : value,
984
1065
  toCsv ? value.replace(/"/g, '') : value,
1066
+ value
985
1067
  ]);
986
1068
  }
987
1069
  else {
@@ -998,7 +1080,8 @@ var mtext = function () {
998
1080
  : '"' + value + '"',
999
1081
  serialize.options.tableToCsv
1000
1082
  ? value.replace(/"/g, '')
1001
- : value
1083
+ : value,
1084
+ value
1002
1085
  ]);
1003
1086
  }
1004
1087
  }
@@ -1015,7 +1098,8 @@ var mi = function () {
1015
1098
  var res = {
1016
1099
  ascii: '',
1017
1100
  ascii_tsv: '',
1018
- ascii_csv: ''
1101
+ ascii_csv: '',
1102
+ ascii_md: ''
1019
1103
  };
1020
1104
  try {
1021
1105
  if (!node.childNodes || node.childNodes.length === 0) {
@@ -1048,7 +1132,8 @@ var mo = function () {
1048
1132
  var res = {
1049
1133
  ascii: '',
1050
1134
  ascii_tsv: '',
1051
- ascii_csv: ''
1135
+ ascii_csv: '',
1136
+ ascii_md: ''
1052
1137
  };
1053
1138
  try {
1054
1139
  var value = getChildrenText(node);
@@ -1070,6 +1155,7 @@ var mo = function () {
1070
1155
  '"' + abs + '"',
1071
1156
  "" + (serialize.options.tableToTsv ? abs : '"' + abs + '"'),
1072
1157
  abs,
1158
+ abs
1073
1159
  ]);
1074
1160
  }
1075
1161
  else {
@@ -1077,6 +1163,7 @@ var mo = function () {
1077
1163
  abs,
1078
1164
  abs === '"' ? '' : abs,
1079
1165
  abs === '"' ? '' : abs,
1166
+ abs
1080
1167
  ]);
1081
1168
  }
1082
1169
  }
@@ -1088,6 +1175,7 @@ var mo = function () {
1088
1175
  ascii: '',
1089
1176
  ascii_tsv: '',
1090
1177
  ascii_csv: '',
1178
+ ascii_md: ''
1091
1179
  };
1092
1180
  }
1093
1181
  }
@@ -1105,6 +1193,7 @@ var mspace = function (handlerApi) {
1105
1193
  ascii: '',
1106
1194
  ascii_tsv: '',
1107
1195
  ascii_csv: '',
1196
+ ascii_md: ''
1108
1197
  };
1109
1198
  try {
1110
1199
  var atr = exports.getAttributes(node);
@@ -1121,7 +1210,7 @@ var mspace = function (handlerApi) {
1121
1210
  return res;
1122
1211
  }
1123
1212
  var data = handlerApi.handleAll(node, serialize);
1124
- res = common_1.AddToAsciiData(res, [data.ascii, data.ascii_tsv, data.ascii_csv]);
1213
+ res = common_1.AddToAsciiData(res, [data.ascii, data.ascii_tsv, data.ascii_csv, data.ascii_md]);
1125
1214
  return res;
1126
1215
  }
1127
1216
  catch (e) {
@@ -1140,13 +1229,14 @@ var handleAll = function (node, serialize) {
1140
1229
  ascii: '',
1141
1230
  ascii_tsv: '',
1142
1231
  ascii_csv: '',
1232
+ ascii_md: ''
1143
1233
  };
1144
1234
  try {
1145
1235
  try {
1146
1236
  for (var _b = tslib_1.__values(node.childNodes), _c = _b.next(); !_c.done; _c = _b.next()) {
1147
1237
  var child = _c.value;
1148
1238
  var data = serialize.visitNode(child, '');
1149
- res = common_1.AddToAsciiData(res, [data.ascii, data.ascii_tsv, data.ascii_csv]);
1239
+ res = common_1.AddToAsciiData(res, [data.ascii, data.ascii_tsv, data.ascii_csv, data.ascii_md]);
1150
1240
  }
1151
1241
  }
1152
1242
  catch (e_2_1) { e_2 = { error: e_2_1 }; }