first commit

This commit is contained in:
Missdrop
2025-07-16 16:30:56 +00:00
commit 7ee33927cb
11326 changed files with 1230901 additions and 0 deletions

201
node_modules/mhchemparser/LICENSE.txt generated vendored Normal file
View File

@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright {yyyy} {name of copyright owner}
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

35
node_modules/mhchemparser/README.md generated vendored Normal file
View File

@@ -0,0 +1,35 @@
# mhchem Parser
mhchem is an input syntax for typesetting chemical equations and physical units.
This is the parser to convert mhchem syntax to LaTeX syntax, for downstream inclusion in [MathJax](https://mathjax.org), [KaTeX](https://katex.org) and similar projects.
## Usage
Users of MathJax and KaTex can write
\ce{CO2 + C -> 2 CO}
\pu{123 kJ*mol-1}
For a hundred more features and how to configure MathJax or KaTeX, see
[the manual](https://mhchem.github.io/MathJax-mhchem/).
## Usage for Downstream Software
For "translating" the `\ce` syntax, make a call like
mhchemParser.toTex("CO2 + C -> 2 CO", "ce");
This will return
"{\mathrm{CO}{\vphantom{A}}_{\smash[t]{2}} {}+{} \mathrm{C} {}\mathrel{\longrightarrow}{} 2\,\mathrm{CO}}"
For the `\pu` command, call
mhchemParser.toTex("123 kJ*mol-1", "pu");
You could also insert a TeX string. All instances of `\ce` and `\pu` will be replaced in the returned value. This might make integration easier, because the mhchem parser does not need to be called from the TeX parser.
mhchemParser.toTex("m_{\\ce{H2O}}", "tex");

35
node_modules/mhchemparser/dist/mhchemParser.d.ts generated vendored Normal file
View File

@@ -0,0 +1,35 @@
/*!
*************************************************************************
*
* mhchemParser.ts
* 4.2.1
*
* Parser for the \ce command and \pu command for MathJax and Co.
*
* mhchem's \ce is a tool for writing beautiful chemical equations easily.
* mhchem's \pu is a tool for writing physical units easily.
*
* ----------------------------------------------------------------------
*
* Copyright (c) 2015-2023 Martin Hensel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ----------------------------------------------------------------------
*
* https://github.com/mhchem/mhchemParser
*
*/
export declare class mhchemParser {
static toTex(input: string, type: "tex" | "ce" | "pu"): string;
}

1758
node_modules/mhchemparser/dist/mhchemParser.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

35
node_modules/mhchemparser/esm/mhchemParser.d.ts generated vendored Normal file
View File

@@ -0,0 +1,35 @@
/*!
*************************************************************************
*
* mhchemParser.ts
* 4.2.1
*
* Parser for the \ce command and \pu command for MathJax and Co.
*
* mhchem's \ce is a tool for writing beautiful chemical equations easily.
* mhchem's \pu is a tool for writing physical units easily.
*
* ----------------------------------------------------------------------
*
* Copyright (c) 2015-2023 Martin Hensel
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* ----------------------------------------------------------------------
*
* https://github.com/mhchem/mhchemParser
*
*/
export declare class mhchemParser {
static toTex(input: string, type: "tex" | "ce" | "pu"): string;
}

1751
node_modules/mhchemparser/esm/mhchemParser.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

3
node_modules/mhchemparser/esm/package.json generated vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"type": "module"
}

12
node_modules/mhchemparser/package.json generated vendored Normal file
View File

@@ -0,0 +1,12 @@
{
"name": "mhchemparser",
"version": "4.2.1",
"description": "Parser to convert mhchem syntax to LaTeX syntax, for downstream inclusion in MathJax, KaTeX and similar projects.",
"keywords": [ "mhchem", "MathJax", "LaTeX", "chemistry" ],
"homepage": "https://github.com/mhchem/mhchemParser",
"bugs": "https://github.com/mhchem/mhchemParser/issues",
"repository": "github:mhchem/mhchemParser",
"license": "Apache-2.0",
"author": "Martin Hensel",
"main": "dist/mhchemParser.js"
}

251
node_modules/mhchemparser/src/mhchemParser.d.ts generated vendored Normal file
View File

@@ -0,0 +1,251 @@
interface MhchemParser {
go: { (input: string | undefined, stateMachine: StateMachineName): Parsed[]; };
concatArray: { (a: any[], b: any): void };
patterns: {
patterns: {
[pattern in PatternNameReturningString]?:
RegExp | PatternFunction<string>
} & {
[pattern in PatternNameReturningArray]?:
RegExp | PatternFunction<string[]>
};
findObserveGroups: {
(
input: string,
begExcl: string | RegExp,
begIncl: string | RegExp,
endIncl: string | RegExp,
endExcl: string | RegExp,
beg2Excl?: string | RegExp,
beg2Incl?: string | RegExp,
end2Incl?: string | RegExp,
end2Excl?: string | RegExp,
combine?: boolean
): MatchResult<string | string[]>
};
match_: { (m: PatternName, input: string): MatchResult<string | string[]> | null };
},
actions: ActionList;
stateMachines: { [key in StateMachineName]: StateMachine };
}
type PatternFunction<T> = (input: string) => MatchResult<T> | null;
type StateMachineName = "tex" | "ce" | "a" | "o" | "text" | "pq" | "bd" | "oxidation" | "tex-math" | "tex-math tight" | "9,9" | "pu" | "pu-2" | "pu-9,9";
type MatchResult<T> = {
match_: T;
remainder: string;
}
type StateName =
"0" | // begin of main part (arrow/operator unlikely)
"1" | // next entity
"2" | // next entity (arrow/operator unlikely)
"3" | // next atom
"c" | // macro
"a" | // amount
"o" | // element
"b" | // left-side superscript
"p" | // left-side subscript
"q" | // right-side subscript
"d" | "D" | // right-side superscript
"r" | // arrow
"rd" | // arrow, script above
"f" | "*";
type StateNameCombined = StateName | "0|1|2" | "0|1|2|3" | "0|1|2|3|a|as|b|p|bp" | "0|1|2|3|a|as|b|p|bp|o" | "0|1|2|3|a|as|b|p|bp|o|c0" | "0|1|2|3|a|as|o" | "0|1|2|3|a|as|o|q|d|D|qd|qD|dq" | "0|1|2|3|as|b|p|bp|o" | "0|1|2|3|b|p|bp|o" | "0|1|2|a|as" | "0|1|2|as" | "0|2" | "0|a" | "0|d" | "1|2" | "1|3" | "3|o" | "a|as" | "a|as|d|D|q|qd|qD|dq" | "a|as|o" | "as" | "as|o" | "b|p|bp" | "d|D" | "d|D|q|qd|qD|dq" | "d|D|qd|qD" | "d|D|qd|qD|dq" | "d|qd|D|qD" | "d|qd|dq" | "D|qD|p" | "dq" | "o|d|D|dq|qd|qD" | "o|d|D|q|qd|qD|dq" | "o|q" | "q|d|D|qd|qD|dq" | "q|dq" | "q|qd|qD|dq" | "qd" | "qD|dq" | "qd|qD" | "r|rt" | "r|rt|rd|rdt|rdq" | "rd|rdt" | "/|q";
type ActionList = {
[key in ActionNameUsingMNone]?: ActionFunction<string>
} & {
[key in ActionNameUsingMString]?: ActionFunction<string>
} & {
[key in ActionNameUsingMStringOption]?: ActionFunction<string>
} & {
[key in ActionNameUsingMArray]?: ActionFunction<string[]>
}
interface ActionFunction<T> {
(buffer: Buffer, m?: T, option?: string | number | boolean): undefined | Parsed | Parsed[];
}
type TransitionsRaw = {
[pattern in PatternNameReturningString]?: {
[state in StateNameCombined]?: {
action_:
ActionNameUsingMString | ActionNameUsingMStringOption | ActionNameUsingMNone |
ActionNameWithParameter<ActionNameUsingMString> | ActionNameWithParameter<ActionNameUsingMStringOption> | ActionNameWithParameter<ActionNameUsingMNone> |
(ActionNameUsingMString | ActionNameUsingMStringOption | ActionNameUsingMNone |
ActionNameWithParameter<ActionNameUsingMString> | ActionNameWithParameter<ActionNameUsingMStringOption> | ActionNameWithParameter<ActionNameUsingMNone>)[];
nextState?: string;
revisit?: boolean;
toContinue?: boolean;
stateArray?: StateName[];
}
}
} & {
[pattern in PatternNameReturningArray2]?: {
[state in StateNameCombined]?: {
action_:
ActionNameUsingMArray2 | (ActionNameUsingMArray2 | ActionNameUsingMString | ActionNameUsingMNone | ActionNameWithParameter<ActionNameUsingMNone>)[]; // ... list ist not complete
nextState?: string;
revisit?: boolean;
toContinue?: boolean;
stateArray?: StateName[];
}
}
} & {
[pattern in PatternNameReturningArray3]?: {
[state in StateNameCombined]?: {
action_: ActionNameUsingMArray3 | ActionNameUsingMArray3[];
nextState?: string;
revisit?: boolean;
toContinue?: boolean;
stateArray?: StateName[];
}
}
} & {
[pattern in PatternNameReturningArray6]?: {
[state in StateNameCombined]?: {
action_: ActionNameUsingMArray6 | ActionNameUsingMArray6[];
nextState?: string;
revisit?: boolean;
toContinue?: boolean;
stateArray?: StateName[];
}
}
}
type PatternNameReturningString =
"empty" | "else" | "else2" | "space" | "space A" | "space$" | "a-z" | "x" | "x$" | "i$" | "letters" | "\\greek" | "one lowercase latin letter $" | "$one lowercase latin letter$ $" | "one lowercase greek letter $" | "digits" | "-9.,9" | "-9.,9 no missing 0" | "state of aggregation $" | "{[(" | ")]}" | ", " | "," | "." | ". __* " | "..." | "^{(...)}" | "^($...$)" | "^a" | "^\\x{}" | "^\\x" | "^(-1)" | "\'" | "_{(...)}" | "_($...$)" | "_9" | "_\\x{}{}" | "_\\x{}" | "_\\x" | "^_" | "{}^" | "{}" | "{...}" | "{(...)}" | "$...$" | "${(...)}$__$(...)$" | "=<>" | "#" | "+" | "-$" | "-9" | "- orbital overlap" | "-" | "pm-operator" | "operator" | "arrowUpDown" | "\\bond{(...)}" | "->" | "CMT" | "[(...)]" | "1st-level escape" | "\\," | "\\x{}" | "\\ca" | "\\x" | "orbital" | "others" | "\\color{(...)}" | "\\ce{(...)}" | "\\pu{(...)}" | "oxidation$" | "d-oxidation$" | "1/2$" | "amount" | "amount2" | "(KV letters)," | "formula$" | "uprightEntities" | "/" | "//" | "*" | "\\x{}{}" | "^\\x{}{}" |
"^{(...)}|^($...$)" | "^a|^\\x{}{}|^\\x{}|^\\x|\'" | "_{(...)}|_($...$)|_9|_\\x{}{}|_\\x{}|_\\x" | "\\,|\\x{}{}|\\x{}|\\x" | "{...}|\\,|\\x{}{}|\\x{}|\\x" | "\\x{}{}|\\x{}|\\x" | "-|+" | "{[(|)]}" | "{...}|else" | "^{(...)}|^(-1)";
type PatternNameReturningArray2 = "_{(state of aggregation)}$" | "\\frac{(...)}" | "\\overset{(...)}" | "\\underset{(...)}" | "\\underbrace{(...)}" | "\\color{(...)}{(...)}";
type PatternNameReturningArray3 = "(-)(9)^(-9)";
type PatternNameReturningArray6 = "(-)(9.,9)(e)(99)";
type PatternName = PatternNameReturningString | PatternNameReturningArray2 | PatternNameReturningArray3 | PatternNameReturningArray6;
type PatternNameReturningArray = PatternNameReturningArray2 | PatternNameReturningArray3 | PatternNameReturningArray6;
type ActionNameUsingMNone = "a to o" | "sb=true" | "sb=false" | "beginsWithBond=true" | "beginsWithBond=false" | "parenthesisLevel++" | "parenthesisLevel--" | "output" | "space" | "cdot" | "output-0" | "output-o" | "tight operator";
type ActionNameUsingMString = "a=" | "b=" | "p=" | "o=" | "o=+p1" | "q=" | "d=" | "rm=" | "text=" | "copy" | "rm" | "text" | "tex-math" | "tex-math tight" | "ce" | "pu" | "1/2" | "9,9" | "o after d" | "d= kv" | "charge or bond" | "state of aggregation" | "comma" | "oxidation-output" | "r=" | "rdt=" | "rd=" | "rqt=" | "rq=" | "operator" | "bond" | "color0-output" | "roman-numeral" | "^(-1)";
type ActionNameUsingMStringOption = "insert" | "insert+p1" | "write" | "bond" | "- after o/d";
type ActionNameUsingMArray2 = "insert+p1+p2" | "frac-output" | "overset-output" | "underset-output" | "underbrace-output" | "color-output";
type ActionNameUsingMArray3 = "number^";
type ActionNameUsingMArray6 = "enumber";
type ActionName = ActionNameUsingMNone | ActionNameUsingMString | ActionNameUsingMStringOption | ActionNameUsingMArray2 | ActionNameUsingMArray3 | ActionNameUsingMArray6;
type ActionNameUsingMArray = ActionNameUsingMArray2 | ActionNameUsingMArray3 | ActionNameUsingMArray6;
type StateMachine = {
transitions: Transitions;
actions: ActionList;
}
type Transitions = {
[state in StateName]?: Transition[];
}
interface Transition { // e.g. { pattern: 'letter', task: { '*': { action_: ['output'], nextState: '1' } } }
pattern: PatternName;
task: Action;
}
interface Action {
action_: ActionNameWithParameter<ActionName>[];
nextState?: StateName;
revisit?: boolean;
toContinue?: boolean;
}
interface ActionNameWithParameter<T> {
type_: T;
option?: string | number | boolean;
}
interface Buffer {
a?: string; // amount
o?: string; // element
b?: string; // left-side superscript
p?: string; // left-side subscript
q?: string; // right-side subscript
d?: string; // right-side superscript
dType?: string;
r?: ArrowName; // arrow
rdt?: string; // arrow, script above, type
rd?: string; // arrow, script above, content
rqt?: string; // arrow, script below, type
rq?: string; // arrow, script below, content
text_?: string;
rm?: string;
parenthesisLevel?: number; // starting at 0
sb?: boolean; // space before
beginsWithBond?: boolean;
}
type ParsedWithoutString =
{ type_: "chemfive",
a: Parsed[],
b: Parsed[],
p: Parsed[],
o: Parsed[],
q: Parsed[],
d: Parsed[],
dType: string } |
{ type_: "rm", p1: string } |
{ type_: "text", p1: string } |
{ type_: "roman numeral", p1: string } |
{ type_: "state of aggregation", p1: Parsed[] } |
{ type_: "state of aggregation subscript", p1: Parsed[] } |
{ type_: "bond", kind_: BondName } |
{ type_: "frac", p1: string, p2: string } |
{ type_: "pu-frac", p1: Parsed[], p2: Parsed[] } |
{ type_: "tex-math", p1: string } |
{ type_: "frac-ce", p1: Parsed[], p2: Parsed[] } |
{ type_: "overset", p1: Parsed[], p2: Parsed[] } |
{ type_: "underset", p1: Parsed[], p2: Parsed[] } |
{ type_: "underbrace", p1: Parsed[], p2: Parsed[] } |
{ type_: "color", color1: string, color2: Parsed[] } |
{ type_: "color0", color: string } |
{ type_: "arrow",
r: ArrowName,
rd?: Parsed[],
rq?: Parsed[]} |
{ type_: "operator", kind_: OperatorName } |
{ type_: "1st-level escape", p1: string } |
{ type_: "space" } |
{ type_: "tinySkip" } |
{ type_: "entitySkip" } |
{ type_: "pu-space-1" } |
{ type_: "pu-space-2" } |
{ type_: "1000 separator" } |
{ type_: "commaDecimal" } |
{ type_: "comma enumeration L", p1: string } |
{ type_: "comma enumeration M", p1: string } |
{ type_: "comma enumeration S", p1: string } |
{ type_: "hyphen" } |
{ type_: "addition compound" } |
{ type_: "electron dot" } |
{ type_: "KV x" } |
{ type_: "prime" } |
{ type_: "cdot" } |
{ type_: "tight cdot" } |
{ type_: "times" } |
{ type_: "circa" } |
{ type_: "^" } |
{ type_: "v" } |
{ type_: "ellipsis" } |
{ type_: "/" } |
{ type_: " / " };
type Parsed = ParsedWithoutString | string;
type ArrowName = "->" | "\u2192" | "\u27F6" | "<-" | "<->" | "<-->" | "<=>" | "\u21CC" | "<=>>" | "<<=>"; // keep aligned with definition of pattern '->'
type BondName = "-" | "1" | "=" | "2" | "#" | "3" | "~" | "~-" | "~=" | "~--" | "-~-" | "..." | "...." | "->" | "<-" | "<" | ">";
type OperatorName = "+" | "-" | "=" | "<" | ">" | "<<" | ">>" | "\\pm" | "\\approx" | "$\\approx$" | "v" | "(v)" | "^" | "(^)";
interface MhchemTexify {
go: { (input: Parsed[] | undefined, isInner?: boolean): string; };
_goInner: { (input: Parsed[]): string};
_go2: { (input: ParsedWithoutString): string };
_getArrow: { (input: ArrowName): string };
_getBond: { (input: BondName): string };
_getOperator: { (input: OperatorName): string };
}

1626
node_modules/mhchemparser/src/mhchemParser.ts generated vendored Normal file

File diff suppressed because it is too large Load Diff

212
node_modules/mhchemparser/test/test-dist.html generated vendored Normal file
View File

@@ -0,0 +1,212 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<script>
var exports = {};
</script>
<script src="../dist/mhchemParser.js"></script>
</head>
<body>
<h1>mhchem Parser Tests</h1>
<div id="output"><span style="color: red">Could not load parser. This is likely a CORS restriction, e.g. if you opened this document via file://.</span></div>
<script>
document.getElementById('output').innerHTML = '';
/// create tests
let errorsFound = false;
function test(type, input, expected) {
let actual = mhchemParser.toTex(input, type);
if (actual !== expected) {
output('<span style="color: red">Test case failed. ' + input + '</span>');
errorsFound = true;
}
}
function output(html) {
let a = document.createElement('p');
a.innerHTML = html;
document.getElementById('output').appendChild(a);
}
///
/// test cases
///
test('tex', 'm_{\\ce{H2O}} = \\pu{1.2kg}', 'm_{{\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}} = {1.2~\\mathrm{kg}}')
///
/// test cases from documentation
///
/// Chemical Equations
test('ce', 'CO2 + C -> 2 CO', '{\\mathrm{CO}{\\vphantom{A}}_{\\smash[t]{2}} {}+{} \\mathrm{C} {}\\mathrel{\\longrightarrow}{} 2\\,\\mathrm{CO}}');
test('ce', 'Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-', '{\\mathrm{Hg}{\\vphantom{A}}^{2+} {}\\mathrel{\\xrightarrow{\\mathrm{I}{\\vphantom{A}}^{-}}}{} \\mathrm{HgI}{\\vphantom{A}}_{\\smash[t]{2}} {}\\mathrel{\\xrightarrow{\\mathrm{I}{\\vphantom{A}}^{-}}}{} [\\mathrm{Hg}{\\vphantom{A}}^{\\mathrm{II}}\\mathrm{I}{\\vphantom{A}}_{\\smash[t]{4}}]{\\vphantom{A}}^{2-}}');
/// Chemical formulae
test('ce', 'H2O', '{\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'Sb2O3', '{\\mathrm{Sb}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}{\\vphantom{A}}_{\\smash[t]{3}}}');
/// Charges
test('ce', 'H+', '{\\mathrm{H}{\\vphantom{A}}^{+}}');
test('ce', 'CrO4^2-', '{\\mathrm{CrO}{\\vphantom{A}}_{\\smash[t]{4}}{\\vphantom{A}}^{2-}}');
test('ce', '[AgCl2]-', '{[\\mathrm{AgCl}{\\vphantom{A}}_{\\smash[t]{2}}]{\\vphantom{A}}^{-}}');
test('ce', 'Y^99+', '{\\mathrm{Y}{\\vphantom{A}}^{99+}}');
test('ce', 'Y^{99+}', '{\\mathrm{Y}{\\vphantom{A}}^{99+}}');
/// Stoichiometric Numbers
test('ce', '2 H2O', '{2\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', '2H2O', '{2\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', '0.5 H2O', '{0.5\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', '1/2 H2O', '{\\mathchoice{\\textstyle\\frac{1}{2}}{\\frac{1}{2}}{\\frac{1}{2}}{\\frac{1}{2}}\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', '(1/2) H2O', '{(1/2)\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', '$n$ H2O', '{n \\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'n H2O', '{n\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'nH2O', '{n\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'n/2 H2O', '{\\mathchoice{\\textstyle\\frac{n}{2}}{\\frac{n}{2}}{\\frac{n}{2}}{\\frac{n}{2}}\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
/// Nuclides, Isotopes
test('ce', '^{227}_{90}Th+', '{{\\vphantom{A}}^{\\hphantom{227}}_{\\hphantom{90}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{227}}_{\\vphantom{2}\\llap{\\smash[t]{90}}}\\mathrm{Th}{\\vphantom{A}}^{+}}');
test('ce', '^227_90Th+', '{{\\vphantom{A}}^{\\hphantom{227}}_{\\hphantom{90}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{227}}_{\\vphantom{2}\\llap{\\smash[t]{90}}}\\mathrm{Th}{\\vphantom{A}}^{+}}');
test('ce', '^{0}_{-1}n^{-}', '{{\\vphantom{A}}^{\\hphantom{0}}_{\\hphantom{-1}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{0}}_{\\vphantom{2}\\llap{\\smash[t]{-1}}}\\mathrm{n}{\\vphantom{A}}^{-}}');
test('ce', '^0_-1n-', '{{\\vphantom{A}}^{\\hphantom{0}}_{\\hphantom{-1}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{0}}_{\\vphantom{2}\\llap{\\smash[t]{-1}}}\\mathrm{n}{\\vphantom{A}}^{-}}');
test('ce', 'H{}^3HO', '{\\mathrm{H}\\mkern2mu{\\vphantom{A}}^{\\hphantom{3}}_{\\hphantom{}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{3}}_{\\vphantom{2}\\llap{\\smash[t]{}}}\\mathrm{HO}}');
test('ce', 'H^3HO', '{\\mathrm{H}\\mkern2mu{\\vphantom{A}}^{\\hphantom{3}}_{\\hphantom{}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{3}}_{\\vphantom{2}\\llap{\\smash[t]{}}}\\mathrm{HO}}');
/// Reaction Arrows
test('ce', 'A -> B', '{\\mathrm{A} {}\\mathrel{\\longrightarrow}{} \\mathrm{B}}');
test('ce', 'A <- B', '{\\mathrm{A} {}\\mathrel{\\longleftarrow}{} \\mathrm{B}}');
test('ce', 'A <-> B', '{\\mathrm{A} {}\\mathrel{\\longleftrightarrow}{} \\mathrm{B}}');
test('ce', 'A <--> B', '{\\mathrm{A} {}\\mathrel{\\longleftrightarrows}{} \\mathrm{B}}');
test('ce', 'A <=> B', '{\\mathrm{A} {}\\mathrel{\\longrightleftharpoons}{} \\mathrm{B}}');
test('ce', 'A <=>> B', '{\\mathrm{A} {}\\mathrel{\\longRightleftharpoons}{} \\mathrm{B}}');
test('ce', 'A <<=> B', '{\\mathrm{A} {}\\mathrel{\\longLeftrightharpoons}{} \\mathrm{B}}');
test('ce', 'A ->[H2O] B', '{\\mathrm{A} {}\\mathrel{\\xrightarrow{\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}}{} \\mathrm{B}}');
test('ce', 'A ->[{text above}][{text below}] B', '{\\mathrm{A} {}\\mathrel{\\xrightarrow[{{\\text{text below}}}]{{\\text{text above}}}}{} \\mathrm{B}}');
test('ce', 'A ->[$x$][$x_i$] B', '{\\mathrm{A} {}\\mathrel{\\xrightarrow[{x_i }]{x }}{} \\mathrm{B}}');
/// Parentheses, Brackets, Braces
test('ce', '(NH4)2S', '{(\\mathrm{NH}{\\vphantom{A}}_{\\smash[t]{4}}){\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{S}}');
test('ce', '[\\{(X2)3\\}2]^3+', '{[\\{(\\mathrm{X}{\\vphantom{A}}_{\\smash[t]{2}}){\\vphantom{A}}_{\\smash[t]{3}}\\}{\\vphantom{A}}_{\\smash[t]{2}}]{\\vphantom{A}}^{3+}}');
test('ce', 'CH4 + 2 $\\left( \\ce{O2 + 79/21 N2} \\right)$', '{\\mathrm{CH}{\\vphantom{A}}_{\\smash[t]{4}} {}+{} 2\\,\\left( \\mathrm{O}{\\vphantom{A}}_{\\smash[t]{2}} {}+{} \\mathchoice{\\textstyle\\frac{79}{21}}{\\frac{79}{21}}{\\frac{79}{21}}{\\frac{79}{21}}\\,\\mathrm{N}{\\vphantom{A}}_{\\smash[t]{2}} \\right) }');
/// States of Aggregation
test('ce', 'H2(aq)', '{\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mskip2mu (\\mathrm{aq})}');
test('ce', 'CO3^2-_{(aq)}', '{\\mathrm{CO}{\\vphantom{A}}_{\\smash[t]{3}}{\\vphantom{A}}^{2-}{\\vphantom{A}}_{\\smash[t]{\\mskip1mu (\\mathrm{aq})}}}');
test('ce', 'CO3^2-{}_{(aq)}', '{\\mathrm{CO}{\\vphantom{A}}_{\\smash[t]{3}}{\\vphantom{A}}^{2-}{\\vphantom{A}}_{\\smash[t]{\\mskip1mu (\\mathrm{aq})}}}');
test('ce', 'NaOH(aq,$\\infty$)', '{\\mathrm{NaOH}\\mskip2mu (\\mathrm{aq},\\infty )}');
/// Crystal Systems
test('ce', 'ZnS ($c$)', '{\\mathrm{ZnS}\\mskip2mu (c )}');
test('ce', 'ZnS (\\ca$c$)', '{\\mathrm{ZnS}\\mskip2mu ({\\sim}c )}');
/// Variables like __*x*, *n*, 2*n*+1__
test('ce', 'NO_x', '{\\mathrm{NO}{\\vphantom{A}}_{\\smash[t]{x }}}');
test('ce', 'Fe^n+', '{\\mathrm{Fe}{\\vphantom{A}}^{n +}}');
test('ce', 'x Na(NH4)HPO4 ->[\Delta] (NaPO3)_x + x NH3 ^ + x H2O', '{x\\,\\mathrm{Na}(\\mathrm{NH}{\\vphantom{A}}_{\\smash[t]{4}})\\mathrm{HPO}{\\vphantom{A}}_{\\smash[t]{4}} {}\\mathrel{\\xrightarrow{\\mathrm{Delta}}}{} (\\mathrm{NaPO}{\\vphantom{A}}_{\\smash[t]{3}}){\\vphantom{A}}_{\\smash[t]{x }} {}+{} x\\,\\mathrm{NH}{\\vphantom{A}}_{\\smash[t]{3}} \\uparrow{} {}+{} x\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
/// Greek Characters
test('ce', '\mu-Cl', '{\\mathrm{mu}{-}\\mathrm{Cl}}');
test('ce', '[Pt(\\eta^2-C2H4)Cl3]-', '{[\\mathrm{Pt}(\\mathrm{\\eta}{\\vphantom{A}}^{2}\\text{-}\\mathrm{C}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{4}})\\mathrm{Cl}{\\vphantom{A}}_{\\smash[t]{3}}]{\\vphantom{A}}^{-}}');
test('ce', '\\beta +', '{\\mathrm{\\beta }{\\vphantom{A}}^{+}}');
test('ce', '^40_18Ar + \\gamma{} + \\nu_e', '{{\\vphantom{A}}^{\\hphantom{40}}_{\\hphantom{18}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{40}}_{\\vphantom{2}\\llap{\\smash[t]{18}}}\\mathrm{Ar} {}+{} \\mathrm{\\gamma{}} {}+{} \\mathrm{\\nu}{\\vphantom{A}}_{\\smash[t]{e }}}');
/// (Italic) Math
test('ce', 'NaOH(aq,$\\infty$)', '{\\mathrm{NaOH}\\mskip2mu (\\mathrm{aq},\\infty )}');
test('ce', 'Fe(CN)_{$\\frac{6}{2}$}', '{\\mathrm{Fe}(\\mathrm{CN}){\\vphantom{A}}_{\\smash[t]{\\frac{6}{2} }}}');
test('ce', 'X_{$i$}^{$x$}', '{\\mathrm{X}{\\vphantom{A}}_{\\smash[t]{i }}{\\vphantom{A}}^{x }}');
test('ce', 'X_$i$^$x$', '{\\mathrm{X}{\\vphantom{A}}_{\\smash[t]{i }}{\\vphantom{A}}^{x }}');
/// Italic Text
test('ce', '$cis${-}[PtCl2(NH3)2]', '{cis {\\text{-}}[\\mathrm{PtCl}{\\vphantom{A}}_{\\smash[t]{2}}(\\mathrm{NH}{\\vphantom{A}}_{\\smash[t]{3}}){\\vphantom{A}}_{\\smash[t]{2}}]}');
test('ce', 'CuS($hP12$)', '{\\mathrm{CuS}(hP12 )}');
/// Upright Text, Escape Parsing
test('ce', '{Gluconic Acid} + H2O2', '{{\\text{Gluconic Acid}} {}+{} \\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}{\\vphantom{A}}_{\\smash[t]{2}}}');
test('ce', 'X_{{red}}', '{\\mathrm{X}{\\vphantom{A}}_{\\smash[t]{\\text{red}}}}');
test('ce', '{(+)}_589{-}[Co(en)3]Cl3', '{{\\text{(+)}}{\\vphantom{A}}_{\\smash[t]{589}}{\\text{-}}[\\mathrm{Co}(\\mathrm{en}){\\vphantom{A}}_{\\smash[t]{3}}]\\mathrm{Cl}{\\vphantom{A}}_{\\smash[t]{3}}}');
/// Bonds
test('ce', 'C6H5-CHO', '{\\mathrm{C}{\\vphantom{A}}_{\\smash[t]{6}}\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{5}}{-}\\mathrm{CHO}}');
test('ce', 'A-B=C#D', '{\\mathrm{A}{-}\\mathrm{B}{=}\\mathrm{C}{\\equiv}\\mathrm{D}}');
test('ce', 'A\\bond{-}B\\bond{=}C\\bond{#}D', '{\\mathrm{A}{-}\\mathrm{B}{=}\\mathrm{C}{\\equiv}\\mathrm{D}}');
test('ce', 'A\\bond{1}B\\bond{2}C\\bond{3}D', '{\\mathrm{A}{-}\\mathrm{B}{=}\\mathrm{C}{\\equiv}\\mathrm{D}}');
test('ce', 'A\\bond{~}B\\bond{~-}C', '{\\mathrm{A}{\\tripledash}\\mathrm{B}{\\rlap{\\lower.1em{-}}\\raise.1em{\\tripledash}}\\mathrm{C}}');
test('ce', 'A\\bond{~--}B\\bond{~=}C\\bond{-~-}D', '{\\mathrm{A}{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{\\tripledash}}-}\\mathrm{B}{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{\\tripledash}}-}\\mathrm{C}{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{-}}\\tripledash}\\mathrm{D}}');
test('ce', 'A\\bond{...}B\\bond{....}C', '{\\mathrm{A}{{\\cdot}{\\cdot}{\\cdot}}\\mathrm{B}{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}\\mathrm{C}}');
test('ce', 'A\\bond{->}B\\bond{<-}C', '{\\mathrm{A}{\\rightarrow}\\mathrm{B}{\\leftarrow}\\mathrm{C}}');
/// Addition Compounds
test('ce', 'KCr(SO4)2*12H2O', '{\\mathrm{KCr}(\\mathrm{SO}{\\vphantom{A}}_{\\smash[t]{4}}){\\vphantom{A}}_{\\smash[t]{2}}\\,{\\cdot}\\,12\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'KCr(SO4)2.12H2O', '{\\mathrm{KCr}(\\mathrm{SO}{\\vphantom{A}}_{\\smash[t]{4}}){\\vphantom{A}}_{\\smash[t]{2}}\\,{\\cdot}\\,12\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'KCr(SO4)2 * 12 H2O', '{\\mathrm{KCr}(\\mathrm{SO}{\\vphantom{A}}_{\\smash[t]{4}}){\\vphantom{A}}_{\\smash[t]{2}}\\,{\\cdot}\\,12\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
/// Oxidation States
test('ce', 'Fe^{II}Fe^{III}2O4', '{\\mathrm{Fe}{\\vphantom{A}}^{\\mathrm{II}}\\mathrm{Fe}{\\vphantom{A}}^{\\mathrm{III}}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}{\\vphantom{A}}_{\\smash[t]{4}}}');
/// Unpaired Electrons, Radical Dots
test('ce', 'OCO^{.-}', '{\\mathrm{OCO}{\\vphantom{A}}^{\\mkern1mu \\bullet\\mkern1mu -}}');
test('ce', 'NO^{(2.)-}', '{\\mathrm{NO}{\\vphantom{A}}^{(2\\mkern1mu \\bullet\\mkern1mu )-}}');
/// Kröger-Vink Notation
test('ce', 'Li^x_{Li,1-2x}Mg^._{Li,x}$V$\'_{Li,x}Cl^x_{Cl}', '{\\mathrm{Li}{\\vphantom{A}}^{{\\times}}_{\\smash[t]{\\mathrm{Li}{,}\\mkern1mu 1-2x }}\\mathrm{Mg}{\\vphantom{A}}^{\\mkern1mu \\bullet\\mkern1mu }_{\\smash[t]{\\mathrm{Li}{,}\\mkern1mu x }}V {\\vphantom{A}}^{\\prime }_{\\smash[t]{\\mathrm{Li}{,}\\mkern1mu x }}\\mathrm{Cl}{\\vphantom{A}}^{{\\times}}_{\\smash[t]{\\mathrm{Cl}}}}');
test('ce', 'O\'\'_{i,x}', '{\\mathrm{O}{\\vphantom{A}}^{\\prime \\prime }_{\\smash[t]{\\mathrm{i}{,}\\mkern1mu x }}}');
test('ce', 'M^{..}_i', '{\\mathrm{M}{\\vphantom{A}}^{\\mkern1mu \\bullet\\mkern1mu \\mkern1mu \\bullet\\mkern1mu }_{\\smash[t]{\\mathrm{i}}}}');
test('ce', '$V$^{4\'}_{Ti}', '{V {\\vphantom{A}}^{4\\prime }_{\\smash[t]{\\mathrm{Ti}}}}');
test('ce', 'V_{V,1}C_{C,0.8}$V$_{C,0.2}', '{\\mathrm{V}{\\vphantom{A}}_{\\smash[t]{\\mathrm{V}{,}\\mkern1mu 1}}\\mathrm{C}{\\vphantom{A}}_{\\smash[t]{\\mathrm{C}{,}\\mkern1mu 0.8}}V {\\vphantom{A}}_{\\smash[t]{\\mathrm{C}{,}\\mkern1mu 0.2}}}');
/// Equation Operators
test('ce', 'A + B', '{\\mathrm{A} {}+{} \\mathrm{B}}');
test('ce', 'A - B', '{\\mathrm{A} {}-{} \\mathrm{B}}');
test('ce', 'A = B', '{\\mathrm{A} {}={} \\mathrm{B}}');
test('ce', 'A \\pm B', '{\\mathrm{A} {}\\pm{} \\mathrm{B}}');
/// Precipitate and Gas
test('ce', 'SO4^2- + Ba^2+ -> BaSO4 v', '{\\mathrm{SO}{\\vphantom{A}}_{\\smash[t]{4}}{\\vphantom{A}}^{2-} {}+{} \\mathrm{Ba}{\\vphantom{A}}^{2+} {}\\mathrel{\\longrightarrow}{} \\mathrm{BaSO}{\\vphantom{A}}_{\\smash[t]{4}} \\downarrow{} }');
test('ce', 'A v B (v) -> B ^ B (^)', '{\\mathrm{A} \\downarrow{} ~\\mathrm{B} \\downarrow{} {}\\mathrel{\\longrightarrow}{} \\mathrm{B} \\uparrow{} ~\\mathrm{B} \\uparrow{} }');
/// Other Symbols and Shortcuts
test('ce', 'NO^*', '{\\mathrm{NO}{\\vphantom{A}}^{*}}');
test('ce', '1s^2-N', '{1\\mathrm{s}{\\vphantom{A}}^{2}\\text{-}\\mathrm{N}}');
test('ce', 'n-Pr', '{n \\text{-}\\mathrm{Pr}}');
test('ce', 'iPr', '{\\mathrm{iPr}}');
test('ce', '\\ca Fe', '{{\\sim}\\mathrm{Fe}}');
test('ce', 'A, B, C; F', '{\\mathrm{A}{,}\\mkern6mu \\mathrm{B}{,}\\mkern6mu \\mathrm{C}{;}\\mkern6mu \\mathrm{F}}');
test('ce', '{and others}', '{{\\text{and others}}}');
/// Complex Examples
test('ce', 'Zn^2+ <=>[+ 2OH-][+ 2H+] $\\underset{\\text{amphoteres Hydroxid}}{\\ce{Zn(OH)2 v}}$ <=>[+ 2OH-][+ 2H+] $\\underset{\\text{Hydroxozikat}}{\\ce{[Zn(OH)4]^2-}}$', '{\\mathrm{Zn}{\\vphantom{A}}^{2+} {}\\mathrel{\\underset{\\lower6mu{ {}+{} 2\\,\\mathrm{H}{\\vphantom{A}}^{+}}}{\\overset{ {}+{} 2\\,\\mathrm{OH}{\\vphantom{A}}^{-}}{\\longrightleftharpoons}}}{} \\underset{\\text{amphoteres Hydroxid}}{\\ce{Zn(OH)2 v}} {}\\mathrel{\\underset{\\lower6mu{ {}+{} 2\\,\\mathrm{H}{\\vphantom{A}}^{+}}}{\\overset{ {}+{} 2\\,\\mathrm{OH}{\\vphantom{A}}^{-}}{\\longrightleftharpoons}}}{} \\underset{\\text{Hydroxozikat}}{\\ce{[Zn(OH)4]^2-}} }');
test('ce', '$K = \\frac{[\\ce{Hg^2+}][\\ce{Hg}]}{[\\ce{Hg2^2+}]}$', '{K = \\frac{[\\ce{Hg^2+}][\\ce{Hg}]}{[\\ce{Hg2^2+}]} }');
test('ce', '$K = \\ce{\\frac{[Hg^2+][Hg]}{[Hg2^2+]}}$', '{K = \\frac{[\\mathrm{Hg}{\\vphantom{A}}^{2+}][\\mathrm{Hg}]}{[\\mathrm{Hg}{\\vphantom{A}}_{\\smash[t]{2}}{\\vphantom{A}}^{2+}]}}');
test('ce', 'Hg^2+ ->[I-] $\\underset{\\mathrm{red}}{\\ce{HgI2}}$ ->[I-] $\\underset{\\mathrm{red}}{\\ce{[Hg^{II}I4]^2-}}$', '{\\mathrm{Hg}{\\vphantom{A}}^{2+} {}\\mathrel{\\xrightarrow{\\mathrm{I}{\\vphantom{A}}^{-}}}{} \\underset{\\mathrm{red}}{\\ce{HgI2}} {}\\mathrel{\\xrightarrow{\\mathrm{I}{\\vphantom{A}}^{-}}}{} \\underset{\\mathrm{red}}{\\ce{[Hg^{II}I4]^2-}} }');
/// \pu
test('pu', '123 kJ', '{123~\\mathrm{kJ}}');
test('pu', '123 mm2', '{123~\\mathrm{mm^{2}}}');
test('pu', '123 J s', '{123~\\mathrm{J}\\mkern3mu \\mathrm{s}}');
test('pu', '123 J*s', '{123~\\mathrm{J}\\mkern1mu{\\cdot}\\mkern1mu \\mathrm{s}}');
test('pu', '123 kJ/mol', '{123~\\mathrm{kJ}/\\mathrm{mol}}');
test('pu', '123 kJ//mol', '{123~\\mathchoice{\\textstyle\\frac{\\mathrm{kJ}}{\\mathrm{mol}}}{\\frac{\\mathrm{kJ}}{\\mathrm{mol}}}{\\frac{\\mathrm{kJ}}{\\mathrm{mol}}}{\\frac{\\mathrm{kJ}}{\\mathrm{mol}}}}');
test('pu', '123 kJ mol^-1', '{123~\\mathrm{kJ}\\mkern3mu \\mathrm{mol^{-1}}}');
test('pu', '123 kJ*mol-1', '{123~\\mathrm{kJ}\\mkern1mu{\\cdot}\\mkern1mu \\mathrm{mol^{-1}}}');
test('pu', '123 kJ.mol-1', '{123~\\mathrm{kJ}\\mkern1mu{\\cdot}\\mkern1mu \\mathrm{mol^{-1}}}');
test('pu', '1.2e3 kJ', '{1.2\\cdot 10^{3}~\\mathrm{kJ}}');
test('pu', '1,2e3 kJ', '{1{,}2\\cdot 10^{3}~\\mathrm{kJ}}');
test('pu', '1.2E3 kJ', '{1.2\\times 10^{3}~\\mathrm{kJ}}');
test('pu', '1,2E3 kJ', '{1{,}2\\times 10^{3}~\\mathrm{kJ}}');
test('pu', '1234', '{1234}');
test('pu', '12345', '{12\\mkern2mu 345}');
test('pu', '1\u00B0C', '{1~\\mathrm{{}^{\\circ}C}}');
test('pu', '23.4782(32) m', '{23.4782(32)~\\mathrm{m}}');
test('pu', '8.00001 \\pm 0.00005 nm', '{8.000\\mkern2mu 01 {}\\pm{} 0.000\\mkern2mu 05~\\mathrm{nm}}');
test('pu', '.25', '{.25}');
test('pu', '1 mol ', '{1~\\mathrm{mol}~}');
test('pu', '123 l//100km', '{123~\\mathchoice{\\textstyle\\frac{\\mathrm{l}}{100~\\mathrm{km}}}{\\frac{\\mathrm{l}}{100~\\mathrm{km}}}{\\frac{\\mathrm{l}}{100~\\mathrm{km}}}{\\frac{\\mathrm{l}}{100~\\mathrm{km}}}}');
if (!errorsFound) {
output('<span style="color: green">All test executed. All successful.</span>');
}
</script>
</body>
</html>

209
node_modules/mhchemparser/test/test-esm.html generated vendored Normal file
View File

@@ -0,0 +1,209 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<h1>mhchem Parser Tests</h1>
<div id="output"><span style="color: red">Could not load parser. This is likely a CORS restriction, e.g. if you opened this document via file://.</span></div>
<script type="module">
import { mhchemParser } from "../esm/mhchemParser.js";
document.getElementById('output').innerHTML = '';
/// create tests
let errorsFound = false;
function test(type, input, expected) {
let actual = mhchemParser.toTex(input, type);
if (actual !== expected) {
output('<span style="color: red">Test case failed. ' + input + '</span>');
errorsFound = true;
}
}
function output(html) {
let a = document.createElement('p');
a.innerHTML = html;
document.getElementById('output').appendChild(a);
}
///
/// test cases
///
test('tex', 'm_{\\ce{H2O}} = \\pu{1.2kg}', 'm_{{\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}} = {1.2~\\mathrm{kg}}')
///
/// test cases from documentation
///
/// Chemical Equations
test('ce', 'CO2 + C -> 2 CO', '{\\mathrm{CO}{\\vphantom{A}}_{\\smash[t]{2}} {}+{} \\mathrm{C} {}\\mathrel{\\longrightarrow}{} 2\\,\\mathrm{CO}}');
test('ce', 'Hg^2+ ->[I-] HgI2 ->[I-] [Hg^{II}I4]^2-', '{\\mathrm{Hg}{\\vphantom{A}}^{2+} {}\\mathrel{\\xrightarrow{\\mathrm{I}{\\vphantom{A}}^{-}}}{} \\mathrm{HgI}{\\vphantom{A}}_{\\smash[t]{2}} {}\\mathrel{\\xrightarrow{\\mathrm{I}{\\vphantom{A}}^{-}}}{} [\\mathrm{Hg}{\\vphantom{A}}^{\\mathrm{II}}\\mathrm{I}{\\vphantom{A}}_{\\smash[t]{4}}]{\\vphantom{A}}^{2-}}');
/// Chemical formulae
test('ce', 'H2O', '{\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'Sb2O3', '{\\mathrm{Sb}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}{\\vphantom{A}}_{\\smash[t]{3}}}');
/// Charges
test('ce', 'H+', '{\\mathrm{H}{\\vphantom{A}}^{+}}');
test('ce', 'CrO4^2-', '{\\mathrm{CrO}{\\vphantom{A}}_{\\smash[t]{4}}{\\vphantom{A}}^{2-}}');
test('ce', '[AgCl2]-', '{[\\mathrm{AgCl}{\\vphantom{A}}_{\\smash[t]{2}}]{\\vphantom{A}}^{-}}');
test('ce', 'Y^99+', '{\\mathrm{Y}{\\vphantom{A}}^{99+}}');
test('ce', 'Y^{99+}', '{\\mathrm{Y}{\\vphantom{A}}^{99+}}');
/// Stoichiometric Numbers
test('ce', '2 H2O', '{2\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', '2H2O', '{2\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', '0.5 H2O', '{0.5\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', '1/2 H2O', '{\\mathchoice{\\textstyle\\frac{1}{2}}{\\frac{1}{2}}{\\frac{1}{2}}{\\frac{1}{2}}\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', '(1/2) H2O', '{(1/2)\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', '$n$ H2O', '{n \\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'n H2O', '{n\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'nH2O', '{n\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'n/2 H2O', '{\\mathchoice{\\textstyle\\frac{n}{2}}{\\frac{n}{2}}{\\frac{n}{2}}{\\frac{n}{2}}\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
/// Nuclides, Isotopes
test('ce', '^{227}_{90}Th+', '{{\\vphantom{A}}^{\\hphantom{227}}_{\\hphantom{90}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{227}}_{\\vphantom{2}\\llap{\\smash[t]{90}}}\\mathrm{Th}{\\vphantom{A}}^{+}}');
test('ce', '^227_90Th+', '{{\\vphantom{A}}^{\\hphantom{227}}_{\\hphantom{90}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{227}}_{\\vphantom{2}\\llap{\\smash[t]{90}}}\\mathrm{Th}{\\vphantom{A}}^{+}}');
test('ce', '^{0}_{-1}n^{-}', '{{\\vphantom{A}}^{\\hphantom{0}}_{\\hphantom{-1}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{0}}_{\\vphantom{2}\\llap{\\smash[t]{-1}}}\\mathrm{n}{\\vphantom{A}}^{-}}');
test('ce', '^0_-1n-', '{{\\vphantom{A}}^{\\hphantom{0}}_{\\hphantom{-1}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{0}}_{\\vphantom{2}\\llap{\\smash[t]{-1}}}\\mathrm{n}{\\vphantom{A}}^{-}}');
test('ce', 'H{}^3HO', '{\\mathrm{H}\\mkern2mu{\\vphantom{A}}^{\\hphantom{3}}_{\\hphantom{}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{3}}_{\\vphantom{2}\\llap{\\smash[t]{}}}\\mathrm{HO}}');
test('ce', 'H^3HO', '{\\mathrm{H}\\mkern2mu{\\vphantom{A}}^{\\hphantom{3}}_{\\hphantom{}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{3}}_{\\vphantom{2}\\llap{\\smash[t]{}}}\\mathrm{HO}}');
/// Reaction Arrows
test('ce', 'A -> B', '{\\mathrm{A} {}\\mathrel{\\longrightarrow}{} \\mathrm{B}}');
test('ce', 'A <- B', '{\\mathrm{A} {}\\mathrel{\\longleftarrow}{} \\mathrm{B}}');
test('ce', 'A <-> B', '{\\mathrm{A} {}\\mathrel{\\longleftrightarrow}{} \\mathrm{B}}');
test('ce', 'A <--> B', '{\\mathrm{A} {}\\mathrel{\\longleftrightarrows}{} \\mathrm{B}}');
test('ce', 'A <=> B', '{\\mathrm{A} {}\\mathrel{\\longrightleftharpoons}{} \\mathrm{B}}');
test('ce', 'A <=>> B', '{\\mathrm{A} {}\\mathrel{\\longRightleftharpoons}{} \\mathrm{B}}');
test('ce', 'A <<=> B', '{\\mathrm{A} {}\\mathrel{\\longLeftrightharpoons}{} \\mathrm{B}}');
test('ce', 'A ->[H2O] B', '{\\mathrm{A} {}\\mathrel{\\xrightarrow{\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}}{} \\mathrm{B}}');
test('ce', 'A ->[{text above}][{text below}] B', '{\\mathrm{A} {}\\mathrel{\\xrightarrow[{{\\text{text below}}}]{{\\text{text above}}}}{} \\mathrm{B}}');
test('ce', 'A ->[$x$][$x_i$] B', '{\\mathrm{A} {}\\mathrel{\\xrightarrow[{x_i }]{x }}{} \\mathrm{B}}');
/// Parentheses, Brackets, Braces
test('ce', '(NH4)2S', '{(\\mathrm{NH}{\\vphantom{A}}_{\\smash[t]{4}}){\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{S}}');
test('ce', '[\\{(X2)3\\}2]^3+', '{[\\{(\\mathrm{X}{\\vphantom{A}}_{\\smash[t]{2}}){\\vphantom{A}}_{\\smash[t]{3}}\\}{\\vphantom{A}}_{\\smash[t]{2}}]{\\vphantom{A}}^{3+}}');
test('ce', 'CH4 + 2 $\\left( \\ce{O2 + 79/21 N2} \\right)$', '{\\mathrm{CH}{\\vphantom{A}}_{\\smash[t]{4}} {}+{} 2\\,\\left( \\mathrm{O}{\\vphantom{A}}_{\\smash[t]{2}} {}+{} \\mathchoice{\\textstyle\\frac{79}{21}}{\\frac{79}{21}}{\\frac{79}{21}}{\\frac{79}{21}}\\,\\mathrm{N}{\\vphantom{A}}_{\\smash[t]{2}} \\right) }');
/// States of Aggregation
test('ce', 'H2(aq)', '{\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mskip2mu (\\mathrm{aq})}');
test('ce', 'CO3^2-_{(aq)}', '{\\mathrm{CO}{\\vphantom{A}}_{\\smash[t]{3}}{\\vphantom{A}}^{2-}{\\vphantom{A}}_{\\smash[t]{\\mskip1mu (\\mathrm{aq})}}}');
test('ce', 'CO3^2-{}_{(aq)}', '{\\mathrm{CO}{\\vphantom{A}}_{\\smash[t]{3}}{\\vphantom{A}}^{2-}{\\vphantom{A}}_{\\smash[t]{\\mskip1mu (\\mathrm{aq})}}}');
test('ce', 'NaOH(aq,$\\infty$)', '{\\mathrm{NaOH}\\mskip2mu (\\mathrm{aq},\\infty )}');
/// Crystal Systems
test('ce', 'ZnS ($c$)', '{\\mathrm{ZnS}\\mskip2mu (c )}');
test('ce', 'ZnS (\\ca$c$)', '{\\mathrm{ZnS}\\mskip2mu ({\\sim}c )}');
/// Variables like __*x*, *n*, 2*n*+1__
test('ce', 'NO_x', '{\\mathrm{NO}{\\vphantom{A}}_{\\smash[t]{x }}}');
test('ce', 'Fe^n+', '{\\mathrm{Fe}{\\vphantom{A}}^{n +}}');
test('ce', 'x Na(NH4)HPO4 ->[\Delta] (NaPO3)_x + x NH3 ^ + x H2O', '{x\\,\\mathrm{Na}(\\mathrm{NH}{\\vphantom{A}}_{\\smash[t]{4}})\\mathrm{HPO}{\\vphantom{A}}_{\\smash[t]{4}} {}\\mathrel{\\xrightarrow{\\mathrm{Delta}}}{} (\\mathrm{NaPO}{\\vphantom{A}}_{\\smash[t]{3}}){\\vphantom{A}}_{\\smash[t]{x }} {}+{} x\\,\\mathrm{NH}{\\vphantom{A}}_{\\smash[t]{3}} \\uparrow{} {}+{} x\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
/// Greek Characters
test('ce', '\mu-Cl', '{\\mathrm{mu}{-}\\mathrm{Cl}}');
test('ce', '[Pt(\\eta^2-C2H4)Cl3]-', '{[\\mathrm{Pt}(\\mathrm{\\eta}{\\vphantom{A}}^{2}\\text{-}\\mathrm{C}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{4}})\\mathrm{Cl}{\\vphantom{A}}_{\\smash[t]{3}}]{\\vphantom{A}}^{-}}');
test('ce', '\\beta +', '{\\mathrm{\\beta }{\\vphantom{A}}^{+}}');
test('ce', '^40_18Ar + \\gamma{} + \\nu_e', '{{\\vphantom{A}}^{\\hphantom{40}}_{\\hphantom{18}}\\mkern-1.5mu{\\vphantom{A}}^{\\smash[t]{\\vphantom{2}}\\llap{40}}_{\\vphantom{2}\\llap{\\smash[t]{18}}}\\mathrm{Ar} {}+{} \\mathrm{\\gamma{}} {}+{} \\mathrm{\\nu}{\\vphantom{A}}_{\\smash[t]{e }}}');
/// (Italic) Math
test('ce', 'NaOH(aq,$\\infty$)', '{\\mathrm{NaOH}\\mskip2mu (\\mathrm{aq},\\infty )}');
test('ce', 'Fe(CN)_{$\\frac{6}{2}$}', '{\\mathrm{Fe}(\\mathrm{CN}){\\vphantom{A}}_{\\smash[t]{\\frac{6}{2} }}}');
test('ce', 'X_{$i$}^{$x$}', '{\\mathrm{X}{\\vphantom{A}}_{\\smash[t]{i }}{\\vphantom{A}}^{x }}');
test('ce', 'X_$i$^$x$', '{\\mathrm{X}{\\vphantom{A}}_{\\smash[t]{i }}{\\vphantom{A}}^{x }}');
/// Italic Text
test('ce', '$cis${-}[PtCl2(NH3)2]', '{cis {\\text{-}}[\\mathrm{PtCl}{\\vphantom{A}}_{\\smash[t]{2}}(\\mathrm{NH}{\\vphantom{A}}_{\\smash[t]{3}}){\\vphantom{A}}_{\\smash[t]{2}}]}');
test('ce', 'CuS($hP12$)', '{\\mathrm{CuS}(hP12 )}');
/// Upright Text, Escape Parsing
test('ce', '{Gluconic Acid} + H2O2', '{{\\text{Gluconic Acid}} {}+{} \\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}{\\vphantom{A}}_{\\smash[t]{2}}}');
test('ce', 'X_{{red}}', '{\\mathrm{X}{\\vphantom{A}}_{\\smash[t]{\\text{red}}}}');
test('ce', '{(+)}_589{-}[Co(en)3]Cl3', '{{\\text{(+)}}{\\vphantom{A}}_{\\smash[t]{589}}{\\text{-}}[\\mathrm{Co}(\\mathrm{en}){\\vphantom{A}}_{\\smash[t]{3}}]\\mathrm{Cl}{\\vphantom{A}}_{\\smash[t]{3}}}');
/// Bonds
test('ce', 'C6H5-CHO', '{\\mathrm{C}{\\vphantom{A}}_{\\smash[t]{6}}\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{5}}{-}\\mathrm{CHO}}');
test('ce', 'A-B=C#D', '{\\mathrm{A}{-}\\mathrm{B}{=}\\mathrm{C}{\\equiv}\\mathrm{D}}');
test('ce', 'A\\bond{-}B\\bond{=}C\\bond{#}D', '{\\mathrm{A}{-}\\mathrm{B}{=}\\mathrm{C}{\\equiv}\\mathrm{D}}');
test('ce', 'A\\bond{1}B\\bond{2}C\\bond{3}D', '{\\mathrm{A}{-}\\mathrm{B}{=}\\mathrm{C}{\\equiv}\\mathrm{D}}');
test('ce', 'A\\bond{~}B\\bond{~-}C', '{\\mathrm{A}{\\tripledash}\\mathrm{B}{\\rlap{\\lower.1em{-}}\\raise.1em{\\tripledash}}\\mathrm{C}}');
test('ce', 'A\\bond{~--}B\\bond{~=}C\\bond{-~-}D', '{\\mathrm{A}{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{\\tripledash}}-}\\mathrm{B}{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{\\tripledash}}-}\\mathrm{C}{\\rlap{\\lower.2em{-}}\\rlap{\\raise.2em{-}}\\tripledash}\\mathrm{D}}');
test('ce', 'A\\bond{...}B\\bond{....}C', '{\\mathrm{A}{{\\cdot}{\\cdot}{\\cdot}}\\mathrm{B}{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}\\mathrm{C}}');
test('ce', 'A\\bond{->}B\\bond{<-}C', '{\\mathrm{A}{\\rightarrow}\\mathrm{B}{\\leftarrow}\\mathrm{C}}');
/// Addition Compounds
test('ce', 'KCr(SO4)2*12H2O', '{\\mathrm{KCr}(\\mathrm{SO}{\\vphantom{A}}_{\\smash[t]{4}}){\\vphantom{A}}_{\\smash[t]{2}}\\,{\\cdot}\\,12\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'KCr(SO4)2.12H2O', '{\\mathrm{KCr}(\\mathrm{SO}{\\vphantom{A}}_{\\smash[t]{4}}){\\vphantom{A}}_{\\smash[t]{2}}\\,{\\cdot}\\,12\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
test('ce', 'KCr(SO4)2 * 12 H2O', '{\\mathrm{KCr}(\\mathrm{SO}{\\vphantom{A}}_{\\smash[t]{4}}){\\vphantom{A}}_{\\smash[t]{2}}\\,{\\cdot}\\,12\\,\\mathrm{H}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}}');
/// Oxidation States
test('ce', 'Fe^{II}Fe^{III}2O4', '{\\mathrm{Fe}{\\vphantom{A}}^{\\mathrm{II}}\\mathrm{Fe}{\\vphantom{A}}^{\\mathrm{III}}{\\vphantom{A}}_{\\smash[t]{2}}\\mathrm{O}{\\vphantom{A}}_{\\smash[t]{4}}}');
/// Unpaired Electrons, Radical Dots
test('ce', 'OCO^{.-}', '{\\mathrm{OCO}{\\vphantom{A}}^{\\mkern1mu \\bullet\\mkern1mu -}}');
test('ce', 'NO^{(2.)-}', '{\\mathrm{NO}{\\vphantom{A}}^{(2\\mkern1mu \\bullet\\mkern1mu )-}}');
/// Kröger-Vink Notation
test('ce', 'Li^x_{Li,1-2x}Mg^._{Li,x}$V$\'_{Li,x}Cl^x_{Cl}', '{\\mathrm{Li}{\\vphantom{A}}^{{\\times}}_{\\smash[t]{\\mathrm{Li}{,}\\mkern1mu 1-2x }}\\mathrm{Mg}{\\vphantom{A}}^{\\mkern1mu \\bullet\\mkern1mu }_{\\smash[t]{\\mathrm{Li}{,}\\mkern1mu x }}V {\\vphantom{A}}^{\\prime }_{\\smash[t]{\\mathrm{Li}{,}\\mkern1mu x }}\\mathrm{Cl}{\\vphantom{A}}^{{\\times}}_{\\smash[t]{\\mathrm{Cl}}}}');
test('ce', 'O\'\'_{i,x}', '{\\mathrm{O}{\\vphantom{A}}^{\\prime \\prime }_{\\smash[t]{\\mathrm{i}{,}\\mkern1mu x }}}');
test('ce', 'M^{..}_i', '{\\mathrm{M}{\\vphantom{A}}^{\\mkern1mu \\bullet\\mkern1mu \\mkern1mu \\bullet\\mkern1mu }_{\\smash[t]{\\mathrm{i}}}}');
test('ce', '$V$^{4\'}_{Ti}', '{V {\\vphantom{A}}^{4\\prime }_{\\smash[t]{\\mathrm{Ti}}}}');
test('ce', 'V_{V,1}C_{C,0.8}$V$_{C,0.2}', '{\\mathrm{V}{\\vphantom{A}}_{\\smash[t]{\\mathrm{V}{,}\\mkern1mu 1}}\\mathrm{C}{\\vphantom{A}}_{\\smash[t]{\\mathrm{C}{,}\\mkern1mu 0.8}}V {\\vphantom{A}}_{\\smash[t]{\\mathrm{C}{,}\\mkern1mu 0.2}}}');
/// Equation Operators
test('ce', 'A + B', '{\\mathrm{A} {}+{} \\mathrm{B}}');
test('ce', 'A - B', '{\\mathrm{A} {}-{} \\mathrm{B}}');
test('ce', 'A = B', '{\\mathrm{A} {}={} \\mathrm{B}}');
test('ce', 'A \\pm B', '{\\mathrm{A} {}\\pm{} \\mathrm{B}}');
/// Precipitate and Gas
test('ce', 'SO4^2- + Ba^2+ -> BaSO4 v', '{\\mathrm{SO}{\\vphantom{A}}_{\\smash[t]{4}}{\\vphantom{A}}^{2-} {}+{} \\mathrm{Ba}{\\vphantom{A}}^{2+} {}\\mathrel{\\longrightarrow}{} \\mathrm{BaSO}{\\vphantom{A}}_{\\smash[t]{4}} \\downarrow{} }');
test('ce', 'A v B (v) -> B ^ B (^)', '{\\mathrm{A} \\downarrow{} ~\\mathrm{B} \\downarrow{} {}\\mathrel{\\longrightarrow}{} \\mathrm{B} \\uparrow{} ~\\mathrm{B} \\uparrow{} }');
/// Other Symbols and Shortcuts
test('ce', 'NO^*', '{\\mathrm{NO}{\\vphantom{A}}^{*}}');
test('ce', '1s^2-N', '{1\\mathrm{s}{\\vphantom{A}}^{2}\\text{-}\\mathrm{N}}');
test('ce', 'n-Pr', '{n \\text{-}\\mathrm{Pr}}');
test('ce', 'iPr', '{\\mathrm{iPr}}');
test('ce', '\\ca Fe', '{{\\sim}\\mathrm{Fe}}');
test('ce', 'A, B, C; F', '{\\mathrm{A}{,}\\mkern6mu \\mathrm{B}{,}\\mkern6mu \\mathrm{C}{;}\\mkern6mu \\mathrm{F}}');
test('ce', '{and others}', '{{\\text{and others}}}');
/// Complex Examples
test('ce', 'Zn^2+ <=>[+ 2OH-][+ 2H+] $\\underset{\\text{amphoteres Hydroxid}}{\\ce{Zn(OH)2 v}}$ <=>[+ 2OH-][+ 2H+] $\\underset{\\text{Hydroxozikat}}{\\ce{[Zn(OH)4]^2-}}$', '{\\mathrm{Zn}{\\vphantom{A}}^{2+} {}\\mathrel{\\underset{\\lower6mu{ {}+{} 2\\,\\mathrm{H}{\\vphantom{A}}^{+}}}{\\overset{ {}+{} 2\\,\\mathrm{OH}{\\vphantom{A}}^{-}}{\\longrightleftharpoons}}}{} \\underset{\\text{amphoteres Hydroxid}}{\\ce{Zn(OH)2 v}} {}\\mathrel{\\underset{\\lower6mu{ {}+{} 2\\,\\mathrm{H}{\\vphantom{A}}^{+}}}{\\overset{ {}+{} 2\\,\\mathrm{OH}{\\vphantom{A}}^{-}}{\\longrightleftharpoons}}}{} \\underset{\\text{Hydroxozikat}}{\\ce{[Zn(OH)4]^2-}} }');
test('ce', '$K = \\frac{[\\ce{Hg^2+}][\\ce{Hg}]}{[\\ce{Hg2^2+}]}$', '{K = \\frac{[\\ce{Hg^2+}][\\ce{Hg}]}{[\\ce{Hg2^2+}]} }');
test('ce', '$K = \\ce{\\frac{[Hg^2+][Hg]}{[Hg2^2+]}}$', '{K = \\frac{[\\mathrm{Hg}{\\vphantom{A}}^{2+}][\\mathrm{Hg}]}{[\\mathrm{Hg}{\\vphantom{A}}_{\\smash[t]{2}}{\\vphantom{A}}^{2+}]}}');
test('ce', 'Hg^2+ ->[I-] $\\underset{\\mathrm{red}}{\\ce{HgI2}}$ ->[I-] $\\underset{\\mathrm{red}}{\\ce{[Hg^{II}I4]^2-}}$', '{\\mathrm{Hg}{\\vphantom{A}}^{2+} {}\\mathrel{\\xrightarrow{\\mathrm{I}{\\vphantom{A}}^{-}}}{} \\underset{\\mathrm{red}}{\\ce{HgI2}} {}\\mathrel{\\xrightarrow{\\mathrm{I}{\\vphantom{A}}^{-}}}{} \\underset{\\mathrm{red}}{\\ce{[Hg^{II}I4]^2-}} }');
/// \pu
test('pu', '123 kJ', '{123~\\mathrm{kJ}}');
test('pu', '123 mm2', '{123~\\mathrm{mm^{2}}}');
test('pu', '123 J s', '{123~\\mathrm{J}\\mkern3mu \\mathrm{s}}');
test('pu', '123 J*s', '{123~\\mathrm{J}\\mkern1mu{\\cdot}\\mkern1mu \\mathrm{s}}');
test('pu', '123 kJ/mol', '{123~\\mathrm{kJ}/\\mathrm{mol}}');
test('pu', '123 kJ//mol', '{123~\\mathchoice{\\textstyle\\frac{\\mathrm{kJ}}{\\mathrm{mol}}}{\\frac{\\mathrm{kJ}}{\\mathrm{mol}}}{\\frac{\\mathrm{kJ}}{\\mathrm{mol}}}{\\frac{\\mathrm{kJ}}{\\mathrm{mol}}}}');
test('pu', '123 kJ mol^-1', '{123~\\mathrm{kJ}\\mkern3mu \\mathrm{mol^{-1}}}');
test('pu', '123 kJ*mol-1', '{123~\\mathrm{kJ}\\mkern1mu{\\cdot}\\mkern1mu \\mathrm{mol^{-1}}}');
test('pu', '123 kJ.mol-1', '{123~\\mathrm{kJ}\\mkern1mu{\\cdot}\\mkern1mu \\mathrm{mol^{-1}}}');
test('pu', '1.2e3 kJ', '{1.2\\cdot 10^{3}~\\mathrm{kJ}}');
test('pu', '1,2e3 kJ', '{1{,}2\\cdot 10^{3}~\\mathrm{kJ}}');
test('pu', '1.2E3 kJ', '{1.2\\times 10^{3}~\\mathrm{kJ}}');
test('pu', '1,2E3 kJ', '{1{,}2\\times 10^{3}~\\mathrm{kJ}}');
test('pu', '1234', '{1234}');
test('pu', '12345', '{12\\mkern2mu 345}');
test('pu', '1\u00B0C', '{1~\\mathrm{{}^{\\circ}C}}');
test('pu', '23.4782(32) m', '{23.4782(32)~\\mathrm{m}}');
test('pu', '8.00001 \\pm 0.00005 nm', '{8.000\\mkern2mu 01 {}\\pm{} 0.000\\mkern2mu 05~\\mathrm{nm}}');
test('pu', '.25', '{.25}');
test('pu', '1 mol ', '{1~\\mathrm{mol}~}');
test('pu', '123 l//100km', '{123~\\mathchoice{\\textstyle\\frac{\\mathrm{l}}{100~\\mathrm{km}}}{\\frac{\\mathrm{l}}{100~\\mathrm{km}}}{\\frac{\\mathrm{l}}{100~\\mathrm{km}}}{\\frac{\\mathrm{l}}{100~\\mathrm{km}}}}');
if (!errorsFound) {
output('<span style="color: green">All test executed. All successful.</span>');
}
</script>
</body>
</html>

11
node_modules/mhchemparser/tsconfig-es6.json generated vendored Normal file
View File

@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"target": "ES6",
"module": "ES6",
"moduleResolution": "node",
"outDir": "esm",
"baseUrl": ".",
"typeRoots": []
}
}

19
node_modules/mhchemparser/tsconfig.json generated vendored Normal file
View File

@@ -0,0 +1,19 @@
{
"compileOnSave": true,
"compilerOptions": {
"target": "ES5",
"downlevelIteration": true,
"declaration": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
"sourceMap": false,
"outDir": "dist"
},
"files": [
"src/mhchemParser.ts",
"src/mhchemParser.d.ts"
]
}