|
| 1 | +/************************************************************* |
| 2 | + * |
| 3 | + * Copyright (c) 2021 The MathJax Consortium |
| 4 | + * |
| 5 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | + * you may not use this file except in compliance with the License. |
| 7 | + * You may obtain a copy of the License at |
| 8 | + * |
| 9 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | + * |
| 11 | + * Unless required by applicable law or agreed to in writing, software |
| 12 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | + * See the License for the specific language governing permissions and |
| 15 | + * limitations under the License. |
| 16 | + */ |
| 17 | + |
| 18 | + |
| 19 | +/** |
| 20 | + * @fileoverview Mappings for the textcomp package. |
| 21 | + * |
| 22 | + * @author v.sorge@mathjax.org (Volker Sorge) |
| 23 | + */ |
| 24 | + |
| 25 | + |
| 26 | +import {CommandMap} from '../SymbolMap.js'; |
| 27 | +import {TexConstant} from '../TexConstants.js'; |
| 28 | +import {TextMacrosMethods} from '../textmacros/TextMacrosMethods.js'; |
| 29 | +import TexParser from '../TexParser.js'; |
| 30 | +import ParseUtil from '../ParseUtil.js'; |
| 31 | +import {TextParser} from '../textmacros/TextParser.js'; |
| 32 | + |
| 33 | + |
| 34 | +/** |
| 35 | + * Identifiers from the Textcomp package. |
| 36 | + */ |
| 37 | +new CommandMap('textcomp-macros', { |
| 38 | + |
| 39 | + // Table 3: Predefined LATEX 2ε Text-Mode Commands |
| 40 | + 'textasciicircum': ['Insert', '\u005E'], |
| 41 | + 'textasciitilde': ['Insert', '\u007E'], |
| 42 | + 'textasteriskcentered': ['Insert', '\u002A'], |
| 43 | + 'textbackslash': ['Insert', '\u005C'], |
| 44 | + 'textbar': ['Insert', '\u007C'], |
| 45 | + 'textbraceleft': ['Insert', '\u007B'], |
| 46 | + 'textbraceright': ['Insert', '\u007D'], |
| 47 | + 'textbullet': ['Insert', '\u2022'], |
| 48 | + 'textdagger': ['Insert', '\u2020'], |
| 49 | + 'textdaggerdbl': ['Insert', '\u2021'], |
| 50 | + 'textellipsis': ['Insert', '\u2026'], |
| 51 | + 'textemdash': ['Insert', '\u2014'], |
| 52 | + 'textendash': ['Insert', '\u2013'], |
| 53 | + 'textexclamdown': ['Insert', '\u00A1'], |
| 54 | + 'textgreater': ['Insert', '\u003E'], |
| 55 | + 'textless': ['Insert', '\u003C'], |
| 56 | + 'textordfeminine': ['Insert', '\u00AA'], |
| 57 | + 'textordmasculine': ['Insert', '\u00BA'], |
| 58 | + 'textparagraph': ['Insert', '\u00B6'], |
| 59 | + 'textperiodcentered': ['Insert', '\u00B7'], |
| 60 | + 'textquestiondown': ['Insert', '\u00BF'], |
| 61 | + 'textquotedblleft': ['Insert', '\u201C'], |
| 62 | + 'textquotedblright': ['Insert', '\u201D'], |
| 63 | + 'textquoteleft': ['Insert', '\u2018'], |
| 64 | + 'textquoteright': ['Insert', '\u2019'], |
| 65 | + 'textsection': ['Insert', '\u00A7'], |
| 66 | + 'textunderscore': ['Insert', '\u005F'], |
| 67 | + 'textvisiblespace': ['Insert', '\u2423'], |
| 68 | + |
| 69 | + // Table 12: textcomp Diacritics |
| 70 | + 'textacutedbl': ['Insert', '\u02DD'], |
| 71 | + 'textasciiacute': ['Insert', '\u00B4'], |
| 72 | + 'textasciibreve': ['Insert', '\u02D8'], |
| 73 | + 'textasciicaron': ['Insert', '\u02C7'], |
| 74 | + 'textasciidieresis': ['Insert', '\u00A8'], |
| 75 | + 'textasciimacron': ['Insert', '\u00AF'], |
| 76 | + 'textgravedbl': ['Insert', '\u02F5'], |
| 77 | + 'texttildelow': ['Insert', '\u02F7'], |
| 78 | + |
| 79 | + // Table 13: textcomp Currency Symbols |
| 80 | + 'textbaht': ['Insert', '\u0E3F'], |
| 81 | + 'textcent': ['Insert', '\u00A2'], |
| 82 | + 'textcolonmonetary': ['Insert', '\u20A1'], |
| 83 | + 'textcurrency': ['Insert', '\u00A4'], |
| 84 | + 'textdollar': ['Insert', '\u0024'], |
| 85 | + 'textdong': ['Insert', '\u20AB'], |
| 86 | + 'texteuro': ['Insert', '\u20AC'], |
| 87 | + 'textflorin': ['Insert', '\u0192'], |
| 88 | + 'textguarani': ['Insert', '\u20B2'], |
| 89 | + 'textlira': ['Insert', '\u20A4'], |
| 90 | + 'textnaira': ['Insert', '\u20A6'], |
| 91 | + 'textpeso': ['Insert', '\u20B1'], |
| 92 | + 'textsterling': ['Insert', '\u00A3'], |
| 93 | + 'textwon': ['Insert', '\u20A9'], |
| 94 | + 'textyen': ['Insert', '\u00A5'], |
| 95 | + |
| 96 | + // Table 15: textcomp Legal Symbols |
| 97 | + 'textcircledP': ['Insert', '\u2117'], |
| 98 | + 'textcompwordmark': ['Insert', '\u200C'], |
| 99 | + 'textcopyleft': ['Insert', '\u{1F12F}'], |
| 100 | + 'textcopyright': ['Insert', '\u00A9'], |
| 101 | + 'textregistered': ['Insert', '\u00AE'], |
| 102 | + 'textservicemark': ['Insert', '\u2120'], |
| 103 | + 'texttrademark': ['Insert', '\u2122'], |
| 104 | + |
| 105 | + // Table 20: Miscellaneous textcomp Symbol |
| 106 | + 'textbardbl': ['Insert', '\u2016'], |
| 107 | + 'textbigcircle': ['Insert', '\u25EF'], |
| 108 | + 'textblank': ['Insert', '\u2422'], |
| 109 | + 'textbrokenbar': ['Insert', '\u00A6'], |
| 110 | + 'textdiscount': ['Insert', '\u2052'], |
| 111 | + 'textestimated': ['Insert', '\u212E'], |
| 112 | + 'textinterrobang': ['Insert', '\u203D'], |
| 113 | + 'textinterrobangdown': ['Insert', '\u2E18'], |
| 114 | + 'textmusicalnote': ['Insert', '\u266A'], |
| 115 | + 'textnumero': ['Insert', '\u2116'], |
| 116 | + 'textopenbullet': ['Insert', '\u25E6'], |
| 117 | + 'textpertenthousand': ['Insert', '\u2031'], |
| 118 | + 'textperthousand': ['Insert', '\u2030'], |
| 119 | + 'textrecipe': ['Insert', '\u211E'], |
| 120 | + 'textreferencemark': ['Insert', '\u203B'], |
| 121 | + // 'textthreequartersemdash' |
| 122 | + // 'texttwelveudash' |
| 123 | + |
| 124 | + // Table 51: textcomp Text-Mode Delimiters |
| 125 | + 'textlangle': ['Insert', '\u2329'], |
| 126 | + 'textrangle': ['Insert', '\u232A'], |
| 127 | + 'textlbrackdbl': ['Insert', '\u27E6'], |
| 128 | + 'textrbrackdbl': ['Insert', '\u27E7'], |
| 129 | + 'textlquill': ['Insert', '\u2045'], |
| 130 | + 'textrquill': ['Insert', '\u2046'], |
| 131 | + |
| 132 | + // Table 62: textcomp Text-Mode Math and Science Symbols |
| 133 | + 'textcelsius': ['Insert', '\u2103'], |
| 134 | + 'textdegree': ['Insert', '\u00B0'], |
| 135 | + 'textdiv': ['Insert', '\u00F7'], |
| 136 | + 'textdownarrow': ['Insert', '\u2193'], |
| 137 | + 'textfractionsolidus': ['Insert', '\u2044'], |
| 138 | + 'textleftarrow': ['Insert', '\u2190'], |
| 139 | + 'textlnot': ['Insert', '\u00AC'], |
| 140 | + 'textmho': ['Insert', '\u2127'], |
| 141 | + 'textminus': ['Insert', '\u2212'], |
| 142 | + 'textmu': ['Insert', '\u00B5'], |
| 143 | + 'textohm': ['Insert', '\u2126'], |
| 144 | + 'textonehalf': ['Insert', '\u00BD'], |
| 145 | + 'textonequarter': ['Insert', '\u00BC'], |
| 146 | + 'textonesuperior': ['Insert', '\u00B9'], |
| 147 | + 'textpm': ['Insert', '\u00B1'], |
| 148 | + 'textrightarrow': ['Insert', '\u2192'], |
| 149 | + 'textsurd': ['Insert', '\u221A'], |
| 150 | + 'textthreequarters': ['Insert', '\u00BE'], |
| 151 | + 'textthreesuperior': ['Insert', '\u00B3'], |
| 152 | + 'texttimes': ['Insert', '\u00D7'], |
| 153 | + 'texttwosuperior': ['Insert', '\u00B2'], |
| 154 | + 'textuparrow': ['Insert', '\u2191'], |
| 155 | + |
| 156 | + // Table 110: textcomp Genealogical Symbols |
| 157 | + 'textborn': ['Insert', '\u002A'], |
| 158 | + 'textdied': ['Insert', '\u2020'], |
| 159 | + 'textdivorced': ['Insert', '\u26AE'], |
| 160 | + // 'textleaf' |
| 161 | + 'textmarried': ['Insert', '\u26AD'], |
| 162 | + |
| 163 | + // This is not the correct glyph |
| 164 | + 'textcentoldstyle': ['Insert', '\u00A2', TexConstant.Variant.OLDSTYLE], |
| 165 | + // This is not the correct glyph |
| 166 | + 'textdollaroldstyle': ['Insert', '\u0024', TexConstant.Variant.OLDSTYLE], |
| 167 | + |
| 168 | + // Table 16: textcomp Old-Style Numerals |
| 169 | + 'textzerooldstyle': ['Insert', '0', TexConstant.Variant.OLDSTYLE], |
| 170 | + 'textoneoldstyle': ['Insert', '1', TexConstant.Variant.OLDSTYLE], |
| 171 | + 'texttwooldstyle': ['Insert', '2', TexConstant.Variant.OLDSTYLE], |
| 172 | + 'textthreeoldstyle': ['Insert', '3', TexConstant.Variant.OLDSTYLE], |
| 173 | + 'textfouroldstyle': ['Insert', '4', TexConstant.Variant.OLDSTYLE], |
| 174 | + 'textfiveoldstyle': ['Insert', '5', TexConstant.Variant.OLDSTYLE], |
| 175 | + 'textsixoldstyle': ['Insert', '6', TexConstant.Variant.OLDSTYLE], |
| 176 | + 'textsevenoldstyle': ['Insert', '7', TexConstant.Variant.OLDSTYLE], |
| 177 | + 'texteightoldstyle': ['Insert', '8', TexConstant.Variant.OLDSTYLE], |
| 178 | + 'textnineoldstyle': ['Insert', '9', TexConstant.Variant.OLDSTYLE] |
| 179 | +}, { |
| 180 | + Insert: function(parser: TexParser, name: string, c: string, font: string) { |
| 181 | + if (parser instanceof TextParser) { |
| 182 | + if (!font) { |
| 183 | + TextMacrosMethods.Insert(parser, name, c); |
| 184 | + return; |
| 185 | + } |
| 186 | + parser.saveText(); |
| 187 | + } |
| 188 | + parser.Push(ParseUtil.internalText( |
| 189 | + parser, c, font ? {mathvariant: font} : {})); |
| 190 | + } |
| 191 | +}); |
0 commit comments