TextcompMappings.ts 7.7 KB

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