katex 0.16.9 → 0.16.10
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/README.md +3 -3
- package/contrib/copy-tex/README.md +2 -2
- package/contrib/mathtex-script-type/README.md +5 -5
- package/contrib/mhchem/README.md +1 -1
- package/dist/README.md +3 -3
- package/dist/contrib/auto-render.js +39 -47
- package/dist/contrib/auto-render.min.js +1 -1
- package/dist/contrib/copy-tex.js +24 -27
- package/dist/contrib/copy-tex.min.js +1 -1
- package/dist/contrib/mathtex-script-type.js +3 -3
- package/dist/contrib/mathtex-script-type.min.js +1 -1
- package/dist/contrib/mhchem.js +116 -116
- package/dist/contrib/render-a11y-string.js +52 -43
- package/dist/contrib/render-a11y-string.min.js +1 -1
- package/dist/katex.css +1 -1
- package/dist/katex.js +3398 -3231
- package/dist/katex.min.css +1 -1
- package/dist/katex.min.js +1 -1
- package/dist/katex.mjs +61 -21
- package/package.json +2 -2
- package/src/MacroExpander.js +16 -5
- package/src/Parser.js +4 -3
- package/src/Settings.js +5 -1
- package/src/domTree.js +6 -5
- package/src/symbols.js +1 -1
- package/src/utils.js +23 -4
package/dist/contrib/mhchem.js
CHANGED
|
@@ -151,7 +151,7 @@ katex__WEBPACK_IMPORTED_MODULE_0___default().__defineMacro("\\tripledash", "{\\v
|
|
|
151
151
|
// It takes the argument to \ce or \pu and returns the corresponding TeX string.
|
|
152
152
|
//
|
|
153
153
|
|
|
154
|
-
var chemParse = function
|
|
154
|
+
var chemParse = function (tokens, stateMachine) {
|
|
155
155
|
// Recreate the argument string from KaTeX's array of tokens.
|
|
156
156
|
var str = "";
|
|
157
157
|
var expectedLoc = tokens.length && tokens[tokens.length - 1].loc.start;
|
|
@@ -183,7 +183,7 @@ var mhchemParser = {
|
|
|
183
183
|
// Call like
|
|
184
184
|
// go("H2O");
|
|
185
185
|
//
|
|
186
|
-
go: function
|
|
186
|
+
go: function (input, stateMachine) {
|
|
187
187
|
if (!input) {
|
|
188
188
|
return [];
|
|
189
189
|
}
|
|
@@ -315,7 +315,7 @@ var mhchemParser = {
|
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
},
|
|
318
|
-
concatArray: function
|
|
318
|
+
concatArray: function (a, b) {
|
|
319
319
|
if (b) {
|
|
320
320
|
if (Array.isArray(b)) {
|
|
321
321
|
for (var iB = 0; iB < b.length; iB++) {
|
|
@@ -351,7 +351,7 @@ var mhchemParser = {
|
|
|
351
351
|
'digits': /^[0-9]+/,
|
|
352
352
|
'-9.,9': /^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,
|
|
353
353
|
'-9.,9 no missing 0': /^[+\-]?[0-9]+(?:[.,][0-9]+)?/,
|
|
354
|
-
'(-)(9.,9)(e)(99)': function
|
|
354
|
+
'(-)(9.,9)(e)(99)': function (input) {
|
|
355
355
|
var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:([eE]|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);
|
|
356
356
|
|
|
357
357
|
if (m && m[0]) {
|
|
@@ -363,7 +363,7 @@ var mhchemParser = {
|
|
|
363
363
|
|
|
364
364
|
return null;
|
|
365
365
|
},
|
|
366
|
-
'(-)(9)^(-9)': function
|
|
366
|
+
'(-)(9)^(-9)': function (input) {
|
|
367
367
|
var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/);
|
|
368
368
|
|
|
369
369
|
if (m && m[0]) {
|
|
@@ -375,7 +375,7 @@ var mhchemParser = {
|
|
|
375
375
|
|
|
376
376
|
return null;
|
|
377
377
|
},
|
|
378
|
-
'state of aggregation $': function
|
|
378
|
+
'state of aggregation $': function (input) {
|
|
379
379
|
// ... or crystal system
|
|
380
380
|
var a = mhchemParser.patterns.findObserveGroups(input, "", /^\([a-z]{1,3}(?=[\),])/, ")", ""); // (aq), (aq,$\infty$), (aq, sat)
|
|
381
381
|
|
|
@@ -404,51 +404,51 @@ var mhchemParser = {
|
|
|
404
404
|
'. ': /^([.\u22C5\u00B7\u2022])\s*/,
|
|
405
405
|
'...': /^\.\.\.(?=$|[^.])/,
|
|
406
406
|
'* ': /^([*])\s*/,
|
|
407
|
-
'^{(...)}': function
|
|
407
|
+
'^{(...)}': function (input) {
|
|
408
408
|
return mhchemParser.patterns.findObserveGroups(input, "^{", "", "", "}");
|
|
409
409
|
},
|
|
410
|
-
'^($...$)': function
|
|
410
|
+
'^($...$)': function (input) {
|
|
411
411
|
return mhchemParser.patterns.findObserveGroups(input, "^", "$", "$", "");
|
|
412
412
|
},
|
|
413
413
|
'^a': /^\^([0-9]+|[^\\_])/,
|
|
414
|
-
'^\\x{}{}': function
|
|
414
|
+
'^\\x{}{}': function (input) {
|
|
415
415
|
return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true);
|
|
416
416
|
},
|
|
417
|
-
'^\\x{}': function
|
|
417
|
+
'^\\x{}': function (input) {
|
|
418
418
|
return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", "");
|
|
419
419
|
},
|
|
420
420
|
'^\\x': /^\^(\\[a-zA-Z]+)\s*/,
|
|
421
421
|
'^(-1)': /^\^(-?\d+)/,
|
|
422
422
|
'\'': /^'/,
|
|
423
|
-
'_{(...)}': function
|
|
423
|
+
'_{(...)}': function (input) {
|
|
424
424
|
return mhchemParser.patterns.findObserveGroups(input, "_{", "", "", "}");
|
|
425
425
|
},
|
|
426
|
-
'_($...$)': function
|
|
426
|
+
'_($...$)': function (input) {
|
|
427
427
|
return mhchemParser.patterns.findObserveGroups(input, "_", "$", "$", "");
|
|
428
428
|
},
|
|
429
429
|
'_9': /^_([+\-]?[0-9]+|[^\\])/,
|
|
430
|
-
'_\\x{}{}': function
|
|
430
|
+
'_\\x{}{}': function (input) {
|
|
431
431
|
return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true);
|
|
432
432
|
},
|
|
433
|
-
'_\\x{}': function
|
|
433
|
+
'_\\x{}': function (input) {
|
|
434
434
|
return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", "");
|
|
435
435
|
},
|
|
436
436
|
'_\\x': /^_(\\[a-zA-Z]+)\s*/,
|
|
437
437
|
'^_': /^(?:\^(?=_)|\_(?=\^)|[\^_]$)/,
|
|
438
438
|
'{}': /^\{\}/,
|
|
439
|
-
'{...}': function
|
|
439
|
+
'{...}': function (input) {
|
|
440
440
|
return mhchemParser.patterns.findObserveGroups(input, "", "{", "}", "");
|
|
441
441
|
},
|
|
442
|
-
'{(...)}': function
|
|
442
|
+
'{(...)}': function (input) {
|
|
443
443
|
return mhchemParser.patterns.findObserveGroups(input, "{", "", "", "}");
|
|
444
444
|
},
|
|
445
|
-
'$...$': function
|
|
445
|
+
'$...$': function (input) {
|
|
446
446
|
return mhchemParser.patterns.findObserveGroups(input, "", "$", "$", "");
|
|
447
447
|
},
|
|
448
|
-
'${(...)}$': function
|
|
448
|
+
'${(...)}$': function (input) {
|
|
449
449
|
return mhchemParser.patterns.findObserveGroups(input, "${", "", "", "}$");
|
|
450
450
|
},
|
|
451
|
-
'$(...)$': function
|
|
451
|
+
'$(...)$': function (input) {
|
|
452
452
|
return mhchemParser.patterns.findObserveGroups(input, "$", "", "", "$");
|
|
453
453
|
},
|
|
454
454
|
'=<>': /^[=<>]/,
|
|
@@ -462,21 +462,21 @@ var mhchemParser = {
|
|
|
462
462
|
'pm-operator': /^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,
|
|
463
463
|
'operator': /^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,
|
|
464
464
|
'arrowUpDown': /^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,
|
|
465
|
-
'\\bond{(...)}': function
|
|
465
|
+
'\\bond{(...)}': function (input) {
|
|
466
466
|
return mhchemParser.patterns.findObserveGroups(input, "\\bond{", "", "", "}");
|
|
467
467
|
},
|
|
468
468
|
'->': /^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,
|
|
469
469
|
'CMT': /^[CMT](?=\[)/,
|
|
470
|
-
'[(...)]': function
|
|
470
|
+
'[(...)]': function (input) {
|
|
471
471
|
return mhchemParser.patterns.findObserveGroups(input, "[", "", "", "]");
|
|
472
472
|
},
|
|
473
473
|
'1st-level escape': /^(&|\\\\|\\hline)\s*/,
|
|
474
474
|
'\\,': /^(?:\\[,\ ;:])/,
|
|
475
475
|
// \\x - but output no space before
|
|
476
|
-
'\\x{}{}': function
|
|
476
|
+
'\\x{}{}': function (input) {
|
|
477
477
|
return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true);
|
|
478
478
|
},
|
|
479
|
-
'\\x{}': function
|
|
479
|
+
'\\x{}': function (input) {
|
|
480
480
|
return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", "");
|
|
481
481
|
},
|
|
482
482
|
'\\ca': /^\\ca(?:\s+|(?![a-zA-Z]))/,
|
|
@@ -484,28 +484,28 @@ var mhchemParser = {
|
|
|
484
484
|
'orbital': /^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,
|
|
485
485
|
// only those with numbers in front, because the others will be formatted correctly anyway
|
|
486
486
|
'others': /^[\/~|]/,
|
|
487
|
-
'\\frac{(...)}': function
|
|
487
|
+
'\\frac{(...)}': function (input) {
|
|
488
488
|
return mhchemParser.patterns.findObserveGroups(input, "\\frac{", "", "", "}", "{", "", "", "}");
|
|
489
489
|
},
|
|
490
|
-
'\\overset{(...)}': function
|
|
490
|
+
'\\overset{(...)}': function (input) {
|
|
491
491
|
return mhchemParser.patterns.findObserveGroups(input, "\\overset{", "", "", "}", "{", "", "", "}");
|
|
492
492
|
},
|
|
493
|
-
|
|
493
|
+
'\\underset{(...)}': function (input) {
|
|
494
494
|
return mhchemParser.patterns.findObserveGroups(input, "\\underset{", "", "", "}", "{", "", "", "}");
|
|
495
495
|
},
|
|
496
|
-
|
|
496
|
+
'\\underbrace{(...)}': function (input) {
|
|
497
497
|
return mhchemParser.patterns.findObserveGroups(input, "\\underbrace{", "", "", "}_", "{", "", "", "}");
|
|
498
498
|
},
|
|
499
|
-
'\\color{(...)}0': function
|
|
499
|
+
'\\color{(...)}0': function (input) {
|
|
500
500
|
return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}");
|
|
501
501
|
},
|
|
502
|
-
'\\color{(...)}{(...)}1': function
|
|
502
|
+
'\\color{(...)}{(...)}1': function (input) {
|
|
503
503
|
return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}", "{", "", "", "}");
|
|
504
504
|
},
|
|
505
|
-
'\\color(...){(...)}2': function
|
|
505
|
+
'\\color(...){(...)}2': function (input) {
|
|
506
506
|
return mhchemParser.patterns.findObserveGroups(input, "\\color", "\\", "", /^(?=\{)/, "{", "", "", "}");
|
|
507
507
|
},
|
|
508
|
-
'\\ce{(...)}': function
|
|
508
|
+
'\\ce{(...)}': function (input) {
|
|
509
509
|
return mhchemParser.patterns.findObserveGroups(input, "\\ce{", "", "", "}");
|
|
510
510
|
},
|
|
511
511
|
'oxidation$': /^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,
|
|
@@ -513,7 +513,7 @@ var mhchemParser = {
|
|
|
513
513
|
// 0 could be oxidation or charge
|
|
514
514
|
'roman numeral': /^[IVX]+/,
|
|
515
515
|
'1/2$': /^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,
|
|
516
|
-
'amount': function
|
|
516
|
+
'amount': function (input) {
|
|
517
517
|
var match; // e.g. 2, 0.5, 1/2, -2, n/2, +; $a$ could be added later in parsing
|
|
518
518
|
|
|
519
519
|
match = input.match(/^(?:(?:(?:\([+\-]?[0-9]+\/[0-9]+\)|[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+|[+\-]?[0-9]+[.,][0-9]+|[+\-]?\.[0-9]+|[+\-]?[0-9]+)(?:[a-z](?=\s*[A-Z]))?)|[+\-]?[a-z](?=\s*[A-Z])|\+(?!\s))/);
|
|
@@ -541,11 +541,11 @@ var mhchemParser = {
|
|
|
541
541
|
|
|
542
542
|
return null;
|
|
543
543
|
},
|
|
544
|
-
'amount2': function
|
|
544
|
+
'amount2': function (input) {
|
|
545
545
|
return this['amount'](input);
|
|
546
546
|
},
|
|
547
547
|
'(KV letters),': /^(?:[A-Z][a-z]{0,2}|i)(?=,)/,
|
|
548
|
-
'formula$': function
|
|
548
|
+
'formula$': function (input) {
|
|
549
549
|
if (input.match(/^\([a-z]+\)$/)) {
|
|
550
550
|
return null;
|
|
551
551
|
} // state of aggregation = no formula
|
|
@@ -567,9 +567,9 @@ var mhchemParser = {
|
|
|
567
567
|
'//': /^\s*(\/\/)\s*/,
|
|
568
568
|
'*': /^\s*[*.]\s*/
|
|
569
569
|
},
|
|
570
|
-
findObserveGroups: function
|
|
570
|
+
findObserveGroups: function (input, begExcl, begIncl, endIncl, endExcl, beg2Excl, beg2Incl, end2Incl, end2Excl, combine) {
|
|
571
571
|
/** @type {{(input: string, pattern: string | RegExp): string | string[] | null;}} */
|
|
572
|
-
var _match = function
|
|
572
|
+
var _match = function (input, pattern) {
|
|
573
573
|
if (typeof pattern === "string") {
|
|
574
574
|
if (input.indexOf(pattern) !== 0) {
|
|
575
575
|
return null;
|
|
@@ -589,7 +589,7 @@ var mhchemParser = {
|
|
|
589
589
|
/** @type {{(input: string, i: number, endChars: string | RegExp): {endMatchBegin: number, endMatchEnd: number} | null;}} */
|
|
590
590
|
|
|
591
591
|
|
|
592
|
-
var _findObserveGroups = function
|
|
592
|
+
var _findObserveGroups = function (input, i, endChars) {
|
|
593
593
|
var braces = 0;
|
|
594
594
|
|
|
595
595
|
while (i < input.length) {
|
|
@@ -669,7 +669,7 @@ var mhchemParser = {
|
|
|
669
669
|
// e.g. match("a", input) will look for the regexp called "a" and see if it matches
|
|
670
670
|
// returns null or {match_:"a", remainder:"bc"}
|
|
671
671
|
//
|
|
672
|
-
match_: function
|
|
672
|
+
match_: function (m, input) {
|
|
673
673
|
var pattern = mhchemParser.patterns.patterns[m];
|
|
674
674
|
|
|
675
675
|
if (pattern === undefined) {
|
|
@@ -705,88 +705,88 @@ var mhchemParser = {
|
|
|
705
705
|
// Generic state machine actions
|
|
706
706
|
//
|
|
707
707
|
actions: {
|
|
708
|
-
'a=': function
|
|
708
|
+
'a=': function (buffer, m) {
|
|
709
709
|
buffer.a = (buffer.a || "") + m;
|
|
710
710
|
},
|
|
711
|
-
'b=': function
|
|
711
|
+
'b=': function (buffer, m) {
|
|
712
712
|
buffer.b = (buffer.b || "") + m;
|
|
713
713
|
},
|
|
714
|
-
'p=': function
|
|
714
|
+
'p=': function (buffer, m) {
|
|
715
715
|
buffer.p = (buffer.p || "") + m;
|
|
716
716
|
},
|
|
717
|
-
'o=': function
|
|
717
|
+
'o=': function (buffer, m) {
|
|
718
718
|
buffer.o = (buffer.o || "") + m;
|
|
719
719
|
},
|
|
720
|
-
'q=': function
|
|
720
|
+
'q=': function (buffer, m) {
|
|
721
721
|
buffer.q = (buffer.q || "") + m;
|
|
722
722
|
},
|
|
723
|
-
'd=': function
|
|
723
|
+
'd=': function (buffer, m) {
|
|
724
724
|
buffer.d = (buffer.d || "") + m;
|
|
725
725
|
},
|
|
726
|
-
'rm=': function
|
|
726
|
+
'rm=': function (buffer, m) {
|
|
727
727
|
buffer.rm = (buffer.rm || "") + m;
|
|
728
728
|
},
|
|
729
|
-
'text=': function
|
|
729
|
+
'text=': function (buffer, m) {
|
|
730
730
|
buffer.text_ = (buffer.text_ || "") + m;
|
|
731
731
|
},
|
|
732
|
-
'insert': function
|
|
732
|
+
'insert': function (buffer, m, a) {
|
|
733
733
|
return {
|
|
734
734
|
type_: a
|
|
735
735
|
};
|
|
736
736
|
},
|
|
737
|
-
'insert+p1': function
|
|
737
|
+
'insert+p1': function (buffer, m, a) {
|
|
738
738
|
return {
|
|
739
739
|
type_: a,
|
|
740
740
|
p1: m
|
|
741
741
|
};
|
|
742
742
|
},
|
|
743
|
-
'insert+p1+p2': function
|
|
743
|
+
'insert+p1+p2': function (buffer, m, a) {
|
|
744
744
|
return {
|
|
745
745
|
type_: a,
|
|
746
746
|
p1: m[0],
|
|
747
747
|
p2: m[1]
|
|
748
748
|
};
|
|
749
749
|
},
|
|
750
|
-
'copy': function
|
|
750
|
+
'copy': function (buffer, m) {
|
|
751
751
|
return m;
|
|
752
752
|
},
|
|
753
|
-
'rm': function
|
|
753
|
+
'rm': function (buffer, m) {
|
|
754
754
|
return {
|
|
755
755
|
type_: 'rm',
|
|
756
756
|
p1: m || ""
|
|
757
757
|
};
|
|
758
758
|
},
|
|
759
|
-
'text': function
|
|
759
|
+
'text': function (buffer, m) {
|
|
760
760
|
return mhchemParser.go(m, 'text');
|
|
761
761
|
},
|
|
762
|
-
'{text}': function
|
|
762
|
+
'{text}': function (buffer, m) {
|
|
763
763
|
var ret = ["{"];
|
|
764
764
|
mhchemParser.concatArray(ret, mhchemParser.go(m, 'text'));
|
|
765
765
|
ret.push("}");
|
|
766
766
|
return ret;
|
|
767
767
|
},
|
|
768
|
-
'tex-math': function
|
|
768
|
+
'tex-math': function (buffer, m) {
|
|
769
769
|
return mhchemParser.go(m, 'tex-math');
|
|
770
770
|
},
|
|
771
|
-
'tex-math tight': function
|
|
771
|
+
'tex-math tight': function (buffer, m) {
|
|
772
772
|
return mhchemParser.go(m, 'tex-math tight');
|
|
773
773
|
},
|
|
774
|
-
'bond': function
|
|
774
|
+
'bond': function (buffer, m, k) {
|
|
775
775
|
return {
|
|
776
776
|
type_: 'bond',
|
|
777
777
|
kind_: k || m
|
|
778
778
|
};
|
|
779
779
|
},
|
|
780
|
-
'color0-output': function
|
|
780
|
+
'color0-output': function (buffer, m) {
|
|
781
781
|
return {
|
|
782
782
|
type_: 'color0',
|
|
783
783
|
color: m[0]
|
|
784
784
|
};
|
|
785
785
|
},
|
|
786
|
-
'ce': function
|
|
786
|
+
'ce': function (buffer, m) {
|
|
787
787
|
return mhchemParser.go(m);
|
|
788
788
|
},
|
|
789
|
-
'1/2': function
|
|
789
|
+
'1/2': function (buffer, m) {
|
|
790
790
|
/** @type {ParserOutput[]} */
|
|
791
791
|
var ret = [];
|
|
792
792
|
|
|
@@ -813,7 +813,7 @@ var mhchemParser = {
|
|
|
813
813
|
|
|
814
814
|
return ret;
|
|
815
815
|
},
|
|
816
|
-
'9,9': function
|
|
816
|
+
'9,9': function (buffer, m) {
|
|
817
817
|
return mhchemParser.go(m, '9,9');
|
|
818
818
|
}
|
|
819
819
|
},
|
|
@@ -822,7 +822,7 @@ var mhchemParser = {
|
|
|
822
822
|
// convert { 'letter': { 'state': { action_: 'output' } } } to { 'state' => [ { pattern: 'letter', task: { action_: [{type_: 'output'}] } } ] }
|
|
823
823
|
// with expansion of 'a|b' to 'a' and 'b' (at 2 places)
|
|
824
824
|
//
|
|
825
|
-
createTransitions: function
|
|
825
|
+
createTransitions: function (o) {
|
|
826
826
|
var pattern, state;
|
|
827
827
|
/** @type {string[]} */
|
|
828
828
|
|
|
@@ -1458,7 +1458,7 @@ mhchemParser.stateMachines = {
|
|
|
1458
1458
|
nextState: '3'
|
|
1459
1459
|
}
|
|
1460
1460
|
},
|
|
1461
|
-
|
|
1461
|
+
'\\underset{(...)}': {
|
|
1462
1462
|
'*': {
|
|
1463
1463
|
action_: [{
|
|
1464
1464
|
type_: 'output',
|
|
@@ -1467,7 +1467,7 @@ mhchemParser.stateMachines = {
|
|
|
1467
1467
|
nextState: '3'
|
|
1468
1468
|
}
|
|
1469
1469
|
},
|
|
1470
|
-
|
|
1470
|
+
'\\underbrace{(...)}': {
|
|
1471
1471
|
'*': {
|
|
1472
1472
|
action_: [{
|
|
1473
1473
|
type_: 'output',
|
|
@@ -1553,7 +1553,7 @@ mhchemParser.stateMachines = {
|
|
|
1553
1553
|
}
|
|
1554
1554
|
}),
|
|
1555
1555
|
actions: {
|
|
1556
|
-
'o after d': function
|
|
1556
|
+
'o after d': function (buffer, m) {
|
|
1557
1557
|
var ret;
|
|
1558
1558
|
|
|
1559
1559
|
if ((buffer.d || "").match(/^[0-9]+$/)) {
|
|
@@ -1568,11 +1568,11 @@ mhchemParser.stateMachines = {
|
|
|
1568
1568
|
mhchemParser.actions['o='](buffer, m);
|
|
1569
1569
|
return ret;
|
|
1570
1570
|
},
|
|
1571
|
-
'd= kv': function
|
|
1571
|
+
'd= kv': function (buffer, m) {
|
|
1572
1572
|
buffer.d = m;
|
|
1573
1573
|
buffer.dType = 'kv';
|
|
1574
1574
|
},
|
|
1575
|
-
'charge or bond': function
|
|
1575
|
+
'charge or bond': function (buffer, m) {
|
|
1576
1576
|
if (buffer['beginsWithBond']) {
|
|
1577
1577
|
/** @type {ParserOutput[]} */
|
|
1578
1578
|
var ret = [];
|
|
@@ -1583,7 +1583,7 @@ mhchemParser.stateMachines = {
|
|
|
1583
1583
|
buffer.d = m;
|
|
1584
1584
|
}
|
|
1585
1585
|
},
|
|
1586
|
-
'- after o/d': function
|
|
1586
|
+
'- after o/d': function (buffer, m, isAfterD) {
|
|
1587
1587
|
var c1 = mhchemParser.patterns.match_('orbital', buffer.o || "");
|
|
1588
1588
|
var c2 = mhchemParser.patterns.match_('one lowercase greek letter $', buffer.o || "");
|
|
1589
1589
|
var c3 = mhchemParser.patterns.match_('one lowercase latin letter $', buffer.o || "");
|
|
@@ -1617,35 +1617,35 @@ mhchemParser.stateMachines = {
|
|
|
1617
1617
|
|
|
1618
1618
|
return ret;
|
|
1619
1619
|
},
|
|
1620
|
-
'a to o': function
|
|
1620
|
+
'a to o': function (buffer) {
|
|
1621
1621
|
buffer.o = buffer.a;
|
|
1622
1622
|
buffer.a = undefined;
|
|
1623
1623
|
},
|
|
1624
|
-
'sb=true': function
|
|
1624
|
+
'sb=true': function (buffer) {
|
|
1625
1625
|
buffer.sb = true;
|
|
1626
1626
|
},
|
|
1627
|
-
'sb=false': function
|
|
1627
|
+
'sb=false': function (buffer) {
|
|
1628
1628
|
buffer.sb = false;
|
|
1629
1629
|
},
|
|
1630
|
-
'beginsWithBond=true': function
|
|
1630
|
+
'beginsWithBond=true': function (buffer) {
|
|
1631
1631
|
buffer['beginsWithBond'] = true;
|
|
1632
1632
|
},
|
|
1633
|
-
'beginsWithBond=false': function
|
|
1633
|
+
'beginsWithBond=false': function (buffer) {
|
|
1634
1634
|
buffer['beginsWithBond'] = false;
|
|
1635
1635
|
},
|
|
1636
|
-
'parenthesisLevel++': function
|
|
1636
|
+
'parenthesisLevel++': function (buffer) {
|
|
1637
1637
|
buffer['parenthesisLevel']++;
|
|
1638
1638
|
},
|
|
1639
|
-
'parenthesisLevel--': function
|
|
1639
|
+
'parenthesisLevel--': function (buffer) {
|
|
1640
1640
|
buffer['parenthesisLevel']--;
|
|
1641
1641
|
},
|
|
1642
|
-
'state of aggregation': function
|
|
1642
|
+
'state of aggregation': function (buffer, m) {
|
|
1643
1643
|
return {
|
|
1644
1644
|
type_: 'state of aggregation',
|
|
1645
1645
|
p1: mhchemParser.go(m, 'o')
|
|
1646
1646
|
};
|
|
1647
1647
|
},
|
|
1648
|
-
'comma': function
|
|
1648
|
+
'comma': function (buffer, m) {
|
|
1649
1649
|
var a = m.replace(/\s*$/, '');
|
|
1650
1650
|
var withSpace = a !== m;
|
|
1651
1651
|
|
|
@@ -1661,7 +1661,7 @@ mhchemParser.stateMachines = {
|
|
|
1661
1661
|
};
|
|
1662
1662
|
}
|
|
1663
1663
|
},
|
|
1664
|
-
'output': function
|
|
1664
|
+
'output': function (buffer, m, entityFollows) {
|
|
1665
1665
|
// entityFollows:
|
|
1666
1666
|
// undefined = if we have nothing else to output, also ignore the just read space (buffer.sb)
|
|
1667
1667
|
// 1 = an entity follows, never omit the space if there was one just read before (can only apply to state 1)
|
|
@@ -1756,63 +1756,63 @@ mhchemParser.stateMachines = {
|
|
|
1756
1756
|
|
|
1757
1757
|
return ret;
|
|
1758
1758
|
},
|
|
1759
|
-
'oxidation-output': function
|
|
1759
|
+
'oxidation-output': function (buffer, m) {
|
|
1760
1760
|
var ret = ["{"];
|
|
1761
1761
|
mhchemParser.concatArray(ret, mhchemParser.go(m, 'oxidation'));
|
|
1762
1762
|
ret.push("}");
|
|
1763
1763
|
return ret;
|
|
1764
1764
|
},
|
|
1765
|
-
'frac-output': function
|
|
1765
|
+
'frac-output': function (buffer, m) {
|
|
1766
1766
|
return {
|
|
1767
1767
|
type_: 'frac-ce',
|
|
1768
1768
|
p1: mhchemParser.go(m[0]),
|
|
1769
1769
|
p2: mhchemParser.go(m[1])
|
|
1770
1770
|
};
|
|
1771
1771
|
},
|
|
1772
|
-
'overset-output': function
|
|
1772
|
+
'overset-output': function (buffer, m) {
|
|
1773
1773
|
return {
|
|
1774
1774
|
type_: 'overset',
|
|
1775
1775
|
p1: mhchemParser.go(m[0]),
|
|
1776
1776
|
p2: mhchemParser.go(m[1])
|
|
1777
1777
|
};
|
|
1778
1778
|
},
|
|
1779
|
-
'underset-output': function
|
|
1779
|
+
'underset-output': function (buffer, m) {
|
|
1780
1780
|
return {
|
|
1781
1781
|
type_: 'underset',
|
|
1782
1782
|
p1: mhchemParser.go(m[0]),
|
|
1783
1783
|
p2: mhchemParser.go(m[1])
|
|
1784
1784
|
};
|
|
1785
1785
|
},
|
|
1786
|
-
'underbrace-output': function
|
|
1786
|
+
'underbrace-output': function (buffer, m) {
|
|
1787
1787
|
return {
|
|
1788
1788
|
type_: 'underbrace',
|
|
1789
1789
|
p1: mhchemParser.go(m[0]),
|
|
1790
1790
|
p2: mhchemParser.go(m[1])
|
|
1791
1791
|
};
|
|
1792
1792
|
},
|
|
1793
|
-
'color-output': function
|
|
1793
|
+
'color-output': function (buffer, m) {
|
|
1794
1794
|
return {
|
|
1795
1795
|
type_: 'color',
|
|
1796
1796
|
color1: m[0],
|
|
1797
1797
|
color2: mhchemParser.go(m[1])
|
|
1798
1798
|
};
|
|
1799
1799
|
},
|
|
1800
|
-
'r=': function
|
|
1800
|
+
'r=': function (buffer, m) {
|
|
1801
1801
|
buffer.r = m;
|
|
1802
1802
|
},
|
|
1803
|
-
'rdt=': function
|
|
1803
|
+
'rdt=': function (buffer, m) {
|
|
1804
1804
|
buffer.rdt = m;
|
|
1805
1805
|
},
|
|
1806
|
-
'rd=': function
|
|
1806
|
+
'rd=': function (buffer, m) {
|
|
1807
1807
|
buffer.rd = m;
|
|
1808
1808
|
},
|
|
1809
|
-
'rqt=': function
|
|
1809
|
+
'rqt=': function (buffer, m) {
|
|
1810
1810
|
buffer.rqt = m;
|
|
1811
1811
|
},
|
|
1812
|
-
'rq=': function
|
|
1812
|
+
'rq=': function (buffer, m) {
|
|
1813
1813
|
buffer.rq = m;
|
|
1814
1814
|
},
|
|
1815
|
-
'operator': function
|
|
1815
|
+
'operator': function (buffer, m, p1) {
|
|
1816
1816
|
return {
|
|
1817
1817
|
type_: 'operator',
|
|
1818
1818
|
kind_: p1 || m
|
|
@@ -1944,7 +1944,7 @@ mhchemParser.stateMachines = {
|
|
|
1944
1944
|
}
|
|
1945
1945
|
}),
|
|
1946
1946
|
actions: {
|
|
1947
|
-
'output': function
|
|
1947
|
+
'output': function (buffer) {
|
|
1948
1948
|
if (buffer.text_) {
|
|
1949
1949
|
/** @type {ParserOutput} */
|
|
1950
1950
|
var ret = {
|
|
@@ -2060,13 +2060,13 @@ mhchemParser.stateMachines = {
|
|
|
2060
2060
|
}
|
|
2061
2061
|
}),
|
|
2062
2062
|
actions: {
|
|
2063
|
-
'state of aggregation': function
|
|
2063
|
+
'state of aggregation': function (buffer, m) {
|
|
2064
2064
|
return {
|
|
2065
2065
|
type_: 'state of aggregation subscript',
|
|
2066
2066
|
p1: mhchemParser.go(m, 'o')
|
|
2067
2067
|
};
|
|
2068
2068
|
},
|
|
2069
|
-
'color-output': function
|
|
2069
|
+
'color-output': function (buffer, m) {
|
|
2070
2070
|
return {
|
|
2071
2071
|
type_: 'color',
|
|
2072
2072
|
color1: m[0],
|
|
@@ -2174,7 +2174,7 @@ mhchemParser.stateMachines = {
|
|
|
2174
2174
|
}
|
|
2175
2175
|
}),
|
|
2176
2176
|
actions: {
|
|
2177
|
-
'color-output': function
|
|
2177
|
+
'color-output': function (buffer, m) {
|
|
2178
2178
|
return {
|
|
2179
2179
|
type_: 'color',
|
|
2180
2180
|
color1: m[0],
|
|
@@ -2205,7 +2205,7 @@ mhchemParser.stateMachines = {
|
|
|
2205
2205
|
}
|
|
2206
2206
|
}),
|
|
2207
2207
|
actions: {
|
|
2208
|
-
'roman-numeral': function
|
|
2208
|
+
'roman-numeral': function (buffer, m) {
|
|
2209
2209
|
return {
|
|
2210
2210
|
type_: 'roman numeral',
|
|
2211
2211
|
p1: m || ""
|
|
@@ -2237,7 +2237,7 @@ mhchemParser.stateMachines = {
|
|
|
2237
2237
|
}
|
|
2238
2238
|
}),
|
|
2239
2239
|
actions: {
|
|
2240
|
-
'output': function
|
|
2240
|
+
'output': function (buffer) {
|
|
2241
2241
|
if (buffer.o) {
|
|
2242
2242
|
/** @type {ParserOutput} */
|
|
2243
2243
|
var ret = {
|
|
@@ -2283,10 +2283,10 @@ mhchemParser.stateMachines = {
|
|
|
2283
2283
|
}
|
|
2284
2284
|
}),
|
|
2285
2285
|
actions: {
|
|
2286
|
-
'tight operator': function
|
|
2286
|
+
'tight operator': function (buffer, m) {
|
|
2287
2287
|
buffer.o = (buffer.o || "") + "{" + m + "}";
|
|
2288
2288
|
},
|
|
2289
|
-
'output': function
|
|
2289
|
+
'output': function (buffer) {
|
|
2290
2290
|
if (buffer.o) {
|
|
2291
2291
|
/** @type {ParserOutput} */
|
|
2292
2292
|
var ret = {
|
|
@@ -2320,7 +2320,7 @@ mhchemParser.stateMachines = {
|
|
|
2320
2320
|
}
|
|
2321
2321
|
}),
|
|
2322
2322
|
actions: {
|
|
2323
|
-
'comma': function
|
|
2323
|
+
'comma': function () {
|
|
2324
2324
|
return {
|
|
2325
2325
|
type_: 'commaDecimal'
|
|
2326
2326
|
};
|
|
@@ -2407,7 +2407,7 @@ mhchemParser.stateMachines = {
|
|
|
2407
2407
|
}
|
|
2408
2408
|
}),
|
|
2409
2409
|
actions: {
|
|
2410
|
-
'enumber': function
|
|
2410
|
+
'enumber': function (buffer, m) {
|
|
2411
2411
|
/** @type {ParserOutput[]} */
|
|
2412
2412
|
var ret = [];
|
|
2413
2413
|
|
|
@@ -2451,7 +2451,7 @@ mhchemParser.stateMachines = {
|
|
|
2451
2451
|
|
|
2452
2452
|
return ret;
|
|
2453
2453
|
},
|
|
2454
|
-
'number^': function
|
|
2454
|
+
'number^': function (buffer, m) {
|
|
2455
2455
|
/** @type {ParserOutput[]} */
|
|
2456
2456
|
var ret = [];
|
|
2457
2457
|
|
|
@@ -2465,18 +2465,18 @@ mhchemParser.stateMachines = {
|
|
|
2465
2465
|
ret.push("^{" + m[2] + "}");
|
|
2466
2466
|
return ret;
|
|
2467
2467
|
},
|
|
2468
|
-
'operator': function
|
|
2468
|
+
'operator': function (buffer, m, p1) {
|
|
2469
2469
|
return {
|
|
2470
2470
|
type_: 'operator',
|
|
2471
2471
|
kind_: p1 || m
|
|
2472
2472
|
};
|
|
2473
2473
|
},
|
|
2474
|
-
'space': function
|
|
2474
|
+
'space': function () {
|
|
2475
2475
|
return {
|
|
2476
2476
|
type_: 'pu-space-1'
|
|
2477
2477
|
};
|
|
2478
2478
|
},
|
|
2479
|
-
'output': function
|
|
2479
|
+
'output': function (buffer) {
|
|
2480
2480
|
/** @type {ParserOutput | ParserOutput[]} */
|
|
2481
2481
|
var ret;
|
|
2482
2482
|
var md = mhchemParser.patterns.match_('{(...)}', buffer.d || "");
|
|
@@ -2586,20 +2586,20 @@ mhchemParser.stateMachines = {
|
|
|
2586
2586
|
}
|
|
2587
2587
|
}),
|
|
2588
2588
|
actions: {
|
|
2589
|
-
'cdot': function
|
|
2589
|
+
'cdot': function () {
|
|
2590
2590
|
return {
|
|
2591
2591
|
type_: 'tight cdot'
|
|
2592
2592
|
};
|
|
2593
2593
|
},
|
|
2594
|
-
'^(-1)': function
|
|
2594
|
+
'^(-1)': function (buffer, m) {
|
|
2595
2595
|
buffer.rm += "^{" + m + "}";
|
|
2596
2596
|
},
|
|
2597
|
-
'space': function
|
|
2597
|
+
'space': function () {
|
|
2598
2598
|
return {
|
|
2599
2599
|
type_: 'pu-space-2'
|
|
2600
2600
|
};
|
|
2601
2601
|
},
|
|
2602
|
-
'output': function
|
|
2602
|
+
'output': function (buffer) {
|
|
2603
2603
|
/** @type {ParserOutput | ParserOutput[]} */
|
|
2604
2604
|
var ret = [];
|
|
2605
2605
|
|
|
@@ -2653,12 +2653,12 @@ mhchemParser.stateMachines = {
|
|
|
2653
2653
|
}
|
|
2654
2654
|
}),
|
|
2655
2655
|
actions: {
|
|
2656
|
-
'comma': function
|
|
2656
|
+
'comma': function () {
|
|
2657
2657
|
return {
|
|
2658
2658
|
type_: 'commaDecimal'
|
|
2659
2659
|
};
|
|
2660
2660
|
},
|
|
2661
|
-
'output-0': function
|
|
2661
|
+
'output-0': function (buffer) {
|
|
2662
2662
|
/** @type {ParserOutput[]} */
|
|
2663
2663
|
var ret = [];
|
|
2664
2664
|
buffer.text_ = buffer.text_ || "";
|
|
@@ -2689,7 +2689,7 @@ mhchemParser.stateMachines = {
|
|
|
2689
2689
|
|
|
2690
2690
|
return ret;
|
|
2691
2691
|
},
|
|
2692
|
-
'output-o': function
|
|
2692
|
+
'output-o': function (buffer) {
|
|
2693
2693
|
/** @type {ParserOutput[]} */
|
|
2694
2694
|
var ret = [];
|
|
2695
2695
|
buffer.text_ = buffer.text_ || "";
|
|
@@ -2725,7 +2725,7 @@ mhchemParser.stateMachines = {
|
|
|
2725
2725
|
/** @type {Texify} */
|
|
2726
2726
|
|
|
2727
2727
|
var texify = {
|
|
2728
|
-
go: function
|
|
2728
|
+
go: function (input, isInner) {
|
|
2729
2729
|
// (recursive, max 4 levels)
|
|
2730
2730
|
if (!input) {
|
|
2731
2731
|
return "";
|
|
@@ -2754,14 +2754,14 @@ var texify = {
|
|
|
2754
2754
|
|
|
2755
2755
|
return res;
|
|
2756
2756
|
},
|
|
2757
|
-
_goInner: function
|
|
2757
|
+
_goInner: function (input) {
|
|
2758
2758
|
if (!input) {
|
|
2759
2759
|
return input;
|
|
2760
2760
|
}
|
|
2761
2761
|
|
|
2762
2762
|
return texify.go(input, true);
|
|
2763
2763
|
},
|
|
2764
|
-
_go2: function
|
|
2764
|
+
_go2: function (buf) {
|
|
2765
2765
|
/** @type {undefined | string} */
|
|
2766
2766
|
var res;
|
|
2767
2767
|
|
|
@@ -3052,7 +3052,7 @@ var texify = {
|
|
|
3052
3052
|
assertString(res);
|
|
3053
3053
|
return res;
|
|
3054
3054
|
},
|
|
3055
|
-
_getArrow: function
|
|
3055
|
+
_getArrow: function (a) {
|
|
3056
3056
|
switch (a) {
|
|
3057
3057
|
case "->":
|
|
3058
3058
|
return "rightarrow";
|
|
@@ -3089,7 +3089,7 @@ var texify = {
|
|
|
3089
3089
|
throw ["MhchemBugT", "mhchem bug T. Please report."];
|
|
3090
3090
|
}
|
|
3091
3091
|
},
|
|
3092
|
-
_getBond: function
|
|
3092
|
+
_getBond: function (a) {
|
|
3093
3093
|
switch (a) {
|
|
3094
3094
|
case "-":
|
|
3095
3095
|
return "{-}";
|
|
@@ -3147,7 +3147,7 @@ var texify = {
|
|
|
3147
3147
|
throw ["MhchemBugT", "mhchem bug T. Please report."];
|
|
3148
3148
|
}
|
|
3149
3149
|
},
|
|
3150
|
-
_getOperator: function
|
|
3150
|
+
_getOperator: function (a) {
|
|
3151
3151
|
switch (a) {
|
|
3152
3152
|
case "+":
|
|
3153
3153
|
return " {}+{} ";
|