// a // if (b5.a) { if (b5.a.match(/^[+\-]/)) { b5.a = "{" + b5.a + "}"; } res += b5.a + "\\,"; } // // b and p // if (b5.b || b5.p) { res += "{\\vphantom{X}}"; res += "^{\\hphantom{" + (b5.b || "") + "}}_{\\hphantom{" + (b5.p || "") + "}}"; res += "{\\vphantom{X}}"; res += "^{\\smash[t]{\\vphantom{2}}\\mathllap{" + (b5.b || "") + "}}"; res += "_{\\vphantom{2}\\mathllap{\\smash[t]{" + (b5.p || "") + "}}}"; } // // o // if (b5.o) { if (b5.o.match(/^[+\-]/)) { b5.o = "{" + b5.o + "}"; } res += b5.o; } // // q and d // if (buf.dType === 'kv') { if (b5.d || b5.q) { res += "{\\vphantom{X}}"; } if (b5.d) { res += "^{" + b5.d + "}"; } if (b5.q) { res += "_{\\smash[t]{" + b5.q + "}}"; } } else if (buf.dType === 'oxidation') { if (b5.d) { res += "{\\vphantom{X}}"; res += "^{" + b5.d + "}"; } if (b5.q) { res += "{\\vphantom{X}}"; res += "_{\\smash[t]{" + b5.q + "}}"; } } else { if (b5.q) { res += "{\\vphantom{X}}"; res += "_{\\smash[t]{" + b5.q + "}}"; } if (b5.d) { res += "{\\vphantom{X}}"; res += "^{" + b5.d + "}"; } } break; case 'rm': res = "\\mathrm{" + buf.p1 + "}"; break; case 'text': if (buf.p1.match(/[\^_]/)) { buf.p1 = buf.p1.replace(" ", "~").replace("-", "\\text{-}"); res = "\\mathrm{" + buf.p1 + "}"; } else { res = "\\text{" + buf.p1 + "}"; } break; case 'roman numeral': res = "\\mathrm{" + buf.p1 + "}"; break; case 'state of aggregation': res = "\\mskip2mu " + texify._goInner(buf.p1); break; case 'state of aggregation subscript': res = "\\mskip1mu " + texify._goInner(buf.p1); break; case 'bond': res = texify._getBond(buf.kind_); if (!res) { throw ["MhchemErrorBond", "mhchem Error. Unknown bond type (" + buf.kind_ + ")"]; } break; case 'frac': var c = "\\frac{" + buf.p1 + "}{" + buf.p2 + "}"; res = "\\mathchoice{\\textstyle" + c + "}{" + c + "}{" + c + "}{" + c + "}"; break; case 'pu-frac': var d = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; res = "\\mathchoice{\\textstyle" + d + "}{" + d + "}{" + d + "}{" + d + "}"; break; case 'tex-math': res = buf.p1 + " "; break; case 'frac-ce': res = "\\frac{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; break; case 'overset': res = "\\overset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; break; case 'underset': res = "\\underset{" + texify._goInner(buf.p1) + "}{" + texify._goInner(buf.p2) + "}"; break; case 'underbrace': res = "\\underbrace{" + texify._goInner(buf.p1) + "}_{" + texify._goInner(buf.p2) + "}"; break; case 'color': res = "{\\color{" + buf.color1 + "}{" + texify._goInner(buf.color2) + "}}"; break; case 'color0': res = "\\color{" + buf.color + "}"; break; case 'arrow': var b6 = { rd: texify._goInner(buf.rd), rq: texify._goInner(buf.rq) }; var arrow = "\\x" + texify._getArrow(buf.r); if (b6.rq) { arrow += "[{" + b6.rq + "}]"; } if (b6.rd) { arrow += "{" + b6.rd + "}"; } else { arrow += "{}"; } res = arrow; break; case 'operator': res = texify._getOperator(buf.kind_); break; case '1st-level escape': res = buf.p1 + " "; // &, \\\\, \\hlin break; case 'space': res = " "; break; case 'entitySkip': res = "~"; break; case 'pu-space-1': res = "~"; break; case 'pu-space-2': res = "\\mkern3mu "; break; case '1000 separator': res = "\\mkern2mu "; break; case 'commaDecimal': res = "{,}"; break; case 'comma enumeration L': res = "{" + buf.p1 + "}\\mkern6mu "; break; case 'comma enumeration M': res = "{" + buf.p1 + "}\\mkern3mu "; break; case 'comma enumeration S': res = "{" + buf.p1 + "}\\mkern1mu "; break; case 'hyphen': res = "\\text{-}"; break; case 'addition compound': res = "\\,{\\cdot}\\,"; break; case 'electron dot': res = "\\mkern1mu \\bullet\\mkern1mu "; break; case 'KV x': res = "{\\times}"; break; case 'prime': res = "\\prime "; break; case 'cdot': res = "\\cdot "; break; case 'tight cdot': res = "\\mkern1mu{\\cdot}\\mkern1mu "; break; case 'times': res = "\\times "; break; case 'circa': res = "{\\sim}"; break; case '^': res = "uparrow"; break; case 'v': res = "downarrow"; break; case 'ellipsis': res = "\\ldots "; break; case '/': res = "/"; break; case ' / ': res = "\\,/\\,"; break; default: assertNever(buf); throw ["MhchemBugT", "mhchem bug T. Please report."]; // Missing texify rule or unknown MhchemParser output } assertString(res); return res; }, _getArrow: function (a) { switch (a) { case "->": return "rightarrow"; case "\u2192": return "rightarrow"; case "\u27F6": return "rightarrow"; case "<-": return "leftarrow"; case "<->": return "leftrightarrow"; case "<-->": return "rightleftarrows"; case "<=>": return "rightleftharpoons"; case "\u21CC": return "rightleftharpoons"; case "<=>>": return "rightequilibrium"; case "<<=>": return "leftequilibrium"; default: assertNever(a); throw ["MhchemBugT", "mhchem bug T. Please report."]; } }, _getBond: function (a) { switch (a) { case "-": return "{-}"; case "1": return "{-}"; case "=": return "{=}"; case "2": return "{=}"; case "#": return "{\\equiv}"; case "3": return "{\\equiv}"; case "~": return "{\\tripledash}"; case "~-": return "{\\mathrlap{\\raisebox{-.1em}{$-$}}\\raisebox{.1em}{$\\tripledash$}}"; case "~=": return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}"; case "~--": return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$\\tripledash$}}-}"; case "-~-": return "{\\mathrlap{\\raisebox{-.2em}{$-$}}\\mathrlap{\\raisebox{.2em}{$-$}}\\tripledash}"; case "...": return "{{\\cdot}{\\cdot}{\\cdot}}"; case "....": return "{{\\cdot}{\\cdot}{\\cdot}{\\cdot}}"; case "->": return "{\\rightarrow}"; case "<-": return "{\\leftarrow}"; case "<": return "{<}"; case ">": return "{>}"; default: assertNever(a); throw ["MhchemBugT", "mhchem bug T. Please report."]; } }, _getOperator: function (a) { switch (a) { case "+": return " {}+{} "; case "-": return " {}-{} "; case "=": return " {}={} "; case "<": return " {}<{} "; case ">": return " {}>{} "; case "<<": return " {}\\ll{} "; case ">>": return " {}\\gg{} "; case "\\pm": return " {}\\pm{} "; case "\\approx": return " {}\\approx{} "; case "$\\approx$": return " {}\\approx{} "; case "v": return " \\downarrow{} "; case "(v)": return " \\downarrow{} "; case "^": return " \\uparrow{} "; case "(^)": return " \\uparrow{} "; default: assertNever(a); throw ["MhchemBugT", "mhchem bug T. Please report."]; } } }; // // Helpers for code analysis // Will show type error at calling position // /** @param {number} a */ function assertNever(a) {} /** @param {string} a */ function assertString(a) {} __webpack_exports__ = __webpack_exports__["default"]; /******/ return __webpack_exports__; /******/ })() ; });