ai-read-over-mobile 0.0.13 → 0.0.15
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/components/demo/src/read-over.vue +34 -28
- package/dist/ai-read-over-mobile.common.js +2923 -41
- package/dist/ai-read-over-mobile.common.js.map +1 -1
- package/dist/ai-read-over-mobile.css +1 -1
- package/dist/ai-read-over-mobile.umd.js +2923 -41
- package/dist/ai-read-over-mobile.umd.js.map +1 -1
- package/dist/ai-read-over-mobile.umd.min.js +4 -4
- package/dist/ai-read-over-mobile.umd.min.js.map +1 -1
- package/package.json +4 -1
|
@@ -6714,8 +6714,8 @@ var staticRenderFns = [];
|
|
|
6714
6714
|
|
|
6715
6715
|
;// CONCATENATED MODULE: ./components/demo/src/main.vue?vue&type=template&id=0265c882&scoped=true
|
|
6716
6716
|
|
|
6717
|
-
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/read-over.vue?vue&type=template&id=
|
|
6718
|
-
var
|
|
6717
|
+
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/read-over.vue?vue&type=template&id=339a0348&scoped=true
|
|
6718
|
+
var read_overvue_type_template_id_339a0348_scoped_true_render = function render() {
|
|
6719
6719
|
var _vm = this,
|
|
6720
6720
|
_c = _vm._self._c;
|
|
6721
6721
|
return _c('div', {
|
|
@@ -6804,7 +6804,7 @@ var read_overvue_type_template_id_0d0512b4_scoped_true_render = function render(
|
|
|
6804
6804
|
}
|
|
6805
6805
|
}, [_vm._v("应用")])], 1) : _vm._e()])] : _vm._e()], 2)]);
|
|
6806
6806
|
};
|
|
6807
|
-
var
|
|
6807
|
+
var read_overvue_type_template_id_339a0348_scoped_true_staticRenderFns = [function () {
|
|
6808
6808
|
var _vm = this,
|
|
6809
6809
|
_c = _vm._self._c;
|
|
6810
6810
|
return _c('div', {
|
|
@@ -6818,7 +6818,7 @@ var read_overvue_type_template_id_0d0512b4_scoped_true_staticRenderFns = [functi
|
|
|
6818
6818
|
}), _vm._v(" 回答 ")]);
|
|
6819
6819
|
}];
|
|
6820
6820
|
|
|
6821
|
-
;// CONCATENATED MODULE: ./components/demo/src/read-over.vue?vue&type=template&id=
|
|
6821
|
+
;// CONCATENATED MODULE: ./components/demo/src/read-over.vue?vue&type=template&id=339a0348&scoped=true
|
|
6822
6822
|
|
|
6823
6823
|
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/templateLoader.js??ruleSet[1].rules[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/chat-tools.vue?vue&type=template&id=7c9d0523&scoped=true
|
|
6824
6824
|
var chat_toolsvue_type_template_id_7c9d0523_scoped_true_render = function render() {
|
|
@@ -14105,11 +14105,2892 @@ if(typeof document!=="undefined"){if(document.compatMode!=="CSS1Compat"){typeof
|
|
|
14105
14105
|
* The internal tree representation is unstable and is very likely
|
|
14106
14106
|
* to change. Use at your own risk.
|
|
14107
14107
|
*/__domTree:{Span,Anchor,SymbolNode,SvgNode,PathNode,LineNode}};
|
|
14108
|
+
;// CONCATENATED MODULE: ./node_modules/katex/contrib/mhchem/mhchem.js
|
|
14109
|
+
/* eslint-disable */
|
|
14110
|
+
/* -*- Mode: Javascript; indent-tabs-mode:nil; js-indent-level: 2 -*- */
|
|
14111
|
+
/* vim: set ts=2 et sw=2 tw=80: */
|
|
14112
|
+
|
|
14113
|
+
/*************************************************************
|
|
14114
|
+
*
|
|
14115
|
+
* KaTeX mhchem.js
|
|
14116
|
+
*
|
|
14117
|
+
* This file implements a KaTeX version of mhchem version 3.3.0.
|
|
14118
|
+
* It is adapted from MathJax/extensions/TeX/mhchem.js
|
|
14119
|
+
* It differs from the MathJax version as follows:
|
|
14120
|
+
* 1. The interface is changed so that it can be called from KaTeX, not MathJax.
|
|
14121
|
+
* 2. \rlap and \llap are replaced with \mathrlap and \mathllap.
|
|
14122
|
+
* 3. Four lines of code are edited in order to use \raisebox instead of \raise.
|
|
14123
|
+
* 4. The reaction arrow code is simplified. All reaction arrows are rendered
|
|
14124
|
+
* using KaTeX extensible arrows instead of building non-extensible arrows.
|
|
14125
|
+
* 5. \tripledash vertical alignment is slightly adjusted.
|
|
14126
|
+
*
|
|
14127
|
+
* This code, as other KaTeX code, is released under the MIT license.
|
|
14128
|
+
*
|
|
14129
|
+
* /*************************************************************
|
|
14130
|
+
*
|
|
14131
|
+
* MathJax/extensions/TeX/mhchem.js
|
|
14132
|
+
*
|
|
14133
|
+
* Implements the \ce command for handling chemical formulas
|
|
14134
|
+
* from the mhchem LaTeX package.
|
|
14135
|
+
*
|
|
14136
|
+
* ---------------------------------------------------------------------
|
|
14137
|
+
*
|
|
14138
|
+
* Copyright (c) 2011-2015 The MathJax Consortium
|
|
14139
|
+
* Copyright (c) 2015-2018 Martin Hensel
|
|
14140
|
+
*
|
|
14141
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
14142
|
+
* you may not use this file except in compliance with the License.
|
|
14143
|
+
* You may obtain a copy of the License at
|
|
14144
|
+
*
|
|
14145
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
14146
|
+
*
|
|
14147
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14148
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
14149
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14150
|
+
* See the License for the specific language governing permissions and
|
|
14151
|
+
* limitations under the License.
|
|
14152
|
+
*/
|
|
14153
|
+
|
|
14154
|
+
//
|
|
14155
|
+
// Coding Style
|
|
14156
|
+
// - use '' for identifiers that can by minified/uglified
|
|
14157
|
+
// - use "" for strings that need to stay untouched
|
|
14158
|
+
|
|
14159
|
+
// version: "3.3.0" for MathJax and KaTeX
|
|
14160
|
+
|
|
14161
|
+
// Add \ce, \pu, and \tripledash to the KaTeX macros.
|
|
14162
|
+
|
|
14163
|
+
katex.__defineMacro("\\ce", function (context) {
|
|
14164
|
+
return chemParse(context.consumeArgs(1)[0], "ce");
|
|
14165
|
+
});
|
|
14166
|
+
katex.__defineMacro("\\pu", function (context) {
|
|
14167
|
+
return chemParse(context.consumeArgs(1)[0], "pu");
|
|
14168
|
+
});
|
|
14169
|
+
|
|
14170
|
+
// Needed for \bond for the ~ forms
|
|
14171
|
+
// Raise by 2.56mu, not 2mu. We're raising a hyphen-minus, U+002D, not
|
|
14172
|
+
// a mathematical minus, U+2212. So we need that extra 0.56.
|
|
14173
|
+
katex.__defineMacro("\\tripledash", "{\\vphantom{-}\\raisebox{2.56mu}{$\\mkern2mu" + "\\tiny\\text{-}\\mkern1mu\\text{-}\\mkern1mu\\text{-}\\mkern2mu$}}");
|
|
14174
|
+
|
|
14175
|
+
|
|
14176
|
+
//
|
|
14177
|
+
// This is the main function for handing the \ce and \pu commands.
|
|
14178
|
+
// It takes the argument to \ce or \pu and returns the corresponding TeX string.
|
|
14179
|
+
//
|
|
14180
|
+
|
|
14181
|
+
var chemParse = function (tokens, stateMachine) {
|
|
14182
|
+
// Recreate the argument string from KaTeX's array of tokens.
|
|
14183
|
+
var str = "";
|
|
14184
|
+
var expectedLoc = tokens.length && tokens[tokens.length - 1].loc.start;
|
|
14185
|
+
for (var i = tokens.length - 1; i >= 0; i--) {
|
|
14186
|
+
if (tokens[i].loc.start > expectedLoc) {
|
|
14187
|
+
// context.consumeArgs has eaten a space.
|
|
14188
|
+
str += " ";
|
|
14189
|
+
expectedLoc = tokens[i].loc.start;
|
|
14190
|
+
}
|
|
14191
|
+
str += tokens[i].text;
|
|
14192
|
+
expectedLoc += tokens[i].text.length;
|
|
14193
|
+
}
|
|
14194
|
+
var tex = texify.go(mhchemParser.go(str, stateMachine));
|
|
14195
|
+
return tex;
|
|
14196
|
+
};
|
|
14197
|
+
|
|
14198
|
+
//
|
|
14199
|
+
// Core parser for mhchem syntax (recursive)
|
|
14200
|
+
//
|
|
14201
|
+
/** @type {MhchemParser} */
|
|
14202
|
+
var mhchemParser = {
|
|
14203
|
+
//
|
|
14204
|
+
// Parses mchem \ce syntax
|
|
14205
|
+
//
|
|
14206
|
+
// Call like
|
|
14207
|
+
// go("H2O");
|
|
14208
|
+
//
|
|
14209
|
+
go: function (input, stateMachine) {
|
|
14210
|
+
if (!input) {
|
|
14211
|
+
return [];
|
|
14212
|
+
}
|
|
14213
|
+
if (stateMachine === undefined) {
|
|
14214
|
+
stateMachine = 'ce';
|
|
14215
|
+
}
|
|
14216
|
+
var state = '0';
|
|
14217
|
+
|
|
14218
|
+
//
|
|
14219
|
+
// String buffers for parsing:
|
|
14220
|
+
//
|
|
14221
|
+
// buffer.a == amount
|
|
14222
|
+
// buffer.o == element
|
|
14223
|
+
// buffer.b == left-side superscript
|
|
14224
|
+
// buffer.p == left-side subscript
|
|
14225
|
+
// buffer.q == right-side subscript
|
|
14226
|
+
// buffer.d == right-side superscript
|
|
14227
|
+
//
|
|
14228
|
+
// buffer.r == arrow
|
|
14229
|
+
// buffer.rdt == arrow, script above, type
|
|
14230
|
+
// buffer.rd == arrow, script above, content
|
|
14231
|
+
// buffer.rqt == arrow, script below, type
|
|
14232
|
+
// buffer.rq == arrow, script below, content
|
|
14233
|
+
//
|
|
14234
|
+
// buffer.text_
|
|
14235
|
+
// buffer.rm
|
|
14236
|
+
// etc.
|
|
14237
|
+
//
|
|
14238
|
+
// buffer.parenthesisLevel == int, starting at 0
|
|
14239
|
+
// buffer.sb == bool, space before
|
|
14240
|
+
// buffer.beginsWithBond == bool
|
|
14241
|
+
//
|
|
14242
|
+
// These letters are also used as state names.
|
|
14243
|
+
//
|
|
14244
|
+
// Other states:
|
|
14245
|
+
// 0 == begin of main part (arrow/operator unlikely)
|
|
14246
|
+
// 1 == next entity
|
|
14247
|
+
// 2 == next entity (arrow/operator unlikely)
|
|
14248
|
+
// 3 == next atom
|
|
14249
|
+
// c == macro
|
|
14250
|
+
//
|
|
14251
|
+
/** @type {Buffer} */
|
|
14252
|
+
var buffer = {};
|
|
14253
|
+
buffer['parenthesisLevel'] = 0;
|
|
14254
|
+
input = input.replace(/\n/g, " ");
|
|
14255
|
+
input = input.replace(/[\u2212\u2013\u2014\u2010]/g, "-");
|
|
14256
|
+
input = input.replace(/[\u2026]/g, "...");
|
|
14257
|
+
|
|
14258
|
+
//
|
|
14259
|
+
// Looks through mhchemParser.transitions, to execute a matching action
|
|
14260
|
+
// (recursive)
|
|
14261
|
+
//
|
|
14262
|
+
var lastInput;
|
|
14263
|
+
var watchdog = 10;
|
|
14264
|
+
/** @type {ParserOutput[]} */
|
|
14265
|
+
var output = [];
|
|
14266
|
+
while (true) {
|
|
14267
|
+
if (lastInput !== input) {
|
|
14268
|
+
watchdog = 10;
|
|
14269
|
+
lastInput = input;
|
|
14270
|
+
} else {
|
|
14271
|
+
watchdog--;
|
|
14272
|
+
}
|
|
14273
|
+
//
|
|
14274
|
+
// Find actions in transition table
|
|
14275
|
+
//
|
|
14276
|
+
var machine = mhchemParser.stateMachines[stateMachine];
|
|
14277
|
+
var t = machine.transitions[state] || machine.transitions['*'];
|
|
14278
|
+
iterateTransitions: for (var i = 0; i < t.length; i++) {
|
|
14279
|
+
var matches = mhchemParser.patterns.match_(t[i].pattern, input);
|
|
14280
|
+
if (matches) {
|
|
14281
|
+
//
|
|
14282
|
+
// Execute actions
|
|
14283
|
+
//
|
|
14284
|
+
var task = t[i].task;
|
|
14285
|
+
for (var iA = 0; iA < task.action_.length; iA++) {
|
|
14286
|
+
var o;
|
|
14287
|
+
//
|
|
14288
|
+
// Find and execute action
|
|
14289
|
+
//
|
|
14290
|
+
if (machine.actions[task.action_[iA].type_]) {
|
|
14291
|
+
o = machine.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option);
|
|
14292
|
+
} else if (mhchemParser.actions[task.action_[iA].type_]) {
|
|
14293
|
+
o = mhchemParser.actions[task.action_[iA].type_](buffer, matches.match_, task.action_[iA].option);
|
|
14294
|
+
} else {
|
|
14295
|
+
throw ["MhchemBugA", "mhchem bug A. Please report. (" + task.action_[iA].type_ + ")"]; // Trying to use non-existing action
|
|
14296
|
+
}
|
|
14297
|
+
//
|
|
14298
|
+
// Add output
|
|
14299
|
+
//
|
|
14300
|
+
mhchemParser.concatArray(output, o);
|
|
14301
|
+
}
|
|
14302
|
+
//
|
|
14303
|
+
// Set next state,
|
|
14304
|
+
// Shorten input,
|
|
14305
|
+
// Continue with next character
|
|
14306
|
+
// (= apply only one transition per position)
|
|
14307
|
+
//
|
|
14308
|
+
state = task.nextState || state;
|
|
14309
|
+
if (input.length > 0) {
|
|
14310
|
+
if (!task.revisit) {
|
|
14311
|
+
input = matches.remainder;
|
|
14312
|
+
}
|
|
14313
|
+
if (!task.toContinue) {
|
|
14314
|
+
break iterateTransitions;
|
|
14315
|
+
}
|
|
14316
|
+
} else {
|
|
14317
|
+
return output;
|
|
14318
|
+
}
|
|
14319
|
+
}
|
|
14320
|
+
}
|
|
14321
|
+
//
|
|
14322
|
+
// Prevent infinite loop
|
|
14323
|
+
//
|
|
14324
|
+
if (watchdog <= 0) {
|
|
14325
|
+
throw ["MhchemBugU", "mhchem bug U. Please report."]; // Unexpected character
|
|
14326
|
+
}
|
|
14327
|
+
}
|
|
14328
|
+
},
|
|
14329
|
+
concatArray: function (a, b) {
|
|
14330
|
+
if (b) {
|
|
14331
|
+
if (Array.isArray(b)) {
|
|
14332
|
+
for (var iB = 0; iB < b.length; iB++) {
|
|
14333
|
+
a.push(b[iB]);
|
|
14334
|
+
}
|
|
14335
|
+
} else {
|
|
14336
|
+
a.push(b);
|
|
14337
|
+
}
|
|
14338
|
+
}
|
|
14339
|
+
},
|
|
14340
|
+
patterns: {
|
|
14341
|
+
//
|
|
14342
|
+
// Matching patterns
|
|
14343
|
+
// either regexps or function that return null or {match_:"a", remainder:"bc"}
|
|
14344
|
+
//
|
|
14345
|
+
patterns: {
|
|
14346
|
+
// property names must not look like integers ("2") for correct property traversal order, later on
|
|
14347
|
+
'empty': /^$/,
|
|
14348
|
+
'else': /^./,
|
|
14349
|
+
'else2': /^./,
|
|
14350
|
+
'space': /^\s/,
|
|
14351
|
+
'space A': /^\s(?=[A-Z\\$])/,
|
|
14352
|
+
'space$': /^\s$/,
|
|
14353
|
+
'a-z': /^[a-z]/,
|
|
14354
|
+
'x': /^x/,
|
|
14355
|
+
'x$': /^x$/,
|
|
14356
|
+
'i$': /^i$/,
|
|
14357
|
+
'letters': /^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,
|
|
14358
|
+
'\\greek': /^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,
|
|
14359
|
+
'one lowercase latin letter $': /^(?:([a-z])(?:$|[^a-zA-Z]))$/,
|
|
14360
|
+
'$one lowercase latin letter$ $': /^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,
|
|
14361
|
+
'one lowercase greek letter $': /^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,
|
|
14362
|
+
'digits': /^[0-9]+/,
|
|
14363
|
+
'-9.,9': /^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,
|
|
14364
|
+
'-9.,9 no missing 0': /^[+\-]?[0-9]+(?:[.,][0-9]+)?/,
|
|
14365
|
+
'(-)(9.,9)(e)(99)': function (input) {
|
|
14366
|
+
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]+\}))?/);
|
|
14367
|
+
if (m && m[0]) {
|
|
14368
|
+
return {
|
|
14369
|
+
match_: m.splice(1),
|
|
14370
|
+
remainder: input.substr(m[0].length)
|
|
14371
|
+
};
|
|
14372
|
+
}
|
|
14373
|
+
return null;
|
|
14374
|
+
},
|
|
14375
|
+
'(-)(9)^(-9)': function (input) {
|
|
14376
|
+
var m = input.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/);
|
|
14377
|
+
if (m && m[0]) {
|
|
14378
|
+
return {
|
|
14379
|
+
match_: m.splice(1),
|
|
14380
|
+
remainder: input.substr(m[0].length)
|
|
14381
|
+
};
|
|
14382
|
+
}
|
|
14383
|
+
return null;
|
|
14384
|
+
},
|
|
14385
|
+
'state of aggregation $': function (input) {
|
|
14386
|
+
// ... or crystal system
|
|
14387
|
+
var a = mhchemParser.patterns.findObserveGroups(input, "", /^\([a-z]{1,3}(?=[\),])/, ")", ""); // (aq), (aq,$\infty$), (aq, sat)
|
|
14388
|
+
if (a && a.remainder.match(/^($|[\s,;\)\]\}])/)) {
|
|
14389
|
+
return a;
|
|
14390
|
+
} // AND end of 'phrase'
|
|
14391
|
+
var m = input.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/); // OR crystal system ($o$) (\ca$c$)
|
|
14392
|
+
if (m) {
|
|
14393
|
+
return {
|
|
14394
|
+
match_: m[0],
|
|
14395
|
+
remainder: input.substr(m[0].length)
|
|
14396
|
+
};
|
|
14397
|
+
}
|
|
14398
|
+
return null;
|
|
14399
|
+
},
|
|
14400
|
+
'_{(state of aggregation)}$': /^_\{(\([a-z]{1,3}\))\}/,
|
|
14401
|
+
'{[(': /^(?:\\\{|\[|\()/,
|
|
14402
|
+
')]}': /^(?:\)|\]|\\\})/,
|
|
14403
|
+
', ': /^[,;]\s*/,
|
|
14404
|
+
',': /^[,;]/,
|
|
14405
|
+
'.': /^[.]/,
|
|
14406
|
+
'. ': /^([.\u22C5\u00B7\u2022])\s*/,
|
|
14407
|
+
'...': /^\.\.\.(?=$|[^.])/,
|
|
14408
|
+
'* ': /^([*])\s*/,
|
|
14409
|
+
'^{(...)}': function (input) {
|
|
14410
|
+
return mhchemParser.patterns.findObserveGroups(input, "^{", "", "", "}");
|
|
14411
|
+
},
|
|
14412
|
+
'^($...$)': function (input) {
|
|
14413
|
+
return mhchemParser.patterns.findObserveGroups(input, "^", "$", "$", "");
|
|
14414
|
+
},
|
|
14415
|
+
'^a': /^\^([0-9]+|[^\\_])/,
|
|
14416
|
+
'^\\x{}{}': function (input) {
|
|
14417
|
+
return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true);
|
|
14418
|
+
},
|
|
14419
|
+
'^\\x{}': function (input) {
|
|
14420
|
+
return mhchemParser.patterns.findObserveGroups(input, "^", /^\\[a-zA-Z]+\{/, "}", "");
|
|
14421
|
+
},
|
|
14422
|
+
'^\\x': /^\^(\\[a-zA-Z]+)\s*/,
|
|
14423
|
+
'^(-1)': /^\^(-?\d+)/,
|
|
14424
|
+
'\'': /^'/,
|
|
14425
|
+
'_{(...)}': function (input) {
|
|
14426
|
+
return mhchemParser.patterns.findObserveGroups(input, "_{", "", "", "}");
|
|
14427
|
+
},
|
|
14428
|
+
'_($...$)': function (input) {
|
|
14429
|
+
return mhchemParser.patterns.findObserveGroups(input, "_", "$", "$", "");
|
|
14430
|
+
},
|
|
14431
|
+
'_9': /^_([+\-]?[0-9]+|[^\\])/,
|
|
14432
|
+
'_\\x{}{}': function (input) {
|
|
14433
|
+
return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true);
|
|
14434
|
+
},
|
|
14435
|
+
'_\\x{}': function (input) {
|
|
14436
|
+
return mhchemParser.patterns.findObserveGroups(input, "_", /^\\[a-zA-Z]+\{/, "}", "");
|
|
14437
|
+
},
|
|
14438
|
+
'_\\x': /^_(\\[a-zA-Z]+)\s*/,
|
|
14439
|
+
'^_': /^(?:\^(?=_)|\_(?=\^)|[\^_]$)/,
|
|
14440
|
+
'{}': /^\{\}/,
|
|
14441
|
+
'{...}': function (input) {
|
|
14442
|
+
return mhchemParser.patterns.findObserveGroups(input, "", "{", "}", "");
|
|
14443
|
+
},
|
|
14444
|
+
'{(...)}': function (input) {
|
|
14445
|
+
return mhchemParser.patterns.findObserveGroups(input, "{", "", "", "}");
|
|
14446
|
+
},
|
|
14447
|
+
'$...$': function (input) {
|
|
14448
|
+
return mhchemParser.patterns.findObserveGroups(input, "", "$", "$", "");
|
|
14449
|
+
},
|
|
14450
|
+
'${(...)}$': function (input) {
|
|
14451
|
+
return mhchemParser.patterns.findObserveGroups(input, "${", "", "", "}$");
|
|
14452
|
+
},
|
|
14453
|
+
'$(...)$': function (input) {
|
|
14454
|
+
return mhchemParser.patterns.findObserveGroups(input, "$", "", "", "$");
|
|
14455
|
+
},
|
|
14456
|
+
'=<>': /^[=<>]/,
|
|
14457
|
+
'#': /^[#\u2261]/,
|
|
14458
|
+
'+': /^\+/,
|
|
14459
|
+
'-$': /^-(?=[\s_},;\]/]|$|\([a-z]+\))/,
|
|
14460
|
+
// -space -, -; -] -/ -$ -state-of-aggregation
|
|
14461
|
+
'-9': /^-(?=[0-9])/,
|
|
14462
|
+
'- orbital overlap': /^-(?=(?:[spd]|sp)(?:$|[\s,;\)\]\}]))/,
|
|
14463
|
+
'-': /^-/,
|
|
14464
|
+
'pm-operator': /^(?:\\pm|\$\\pm\$|\+-|\+\/-)/,
|
|
14465
|
+
'operator': /^(?:\+|(?:[\-=<>]|<<|>>|\\approx|\$\\approx\$)(?=\s|$|-?[0-9]))/,
|
|
14466
|
+
'arrowUpDown': /^(?:v|\(v\)|\^|\(\^\))(?=$|[\s,;\)\]\}])/,
|
|
14467
|
+
'\\bond{(...)}': function (input) {
|
|
14468
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\bond{", "", "", "}");
|
|
14469
|
+
},
|
|
14470
|
+
'->': /^(?:<->|<-->|->|<-|<=>>|<<=>|<=>|[\u2192\u27F6\u21CC])/,
|
|
14471
|
+
'CMT': /^[CMT](?=\[)/,
|
|
14472
|
+
'[(...)]': function (input) {
|
|
14473
|
+
return mhchemParser.patterns.findObserveGroups(input, "[", "", "", "]");
|
|
14474
|
+
},
|
|
14475
|
+
'1st-level escape': /^(&|\\\\|\\hline)\s*/,
|
|
14476
|
+
'\\,': /^(?:\\[,\ ;:])/,
|
|
14477
|
+
// \\x - but output no space before
|
|
14478
|
+
'\\x{}{}': function (input) {
|
|
14479
|
+
return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", "", "", "{", "}", "", true);
|
|
14480
|
+
},
|
|
14481
|
+
'\\x{}': function (input) {
|
|
14482
|
+
return mhchemParser.patterns.findObserveGroups(input, "", /^\\[a-zA-Z]+\{/, "}", "");
|
|
14483
|
+
},
|
|
14484
|
+
'\\ca': /^\\ca(?:\s+|(?![a-zA-Z]))/,
|
|
14485
|
+
'\\x': /^(?:\\[a-zA-Z]+\s*|\\[_&{}%])/,
|
|
14486
|
+
'orbital': /^(?:[0-9]{1,2}[spdfgh]|[0-9]{0,2}sp)(?=$|[^a-zA-Z])/,
|
|
14487
|
+
// only those with numbers in front, because the others will be formatted correctly anyway
|
|
14488
|
+
'others': /^[\/~|]/,
|
|
14489
|
+
'\\frac{(...)}': function (input) {
|
|
14490
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\frac{", "", "", "}", "{", "", "", "}");
|
|
14491
|
+
},
|
|
14492
|
+
'\\overset{(...)}': function (input) {
|
|
14493
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\overset{", "", "", "}", "{", "", "", "}");
|
|
14494
|
+
},
|
|
14495
|
+
'\\underset{(...)}': function (input) {
|
|
14496
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\underset{", "", "", "}", "{", "", "", "}");
|
|
14497
|
+
},
|
|
14498
|
+
'\\underbrace{(...)}': function (input) {
|
|
14499
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\underbrace{", "", "", "}_", "{", "", "", "}");
|
|
14500
|
+
},
|
|
14501
|
+
'\\color{(...)}0': function (input) {
|
|
14502
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}");
|
|
14503
|
+
},
|
|
14504
|
+
'\\color{(...)}{(...)}1': function (input) {
|
|
14505
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\color{", "", "", "}", "{", "", "", "}");
|
|
14506
|
+
},
|
|
14507
|
+
'\\color(...){(...)}2': function (input) {
|
|
14508
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\color", "\\", "", /^(?=\{)/, "{", "", "", "}");
|
|
14509
|
+
},
|
|
14510
|
+
'\\ce{(...)}': function (input) {
|
|
14511
|
+
return mhchemParser.patterns.findObserveGroups(input, "\\ce{", "", "", "}");
|
|
14512
|
+
},
|
|
14513
|
+
'oxidation$': /^(?:[+-][IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,
|
|
14514
|
+
'd-oxidation$': /^(?:[+-]?\s?[IVX]+|\\pm\s*0|\$\\pm\$\s*0)$/,
|
|
14515
|
+
// 0 could be oxidation or charge
|
|
14516
|
+
'roman numeral': /^[IVX]+/,
|
|
14517
|
+
'1/2$': /^[+\-]?(?:[0-9]+|\$[a-z]\$|[a-z])\/[0-9]+(?:\$[a-z]\$|[a-z])?$/,
|
|
14518
|
+
'amount': function (input) {
|
|
14519
|
+
var match;
|
|
14520
|
+
// e.g. 2, 0.5, 1/2, -2, n/2, +; $a$ could be added later in parsing
|
|
14521
|
+
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))/);
|
|
14522
|
+
if (match) {
|
|
14523
|
+
return {
|
|
14524
|
+
match_: match[0],
|
|
14525
|
+
remainder: input.substr(match[0].length)
|
|
14526
|
+
};
|
|
14527
|
+
}
|
|
14528
|
+
var a = mhchemParser.patterns.findObserveGroups(input, "", "$", "$", "");
|
|
14529
|
+
if (a) {
|
|
14530
|
+
// e.g. $2n-1$, $-$
|
|
14531
|
+
match = a.match_.match(/^\$(?:\(?[+\-]?(?:[0-9]*[a-z]?[+\-])?[0-9]*[a-z](?:[+\-][0-9]*[a-z]?)?\)?|\+|-)\$$/);
|
|
14532
|
+
if (match) {
|
|
14533
|
+
return {
|
|
14534
|
+
match_: match[0],
|
|
14535
|
+
remainder: input.substr(match[0].length)
|
|
14536
|
+
};
|
|
14537
|
+
}
|
|
14538
|
+
}
|
|
14539
|
+
return null;
|
|
14540
|
+
},
|
|
14541
|
+
'amount2': function (input) {
|
|
14542
|
+
return this['amount'](input);
|
|
14543
|
+
},
|
|
14544
|
+
'(KV letters),': /^(?:[A-Z][a-z]{0,2}|i)(?=,)/,
|
|
14545
|
+
'formula$': function (input) {
|
|
14546
|
+
if (input.match(/^\([a-z]+\)$/)) {
|
|
14547
|
+
return null;
|
|
14548
|
+
} // state of aggregation = no formula
|
|
14549
|
+
var match = input.match(/^(?:[a-z]|(?:[0-9\ \+\-\,\.\(\)]+[a-z])+[0-9\ \+\-\,\.\(\)]*|(?:[a-z][0-9\ \+\-\,\.\(\)]+)+[a-z]?)$/);
|
|
14550
|
+
if (match) {
|
|
14551
|
+
return {
|
|
14552
|
+
match_: match[0],
|
|
14553
|
+
remainder: input.substr(match[0].length)
|
|
14554
|
+
};
|
|
14555
|
+
}
|
|
14556
|
+
return null;
|
|
14557
|
+
},
|
|
14558
|
+
'uprightEntities': /^(?:pH|pOH|pC|pK|iPr|iBu)(?=$|[^a-zA-Z])/,
|
|
14559
|
+
'/': /^\s*(\/)\s*/,
|
|
14560
|
+
'//': /^\s*(\/\/)\s*/,
|
|
14561
|
+
'*': /^\s*[*.]\s*/
|
|
14562
|
+
},
|
|
14563
|
+
findObserveGroups: function (input, begExcl, begIncl, endIncl, endExcl, beg2Excl, beg2Incl, end2Incl, end2Excl, combine) {
|
|
14564
|
+
/** @type {{(input: string, pattern: string | RegExp): string | string[] | null;}} */
|
|
14565
|
+
var _match = function (input, pattern) {
|
|
14566
|
+
if (typeof pattern === "string") {
|
|
14567
|
+
if (input.indexOf(pattern) !== 0) {
|
|
14568
|
+
return null;
|
|
14569
|
+
}
|
|
14570
|
+
return pattern;
|
|
14571
|
+
} else {
|
|
14572
|
+
var match = input.match(pattern);
|
|
14573
|
+
if (!match) {
|
|
14574
|
+
return null;
|
|
14575
|
+
}
|
|
14576
|
+
return match[0];
|
|
14577
|
+
}
|
|
14578
|
+
};
|
|
14579
|
+
/** @type {{(input: string, i: number, endChars: string | RegExp): {endMatchBegin: number, endMatchEnd: number} | null;}} */
|
|
14580
|
+
var _findObserveGroups = function (input, i, endChars) {
|
|
14581
|
+
var braces = 0;
|
|
14582
|
+
while (i < input.length) {
|
|
14583
|
+
var a = input.charAt(i);
|
|
14584
|
+
var match = _match(input.substr(i), endChars);
|
|
14585
|
+
if (match !== null && braces === 0) {
|
|
14586
|
+
return {
|
|
14587
|
+
endMatchBegin: i,
|
|
14588
|
+
endMatchEnd: i + match.length
|
|
14589
|
+
};
|
|
14590
|
+
} else if (a === "{") {
|
|
14591
|
+
braces++;
|
|
14592
|
+
} else if (a === "}") {
|
|
14593
|
+
if (braces === 0) {
|
|
14594
|
+
throw ["ExtraCloseMissingOpen", "Extra close brace or missing open brace"];
|
|
14595
|
+
} else {
|
|
14596
|
+
braces--;
|
|
14597
|
+
}
|
|
14598
|
+
}
|
|
14599
|
+
i++;
|
|
14600
|
+
}
|
|
14601
|
+
if (braces > 0) {
|
|
14602
|
+
return null;
|
|
14603
|
+
}
|
|
14604
|
+
return null;
|
|
14605
|
+
};
|
|
14606
|
+
var match = _match(input, begExcl);
|
|
14607
|
+
if (match === null) {
|
|
14608
|
+
return null;
|
|
14609
|
+
}
|
|
14610
|
+
input = input.substr(match.length);
|
|
14611
|
+
match = _match(input, begIncl);
|
|
14612
|
+
if (match === null) {
|
|
14613
|
+
return null;
|
|
14614
|
+
}
|
|
14615
|
+
var e = _findObserveGroups(input, match.length, endIncl || endExcl);
|
|
14616
|
+
if (e === null) {
|
|
14617
|
+
return null;
|
|
14618
|
+
}
|
|
14619
|
+
var match1 = input.substring(0, endIncl ? e.endMatchEnd : e.endMatchBegin);
|
|
14620
|
+
if (!(beg2Excl || beg2Incl)) {
|
|
14621
|
+
return {
|
|
14622
|
+
match_: match1,
|
|
14623
|
+
remainder: input.substr(e.endMatchEnd)
|
|
14624
|
+
};
|
|
14625
|
+
} else {
|
|
14626
|
+
var group2 = this.findObserveGroups(input.substr(e.endMatchEnd), beg2Excl, beg2Incl, end2Incl, end2Excl);
|
|
14627
|
+
if (group2 === null) {
|
|
14628
|
+
return null;
|
|
14629
|
+
}
|
|
14630
|
+
/** @type {string[]} */
|
|
14631
|
+
var matchRet = [match1, group2.match_];
|
|
14632
|
+
return {
|
|
14633
|
+
match_: combine ? matchRet.join("") : matchRet,
|
|
14634
|
+
remainder: group2.remainder
|
|
14635
|
+
};
|
|
14636
|
+
}
|
|
14637
|
+
},
|
|
14638
|
+
//
|
|
14639
|
+
// Matching function
|
|
14640
|
+
// e.g. match("a", input) will look for the regexp called "a" and see if it matches
|
|
14641
|
+
// returns null or {match_:"a", remainder:"bc"}
|
|
14642
|
+
//
|
|
14643
|
+
match_: function (m, input) {
|
|
14644
|
+
var pattern = mhchemParser.patterns.patterns[m];
|
|
14645
|
+
if (pattern === undefined) {
|
|
14646
|
+
throw ["MhchemBugP", "mhchem bug P. Please report. (" + m + ")"]; // Trying to use non-existing pattern
|
|
14647
|
+
} else if (typeof pattern === "function") {
|
|
14648
|
+
return mhchemParser.patterns.patterns[m](input); // cannot use cached var pattern here, because some pattern functions need this===mhchemParser
|
|
14649
|
+
} else {
|
|
14650
|
+
// RegExp
|
|
14651
|
+
var match = input.match(pattern);
|
|
14652
|
+
if (match) {
|
|
14653
|
+
var mm;
|
|
14654
|
+
if (match[2]) {
|
|
14655
|
+
mm = [match[1], match[2]];
|
|
14656
|
+
} else if (match[1]) {
|
|
14657
|
+
mm = match[1];
|
|
14658
|
+
} else {
|
|
14659
|
+
mm = match[0];
|
|
14660
|
+
}
|
|
14661
|
+
return {
|
|
14662
|
+
match_: mm,
|
|
14663
|
+
remainder: input.substr(match[0].length)
|
|
14664
|
+
};
|
|
14665
|
+
}
|
|
14666
|
+
return null;
|
|
14667
|
+
}
|
|
14668
|
+
}
|
|
14669
|
+
},
|
|
14670
|
+
//
|
|
14671
|
+
// Generic state machine actions
|
|
14672
|
+
//
|
|
14673
|
+
actions: {
|
|
14674
|
+
'a=': function (buffer, m) {
|
|
14675
|
+
buffer.a = (buffer.a || "") + m;
|
|
14676
|
+
},
|
|
14677
|
+
'b=': function (buffer, m) {
|
|
14678
|
+
buffer.b = (buffer.b || "") + m;
|
|
14679
|
+
},
|
|
14680
|
+
'p=': function (buffer, m) {
|
|
14681
|
+
buffer.p = (buffer.p || "") + m;
|
|
14682
|
+
},
|
|
14683
|
+
'o=': function (buffer, m) {
|
|
14684
|
+
buffer.o = (buffer.o || "") + m;
|
|
14685
|
+
},
|
|
14686
|
+
'q=': function (buffer, m) {
|
|
14687
|
+
buffer.q = (buffer.q || "") + m;
|
|
14688
|
+
},
|
|
14689
|
+
'd=': function (buffer, m) {
|
|
14690
|
+
buffer.d = (buffer.d || "") + m;
|
|
14691
|
+
},
|
|
14692
|
+
'rm=': function (buffer, m) {
|
|
14693
|
+
buffer.rm = (buffer.rm || "") + m;
|
|
14694
|
+
},
|
|
14695
|
+
'text=': function (buffer, m) {
|
|
14696
|
+
buffer.text_ = (buffer.text_ || "") + m;
|
|
14697
|
+
},
|
|
14698
|
+
'insert': function (buffer, m, a) {
|
|
14699
|
+
return {
|
|
14700
|
+
type_: a
|
|
14701
|
+
};
|
|
14702
|
+
},
|
|
14703
|
+
'insert+p1': function (buffer, m, a) {
|
|
14704
|
+
return {
|
|
14705
|
+
type_: a,
|
|
14706
|
+
p1: m
|
|
14707
|
+
};
|
|
14708
|
+
},
|
|
14709
|
+
'insert+p1+p2': function (buffer, m, a) {
|
|
14710
|
+
return {
|
|
14711
|
+
type_: a,
|
|
14712
|
+
p1: m[0],
|
|
14713
|
+
p2: m[1]
|
|
14714
|
+
};
|
|
14715
|
+
},
|
|
14716
|
+
'copy': function (buffer, m) {
|
|
14717
|
+
return m;
|
|
14718
|
+
},
|
|
14719
|
+
'rm': function (buffer, m) {
|
|
14720
|
+
return {
|
|
14721
|
+
type_: 'rm',
|
|
14722
|
+
p1: m || ""
|
|
14723
|
+
};
|
|
14724
|
+
},
|
|
14725
|
+
'text': function (buffer, m) {
|
|
14726
|
+
return mhchemParser.go(m, 'text');
|
|
14727
|
+
},
|
|
14728
|
+
'{text}': function (buffer, m) {
|
|
14729
|
+
var ret = ["{"];
|
|
14730
|
+
mhchemParser.concatArray(ret, mhchemParser.go(m, 'text'));
|
|
14731
|
+
ret.push("}");
|
|
14732
|
+
return ret;
|
|
14733
|
+
},
|
|
14734
|
+
'tex-math': function (buffer, m) {
|
|
14735
|
+
return mhchemParser.go(m, 'tex-math');
|
|
14736
|
+
},
|
|
14737
|
+
'tex-math tight': function (buffer, m) {
|
|
14738
|
+
return mhchemParser.go(m, 'tex-math tight');
|
|
14739
|
+
},
|
|
14740
|
+
'bond': function (buffer, m, k) {
|
|
14741
|
+
return {
|
|
14742
|
+
type_: 'bond',
|
|
14743
|
+
kind_: k || m
|
|
14744
|
+
};
|
|
14745
|
+
},
|
|
14746
|
+
'color0-output': function (buffer, m) {
|
|
14747
|
+
return {
|
|
14748
|
+
type_: 'color0',
|
|
14749
|
+
color: m[0]
|
|
14750
|
+
};
|
|
14751
|
+
},
|
|
14752
|
+
'ce': function (buffer, m) {
|
|
14753
|
+
return mhchemParser.go(m);
|
|
14754
|
+
},
|
|
14755
|
+
'1/2': function (buffer, m) {
|
|
14756
|
+
/** @type {ParserOutput[]} */
|
|
14757
|
+
var ret = [];
|
|
14758
|
+
if (m.match(/^[+\-]/)) {
|
|
14759
|
+
ret.push(m.substr(0, 1));
|
|
14760
|
+
m = m.substr(1);
|
|
14761
|
+
}
|
|
14762
|
+
var n = m.match(/^([0-9]+|\$[a-z]\$|[a-z])\/([0-9]+)(\$[a-z]\$|[a-z])?$/);
|
|
14763
|
+
n[1] = n[1].replace(/\$/g, "");
|
|
14764
|
+
ret.push({
|
|
14765
|
+
type_: 'frac',
|
|
14766
|
+
p1: n[1],
|
|
14767
|
+
p2: n[2]
|
|
14768
|
+
});
|
|
14769
|
+
if (n[3]) {
|
|
14770
|
+
n[3] = n[3].replace(/\$/g, "");
|
|
14771
|
+
ret.push({
|
|
14772
|
+
type_: 'tex-math',
|
|
14773
|
+
p1: n[3]
|
|
14774
|
+
});
|
|
14775
|
+
}
|
|
14776
|
+
return ret;
|
|
14777
|
+
},
|
|
14778
|
+
'9,9': function (buffer, m) {
|
|
14779
|
+
return mhchemParser.go(m, '9,9');
|
|
14780
|
+
}
|
|
14781
|
+
},
|
|
14782
|
+
//
|
|
14783
|
+
// createTransitions
|
|
14784
|
+
// convert { 'letter': { 'state': { action_: 'output' } } } to { 'state' => [ { pattern: 'letter', task: { action_: [{type_: 'output'}] } } ] }
|
|
14785
|
+
// with expansion of 'a|b' to 'a' and 'b' (at 2 places)
|
|
14786
|
+
//
|
|
14787
|
+
createTransitions: function (o) {
|
|
14788
|
+
var pattern, state;
|
|
14789
|
+
/** @type {string[]} */
|
|
14790
|
+
var stateArray;
|
|
14791
|
+
var i;
|
|
14792
|
+
//
|
|
14793
|
+
// 1. Collect all states
|
|
14794
|
+
//
|
|
14795
|
+
/** @type {Transitions} */
|
|
14796
|
+
var transitions = {};
|
|
14797
|
+
for (pattern in o) {
|
|
14798
|
+
for (state in o[pattern]) {
|
|
14799
|
+
stateArray = state.split("|");
|
|
14800
|
+
o[pattern][state].stateArray = stateArray;
|
|
14801
|
+
for (i = 0; i < stateArray.length; i++) {
|
|
14802
|
+
transitions[stateArray[i]] = [];
|
|
14803
|
+
}
|
|
14804
|
+
}
|
|
14805
|
+
}
|
|
14806
|
+
//
|
|
14807
|
+
// 2. Fill states
|
|
14808
|
+
//
|
|
14809
|
+
for (pattern in o) {
|
|
14810
|
+
for (state in o[pattern]) {
|
|
14811
|
+
stateArray = o[pattern][state].stateArray || [];
|
|
14812
|
+
for (i = 0; i < stateArray.length; i++) {
|
|
14813
|
+
//
|
|
14814
|
+
// 2a. Normalize actions into array: 'text=' ==> [{type_:'text='}]
|
|
14815
|
+
// (Note to myself: Resolving the function here would be problematic. It would need .bind (for *this*) and currying (for *option*).)
|
|
14816
|
+
//
|
|
14817
|
+
/** @type {any} */
|
|
14818
|
+
var p = o[pattern][state];
|
|
14819
|
+
if (p.action_) {
|
|
14820
|
+
p.action_ = [].concat(p.action_);
|
|
14821
|
+
for (var k = 0; k < p.action_.length; k++) {
|
|
14822
|
+
if (typeof p.action_[k] === "string") {
|
|
14823
|
+
p.action_[k] = {
|
|
14824
|
+
type_: p.action_[k]
|
|
14825
|
+
};
|
|
14826
|
+
}
|
|
14827
|
+
}
|
|
14828
|
+
} else {
|
|
14829
|
+
p.action_ = [];
|
|
14830
|
+
}
|
|
14831
|
+
//
|
|
14832
|
+
// 2.b Multi-insert
|
|
14833
|
+
//
|
|
14834
|
+
var patternArray = pattern.split("|");
|
|
14835
|
+
for (var j = 0; j < patternArray.length; j++) {
|
|
14836
|
+
if (stateArray[i] === '*') {
|
|
14837
|
+
// insert into all
|
|
14838
|
+
for (var t in transitions) {
|
|
14839
|
+
transitions[t].push({
|
|
14840
|
+
pattern: patternArray[j],
|
|
14841
|
+
task: p
|
|
14842
|
+
});
|
|
14843
|
+
}
|
|
14844
|
+
} else {
|
|
14845
|
+
transitions[stateArray[i]].push({
|
|
14846
|
+
pattern: patternArray[j],
|
|
14847
|
+
task: p
|
|
14848
|
+
});
|
|
14849
|
+
}
|
|
14850
|
+
}
|
|
14851
|
+
}
|
|
14852
|
+
}
|
|
14853
|
+
}
|
|
14854
|
+
return transitions;
|
|
14855
|
+
},
|
|
14856
|
+
stateMachines: {}
|
|
14857
|
+
};
|
|
14858
|
+
|
|
14859
|
+
//
|
|
14860
|
+
// Definition of state machines
|
|
14861
|
+
//
|
|
14862
|
+
mhchemParser.stateMachines = {
|
|
14863
|
+
//
|
|
14864
|
+
// \ce state machines
|
|
14865
|
+
//
|
|
14866
|
+
//#region ce
|
|
14867
|
+
'ce': {
|
|
14868
|
+
// main parser
|
|
14869
|
+
transitions: mhchemParser.createTransitions({
|
|
14870
|
+
'empty': {
|
|
14871
|
+
'*': {
|
|
14872
|
+
action_: 'output'
|
|
14873
|
+
}
|
|
14874
|
+
},
|
|
14875
|
+
'else': {
|
|
14876
|
+
'0|1|2': {
|
|
14877
|
+
action_: 'beginsWithBond=false',
|
|
14878
|
+
revisit: true,
|
|
14879
|
+
toContinue: true
|
|
14880
|
+
}
|
|
14881
|
+
},
|
|
14882
|
+
'oxidation$': {
|
|
14883
|
+
'0': {
|
|
14884
|
+
action_: 'oxidation-output'
|
|
14885
|
+
}
|
|
14886
|
+
},
|
|
14887
|
+
'CMT': {
|
|
14888
|
+
'r': {
|
|
14889
|
+
action_: 'rdt=',
|
|
14890
|
+
nextState: 'rt'
|
|
14891
|
+
},
|
|
14892
|
+
'rd': {
|
|
14893
|
+
action_: 'rqt=',
|
|
14894
|
+
nextState: 'rdt'
|
|
14895
|
+
}
|
|
14896
|
+
},
|
|
14897
|
+
'arrowUpDown': {
|
|
14898
|
+
'0|1|2|as': {
|
|
14899
|
+
action_: ['sb=false', 'output', 'operator'],
|
|
14900
|
+
nextState: '1'
|
|
14901
|
+
}
|
|
14902
|
+
},
|
|
14903
|
+
'uprightEntities': {
|
|
14904
|
+
'0|1|2': {
|
|
14905
|
+
action_: ['o=', 'output'],
|
|
14906
|
+
nextState: '1'
|
|
14907
|
+
}
|
|
14908
|
+
},
|
|
14909
|
+
'orbital': {
|
|
14910
|
+
'0|1|2|3': {
|
|
14911
|
+
action_: 'o=',
|
|
14912
|
+
nextState: 'o'
|
|
14913
|
+
}
|
|
14914
|
+
},
|
|
14915
|
+
'->': {
|
|
14916
|
+
'0|1|2|3': {
|
|
14917
|
+
action_: 'r=',
|
|
14918
|
+
nextState: 'r'
|
|
14919
|
+
},
|
|
14920
|
+
'a|as': {
|
|
14921
|
+
action_: ['output', 'r='],
|
|
14922
|
+
nextState: 'r'
|
|
14923
|
+
},
|
|
14924
|
+
'*': {
|
|
14925
|
+
action_: ['output', 'r='],
|
|
14926
|
+
nextState: 'r'
|
|
14927
|
+
}
|
|
14928
|
+
},
|
|
14929
|
+
'+': {
|
|
14930
|
+
'o': {
|
|
14931
|
+
action_: 'd= kv',
|
|
14932
|
+
nextState: 'd'
|
|
14933
|
+
},
|
|
14934
|
+
'd|D': {
|
|
14935
|
+
action_: 'd=',
|
|
14936
|
+
nextState: 'd'
|
|
14937
|
+
},
|
|
14938
|
+
'q': {
|
|
14939
|
+
action_: 'd=',
|
|
14940
|
+
nextState: 'qd'
|
|
14941
|
+
},
|
|
14942
|
+
'qd|qD': {
|
|
14943
|
+
action_: 'd=',
|
|
14944
|
+
nextState: 'qd'
|
|
14945
|
+
},
|
|
14946
|
+
'dq': {
|
|
14947
|
+
action_: ['output', 'd='],
|
|
14948
|
+
nextState: 'd'
|
|
14949
|
+
},
|
|
14950
|
+
'3': {
|
|
14951
|
+
action_: ['sb=false', 'output', 'operator'],
|
|
14952
|
+
nextState: '0'
|
|
14953
|
+
}
|
|
14954
|
+
},
|
|
14955
|
+
'amount': {
|
|
14956
|
+
'0|2': {
|
|
14957
|
+
action_: 'a=',
|
|
14958
|
+
nextState: 'a'
|
|
14959
|
+
}
|
|
14960
|
+
},
|
|
14961
|
+
'pm-operator': {
|
|
14962
|
+
'0|1|2|a|as': {
|
|
14963
|
+
action_: ['sb=false', 'output', {
|
|
14964
|
+
type_: 'operator',
|
|
14965
|
+
option: '\\pm'
|
|
14966
|
+
}],
|
|
14967
|
+
nextState: '0'
|
|
14968
|
+
}
|
|
14969
|
+
},
|
|
14970
|
+
'operator': {
|
|
14971
|
+
'0|1|2|a|as': {
|
|
14972
|
+
action_: ['sb=false', 'output', 'operator'],
|
|
14973
|
+
nextState: '0'
|
|
14974
|
+
}
|
|
14975
|
+
},
|
|
14976
|
+
'-$': {
|
|
14977
|
+
'o|q': {
|
|
14978
|
+
action_: ['charge or bond', 'output'],
|
|
14979
|
+
nextState: 'qd'
|
|
14980
|
+
},
|
|
14981
|
+
'd': {
|
|
14982
|
+
action_: 'd=',
|
|
14983
|
+
nextState: 'd'
|
|
14984
|
+
},
|
|
14985
|
+
'D': {
|
|
14986
|
+
action_: ['output', {
|
|
14987
|
+
type_: 'bond',
|
|
14988
|
+
option: "-"
|
|
14989
|
+
}],
|
|
14990
|
+
nextState: '3'
|
|
14991
|
+
},
|
|
14992
|
+
'q': {
|
|
14993
|
+
action_: 'd=',
|
|
14994
|
+
nextState: 'qd'
|
|
14995
|
+
},
|
|
14996
|
+
'qd': {
|
|
14997
|
+
action_: 'd=',
|
|
14998
|
+
nextState: 'qd'
|
|
14999
|
+
},
|
|
15000
|
+
'qD|dq': {
|
|
15001
|
+
action_: ['output', {
|
|
15002
|
+
type_: 'bond',
|
|
15003
|
+
option: "-"
|
|
15004
|
+
}],
|
|
15005
|
+
nextState: '3'
|
|
15006
|
+
}
|
|
15007
|
+
},
|
|
15008
|
+
'-9': {
|
|
15009
|
+
'3|o': {
|
|
15010
|
+
action_: ['output', {
|
|
15011
|
+
type_: 'insert',
|
|
15012
|
+
option: 'hyphen'
|
|
15013
|
+
}],
|
|
15014
|
+
nextState: '3'
|
|
15015
|
+
}
|
|
15016
|
+
},
|
|
15017
|
+
'- orbital overlap': {
|
|
15018
|
+
'o': {
|
|
15019
|
+
action_: ['output', {
|
|
15020
|
+
type_: 'insert',
|
|
15021
|
+
option: 'hyphen'
|
|
15022
|
+
}],
|
|
15023
|
+
nextState: '2'
|
|
15024
|
+
},
|
|
15025
|
+
'd': {
|
|
15026
|
+
action_: ['output', {
|
|
15027
|
+
type_: 'insert',
|
|
15028
|
+
option: 'hyphen'
|
|
15029
|
+
}],
|
|
15030
|
+
nextState: '2'
|
|
15031
|
+
}
|
|
15032
|
+
},
|
|
15033
|
+
'-': {
|
|
15034
|
+
'0|1|2': {
|
|
15035
|
+
action_: [{
|
|
15036
|
+
type_: 'output',
|
|
15037
|
+
option: 1
|
|
15038
|
+
}, 'beginsWithBond=true', {
|
|
15039
|
+
type_: 'bond',
|
|
15040
|
+
option: "-"
|
|
15041
|
+
}],
|
|
15042
|
+
nextState: '3'
|
|
15043
|
+
},
|
|
15044
|
+
'3': {
|
|
15045
|
+
action_: {
|
|
15046
|
+
type_: 'bond',
|
|
15047
|
+
option: "-"
|
|
15048
|
+
}
|
|
15049
|
+
},
|
|
15050
|
+
'a': {
|
|
15051
|
+
action_: ['output', {
|
|
15052
|
+
type_: 'insert',
|
|
15053
|
+
option: 'hyphen'
|
|
15054
|
+
}],
|
|
15055
|
+
nextState: '2'
|
|
15056
|
+
},
|
|
15057
|
+
'as': {
|
|
15058
|
+
action_: [{
|
|
15059
|
+
type_: 'output',
|
|
15060
|
+
option: 2
|
|
15061
|
+
}, {
|
|
15062
|
+
type_: 'bond',
|
|
15063
|
+
option: "-"
|
|
15064
|
+
}],
|
|
15065
|
+
nextState: '3'
|
|
15066
|
+
},
|
|
15067
|
+
'b': {
|
|
15068
|
+
action_: 'b='
|
|
15069
|
+
},
|
|
15070
|
+
'o': {
|
|
15071
|
+
action_: {
|
|
15072
|
+
type_: '- after o/d',
|
|
15073
|
+
option: false
|
|
15074
|
+
},
|
|
15075
|
+
nextState: '2'
|
|
15076
|
+
},
|
|
15077
|
+
'q': {
|
|
15078
|
+
action_: {
|
|
15079
|
+
type_: '- after o/d',
|
|
15080
|
+
option: false
|
|
15081
|
+
},
|
|
15082
|
+
nextState: '2'
|
|
15083
|
+
},
|
|
15084
|
+
'd|qd|dq': {
|
|
15085
|
+
action_: {
|
|
15086
|
+
type_: '- after o/d',
|
|
15087
|
+
option: true
|
|
15088
|
+
},
|
|
15089
|
+
nextState: '2'
|
|
15090
|
+
},
|
|
15091
|
+
'D|qD|p': {
|
|
15092
|
+
action_: ['output', {
|
|
15093
|
+
type_: 'bond',
|
|
15094
|
+
option: "-"
|
|
15095
|
+
}],
|
|
15096
|
+
nextState: '3'
|
|
15097
|
+
}
|
|
15098
|
+
},
|
|
15099
|
+
'amount2': {
|
|
15100
|
+
'1|3': {
|
|
15101
|
+
action_: 'a=',
|
|
15102
|
+
nextState: 'a'
|
|
15103
|
+
}
|
|
15104
|
+
},
|
|
15105
|
+
'letters': {
|
|
15106
|
+
'0|1|2|3|a|as|b|p|bp|o': {
|
|
15107
|
+
action_: 'o=',
|
|
15108
|
+
nextState: 'o'
|
|
15109
|
+
},
|
|
15110
|
+
'q|dq': {
|
|
15111
|
+
action_: ['output', 'o='],
|
|
15112
|
+
nextState: 'o'
|
|
15113
|
+
},
|
|
15114
|
+
'd|D|qd|qD': {
|
|
15115
|
+
action_: 'o after d',
|
|
15116
|
+
nextState: 'o'
|
|
15117
|
+
}
|
|
15118
|
+
},
|
|
15119
|
+
'digits': {
|
|
15120
|
+
'o': {
|
|
15121
|
+
action_: 'q=',
|
|
15122
|
+
nextState: 'q'
|
|
15123
|
+
},
|
|
15124
|
+
'd|D': {
|
|
15125
|
+
action_: 'q=',
|
|
15126
|
+
nextState: 'dq'
|
|
15127
|
+
},
|
|
15128
|
+
'q': {
|
|
15129
|
+
action_: ['output', 'o='],
|
|
15130
|
+
nextState: 'o'
|
|
15131
|
+
},
|
|
15132
|
+
'a': {
|
|
15133
|
+
action_: 'o=',
|
|
15134
|
+
nextState: 'o'
|
|
15135
|
+
}
|
|
15136
|
+
},
|
|
15137
|
+
'space A': {
|
|
15138
|
+
'b|p|bp': {}
|
|
15139
|
+
},
|
|
15140
|
+
'space': {
|
|
15141
|
+
'a': {
|
|
15142
|
+
nextState: 'as'
|
|
15143
|
+
},
|
|
15144
|
+
'0': {
|
|
15145
|
+
action_: 'sb=false'
|
|
15146
|
+
},
|
|
15147
|
+
'1|2': {
|
|
15148
|
+
action_: 'sb=true'
|
|
15149
|
+
},
|
|
15150
|
+
'r|rt|rd|rdt|rdq': {
|
|
15151
|
+
action_: 'output',
|
|
15152
|
+
nextState: '0'
|
|
15153
|
+
},
|
|
15154
|
+
'*': {
|
|
15155
|
+
action_: ['output', 'sb=true'],
|
|
15156
|
+
nextState: '1'
|
|
15157
|
+
}
|
|
15158
|
+
},
|
|
15159
|
+
'1st-level escape': {
|
|
15160
|
+
'1|2': {
|
|
15161
|
+
action_: ['output', {
|
|
15162
|
+
type_: 'insert+p1',
|
|
15163
|
+
option: '1st-level escape'
|
|
15164
|
+
}]
|
|
15165
|
+
},
|
|
15166
|
+
'*': {
|
|
15167
|
+
action_: ['output', {
|
|
15168
|
+
type_: 'insert+p1',
|
|
15169
|
+
option: '1st-level escape'
|
|
15170
|
+
}],
|
|
15171
|
+
nextState: '0'
|
|
15172
|
+
}
|
|
15173
|
+
},
|
|
15174
|
+
'[(...)]': {
|
|
15175
|
+
'r|rt': {
|
|
15176
|
+
action_: 'rd=',
|
|
15177
|
+
nextState: 'rd'
|
|
15178
|
+
},
|
|
15179
|
+
'rd|rdt': {
|
|
15180
|
+
action_: 'rq=',
|
|
15181
|
+
nextState: 'rdq'
|
|
15182
|
+
}
|
|
15183
|
+
},
|
|
15184
|
+
'...': {
|
|
15185
|
+
'o|d|D|dq|qd|qD': {
|
|
15186
|
+
action_: ['output', {
|
|
15187
|
+
type_: 'bond',
|
|
15188
|
+
option: "..."
|
|
15189
|
+
}],
|
|
15190
|
+
nextState: '3'
|
|
15191
|
+
},
|
|
15192
|
+
'*': {
|
|
15193
|
+
action_: [{
|
|
15194
|
+
type_: 'output',
|
|
15195
|
+
option: 1
|
|
15196
|
+
}, {
|
|
15197
|
+
type_: 'insert',
|
|
15198
|
+
option: 'ellipsis'
|
|
15199
|
+
}],
|
|
15200
|
+
nextState: '1'
|
|
15201
|
+
}
|
|
15202
|
+
},
|
|
15203
|
+
'. |* ': {
|
|
15204
|
+
'*': {
|
|
15205
|
+
action_: ['output', {
|
|
15206
|
+
type_: 'insert',
|
|
15207
|
+
option: 'addition compound'
|
|
15208
|
+
}],
|
|
15209
|
+
nextState: '1'
|
|
15210
|
+
}
|
|
15211
|
+
},
|
|
15212
|
+
'state of aggregation $': {
|
|
15213
|
+
'*': {
|
|
15214
|
+
action_: ['output', 'state of aggregation'],
|
|
15215
|
+
nextState: '1'
|
|
15216
|
+
}
|
|
15217
|
+
},
|
|
15218
|
+
'{[(': {
|
|
15219
|
+
'a|as|o': {
|
|
15220
|
+
action_: ['o=', 'output', 'parenthesisLevel++'],
|
|
15221
|
+
nextState: '2'
|
|
15222
|
+
},
|
|
15223
|
+
'0|1|2|3': {
|
|
15224
|
+
action_: ['o=', 'output', 'parenthesisLevel++'],
|
|
15225
|
+
nextState: '2'
|
|
15226
|
+
},
|
|
15227
|
+
'*': {
|
|
15228
|
+
action_: ['output', 'o=', 'output', 'parenthesisLevel++'],
|
|
15229
|
+
nextState: '2'
|
|
15230
|
+
}
|
|
15231
|
+
},
|
|
15232
|
+
')]}': {
|
|
15233
|
+
'0|1|2|3|b|p|bp|o': {
|
|
15234
|
+
action_: ['o=', 'parenthesisLevel--'],
|
|
15235
|
+
nextState: 'o'
|
|
15236
|
+
},
|
|
15237
|
+
'a|as|d|D|q|qd|qD|dq': {
|
|
15238
|
+
action_: ['output', 'o=', 'parenthesisLevel--'],
|
|
15239
|
+
nextState: 'o'
|
|
15240
|
+
}
|
|
15241
|
+
},
|
|
15242
|
+
', ': {
|
|
15243
|
+
'*': {
|
|
15244
|
+
action_: ['output', 'comma'],
|
|
15245
|
+
nextState: '0'
|
|
15246
|
+
}
|
|
15247
|
+
},
|
|
15248
|
+
'^_': {
|
|
15249
|
+
// ^ and _ without a sensible argument
|
|
15250
|
+
'*': {}
|
|
15251
|
+
},
|
|
15252
|
+
'^{(...)}|^($...$)': {
|
|
15253
|
+
'0|1|2|as': {
|
|
15254
|
+
action_: 'b=',
|
|
15255
|
+
nextState: 'b'
|
|
15256
|
+
},
|
|
15257
|
+
'p': {
|
|
15258
|
+
action_: 'b=',
|
|
15259
|
+
nextState: 'bp'
|
|
15260
|
+
},
|
|
15261
|
+
'3|o': {
|
|
15262
|
+
action_: 'd= kv',
|
|
15263
|
+
nextState: 'D'
|
|
15264
|
+
},
|
|
15265
|
+
'q': {
|
|
15266
|
+
action_: 'd=',
|
|
15267
|
+
nextState: 'qD'
|
|
15268
|
+
},
|
|
15269
|
+
'd|D|qd|qD|dq': {
|
|
15270
|
+
action_: ['output', 'd='],
|
|
15271
|
+
nextState: 'D'
|
|
15272
|
+
}
|
|
15273
|
+
},
|
|
15274
|
+
'^a|^\\x{}{}|^\\x{}|^\\x|\'': {
|
|
15275
|
+
'0|1|2|as': {
|
|
15276
|
+
action_: 'b=',
|
|
15277
|
+
nextState: 'b'
|
|
15278
|
+
},
|
|
15279
|
+
'p': {
|
|
15280
|
+
action_: 'b=',
|
|
15281
|
+
nextState: 'bp'
|
|
15282
|
+
},
|
|
15283
|
+
'3|o': {
|
|
15284
|
+
action_: 'd= kv',
|
|
15285
|
+
nextState: 'd'
|
|
15286
|
+
},
|
|
15287
|
+
'q': {
|
|
15288
|
+
action_: 'd=',
|
|
15289
|
+
nextState: 'qd'
|
|
15290
|
+
},
|
|
15291
|
+
'd|qd|D|qD': {
|
|
15292
|
+
action_: 'd='
|
|
15293
|
+
},
|
|
15294
|
+
'dq': {
|
|
15295
|
+
action_: ['output', 'd='],
|
|
15296
|
+
nextState: 'd'
|
|
15297
|
+
}
|
|
15298
|
+
},
|
|
15299
|
+
'_{(state of aggregation)}$': {
|
|
15300
|
+
'd|D|q|qd|qD|dq': {
|
|
15301
|
+
action_: ['output', 'q='],
|
|
15302
|
+
nextState: 'q'
|
|
15303
|
+
}
|
|
15304
|
+
},
|
|
15305
|
+
'_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x': {
|
|
15306
|
+
'0|1|2|as': {
|
|
15307
|
+
action_: 'p=',
|
|
15308
|
+
nextState: 'p'
|
|
15309
|
+
},
|
|
15310
|
+
'b': {
|
|
15311
|
+
action_: 'p=',
|
|
15312
|
+
nextState: 'bp'
|
|
15313
|
+
},
|
|
15314
|
+
'3|o': {
|
|
15315
|
+
action_: 'q=',
|
|
15316
|
+
nextState: 'q'
|
|
15317
|
+
},
|
|
15318
|
+
'd|D': {
|
|
15319
|
+
action_: 'q=',
|
|
15320
|
+
nextState: 'dq'
|
|
15321
|
+
},
|
|
15322
|
+
'q|qd|qD|dq': {
|
|
15323
|
+
action_: ['output', 'q='],
|
|
15324
|
+
nextState: 'q'
|
|
15325
|
+
}
|
|
15326
|
+
},
|
|
15327
|
+
'=<>': {
|
|
15328
|
+
'0|1|2|3|a|as|o|q|d|D|qd|qD|dq': {
|
|
15329
|
+
action_: [{
|
|
15330
|
+
type_: 'output',
|
|
15331
|
+
option: 2
|
|
15332
|
+
}, 'bond'],
|
|
15333
|
+
nextState: '3'
|
|
15334
|
+
}
|
|
15335
|
+
},
|
|
15336
|
+
'#': {
|
|
15337
|
+
'0|1|2|3|a|as|o': {
|
|
15338
|
+
action_: [{
|
|
15339
|
+
type_: 'output',
|
|
15340
|
+
option: 2
|
|
15341
|
+
}, {
|
|
15342
|
+
type_: 'bond',
|
|
15343
|
+
option: "#"
|
|
15344
|
+
}],
|
|
15345
|
+
nextState: '3'
|
|
15346
|
+
}
|
|
15347
|
+
},
|
|
15348
|
+
'{}': {
|
|
15349
|
+
'*': {
|
|
15350
|
+
action_: {
|
|
15351
|
+
type_: 'output',
|
|
15352
|
+
option: 1
|
|
15353
|
+
},
|
|
15354
|
+
nextState: '1'
|
|
15355
|
+
}
|
|
15356
|
+
},
|
|
15357
|
+
'{...}': {
|
|
15358
|
+
'0|1|2|3|a|as|b|p|bp': {
|
|
15359
|
+
action_: 'o=',
|
|
15360
|
+
nextState: 'o'
|
|
15361
|
+
},
|
|
15362
|
+
'o|d|D|q|qd|qD|dq': {
|
|
15363
|
+
action_: ['output', 'o='],
|
|
15364
|
+
nextState: 'o'
|
|
15365
|
+
}
|
|
15366
|
+
},
|
|
15367
|
+
'$...$': {
|
|
15368
|
+
'a': {
|
|
15369
|
+
action_: 'a='
|
|
15370
|
+
},
|
|
15371
|
+
// 2$n$
|
|
15372
|
+
'0|1|2|3|as|b|p|bp|o': {
|
|
15373
|
+
action_: 'o=',
|
|
15374
|
+
nextState: 'o'
|
|
15375
|
+
},
|
|
15376
|
+
// not 'amount'
|
|
15377
|
+
'as|o': {
|
|
15378
|
+
action_: 'o='
|
|
15379
|
+
},
|
|
15380
|
+
'q|d|D|qd|qD|dq': {
|
|
15381
|
+
action_: ['output', 'o='],
|
|
15382
|
+
nextState: 'o'
|
|
15383
|
+
}
|
|
15384
|
+
},
|
|
15385
|
+
'\\bond{(...)}': {
|
|
15386
|
+
'*': {
|
|
15387
|
+
action_: [{
|
|
15388
|
+
type_: 'output',
|
|
15389
|
+
option: 2
|
|
15390
|
+
}, 'bond'],
|
|
15391
|
+
nextState: "3"
|
|
15392
|
+
}
|
|
15393
|
+
},
|
|
15394
|
+
'\\frac{(...)}': {
|
|
15395
|
+
'*': {
|
|
15396
|
+
action_: [{
|
|
15397
|
+
type_: 'output',
|
|
15398
|
+
option: 1
|
|
15399
|
+
}, 'frac-output'],
|
|
15400
|
+
nextState: '3'
|
|
15401
|
+
}
|
|
15402
|
+
},
|
|
15403
|
+
'\\overset{(...)}': {
|
|
15404
|
+
'*': {
|
|
15405
|
+
action_: [{
|
|
15406
|
+
type_: 'output',
|
|
15407
|
+
option: 2
|
|
15408
|
+
}, 'overset-output'],
|
|
15409
|
+
nextState: '3'
|
|
15410
|
+
}
|
|
15411
|
+
},
|
|
15412
|
+
'\\underset{(...)}': {
|
|
15413
|
+
'*': {
|
|
15414
|
+
action_: [{
|
|
15415
|
+
type_: 'output',
|
|
15416
|
+
option: 2
|
|
15417
|
+
}, 'underset-output'],
|
|
15418
|
+
nextState: '3'
|
|
15419
|
+
}
|
|
15420
|
+
},
|
|
15421
|
+
'\\underbrace{(...)}': {
|
|
15422
|
+
'*': {
|
|
15423
|
+
action_: [{
|
|
15424
|
+
type_: 'output',
|
|
15425
|
+
option: 2
|
|
15426
|
+
}, 'underbrace-output'],
|
|
15427
|
+
nextState: '3'
|
|
15428
|
+
}
|
|
15429
|
+
},
|
|
15430
|
+
'\\color{(...)}{(...)}1|\\color(...){(...)}2': {
|
|
15431
|
+
'*': {
|
|
15432
|
+
action_: [{
|
|
15433
|
+
type_: 'output',
|
|
15434
|
+
option: 2
|
|
15435
|
+
}, 'color-output'],
|
|
15436
|
+
nextState: '3'
|
|
15437
|
+
}
|
|
15438
|
+
},
|
|
15439
|
+
'\\color{(...)}0': {
|
|
15440
|
+
'*': {
|
|
15441
|
+
action_: [{
|
|
15442
|
+
type_: 'output',
|
|
15443
|
+
option: 2
|
|
15444
|
+
}, 'color0-output']
|
|
15445
|
+
}
|
|
15446
|
+
},
|
|
15447
|
+
'\\ce{(...)}': {
|
|
15448
|
+
'*': {
|
|
15449
|
+
action_: [{
|
|
15450
|
+
type_: 'output',
|
|
15451
|
+
option: 2
|
|
15452
|
+
}, 'ce'],
|
|
15453
|
+
nextState: '3'
|
|
15454
|
+
}
|
|
15455
|
+
},
|
|
15456
|
+
'\\,': {
|
|
15457
|
+
'*': {
|
|
15458
|
+
action_: [{
|
|
15459
|
+
type_: 'output',
|
|
15460
|
+
option: 1
|
|
15461
|
+
}, 'copy'],
|
|
15462
|
+
nextState: '1'
|
|
15463
|
+
}
|
|
15464
|
+
},
|
|
15465
|
+
'\\x{}{}|\\x{}|\\x': {
|
|
15466
|
+
'0|1|2|3|a|as|b|p|bp|o|c0': {
|
|
15467
|
+
action_: ['o=', 'output'],
|
|
15468
|
+
nextState: '3'
|
|
15469
|
+
},
|
|
15470
|
+
'*': {
|
|
15471
|
+
action_: ['output', 'o=', 'output'],
|
|
15472
|
+
nextState: '3'
|
|
15473
|
+
}
|
|
15474
|
+
},
|
|
15475
|
+
'others': {
|
|
15476
|
+
'*': {
|
|
15477
|
+
action_: [{
|
|
15478
|
+
type_: 'output',
|
|
15479
|
+
option: 1
|
|
15480
|
+
}, 'copy'],
|
|
15481
|
+
nextState: '3'
|
|
15482
|
+
}
|
|
15483
|
+
},
|
|
15484
|
+
'else2': {
|
|
15485
|
+
'a': {
|
|
15486
|
+
action_: 'a to o',
|
|
15487
|
+
nextState: 'o',
|
|
15488
|
+
revisit: true
|
|
15489
|
+
},
|
|
15490
|
+
'as': {
|
|
15491
|
+
action_: ['output', 'sb=true'],
|
|
15492
|
+
nextState: '1',
|
|
15493
|
+
revisit: true
|
|
15494
|
+
},
|
|
15495
|
+
'r|rt|rd|rdt|rdq': {
|
|
15496
|
+
action_: ['output'],
|
|
15497
|
+
nextState: '0',
|
|
15498
|
+
revisit: true
|
|
15499
|
+
},
|
|
15500
|
+
'*': {
|
|
15501
|
+
action_: ['output', 'copy'],
|
|
15502
|
+
nextState: '3'
|
|
15503
|
+
}
|
|
15504
|
+
}
|
|
15505
|
+
}),
|
|
15506
|
+
actions: {
|
|
15507
|
+
'o after d': function (buffer, m) {
|
|
15508
|
+
var ret;
|
|
15509
|
+
if ((buffer.d || "").match(/^[0-9]+$/)) {
|
|
15510
|
+
var tmp = buffer.d;
|
|
15511
|
+
buffer.d = undefined;
|
|
15512
|
+
ret = this['output'](buffer);
|
|
15513
|
+
buffer.b = tmp;
|
|
15514
|
+
} else {
|
|
15515
|
+
ret = this['output'](buffer);
|
|
15516
|
+
}
|
|
15517
|
+
mhchemParser.actions['o='](buffer, m);
|
|
15518
|
+
return ret;
|
|
15519
|
+
},
|
|
15520
|
+
'd= kv': function (buffer, m) {
|
|
15521
|
+
buffer.d = m;
|
|
15522
|
+
buffer.dType = 'kv';
|
|
15523
|
+
},
|
|
15524
|
+
'charge or bond': function (buffer, m) {
|
|
15525
|
+
if (buffer['beginsWithBond']) {
|
|
15526
|
+
/** @type {ParserOutput[]} */
|
|
15527
|
+
var ret = [];
|
|
15528
|
+
mhchemParser.concatArray(ret, this['output'](buffer));
|
|
15529
|
+
mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-"));
|
|
15530
|
+
return ret;
|
|
15531
|
+
} else {
|
|
15532
|
+
buffer.d = m;
|
|
15533
|
+
}
|
|
15534
|
+
},
|
|
15535
|
+
'- after o/d': function (buffer, m, isAfterD) {
|
|
15536
|
+
var c1 = mhchemParser.patterns.match_('orbital', buffer.o || "");
|
|
15537
|
+
var c2 = mhchemParser.patterns.match_('one lowercase greek letter $', buffer.o || "");
|
|
15538
|
+
var c3 = mhchemParser.patterns.match_('one lowercase latin letter $', buffer.o || "");
|
|
15539
|
+
var c4 = mhchemParser.patterns.match_('$one lowercase latin letter$ $', buffer.o || "");
|
|
15540
|
+
var hyphenFollows = m === "-" && (c1 && c1.remainder === "" || c2 || c3 || c4);
|
|
15541
|
+
if (hyphenFollows && !buffer.a && !buffer.b && !buffer.p && !buffer.d && !buffer.q && !c1 && c3) {
|
|
15542
|
+
buffer.o = '$' + buffer.o + '$';
|
|
15543
|
+
}
|
|
15544
|
+
/** @type {ParserOutput[]} */
|
|
15545
|
+
var ret = [];
|
|
15546
|
+
if (hyphenFollows) {
|
|
15547
|
+
mhchemParser.concatArray(ret, this['output'](buffer));
|
|
15548
|
+
ret.push({
|
|
15549
|
+
type_: 'hyphen'
|
|
15550
|
+
});
|
|
15551
|
+
} else {
|
|
15552
|
+
c1 = mhchemParser.patterns.match_('digits', buffer.d || "");
|
|
15553
|
+
if (isAfterD && c1 && c1.remainder === '') {
|
|
15554
|
+
mhchemParser.concatArray(ret, mhchemParser.actions['d='](buffer, m));
|
|
15555
|
+
mhchemParser.concatArray(ret, this['output'](buffer));
|
|
15556
|
+
} else {
|
|
15557
|
+
mhchemParser.concatArray(ret, this['output'](buffer));
|
|
15558
|
+
mhchemParser.concatArray(ret, mhchemParser.actions['bond'](buffer, m, "-"));
|
|
15559
|
+
}
|
|
15560
|
+
}
|
|
15561
|
+
return ret;
|
|
15562
|
+
},
|
|
15563
|
+
'a to o': function (buffer) {
|
|
15564
|
+
buffer.o = buffer.a;
|
|
15565
|
+
buffer.a = undefined;
|
|
15566
|
+
},
|
|
15567
|
+
'sb=true': function (buffer) {
|
|
15568
|
+
buffer.sb = true;
|
|
15569
|
+
},
|
|
15570
|
+
'sb=false': function (buffer) {
|
|
15571
|
+
buffer.sb = false;
|
|
15572
|
+
},
|
|
15573
|
+
'beginsWithBond=true': function (buffer) {
|
|
15574
|
+
buffer['beginsWithBond'] = true;
|
|
15575
|
+
},
|
|
15576
|
+
'beginsWithBond=false': function (buffer) {
|
|
15577
|
+
buffer['beginsWithBond'] = false;
|
|
15578
|
+
},
|
|
15579
|
+
'parenthesisLevel++': function (buffer) {
|
|
15580
|
+
buffer['parenthesisLevel']++;
|
|
15581
|
+
},
|
|
15582
|
+
'parenthesisLevel--': function (buffer) {
|
|
15583
|
+
buffer['parenthesisLevel']--;
|
|
15584
|
+
},
|
|
15585
|
+
'state of aggregation': function (buffer, m) {
|
|
15586
|
+
return {
|
|
15587
|
+
type_: 'state of aggregation',
|
|
15588
|
+
p1: mhchemParser.go(m, 'o')
|
|
15589
|
+
};
|
|
15590
|
+
},
|
|
15591
|
+
'comma': function (buffer, m) {
|
|
15592
|
+
var a = m.replace(/\s*$/, '');
|
|
15593
|
+
var withSpace = a !== m;
|
|
15594
|
+
if (withSpace && buffer['parenthesisLevel'] === 0) {
|
|
15595
|
+
return {
|
|
15596
|
+
type_: 'comma enumeration L',
|
|
15597
|
+
p1: a
|
|
15598
|
+
};
|
|
15599
|
+
} else {
|
|
15600
|
+
return {
|
|
15601
|
+
type_: 'comma enumeration M',
|
|
15602
|
+
p1: a
|
|
15603
|
+
};
|
|
15604
|
+
}
|
|
15605
|
+
},
|
|
15606
|
+
'output': function (buffer, m, entityFollows) {
|
|
15607
|
+
// entityFollows:
|
|
15608
|
+
// undefined = if we have nothing else to output, also ignore the just read space (buffer.sb)
|
|
15609
|
+
// 1 = an entity follows, never omit the space if there was one just read before (can only apply to state 1)
|
|
15610
|
+
// 2 = 1 + the entity can have an amount, so output a\, instead of converting it to o (can only apply to states a|as)
|
|
15611
|
+
/** @type {ParserOutput | ParserOutput[]} */
|
|
15612
|
+
var ret;
|
|
15613
|
+
if (!buffer.r) {
|
|
15614
|
+
ret = [];
|
|
15615
|
+
if (!buffer.a && !buffer.b && !buffer.p && !buffer.o && !buffer.q && !buffer.d && !entityFollows) {
|
|
15616
|
+
//ret = [];
|
|
15617
|
+
} else {
|
|
15618
|
+
if (buffer.sb) {
|
|
15619
|
+
ret.push({
|
|
15620
|
+
type_: 'entitySkip'
|
|
15621
|
+
});
|
|
15622
|
+
}
|
|
15623
|
+
if (!buffer.o && !buffer.q && !buffer.d && !buffer.b && !buffer.p && entityFollows !== 2) {
|
|
15624
|
+
buffer.o = buffer.a;
|
|
15625
|
+
buffer.a = undefined;
|
|
15626
|
+
} else if (!buffer.o && !buffer.q && !buffer.d && (buffer.b || buffer.p)) {
|
|
15627
|
+
buffer.o = buffer.a;
|
|
15628
|
+
buffer.d = buffer.b;
|
|
15629
|
+
buffer.q = buffer.p;
|
|
15630
|
+
buffer.a = buffer.b = buffer.p = undefined;
|
|
15631
|
+
} else {
|
|
15632
|
+
if (buffer.o && buffer.dType === 'kv' && mhchemParser.patterns.match_('d-oxidation$', buffer.d || "")) {
|
|
15633
|
+
buffer.dType = 'oxidation';
|
|
15634
|
+
} else if (buffer.o && buffer.dType === 'kv' && !buffer.q) {
|
|
15635
|
+
buffer.dType = undefined;
|
|
15636
|
+
}
|
|
15637
|
+
}
|
|
15638
|
+
ret.push({
|
|
15639
|
+
type_: 'chemfive',
|
|
15640
|
+
a: mhchemParser.go(buffer.a, 'a'),
|
|
15641
|
+
b: mhchemParser.go(buffer.b, 'bd'),
|
|
15642
|
+
p: mhchemParser.go(buffer.p, 'pq'),
|
|
15643
|
+
o: mhchemParser.go(buffer.o, 'o'),
|
|
15644
|
+
q: mhchemParser.go(buffer.q, 'pq'),
|
|
15645
|
+
d: mhchemParser.go(buffer.d, buffer.dType === 'oxidation' ? 'oxidation' : 'bd'),
|
|
15646
|
+
dType: buffer.dType
|
|
15647
|
+
});
|
|
15648
|
+
}
|
|
15649
|
+
} else {
|
|
15650
|
+
// r
|
|
15651
|
+
/** @type {ParserOutput[]} */
|
|
15652
|
+
var rd;
|
|
15653
|
+
if (buffer.rdt === 'M') {
|
|
15654
|
+
rd = mhchemParser.go(buffer.rd, 'tex-math');
|
|
15655
|
+
} else if (buffer.rdt === 'T') {
|
|
15656
|
+
rd = [{
|
|
15657
|
+
type_: 'text',
|
|
15658
|
+
p1: buffer.rd || ""
|
|
15659
|
+
}];
|
|
15660
|
+
} else {
|
|
15661
|
+
rd = mhchemParser.go(buffer.rd);
|
|
15662
|
+
}
|
|
15663
|
+
/** @type {ParserOutput[]} */
|
|
15664
|
+
var rq;
|
|
15665
|
+
if (buffer.rqt === 'M') {
|
|
15666
|
+
rq = mhchemParser.go(buffer.rq, 'tex-math');
|
|
15667
|
+
} else if (buffer.rqt === 'T') {
|
|
15668
|
+
rq = [{
|
|
15669
|
+
type_: 'text',
|
|
15670
|
+
p1: buffer.rq || ""
|
|
15671
|
+
}];
|
|
15672
|
+
} else {
|
|
15673
|
+
rq = mhchemParser.go(buffer.rq);
|
|
15674
|
+
}
|
|
15675
|
+
ret = {
|
|
15676
|
+
type_: 'arrow',
|
|
15677
|
+
r: buffer.r,
|
|
15678
|
+
rd: rd,
|
|
15679
|
+
rq: rq
|
|
15680
|
+
};
|
|
15681
|
+
}
|
|
15682
|
+
for (var p in buffer) {
|
|
15683
|
+
if (p !== 'parenthesisLevel' && p !== 'beginsWithBond') {
|
|
15684
|
+
delete buffer[p];
|
|
15685
|
+
}
|
|
15686
|
+
}
|
|
15687
|
+
return ret;
|
|
15688
|
+
},
|
|
15689
|
+
'oxidation-output': function (buffer, m) {
|
|
15690
|
+
var ret = ["{"];
|
|
15691
|
+
mhchemParser.concatArray(ret, mhchemParser.go(m, 'oxidation'));
|
|
15692
|
+
ret.push("}");
|
|
15693
|
+
return ret;
|
|
15694
|
+
},
|
|
15695
|
+
'frac-output': function (buffer, m) {
|
|
15696
|
+
return {
|
|
15697
|
+
type_: 'frac-ce',
|
|
15698
|
+
p1: mhchemParser.go(m[0]),
|
|
15699
|
+
p2: mhchemParser.go(m[1])
|
|
15700
|
+
};
|
|
15701
|
+
},
|
|
15702
|
+
'overset-output': function (buffer, m) {
|
|
15703
|
+
return {
|
|
15704
|
+
type_: 'overset',
|
|
15705
|
+
p1: mhchemParser.go(m[0]),
|
|
15706
|
+
p2: mhchemParser.go(m[1])
|
|
15707
|
+
};
|
|
15708
|
+
},
|
|
15709
|
+
'underset-output': function (buffer, m) {
|
|
15710
|
+
return {
|
|
15711
|
+
type_: 'underset',
|
|
15712
|
+
p1: mhchemParser.go(m[0]),
|
|
15713
|
+
p2: mhchemParser.go(m[1])
|
|
15714
|
+
};
|
|
15715
|
+
},
|
|
15716
|
+
'underbrace-output': function (buffer, m) {
|
|
15717
|
+
return {
|
|
15718
|
+
type_: 'underbrace',
|
|
15719
|
+
p1: mhchemParser.go(m[0]),
|
|
15720
|
+
p2: mhchemParser.go(m[1])
|
|
15721
|
+
};
|
|
15722
|
+
},
|
|
15723
|
+
'color-output': function (buffer, m) {
|
|
15724
|
+
return {
|
|
15725
|
+
type_: 'color',
|
|
15726
|
+
color1: m[0],
|
|
15727
|
+
color2: mhchemParser.go(m[1])
|
|
15728
|
+
};
|
|
15729
|
+
},
|
|
15730
|
+
'r=': function (buffer, m) {
|
|
15731
|
+
buffer.r = m;
|
|
15732
|
+
},
|
|
15733
|
+
'rdt=': function (buffer, m) {
|
|
15734
|
+
buffer.rdt = m;
|
|
15735
|
+
},
|
|
15736
|
+
'rd=': function (buffer, m) {
|
|
15737
|
+
buffer.rd = m;
|
|
15738
|
+
},
|
|
15739
|
+
'rqt=': function (buffer, m) {
|
|
15740
|
+
buffer.rqt = m;
|
|
15741
|
+
},
|
|
15742
|
+
'rq=': function (buffer, m) {
|
|
15743
|
+
buffer.rq = m;
|
|
15744
|
+
},
|
|
15745
|
+
'operator': function (buffer, m, p1) {
|
|
15746
|
+
return {
|
|
15747
|
+
type_: 'operator',
|
|
15748
|
+
kind_: p1 || m
|
|
15749
|
+
};
|
|
15750
|
+
}
|
|
15751
|
+
}
|
|
15752
|
+
},
|
|
15753
|
+
'a': {
|
|
15754
|
+
transitions: mhchemParser.createTransitions({
|
|
15755
|
+
'empty': {
|
|
15756
|
+
'*': {}
|
|
15757
|
+
},
|
|
15758
|
+
'1/2$': {
|
|
15759
|
+
'0': {
|
|
15760
|
+
action_: '1/2'
|
|
15761
|
+
}
|
|
15762
|
+
},
|
|
15763
|
+
'else': {
|
|
15764
|
+
'0': {
|
|
15765
|
+
nextState: '1',
|
|
15766
|
+
revisit: true
|
|
15767
|
+
}
|
|
15768
|
+
},
|
|
15769
|
+
'$(...)$': {
|
|
15770
|
+
'*': {
|
|
15771
|
+
action_: 'tex-math tight',
|
|
15772
|
+
nextState: '1'
|
|
15773
|
+
}
|
|
15774
|
+
},
|
|
15775
|
+
',': {
|
|
15776
|
+
'*': {
|
|
15777
|
+
action_: {
|
|
15778
|
+
type_: 'insert',
|
|
15779
|
+
option: 'commaDecimal'
|
|
15780
|
+
}
|
|
15781
|
+
}
|
|
15782
|
+
},
|
|
15783
|
+
'else2': {
|
|
15784
|
+
'*': {
|
|
15785
|
+
action_: 'copy'
|
|
15786
|
+
}
|
|
15787
|
+
}
|
|
15788
|
+
}),
|
|
15789
|
+
actions: {}
|
|
15790
|
+
},
|
|
15791
|
+
'o': {
|
|
15792
|
+
transitions: mhchemParser.createTransitions({
|
|
15793
|
+
'empty': {
|
|
15794
|
+
'*': {}
|
|
15795
|
+
},
|
|
15796
|
+
'1/2$': {
|
|
15797
|
+
'0': {
|
|
15798
|
+
action_: '1/2'
|
|
15799
|
+
}
|
|
15800
|
+
},
|
|
15801
|
+
'else': {
|
|
15802
|
+
'0': {
|
|
15803
|
+
nextState: '1',
|
|
15804
|
+
revisit: true
|
|
15805
|
+
}
|
|
15806
|
+
},
|
|
15807
|
+
'letters': {
|
|
15808
|
+
'*': {
|
|
15809
|
+
action_: 'rm'
|
|
15810
|
+
}
|
|
15811
|
+
},
|
|
15812
|
+
'\\ca': {
|
|
15813
|
+
'*': {
|
|
15814
|
+
action_: {
|
|
15815
|
+
type_: 'insert',
|
|
15816
|
+
option: 'circa'
|
|
15817
|
+
}
|
|
15818
|
+
}
|
|
15819
|
+
},
|
|
15820
|
+
'\\x{}{}|\\x{}|\\x': {
|
|
15821
|
+
'*': {
|
|
15822
|
+
action_: 'copy'
|
|
15823
|
+
}
|
|
15824
|
+
},
|
|
15825
|
+
'${(...)}$|$(...)$': {
|
|
15826
|
+
'*': {
|
|
15827
|
+
action_: 'tex-math'
|
|
15828
|
+
}
|
|
15829
|
+
},
|
|
15830
|
+
'{(...)}': {
|
|
15831
|
+
'*': {
|
|
15832
|
+
action_: '{text}'
|
|
15833
|
+
}
|
|
15834
|
+
},
|
|
15835
|
+
'else2': {
|
|
15836
|
+
'*': {
|
|
15837
|
+
action_: 'copy'
|
|
15838
|
+
}
|
|
15839
|
+
}
|
|
15840
|
+
}),
|
|
15841
|
+
actions: {}
|
|
15842
|
+
},
|
|
15843
|
+
'text': {
|
|
15844
|
+
transitions: mhchemParser.createTransitions({
|
|
15845
|
+
'empty': {
|
|
15846
|
+
'*': {
|
|
15847
|
+
action_: 'output'
|
|
15848
|
+
}
|
|
15849
|
+
},
|
|
15850
|
+
'{...}': {
|
|
15851
|
+
'*': {
|
|
15852
|
+
action_: 'text='
|
|
15853
|
+
}
|
|
15854
|
+
},
|
|
15855
|
+
'${(...)}$|$(...)$': {
|
|
15856
|
+
'*': {
|
|
15857
|
+
action_: 'tex-math'
|
|
15858
|
+
}
|
|
15859
|
+
},
|
|
15860
|
+
'\\greek': {
|
|
15861
|
+
'*': {
|
|
15862
|
+
action_: ['output', 'rm']
|
|
15863
|
+
}
|
|
15864
|
+
},
|
|
15865
|
+
'\\,|\\x{}{}|\\x{}|\\x': {
|
|
15866
|
+
'*': {
|
|
15867
|
+
action_: ['output', 'copy']
|
|
15868
|
+
}
|
|
15869
|
+
},
|
|
15870
|
+
'else': {
|
|
15871
|
+
'*': {
|
|
15872
|
+
action_: 'text='
|
|
15873
|
+
}
|
|
15874
|
+
}
|
|
15875
|
+
}),
|
|
15876
|
+
actions: {
|
|
15877
|
+
'output': function (buffer) {
|
|
15878
|
+
if (buffer.text_) {
|
|
15879
|
+
/** @type {ParserOutput} */
|
|
15880
|
+
var ret = {
|
|
15881
|
+
type_: 'text',
|
|
15882
|
+
p1: buffer.text_
|
|
15883
|
+
};
|
|
15884
|
+
for (var p in buffer) {
|
|
15885
|
+
delete buffer[p];
|
|
15886
|
+
}
|
|
15887
|
+
return ret;
|
|
15888
|
+
}
|
|
15889
|
+
}
|
|
15890
|
+
}
|
|
15891
|
+
},
|
|
15892
|
+
'pq': {
|
|
15893
|
+
transitions: mhchemParser.createTransitions({
|
|
15894
|
+
'empty': {
|
|
15895
|
+
'*': {}
|
|
15896
|
+
},
|
|
15897
|
+
'state of aggregation $': {
|
|
15898
|
+
'*': {
|
|
15899
|
+
action_: 'state of aggregation'
|
|
15900
|
+
}
|
|
15901
|
+
},
|
|
15902
|
+
'i$': {
|
|
15903
|
+
'0': {
|
|
15904
|
+
nextState: '!f',
|
|
15905
|
+
revisit: true
|
|
15906
|
+
}
|
|
15907
|
+
},
|
|
15908
|
+
'(KV letters),': {
|
|
15909
|
+
'0': {
|
|
15910
|
+
action_: 'rm',
|
|
15911
|
+
nextState: '0'
|
|
15912
|
+
}
|
|
15913
|
+
},
|
|
15914
|
+
'formula$': {
|
|
15915
|
+
'0': {
|
|
15916
|
+
nextState: 'f',
|
|
15917
|
+
revisit: true
|
|
15918
|
+
}
|
|
15919
|
+
},
|
|
15920
|
+
'1/2$': {
|
|
15921
|
+
'0': {
|
|
15922
|
+
action_: '1/2'
|
|
15923
|
+
}
|
|
15924
|
+
},
|
|
15925
|
+
'else': {
|
|
15926
|
+
'0': {
|
|
15927
|
+
nextState: '!f',
|
|
15928
|
+
revisit: true
|
|
15929
|
+
}
|
|
15930
|
+
},
|
|
15931
|
+
'${(...)}$|$(...)$': {
|
|
15932
|
+
'*': {
|
|
15933
|
+
action_: 'tex-math'
|
|
15934
|
+
}
|
|
15935
|
+
},
|
|
15936
|
+
'{(...)}': {
|
|
15937
|
+
'*': {
|
|
15938
|
+
action_: 'text'
|
|
15939
|
+
}
|
|
15940
|
+
},
|
|
15941
|
+
'a-z': {
|
|
15942
|
+
'f': {
|
|
15943
|
+
action_: 'tex-math'
|
|
15944
|
+
}
|
|
15945
|
+
},
|
|
15946
|
+
'letters': {
|
|
15947
|
+
'*': {
|
|
15948
|
+
action_: 'rm'
|
|
15949
|
+
}
|
|
15950
|
+
},
|
|
15951
|
+
'-9.,9': {
|
|
15952
|
+
'*': {
|
|
15953
|
+
action_: '9,9'
|
|
15954
|
+
}
|
|
15955
|
+
},
|
|
15956
|
+
',': {
|
|
15957
|
+
'*': {
|
|
15958
|
+
action_: {
|
|
15959
|
+
type_: 'insert+p1',
|
|
15960
|
+
option: 'comma enumeration S'
|
|
15961
|
+
}
|
|
15962
|
+
}
|
|
15963
|
+
},
|
|
15964
|
+
'\\color{(...)}{(...)}1|\\color(...){(...)}2': {
|
|
15965
|
+
'*': {
|
|
15966
|
+
action_: 'color-output'
|
|
15967
|
+
}
|
|
15968
|
+
},
|
|
15969
|
+
'\\color{(...)}0': {
|
|
15970
|
+
'*': {
|
|
15971
|
+
action_: 'color0-output'
|
|
15972
|
+
}
|
|
15973
|
+
},
|
|
15974
|
+
'\\ce{(...)}': {
|
|
15975
|
+
'*': {
|
|
15976
|
+
action_: 'ce'
|
|
15977
|
+
}
|
|
15978
|
+
},
|
|
15979
|
+
'\\,|\\x{}{}|\\x{}|\\x': {
|
|
15980
|
+
'*': {
|
|
15981
|
+
action_: 'copy'
|
|
15982
|
+
}
|
|
15983
|
+
},
|
|
15984
|
+
'else2': {
|
|
15985
|
+
'*': {
|
|
15986
|
+
action_: 'copy'
|
|
15987
|
+
}
|
|
15988
|
+
}
|
|
15989
|
+
}),
|
|
15990
|
+
actions: {
|
|
15991
|
+
'state of aggregation': function (buffer, m) {
|
|
15992
|
+
return {
|
|
15993
|
+
type_: 'state of aggregation subscript',
|
|
15994
|
+
p1: mhchemParser.go(m, 'o')
|
|
15995
|
+
};
|
|
15996
|
+
},
|
|
15997
|
+
'color-output': function (buffer, m) {
|
|
15998
|
+
return {
|
|
15999
|
+
type_: 'color',
|
|
16000
|
+
color1: m[0],
|
|
16001
|
+
color2: mhchemParser.go(m[1], 'pq')
|
|
16002
|
+
};
|
|
16003
|
+
}
|
|
16004
|
+
}
|
|
16005
|
+
},
|
|
16006
|
+
'bd': {
|
|
16007
|
+
transitions: mhchemParser.createTransitions({
|
|
16008
|
+
'empty': {
|
|
16009
|
+
'*': {}
|
|
16010
|
+
},
|
|
16011
|
+
'x$': {
|
|
16012
|
+
'0': {
|
|
16013
|
+
nextState: '!f',
|
|
16014
|
+
revisit: true
|
|
16015
|
+
}
|
|
16016
|
+
},
|
|
16017
|
+
'formula$': {
|
|
16018
|
+
'0': {
|
|
16019
|
+
nextState: 'f',
|
|
16020
|
+
revisit: true
|
|
16021
|
+
}
|
|
16022
|
+
},
|
|
16023
|
+
'else': {
|
|
16024
|
+
'0': {
|
|
16025
|
+
nextState: '!f',
|
|
16026
|
+
revisit: true
|
|
16027
|
+
}
|
|
16028
|
+
},
|
|
16029
|
+
'-9.,9 no missing 0': {
|
|
16030
|
+
'*': {
|
|
16031
|
+
action_: '9,9'
|
|
16032
|
+
}
|
|
16033
|
+
},
|
|
16034
|
+
'.': {
|
|
16035
|
+
'*': {
|
|
16036
|
+
action_: {
|
|
16037
|
+
type_: 'insert',
|
|
16038
|
+
option: 'electron dot'
|
|
16039
|
+
}
|
|
16040
|
+
}
|
|
16041
|
+
},
|
|
16042
|
+
'a-z': {
|
|
16043
|
+
'f': {
|
|
16044
|
+
action_: 'tex-math'
|
|
16045
|
+
}
|
|
16046
|
+
},
|
|
16047
|
+
'x': {
|
|
16048
|
+
'*': {
|
|
16049
|
+
action_: {
|
|
16050
|
+
type_: 'insert',
|
|
16051
|
+
option: 'KV x'
|
|
16052
|
+
}
|
|
16053
|
+
}
|
|
16054
|
+
},
|
|
16055
|
+
'letters': {
|
|
16056
|
+
'*': {
|
|
16057
|
+
action_: 'rm'
|
|
16058
|
+
}
|
|
16059
|
+
},
|
|
16060
|
+
'\'': {
|
|
16061
|
+
'*': {
|
|
16062
|
+
action_: {
|
|
16063
|
+
type_: 'insert',
|
|
16064
|
+
option: 'prime'
|
|
16065
|
+
}
|
|
16066
|
+
}
|
|
16067
|
+
},
|
|
16068
|
+
'${(...)}$|$(...)$': {
|
|
16069
|
+
'*': {
|
|
16070
|
+
action_: 'tex-math'
|
|
16071
|
+
}
|
|
16072
|
+
},
|
|
16073
|
+
'{(...)}': {
|
|
16074
|
+
'*': {
|
|
16075
|
+
action_: 'text'
|
|
16076
|
+
}
|
|
16077
|
+
},
|
|
16078
|
+
'\\color{(...)}{(...)}1|\\color(...){(...)}2': {
|
|
16079
|
+
'*': {
|
|
16080
|
+
action_: 'color-output'
|
|
16081
|
+
}
|
|
16082
|
+
},
|
|
16083
|
+
'\\color{(...)}0': {
|
|
16084
|
+
'*': {
|
|
16085
|
+
action_: 'color0-output'
|
|
16086
|
+
}
|
|
16087
|
+
},
|
|
16088
|
+
'\\ce{(...)}': {
|
|
16089
|
+
'*': {
|
|
16090
|
+
action_: 'ce'
|
|
16091
|
+
}
|
|
16092
|
+
},
|
|
16093
|
+
'\\,|\\x{}{}|\\x{}|\\x': {
|
|
16094
|
+
'*': {
|
|
16095
|
+
action_: 'copy'
|
|
16096
|
+
}
|
|
16097
|
+
},
|
|
16098
|
+
'else2': {
|
|
16099
|
+
'*': {
|
|
16100
|
+
action_: 'copy'
|
|
16101
|
+
}
|
|
16102
|
+
}
|
|
16103
|
+
}),
|
|
16104
|
+
actions: {
|
|
16105
|
+
'color-output': function (buffer, m) {
|
|
16106
|
+
return {
|
|
16107
|
+
type_: 'color',
|
|
16108
|
+
color1: m[0],
|
|
16109
|
+
color2: mhchemParser.go(m[1], 'bd')
|
|
16110
|
+
};
|
|
16111
|
+
}
|
|
16112
|
+
}
|
|
16113
|
+
},
|
|
16114
|
+
'oxidation': {
|
|
16115
|
+
transitions: mhchemParser.createTransitions({
|
|
16116
|
+
'empty': {
|
|
16117
|
+
'*': {}
|
|
16118
|
+
},
|
|
16119
|
+
'roman numeral': {
|
|
16120
|
+
'*': {
|
|
16121
|
+
action_: 'roman-numeral'
|
|
16122
|
+
}
|
|
16123
|
+
},
|
|
16124
|
+
'${(...)}$|$(...)$': {
|
|
16125
|
+
'*': {
|
|
16126
|
+
action_: 'tex-math'
|
|
16127
|
+
}
|
|
16128
|
+
},
|
|
16129
|
+
'else': {
|
|
16130
|
+
'*': {
|
|
16131
|
+
action_: 'copy'
|
|
16132
|
+
}
|
|
16133
|
+
}
|
|
16134
|
+
}),
|
|
16135
|
+
actions: {
|
|
16136
|
+
'roman-numeral': function (buffer, m) {
|
|
16137
|
+
return {
|
|
16138
|
+
type_: 'roman numeral',
|
|
16139
|
+
p1: m || ""
|
|
16140
|
+
};
|
|
16141
|
+
}
|
|
16142
|
+
}
|
|
16143
|
+
},
|
|
16144
|
+
'tex-math': {
|
|
16145
|
+
transitions: mhchemParser.createTransitions({
|
|
16146
|
+
'empty': {
|
|
16147
|
+
'*': {
|
|
16148
|
+
action_: 'output'
|
|
16149
|
+
}
|
|
16150
|
+
},
|
|
16151
|
+
'\\ce{(...)}': {
|
|
16152
|
+
'*': {
|
|
16153
|
+
action_: ['output', 'ce']
|
|
16154
|
+
}
|
|
16155
|
+
},
|
|
16156
|
+
'{...}|\\,|\\x{}{}|\\x{}|\\x': {
|
|
16157
|
+
'*': {
|
|
16158
|
+
action_: 'o='
|
|
16159
|
+
}
|
|
16160
|
+
},
|
|
16161
|
+
'else': {
|
|
16162
|
+
'*': {
|
|
16163
|
+
action_: 'o='
|
|
16164
|
+
}
|
|
16165
|
+
}
|
|
16166
|
+
}),
|
|
16167
|
+
actions: {
|
|
16168
|
+
'output': function (buffer) {
|
|
16169
|
+
if (buffer.o) {
|
|
16170
|
+
/** @type {ParserOutput} */
|
|
16171
|
+
var ret = {
|
|
16172
|
+
type_: 'tex-math',
|
|
16173
|
+
p1: buffer.o
|
|
16174
|
+
};
|
|
16175
|
+
for (var p in buffer) {
|
|
16176
|
+
delete buffer[p];
|
|
16177
|
+
}
|
|
16178
|
+
return ret;
|
|
16179
|
+
}
|
|
16180
|
+
}
|
|
16181
|
+
}
|
|
16182
|
+
},
|
|
16183
|
+
'tex-math tight': {
|
|
16184
|
+
transitions: mhchemParser.createTransitions({
|
|
16185
|
+
'empty': {
|
|
16186
|
+
'*': {
|
|
16187
|
+
action_: 'output'
|
|
16188
|
+
}
|
|
16189
|
+
},
|
|
16190
|
+
'\\ce{(...)}': {
|
|
16191
|
+
'*': {
|
|
16192
|
+
action_: ['output', 'ce']
|
|
16193
|
+
}
|
|
16194
|
+
},
|
|
16195
|
+
'{...}|\\,|\\x{}{}|\\x{}|\\x': {
|
|
16196
|
+
'*': {
|
|
16197
|
+
action_: 'o='
|
|
16198
|
+
}
|
|
16199
|
+
},
|
|
16200
|
+
'-|+': {
|
|
16201
|
+
'*': {
|
|
16202
|
+
action_: 'tight operator'
|
|
16203
|
+
}
|
|
16204
|
+
},
|
|
16205
|
+
'else': {
|
|
16206
|
+
'*': {
|
|
16207
|
+
action_: 'o='
|
|
16208
|
+
}
|
|
16209
|
+
}
|
|
16210
|
+
}),
|
|
16211
|
+
actions: {
|
|
16212
|
+
'tight operator': function (buffer, m) {
|
|
16213
|
+
buffer.o = (buffer.o || "") + "{" + m + "}";
|
|
16214
|
+
},
|
|
16215
|
+
'output': function (buffer) {
|
|
16216
|
+
if (buffer.o) {
|
|
16217
|
+
/** @type {ParserOutput} */
|
|
16218
|
+
var ret = {
|
|
16219
|
+
type_: 'tex-math',
|
|
16220
|
+
p1: buffer.o
|
|
16221
|
+
};
|
|
16222
|
+
for (var p in buffer) {
|
|
16223
|
+
delete buffer[p];
|
|
16224
|
+
}
|
|
16225
|
+
return ret;
|
|
16226
|
+
}
|
|
16227
|
+
}
|
|
16228
|
+
}
|
|
16229
|
+
},
|
|
16230
|
+
'9,9': {
|
|
16231
|
+
transitions: mhchemParser.createTransitions({
|
|
16232
|
+
'empty': {
|
|
16233
|
+
'*': {}
|
|
16234
|
+
},
|
|
16235
|
+
',': {
|
|
16236
|
+
'*': {
|
|
16237
|
+
action_: 'comma'
|
|
16238
|
+
}
|
|
16239
|
+
},
|
|
16240
|
+
'else': {
|
|
16241
|
+
'*': {
|
|
16242
|
+
action_: 'copy'
|
|
16243
|
+
}
|
|
16244
|
+
}
|
|
16245
|
+
}),
|
|
16246
|
+
actions: {
|
|
16247
|
+
'comma': function () {
|
|
16248
|
+
return {
|
|
16249
|
+
type_: 'commaDecimal'
|
|
16250
|
+
};
|
|
16251
|
+
}
|
|
16252
|
+
}
|
|
16253
|
+
},
|
|
16254
|
+
//#endregion
|
|
16255
|
+
//
|
|
16256
|
+
// \pu state machines
|
|
16257
|
+
//
|
|
16258
|
+
//#region pu
|
|
16259
|
+
'pu': {
|
|
16260
|
+
transitions: mhchemParser.createTransitions({
|
|
16261
|
+
'empty': {
|
|
16262
|
+
'*': {
|
|
16263
|
+
action_: 'output'
|
|
16264
|
+
}
|
|
16265
|
+
},
|
|
16266
|
+
'space$': {
|
|
16267
|
+
'*': {
|
|
16268
|
+
action_: ['output', 'space']
|
|
16269
|
+
}
|
|
16270
|
+
},
|
|
16271
|
+
'{[(|)]}': {
|
|
16272
|
+
'0|a': {
|
|
16273
|
+
action_: 'copy'
|
|
16274
|
+
}
|
|
16275
|
+
},
|
|
16276
|
+
'(-)(9)^(-9)': {
|
|
16277
|
+
'0': {
|
|
16278
|
+
action_: 'number^',
|
|
16279
|
+
nextState: 'a'
|
|
16280
|
+
}
|
|
16281
|
+
},
|
|
16282
|
+
'(-)(9.,9)(e)(99)': {
|
|
16283
|
+
'0': {
|
|
16284
|
+
action_: 'enumber',
|
|
16285
|
+
nextState: 'a'
|
|
16286
|
+
}
|
|
16287
|
+
},
|
|
16288
|
+
'space': {
|
|
16289
|
+
'0|a': {}
|
|
16290
|
+
},
|
|
16291
|
+
'pm-operator': {
|
|
16292
|
+
'0|a': {
|
|
16293
|
+
action_: {
|
|
16294
|
+
type_: 'operator',
|
|
16295
|
+
option: '\\pm'
|
|
16296
|
+
},
|
|
16297
|
+
nextState: '0'
|
|
16298
|
+
}
|
|
16299
|
+
},
|
|
16300
|
+
'operator': {
|
|
16301
|
+
'0|a': {
|
|
16302
|
+
action_: 'copy',
|
|
16303
|
+
nextState: '0'
|
|
16304
|
+
}
|
|
16305
|
+
},
|
|
16306
|
+
'//': {
|
|
16307
|
+
'd': {
|
|
16308
|
+
action_: 'o=',
|
|
16309
|
+
nextState: '/'
|
|
16310
|
+
}
|
|
16311
|
+
},
|
|
16312
|
+
'/': {
|
|
16313
|
+
'd': {
|
|
16314
|
+
action_: 'o=',
|
|
16315
|
+
nextState: '/'
|
|
16316
|
+
}
|
|
16317
|
+
},
|
|
16318
|
+
'{...}|else': {
|
|
16319
|
+
'0|d': {
|
|
16320
|
+
action_: 'd=',
|
|
16321
|
+
nextState: 'd'
|
|
16322
|
+
},
|
|
16323
|
+
'a': {
|
|
16324
|
+
action_: ['space', 'd='],
|
|
16325
|
+
nextState: 'd'
|
|
16326
|
+
},
|
|
16327
|
+
'/|q': {
|
|
16328
|
+
action_: 'q=',
|
|
16329
|
+
nextState: 'q'
|
|
16330
|
+
}
|
|
16331
|
+
}
|
|
16332
|
+
}),
|
|
16333
|
+
actions: {
|
|
16334
|
+
'enumber': function (buffer, m) {
|
|
16335
|
+
/** @type {ParserOutput[]} */
|
|
16336
|
+
var ret = [];
|
|
16337
|
+
if (m[0] === "+-" || m[0] === "+/-") {
|
|
16338
|
+
ret.push("\\pm ");
|
|
16339
|
+
} else if (m[0]) {
|
|
16340
|
+
ret.push(m[0]);
|
|
16341
|
+
}
|
|
16342
|
+
if (m[1]) {
|
|
16343
|
+
mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9'));
|
|
16344
|
+
if (m[2]) {
|
|
16345
|
+
if (m[2].match(/[,.]/)) {
|
|
16346
|
+
mhchemParser.concatArray(ret, mhchemParser.go(m[2], 'pu-9,9'));
|
|
16347
|
+
} else {
|
|
16348
|
+
ret.push(m[2]);
|
|
16349
|
+
}
|
|
16350
|
+
}
|
|
16351
|
+
m[3] = m[4] || m[3];
|
|
16352
|
+
if (m[3]) {
|
|
16353
|
+
m[3] = m[3].trim();
|
|
16354
|
+
if (m[3] === "e" || m[3].substr(0, 1) === "*") {
|
|
16355
|
+
ret.push({
|
|
16356
|
+
type_: 'cdot'
|
|
16357
|
+
});
|
|
16358
|
+
} else {
|
|
16359
|
+
ret.push({
|
|
16360
|
+
type_: 'times'
|
|
16361
|
+
});
|
|
16362
|
+
}
|
|
16363
|
+
}
|
|
16364
|
+
}
|
|
16365
|
+
if (m[3]) {
|
|
16366
|
+
ret.push("10^{" + m[5] + "}");
|
|
16367
|
+
}
|
|
16368
|
+
return ret;
|
|
16369
|
+
},
|
|
16370
|
+
'number^': function (buffer, m) {
|
|
16371
|
+
/** @type {ParserOutput[]} */
|
|
16372
|
+
var ret = [];
|
|
16373
|
+
if (m[0] === "+-" || m[0] === "+/-") {
|
|
16374
|
+
ret.push("\\pm ");
|
|
16375
|
+
} else if (m[0]) {
|
|
16376
|
+
ret.push(m[0]);
|
|
16377
|
+
}
|
|
16378
|
+
mhchemParser.concatArray(ret, mhchemParser.go(m[1], 'pu-9,9'));
|
|
16379
|
+
ret.push("^{" + m[2] + "}");
|
|
16380
|
+
return ret;
|
|
16381
|
+
},
|
|
16382
|
+
'operator': function (buffer, m, p1) {
|
|
16383
|
+
return {
|
|
16384
|
+
type_: 'operator',
|
|
16385
|
+
kind_: p1 || m
|
|
16386
|
+
};
|
|
16387
|
+
},
|
|
16388
|
+
'space': function () {
|
|
16389
|
+
return {
|
|
16390
|
+
type_: 'pu-space-1'
|
|
16391
|
+
};
|
|
16392
|
+
},
|
|
16393
|
+
'output': function (buffer) {
|
|
16394
|
+
/** @type {ParserOutput | ParserOutput[]} */
|
|
16395
|
+
var ret;
|
|
16396
|
+
var md = mhchemParser.patterns.match_('{(...)}', buffer.d || "");
|
|
16397
|
+
if (md && md.remainder === '') {
|
|
16398
|
+
buffer.d = md.match_;
|
|
16399
|
+
}
|
|
16400
|
+
var mq = mhchemParser.patterns.match_('{(...)}', buffer.q || "");
|
|
16401
|
+
if (mq && mq.remainder === '') {
|
|
16402
|
+
buffer.q = mq.match_;
|
|
16403
|
+
}
|
|
16404
|
+
if (buffer.d) {
|
|
16405
|
+
buffer.d = buffer.d.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C");
|
|
16406
|
+
buffer.d = buffer.d.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F");
|
|
16407
|
+
}
|
|
16408
|
+
if (buffer.q) {
|
|
16409
|
+
// fraction
|
|
16410
|
+
buffer.q = buffer.q.replace(/\u00B0C|\^oC|\^{o}C/g, "{}^{\\circ}C");
|
|
16411
|
+
buffer.q = buffer.q.replace(/\u00B0F|\^oF|\^{o}F/g, "{}^{\\circ}F");
|
|
16412
|
+
var b5 = {
|
|
16413
|
+
d: mhchemParser.go(buffer.d, 'pu'),
|
|
16414
|
+
q: mhchemParser.go(buffer.q, 'pu')
|
|
16415
|
+
};
|
|
16416
|
+
if (buffer.o === '//') {
|
|
16417
|
+
ret = {
|
|
16418
|
+
type_: 'pu-frac',
|
|
16419
|
+
p1: b5.d,
|
|
16420
|
+
p2: b5.q
|
|
16421
|
+
};
|
|
16422
|
+
} else {
|
|
16423
|
+
ret = b5.d;
|
|
16424
|
+
if (b5.d.length > 1 || b5.q.length > 1) {
|
|
16425
|
+
ret.push({
|
|
16426
|
+
type_: ' / '
|
|
16427
|
+
});
|
|
16428
|
+
} else {
|
|
16429
|
+
ret.push({
|
|
16430
|
+
type_: '/'
|
|
16431
|
+
});
|
|
16432
|
+
}
|
|
16433
|
+
mhchemParser.concatArray(ret, b5.q);
|
|
16434
|
+
}
|
|
16435
|
+
} else {
|
|
16436
|
+
// no fraction
|
|
16437
|
+
ret = mhchemParser.go(buffer.d, 'pu-2');
|
|
16438
|
+
}
|
|
16439
|
+
for (var p in buffer) {
|
|
16440
|
+
delete buffer[p];
|
|
16441
|
+
}
|
|
16442
|
+
return ret;
|
|
16443
|
+
}
|
|
16444
|
+
}
|
|
16445
|
+
},
|
|
16446
|
+
'pu-2': {
|
|
16447
|
+
transitions: mhchemParser.createTransitions({
|
|
16448
|
+
'empty': {
|
|
16449
|
+
'*': {
|
|
16450
|
+
action_: 'output'
|
|
16451
|
+
}
|
|
16452
|
+
},
|
|
16453
|
+
'*': {
|
|
16454
|
+
'*': {
|
|
16455
|
+
action_: ['output', 'cdot'],
|
|
16456
|
+
nextState: '0'
|
|
16457
|
+
}
|
|
16458
|
+
},
|
|
16459
|
+
'\\x': {
|
|
16460
|
+
'*': {
|
|
16461
|
+
action_: 'rm='
|
|
16462
|
+
}
|
|
16463
|
+
},
|
|
16464
|
+
'space': {
|
|
16465
|
+
'*': {
|
|
16466
|
+
action_: ['output', 'space'],
|
|
16467
|
+
nextState: '0'
|
|
16468
|
+
}
|
|
16469
|
+
},
|
|
16470
|
+
'^{(...)}|^(-1)': {
|
|
16471
|
+
'1': {
|
|
16472
|
+
action_: '^(-1)'
|
|
16473
|
+
}
|
|
16474
|
+
},
|
|
16475
|
+
'-9.,9': {
|
|
16476
|
+
'0': {
|
|
16477
|
+
action_: 'rm=',
|
|
16478
|
+
nextState: '0'
|
|
16479
|
+
},
|
|
16480
|
+
'1': {
|
|
16481
|
+
action_: '^(-1)',
|
|
16482
|
+
nextState: '0'
|
|
16483
|
+
}
|
|
16484
|
+
},
|
|
16485
|
+
'{...}|else': {
|
|
16486
|
+
'*': {
|
|
16487
|
+
action_: 'rm=',
|
|
16488
|
+
nextState: '1'
|
|
16489
|
+
}
|
|
16490
|
+
}
|
|
16491
|
+
}),
|
|
16492
|
+
actions: {
|
|
16493
|
+
'cdot': function () {
|
|
16494
|
+
return {
|
|
16495
|
+
type_: 'tight cdot'
|
|
16496
|
+
};
|
|
16497
|
+
},
|
|
16498
|
+
'^(-1)': function (buffer, m) {
|
|
16499
|
+
buffer.rm += "^{" + m + "}";
|
|
16500
|
+
},
|
|
16501
|
+
'space': function () {
|
|
16502
|
+
return {
|
|
16503
|
+
type_: 'pu-space-2'
|
|
16504
|
+
};
|
|
16505
|
+
},
|
|
16506
|
+
'output': function (buffer) {
|
|
16507
|
+
/** @type {ParserOutput | ParserOutput[]} */
|
|
16508
|
+
var ret = [];
|
|
16509
|
+
if (buffer.rm) {
|
|
16510
|
+
var mrm = mhchemParser.patterns.match_('{(...)}', buffer.rm || "");
|
|
16511
|
+
if (mrm && mrm.remainder === '') {
|
|
16512
|
+
ret = mhchemParser.go(mrm.match_, 'pu');
|
|
16513
|
+
} else {
|
|
16514
|
+
ret = {
|
|
16515
|
+
type_: 'rm',
|
|
16516
|
+
p1: buffer.rm
|
|
16517
|
+
};
|
|
16518
|
+
}
|
|
16519
|
+
}
|
|
16520
|
+
for (var p in buffer) {
|
|
16521
|
+
delete buffer[p];
|
|
16522
|
+
}
|
|
16523
|
+
return ret;
|
|
16524
|
+
}
|
|
16525
|
+
}
|
|
16526
|
+
},
|
|
16527
|
+
'pu-9,9': {
|
|
16528
|
+
transitions: mhchemParser.createTransitions({
|
|
16529
|
+
'empty': {
|
|
16530
|
+
'0': {
|
|
16531
|
+
action_: 'output-0'
|
|
16532
|
+
},
|
|
16533
|
+
'o': {
|
|
16534
|
+
action_: 'output-o'
|
|
16535
|
+
}
|
|
16536
|
+
},
|
|
16537
|
+
',': {
|
|
16538
|
+
'0': {
|
|
16539
|
+
action_: ['output-0', 'comma'],
|
|
16540
|
+
nextState: 'o'
|
|
16541
|
+
}
|
|
16542
|
+
},
|
|
16543
|
+
'.': {
|
|
16544
|
+
'0': {
|
|
16545
|
+
action_: ['output-0', 'copy'],
|
|
16546
|
+
nextState: 'o'
|
|
16547
|
+
}
|
|
16548
|
+
},
|
|
16549
|
+
'else': {
|
|
16550
|
+
'*': {
|
|
16551
|
+
action_: 'text='
|
|
16552
|
+
}
|
|
16553
|
+
}
|
|
16554
|
+
}),
|
|
16555
|
+
actions: {
|
|
16556
|
+
'comma': function () {
|
|
16557
|
+
return {
|
|
16558
|
+
type_: 'commaDecimal'
|
|
16559
|
+
};
|
|
16560
|
+
},
|
|
16561
|
+
'output-0': function (buffer) {
|
|
16562
|
+
/** @type {ParserOutput[]} */
|
|
16563
|
+
var ret = [];
|
|
16564
|
+
buffer.text_ = buffer.text_ || "";
|
|
16565
|
+
if (buffer.text_.length > 4) {
|
|
16566
|
+
var a = buffer.text_.length % 3;
|
|
16567
|
+
if (a === 0) {
|
|
16568
|
+
a = 3;
|
|
16569
|
+
}
|
|
16570
|
+
for (var i = buffer.text_.length - 3; i > 0; i -= 3) {
|
|
16571
|
+
ret.push(buffer.text_.substr(i, 3));
|
|
16572
|
+
ret.push({
|
|
16573
|
+
type_: '1000 separator'
|
|
16574
|
+
});
|
|
16575
|
+
}
|
|
16576
|
+
ret.push(buffer.text_.substr(0, a));
|
|
16577
|
+
ret.reverse();
|
|
16578
|
+
} else {
|
|
16579
|
+
ret.push(buffer.text_);
|
|
16580
|
+
}
|
|
16581
|
+
for (var p in buffer) {
|
|
16582
|
+
delete buffer[p];
|
|
16583
|
+
}
|
|
16584
|
+
return ret;
|
|
16585
|
+
},
|
|
16586
|
+
'output-o': function (buffer) {
|
|
16587
|
+
/** @type {ParserOutput[]} */
|
|
16588
|
+
var ret = [];
|
|
16589
|
+
buffer.text_ = buffer.text_ || "";
|
|
16590
|
+
if (buffer.text_.length > 4) {
|
|
16591
|
+
var a = buffer.text_.length - 3;
|
|
16592
|
+
for (var i = 0; i < a; i += 3) {
|
|
16593
|
+
ret.push(buffer.text_.substr(i, 3));
|
|
16594
|
+
ret.push({
|
|
16595
|
+
type_: '1000 separator'
|
|
16596
|
+
});
|
|
16597
|
+
}
|
|
16598
|
+
ret.push(buffer.text_.substr(i));
|
|
16599
|
+
} else {
|
|
16600
|
+
ret.push(buffer.text_);
|
|
16601
|
+
}
|
|
16602
|
+
for (var p in buffer) {
|
|
16603
|
+
delete buffer[p];
|
|
16604
|
+
}
|
|
16605
|
+
return ret;
|
|
16606
|
+
}
|
|
16607
|
+
}
|
|
16608
|
+
}
|
|
16609
|
+
//#endregion
|
|
16610
|
+
};
|
|
16611
|
+
|
|
16612
|
+
//
|
|
16613
|
+
// texify: Take MhchemParser output and convert it to TeX
|
|
16614
|
+
//
|
|
16615
|
+
/** @type {Texify} */
|
|
16616
|
+
var texify = {
|
|
16617
|
+
go: function (input, isInner) {
|
|
16618
|
+
// (recursive, max 4 levels)
|
|
16619
|
+
if (!input) {
|
|
16620
|
+
return "";
|
|
16621
|
+
}
|
|
16622
|
+
var res = "";
|
|
16623
|
+
var cee = false;
|
|
16624
|
+
for (var i = 0; i < input.length; i++) {
|
|
16625
|
+
var inputi = input[i];
|
|
16626
|
+
if (typeof inputi === "string") {
|
|
16627
|
+
res += inputi;
|
|
16628
|
+
} else {
|
|
16629
|
+
res += texify._go2(inputi);
|
|
16630
|
+
if (inputi.type_ === '1st-level escape') {
|
|
16631
|
+
cee = true;
|
|
16632
|
+
}
|
|
16633
|
+
}
|
|
16634
|
+
}
|
|
16635
|
+
if (!isInner && !cee && res) {
|
|
16636
|
+
res = "{" + res + "}";
|
|
16637
|
+
}
|
|
16638
|
+
return res;
|
|
16639
|
+
},
|
|
16640
|
+
_goInner: function (input) {
|
|
16641
|
+
if (!input) {
|
|
16642
|
+
return input;
|
|
16643
|
+
}
|
|
16644
|
+
return texify.go(input, true);
|
|
16645
|
+
},
|
|
16646
|
+
_go2: function (buf) {
|
|
16647
|
+
/** @type {undefined | string} */
|
|
16648
|
+
var res;
|
|
16649
|
+
switch (buf.type_) {
|
|
16650
|
+
case 'chemfive':
|
|
16651
|
+
res = "";
|
|
16652
|
+
var b5 = {
|
|
16653
|
+
a: texify._goInner(buf.a),
|
|
16654
|
+
b: texify._goInner(buf.b),
|
|
16655
|
+
p: texify._goInner(buf.p),
|
|
16656
|
+
o: texify._goInner(buf.o),
|
|
16657
|
+
q: texify._goInner(buf.q),
|
|
16658
|
+
d: texify._goInner(buf.d)
|
|
16659
|
+
};
|
|
16660
|
+
//
|
|
16661
|
+
// a
|
|
16662
|
+
//
|
|
16663
|
+
if (b5.a) {
|
|
16664
|
+
if (b5.a.match(/^[+\-]/)) {
|
|
16665
|
+
b5.a = "{" + b5.a + "}";
|
|
16666
|
+
}
|
|
16667
|
+
res += b5.a + "\\,";
|
|
16668
|
+
}
|
|
16669
|
+
//
|
|
16670
|
+
// b and p
|
|
16671
|
+
//
|
|
16672
|
+
if (b5.b || b5.p) {
|
|
16673
|
+
res += "{\\vphantom{X}}";
|
|
16674
|
+
res += "^{\\hphantom{" + (b5.b || "") + "}}_{\\hphantom{" + (b5.p || "") + "}}";
|
|
16675
|
+
res += "{\\vphantom{X}}";
|
|
16676
|
+
res += "^{\\smash[t]{\\vphantom{2}}\\mathllap{" + (b5.b || "") + "}}";
|
|
16677
|
+
res += "_{\\vphantom{2}\\mathllap{\\smash[t]{" + (b5.p || "") + "}}}";
|
|
16678
|
+
}
|
|
16679
|
+
//
|
|
16680
|
+
// o
|
|
16681
|
+
//
|
|
16682
|
+
if (b5.o) {
|
|
16683
|
+
if (b5.o.match(/^[+\-]/)) {
|
|
16684
|
+
b5.o = "{" + b5.o + "}";
|
|
16685
|
+
}
|
|
16686
|
+
res += b5.o;
|
|
16687
|
+
}
|
|
16688
|
+
//
|
|
16689
|
+
// q and d
|
|
16690
|
+
//
|
|
16691
|
+
if (buf.dType === 'kv') {
|
|
16692
|
+
if (b5.d || b5.q) {
|
|
16693
|
+
res += "{\\vphantom{X}}";
|
|
16694
|
+
}
|
|
16695
|
+
if (b5.d) {
|
|
16696
|
+
res += "^{" + b5.d + "}";
|
|
16697
|
+
}
|
|
16698
|
+
if (b5.q) {
|
|
16699
|
+
res += "_{\\smash[t]{" + b5.q + "}}";
|
|
16700
|
+
}
|
|
16701
|
+
} else if (buf.dType === 'oxidation') {
|
|
16702
|
+
if (b5.d) {
|
|
16703
|
+
res += "{\\vphantom{X}}";
|
|
16704
|
+
res += "^{" + b5.d + "}";
|
|
16705
|
+
}
|
|
16706
|
+
if (b5.q) {
|
|
16707
|
+
res += "{\\vphantom{X}}";
|
|
16708
|
+
res += "_{\\smash[t]{" + b5.q + "}}";
|
|
16709
|
+
}
|
|
16710
|
+
} else {
|
|
16711
|
+
if (b5.q) {
|
|
16712
|
+
res += "{\\vphantom{X}}";
|
|
16713
|
+
res += "_{\\smash[t]{" + b5.q + "}}";
|
|
16714
|
+
}
|
|
16715
|
+
if (b5.d) {
|
|
16716
|
+
res += "{\\vphantom{X}}";
|
|
16717
|
+
res += "^{" + b5.d + "}";
|
|
16718
|
+
}
|
|
16719
|
+
}
|
|
16720
|
+
break;
|
|
16721
|
+
case 'rm':
|
|
16722
|
+
res = "\\mathrm{" + buf.p1 + "}";
|
|
16723
|
+
break;
|
|
16724
|
+
case 'text':
|
|
16725
|
+
if (buf.p1.match(/[\^_]/)) {
|
|
16726
|
+
buf.p1 = buf.p1.replace(" ", "~").replace("-", "\\text{-}");
|
|
16727
|
+
res = "\\mathrm{" + buf.p1 + "}";
|
|
16728
|
+
} else {
|
|
16729
|
+
res = "\\text{" + buf.p1 + "}";
|
|
16730
|
+
}
|
|
16731
|
+
break;
|
|
16732
|
+
case 'roman numeral':
|
|
16733
|
+
res = "\\mathrm{" + buf.p1 + "}";
|
|
16734
|
+
break;
|
|
16735
|
+
case 'state of aggregation':
|
|
16736
|
+
res = "\\mskip2mu " + texify._goInner(buf.p1);
|
|
16737
|
+
break;
|
|
16738
|
+
case 'state of aggregation subscript':
|
|
16739
|
+
res = "\\mskip1mu " + texify._goInner(buf.p1);
|
|
16740
|
+
break;
|
|
16741
|
+
case 'bond':
|
|
16742
|
+
res = texify._getBond(buf.kind_);
|
|
16743
|
+
if (!res) {
|
|
16744
|
+
throw ["MhchemErrorBond", "mhchem Error. Unknown bond type (" + buf.kind_ + ")"];
|
|
16745
|
+
}
|
|
16746
|
+
break;
|
|
16747
|
+
case 'frac':
|
|
16748
|
+
var c = "\\frac{" + buf.p1 + "}{" + buf.p2 + "}";
|
|
16749
|
+
res = "\\mathchoice{\\textstyle" + c + "}{" + c + "}{" + c + "}{" + c + "}";
|
|
16750
|
+
break;
|
|
16751
|
+
case 'pu-frac':
|
|
16752
|
+
var d = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}";
|
|
16753
|
+
res = "\\mathchoice{\\textstyle" + d + "}{" + d + "}{" + d + "}{" + d + "}";
|
|
16754
|
+
break;
|
|
16755
|
+
case 'tex-math':
|
|
16756
|
+
res = buf.p1 + " ";
|
|
16757
|
+
break;
|
|
16758
|
+
case 'frac-ce':
|
|
16759
|
+
res = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}";
|
|
16760
|
+
break;
|
|
16761
|
+
case 'overset':
|
|
16762
|
+
res = "\\overset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}";
|
|
16763
|
+
break;
|
|
16764
|
+
case 'underset':
|
|
16765
|
+
res = "\\underset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}";
|
|
16766
|
+
break;
|
|
16767
|
+
case 'underbrace':
|
|
16768
|
+
res = "\\underbrace{" + texify._goInner(buf.p1) + "}_{" + texify._goInner(buf.p2) + "}";
|
|
16769
|
+
break;
|
|
16770
|
+
case 'color':
|
|
16771
|
+
res = "{\\color{" + buf.color1 + "}{" + texify._goInner(buf.color2) + "}}";
|
|
16772
|
+
break;
|
|
16773
|
+
case 'color0':
|
|
16774
|
+
res = "\\color{" + buf.color + "}";
|
|
16775
|
+
break;
|
|
16776
|
+
case 'arrow':
|
|
16777
|
+
var b6 = {
|
|
16778
|
+
rd: texify._goInner(buf.rd),
|
|
16779
|
+
rq: texify._goInner(buf.rq)
|
|
16780
|
+
};
|
|
16781
|
+
var arrow = "\\x" + texify._getArrow(buf.r);
|
|
16782
|
+
if (b6.rq) {
|
|
16783
|
+
arrow += "[{" + b6.rq + "}]";
|
|
16784
|
+
}
|
|
16785
|
+
if (b6.rd) {
|
|
16786
|
+
arrow += "{" + b6.rd + "}";
|
|
16787
|
+
} else {
|
|
16788
|
+
arrow += "{}";
|
|
16789
|
+
}
|
|
16790
|
+
res = arrow;
|
|
16791
|
+
break;
|
|
16792
|
+
case 'operator':
|
|
16793
|
+
res = texify._getOperator(buf.kind_);
|
|
16794
|
+
break;
|
|
16795
|
+
case '1st-level escape':
|
|
16796
|
+
res = buf.p1 + " "; // &, \\\\, \\hlin
|
|
16797
|
+
break;
|
|
16798
|
+
case 'space':
|
|
16799
|
+
res = " ";
|
|
16800
|
+
break;
|
|
16801
|
+
case 'entitySkip':
|
|
16802
|
+
res = "~";
|
|
16803
|
+
break;
|
|
16804
|
+
case 'pu-space-1':
|
|
16805
|
+
res = "~";
|
|
16806
|
+
break;
|
|
16807
|
+
case 'pu-space-2':
|
|
16808
|
+
res = "\\mkern3mu ";
|
|
16809
|
+
break;
|
|
16810
|
+
case '1000 separator':
|
|
16811
|
+
res = "\\mkern2mu ";
|
|
16812
|
+
break;
|
|
16813
|
+
case 'commaDecimal':
|
|
16814
|
+
res = "{,}";
|
|
16815
|
+
break;
|
|
16816
|
+
case 'comma enumeration L':
|
|
16817
|
+
res = "{" + buf.p1 + "}\\mkern6mu ";
|
|
16818
|
+
break;
|
|
16819
|
+
case 'comma enumeration M':
|
|
16820
|
+
res = "{" + buf.p1 + "}\\mkern3mu ";
|
|
16821
|
+
break;
|
|
16822
|
+
case 'comma enumeration S':
|
|
16823
|
+
res = "{" + buf.p1 + "}\\mkern1mu ";
|
|
16824
|
+
break;
|
|
16825
|
+
case 'hyphen':
|
|
16826
|
+
res = "\\text{-}";
|
|
16827
|
+
break;
|
|
16828
|
+
case 'addition compound':
|
|
16829
|
+
res = "\\,{\\cdot}\\,";
|
|
16830
|
+
break;
|
|
16831
|
+
case 'electron dot':
|
|
16832
|
+
res = "\\mkern1mu \\bullet\\mkern1mu ";
|
|
16833
|
+
break;
|
|
16834
|
+
case 'KV x':
|
|
16835
|
+
res = "{\\times}";
|
|
16836
|
+
break;
|
|
16837
|
+
case 'prime':
|
|
16838
|
+
res = "\\prime ";
|
|
16839
|
+
break;
|
|
16840
|
+
case 'cdot':
|
|
16841
|
+
res = "\\cdot ";
|
|
16842
|
+
break;
|
|
16843
|
+
case 'tight cdot':
|
|
16844
|
+
res = "\\mkern1mu{\\cdot}\\mkern1mu ";
|
|
16845
|
+
break;
|
|
16846
|
+
case 'times':
|
|
16847
|
+
res = "\\times ";
|
|
16848
|
+
break;
|
|
16849
|
+
case 'circa':
|
|
16850
|
+
res = "{\\sim}";
|
|
16851
|
+
break;
|
|
16852
|
+
case '^':
|
|
16853
|
+
res = "uparrow";
|
|
16854
|
+
break;
|
|
16855
|
+
case 'v':
|
|
16856
|
+
res = "downarrow";
|
|
16857
|
+
break;
|
|
16858
|
+
case 'ellipsis':
|
|
16859
|
+
res = "\\ldots ";
|
|
16860
|
+
break;
|
|
16861
|
+
case '/':
|
|
16862
|
+
res = "/";
|
|
16863
|
+
break;
|
|
16864
|
+
case ' / ':
|
|
16865
|
+
res = "\\,/\\,";
|
|
16866
|
+
break;
|
|
16867
|
+
default:
|
|
16868
|
+
assertNever(buf);
|
|
16869
|
+
throw ["MhchemBugT", "mhchem bug T. Please report."];
|
|
16870
|
+
// Missing texify rule or unknown MhchemParser output
|
|
16871
|
+
}
|
|
16872
|
+
assertString(res);
|
|
16873
|
+
return res;
|
|
16874
|
+
},
|
|
16875
|
+
_getArrow: function (a) {
|
|
16876
|
+
switch (a) {
|
|
16877
|
+
case "->":
|
|
16878
|
+
return "rightarrow";
|
|
16879
|
+
case "\u2192":
|
|
16880
|
+
return "rightarrow";
|
|
16881
|
+
case "\u27F6":
|
|
16882
|
+
return "rightarrow";
|
|
16883
|
+
case "<-":
|
|
16884
|
+
return "leftarrow";
|
|
16885
|
+
case "<->":
|
|
16886
|
+
return "leftrightarrow";
|
|
16887
|
+
case "<-->":
|
|
16888
|
+
return "rightleftarrows";
|
|
16889
|
+
case "<=>":
|
|
16890
|
+
return "rightleftharpoons";
|
|
16891
|
+
case "\u21CC":
|
|
16892
|
+
return "rightleftharpoons";
|
|
16893
|
+
case "<=>>":
|
|
16894
|
+
return "rightequilibrium";
|
|
16895
|
+
case "<<=>":
|
|
16896
|
+
return "leftequilibrium";
|
|
16897
|
+
default:
|
|
16898
|
+
assertNever(a);
|
|
16899
|
+
throw ["MhchemBugT", "mhchem bug T. Please report."];
|
|
16900
|
+
}
|
|
16901
|
+
},
|
|
16902
|
+
_getBond: function (a) {
|
|
16903
|
+
switch (a) {
|
|
16904
|
+
case "-":
|
|
16905
|
+
return "{-}";
|
|
16906
|
+
case "1":
|
|
16907
|
+
return "{-}";
|
|
16908
|
+
case "=":
|
|
16909
|
+
return "{=}";
|
|
16910
|
+
case "2":
|
|
16911
|
+
return "{=}";
|
|
16912
|
+
case "#":
|
|
16913
|
+
return "{\\equiv}";
|
|
16914
|
+
case "3":
|
|
16915
|
+
return "{\\equiv}";
|
|
16916
|
+
case "~":
|
|
16917
|
+
return "{\\tripledash}";
|
|
16918
|
+
case "~-":
|
|
16919
|
+
return "{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}";
|
|
16920
|
+
case "~=":
|
|
16921
|
+
return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";
|
|
16922
|
+
case "~--":
|
|
16923
|
+
return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}";
|
|
16924
|
+
case "-~-":
|
|
16925
|
+
return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}";
|
|
16926
|
+
case "...":
|
|
16927
|
+
return "{{\\cdot}{\\cdot}{\\cdot}}";
|
|
16928
|
+
case "....":
|
|
16929
|
+
return "{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}";
|
|
16930
|
+
case "->":
|
|
16931
|
+
return "{\\rightarrow}";
|
|
16932
|
+
case "<-":
|
|
16933
|
+
return "{\\leftarrow}";
|
|
16934
|
+
case "<":
|
|
16935
|
+
return "{<}";
|
|
16936
|
+
case ">":
|
|
16937
|
+
return "{>}";
|
|
16938
|
+
default:
|
|
16939
|
+
assertNever(a);
|
|
16940
|
+
throw ["MhchemBugT", "mhchem bug T. Please report."];
|
|
16941
|
+
}
|
|
16942
|
+
},
|
|
16943
|
+
_getOperator: function (a) {
|
|
16944
|
+
switch (a) {
|
|
16945
|
+
case "+":
|
|
16946
|
+
return " {}+{} ";
|
|
16947
|
+
case "-":
|
|
16948
|
+
return " {}-{} ";
|
|
16949
|
+
case "=":
|
|
16950
|
+
return " {}={} ";
|
|
16951
|
+
case "<":
|
|
16952
|
+
return " {}<{} ";
|
|
16953
|
+
case ">":
|
|
16954
|
+
return " {}>{} ";
|
|
16955
|
+
case "<<":
|
|
16956
|
+
return " {}\\ll{} ";
|
|
16957
|
+
case ">>":
|
|
16958
|
+
return " {}\\gg{} ";
|
|
16959
|
+
case "\\pm":
|
|
16960
|
+
return " {}\\pm{} ";
|
|
16961
|
+
case "\\approx":
|
|
16962
|
+
return " {}\\approx{} ";
|
|
16963
|
+
case "$\\approx$":
|
|
16964
|
+
return " {}\\approx{} ";
|
|
16965
|
+
case "v":
|
|
16966
|
+
return " \\downarrow{} ";
|
|
16967
|
+
case "(v)":
|
|
16968
|
+
return " \\downarrow{} ";
|
|
16969
|
+
case "^":
|
|
16970
|
+
return " \\uparrow{} ";
|
|
16971
|
+
case "(^)":
|
|
16972
|
+
return " \\uparrow{} ";
|
|
16973
|
+
default:
|
|
16974
|
+
assertNever(a);
|
|
16975
|
+
throw ["MhchemBugT", "mhchem bug T. Please report."];
|
|
16976
|
+
}
|
|
16977
|
+
}
|
|
16978
|
+
};
|
|
16979
|
+
|
|
16980
|
+
//
|
|
16981
|
+
// Helpers for code anaylsis
|
|
16982
|
+
// Will show type error at calling position
|
|
16983
|
+
//
|
|
16984
|
+
/** @param {number} a */
|
|
16985
|
+
function assertNever(a) {}
|
|
16986
|
+
/** @param {string} a */
|
|
16987
|
+
function assertString(a) {}
|
|
14108
16988
|
;// CONCATENATED MODULE: ./node_modules/thread-loader/dist/cjs.js!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[1]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/read-over.vue?vue&type=script&lang=js
|
|
14109
16989
|
|
|
14110
16990
|
|
|
14111
16991
|
|
|
14112
16992
|
|
|
16993
|
+
|
|
14113
16994
|
/* harmony default export */ var read_overvue_type_script_lang_js = ({
|
|
14114
16995
|
name: 'ReadOver',
|
|
14115
16996
|
components: {
|
|
@@ -14146,6 +17027,7 @@ if(typeof document!=="undefined"){if(document.compatMode!=="CSS1Compat"){typeof
|
|
|
14146
17027
|
},
|
|
14147
17028
|
renderFormulas(text) {
|
|
14148
17029
|
if (!text) return '';
|
|
17030
|
+
text = text.replace(/>/g, '>').replace(/</g, '<').replace(/&/g, '&').replace(/"/g, '"').replace(/'/g, "'");
|
|
14149
17031
|
// 如果整个文本包含 LaTeX 命令且没有定界符,整体包裹
|
|
14150
17032
|
const hasDelimiter = /\$|\\\(|\\\[/.test(text);
|
|
14151
17033
|
if (!hasDelimiter) {
|
|
@@ -14155,52 +17037,52 @@ if(typeof document!=="undefined"){if(document.compatMode!=="CSS1Compat"){typeof
|
|
|
14155
17037
|
renderToString
|
|
14156
17038
|
} = katex;
|
|
14157
17039
|
return text
|
|
14158
|
-
// 块级公式
|
|
14159
|
-
.replace(/\$\$(
|
|
17040
|
+
// $$ ... $$ 块级公式
|
|
17041
|
+
.replace(/\$\$([\s\S]*?)\$\$/gs, function (_, formula) {
|
|
14160
17042
|
try {
|
|
14161
|
-
|
|
14162
|
-
|
|
14163
|
-
|
|
17043
|
+
const trimmedFormula = formula.trim();
|
|
17044
|
+
return renderToString(trimmedFormula, {
|
|
17045
|
+
displayMode: true
|
|
14164
17046
|
});
|
|
14165
|
-
} catch (
|
|
14166
|
-
console.error('
|
|
14167
|
-
return
|
|
17047
|
+
} catch (error) {
|
|
17048
|
+
console.error('Error rendering block formula:', error);
|
|
17049
|
+
return _;
|
|
14168
17050
|
}
|
|
14169
17051
|
})
|
|
14170
|
-
// 行内公式
|
|
14171
|
-
.replace(
|
|
17052
|
+
// \(...\) 行内公式
|
|
17053
|
+
.replace(/\\\((.*?)\\\)/gs, function (_, formula) {
|
|
14172
17054
|
try {
|
|
14173
|
-
|
|
14174
|
-
|
|
14175
|
-
|
|
17055
|
+
const trimmedFormula = formula.trim();
|
|
17056
|
+
return renderToString(trimmedFormula, {
|
|
17057
|
+
displayMode: false
|
|
14176
17058
|
});
|
|
14177
|
-
} catch (
|
|
14178
|
-
console.error('
|
|
14179
|
-
return
|
|
17059
|
+
} catch (error) {
|
|
17060
|
+
console.error('Error rendering inline formula:', error);
|
|
17061
|
+
return _;
|
|
14180
17062
|
}
|
|
14181
17063
|
})
|
|
14182
|
-
//
|
|
14183
|
-
.replace(/\\\(
|
|
17064
|
+
// \[...\] 块级公式
|
|
17065
|
+
.replace(/\\\[(.*?)\\\]/gs, function (_, formula) {
|
|
14184
17066
|
try {
|
|
14185
|
-
|
|
14186
|
-
|
|
14187
|
-
|
|
17067
|
+
const trimmedFormula = formula.trim();
|
|
17068
|
+
return renderToString(trimmedFormula, {
|
|
17069
|
+
displayMode: true
|
|
14188
17070
|
});
|
|
14189
|
-
} catch (
|
|
14190
|
-
console.error('
|
|
14191
|
-
return
|
|
17071
|
+
} catch (error) {
|
|
17072
|
+
console.error('Error rendering block formula:', error);
|
|
17073
|
+
return _;
|
|
14192
17074
|
}
|
|
14193
17075
|
})
|
|
14194
|
-
//
|
|
14195
|
-
.replace(
|
|
17076
|
+
// $...$ 行内公式
|
|
17077
|
+
.replace(/\$(.+?)\$/gs, function (_, formula) {
|
|
14196
17078
|
try {
|
|
14197
|
-
|
|
14198
|
-
|
|
14199
|
-
|
|
17079
|
+
const trimmedFormula = formula.trim();
|
|
17080
|
+
return renderToString(trimmedFormula, {
|
|
17081
|
+
displayMode: false
|
|
14200
17082
|
});
|
|
14201
|
-
} catch (
|
|
14202
|
-
console.error('
|
|
14203
|
-
return
|
|
17083
|
+
} catch (error) {
|
|
17084
|
+
console.error('Error rendering inline formula with $...$:', error);
|
|
17085
|
+
return _;
|
|
14204
17086
|
}
|
|
14205
17087
|
});
|
|
14206
17088
|
}
|
|
@@ -14208,10 +17090,10 @@ if(typeof document!=="undefined"){if(document.compatMode!=="CSS1Compat"){typeof
|
|
|
14208
17090
|
});
|
|
14209
17091
|
;// CONCATENATED MODULE: ./components/demo/src/read-over.vue?vue&type=script&lang=js
|
|
14210
17092
|
/* harmony default export */ var src_read_overvue_type_script_lang_js = (read_overvue_type_script_lang_js);
|
|
14211
|
-
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-22.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-22.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-22.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-22.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/read-over.vue?vue&type=style&index=0&id=
|
|
17093
|
+
;// CONCATENATED MODULE: ./node_modules/mini-css-extract-plugin/dist/loader.js??clonedRuleSet-22.use[0]!./node_modules/css-loader/dist/cjs.js??clonedRuleSet-22.use[1]!./node_modules/@vue/vue-loader-v15/lib/loaders/stylePostLoader.js!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-22.use[2]!./node_modules/sass-loader/dist/cjs.js??clonedRuleSet-22.use[3]!./node_modules/@vue/vue-loader-v15/lib/index.js??vue-loader-options!./components/demo/src/read-over.vue?vue&type=style&index=0&id=339a0348&prod&lang=scss&scoped=true
|
|
14212
17094
|
// extracted by mini-css-extract-plugin
|
|
14213
17095
|
|
|
14214
|
-
;// CONCATENATED MODULE: ./components/demo/src/read-over.vue?vue&type=style&index=0&id=
|
|
17096
|
+
;// CONCATENATED MODULE: ./components/demo/src/read-over.vue?vue&type=style&index=0&id=339a0348&prod&lang=scss&scoped=true
|
|
14215
17097
|
|
|
14216
17098
|
;// CONCATENATED MODULE: ./components/demo/src/read-over.vue
|
|
14217
17099
|
|
|
@@ -14224,11 +17106,11 @@ if(typeof document!=="undefined"){if(document.compatMode!=="CSS1Compat"){typeof
|
|
|
14224
17106
|
|
|
14225
17107
|
var read_over_component = normalizeComponent(
|
|
14226
17108
|
src_read_overvue_type_script_lang_js,
|
|
14227
|
-
|
|
14228
|
-
|
|
17109
|
+
read_overvue_type_template_id_339a0348_scoped_true_render,
|
|
17110
|
+
read_overvue_type_template_id_339a0348_scoped_true_staticRenderFns,
|
|
14229
17111
|
false,
|
|
14230
17112
|
null,
|
|
14231
|
-
"
|
|
17113
|
+
"339a0348",
|
|
14232
17114
|
null
|
|
14233
17115
|
|
|
14234
17116
|
)
|