Annotation of loncom/interface/entities.pm, revision 1.9
1.1 foxr 1: # The LearningOnline Network
2: # entity -> tex.
3: #
4: # $Id:
5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: # http://www.lon-capa.org/
26: #
27: #
28: package Apache::entities;
29: use strict;
30: #
31: # This file contains a table driven entity-->latex converter.
32: #
33: # Assumptions:
34: # The number of entities in a resource is small compared with the
35: # number of possible entities that might be translated.
36: # Therefore the strategy is to match a general entity pattern
37: # &.+; over and over, pull out the match look it up in an entity -> tex hash
38: # and do the replacement.
39: #
40: # In order to simplify the hash, the following reductions are done:
41: # &#d+; have the &# and ; stripped and is converted to an int.
42: # &#.+; have the &#x and ; stripped and is converted to an int as a hex
43: # value.
44: # All others have the & and ; stripped.
45:
46:
47: # The hash: Add new conversions here; leave off the leading & and the trailing ;
48: # all numeric entities need only appear as their decimal versions
49: # (e.g. no need for 1234 is sufficient, no need for 0x4d2 as well.
50: #
51: # This entity table is mercilessly cribbed from the HTML pocket reference
52: # table starting at pg 82. In most cases the LaTeX equivalent codes come from
53: # the original massive regular expression replacements originally by
54: # A. Sakharuk in lonprintout.pm
55: #
1.2 foxr 56: # I also want to acknowledge
57: # ISO Character entities and their LaTeX equivalents by
58: # Vidar Bronken Gundersen, and Rune Mathisen
59: # http://www.bitjungle.com/isoent-ref.pdf
60: #
61:
1.1 foxr 62: # Note numerical entities are essentially unicode character codes.
63: #
1.7 foxr 64: package Apache::entities;
65:
66: my %entities = (
1.1 foxr 67:
68: # ---- ASCII code page: ----------------
69:
70: # Translation to empty strings:
71:
72: 7 => "",
73: 9 => "",
74: 10 => "",
75: 13 => "",
76:
77: # Translations to simple characters:
78:
79: 32 => " ",
80: 33 => "!",
81: 34 => '"',
82: 'quot' => '"',
1.9 ! foxr 83: 35 => '\\#',
! 84: 36 => '\\$',
! 85: 37 => '\%',
! 86: 38 => '\&',
! 87: 'amp' => '\&',
1.1 foxr 88: 39 => '\'', # Apostrophe
89: 40 => '(',
90: 41 => ')',
1.9 ! foxr 91: 42 => '*',
! 92: 43 => '+',
1.1 foxr 93: 44 => ',', # comma
94: 45 => '-',
1.9 ! foxr 95: 46 => '.',
! 96: 47 => '/',
1.1 foxr 97: 48 => '0',
98: 49 => '1',
99: 50 => '2',
100: 51 => '3',
101: 52 => '4',
102: 53 => '5',
103: 54 => '6',
104: 55 => '7',
105: 56 => '8',
106: 57 => '9',
107: 58 => ':',
108: 59 => ';',
1.9 ! foxr 109: 60 => '\ensuremath{<}',
! 110: 'lt' => '\ensuremath{<}',
! 111: 61 => '\ensuremath{=}',
! 112: 62 => '\ensuremath{>}',
! 113: 'gt' => '\ensuremath{>}',
! 114: 63 => '?',
1.1 foxr 115: 64 => '@',
116: 65 => 'A',
117: 66 => 'B',
118: 67 => 'C',
119: 68 => 'D',
120: 69 => 'E',
121: 70 => 'F',
122: 71 => 'G',
123: 72 => 'H',
124: 73 => 'I',
125: 74 => 'J',
126: 75 => 'K',
127: 76 => 'L',
128: 77 => 'M',
129: 78 => 'N',
130: 79 => 'O',
131: 80 => 'P',
132: 81 => 'Q',
133: 82 => 'R',
134: 83 => 'S',
135: 84 => 'T',
136: 85 => 'U',
137: 86 => 'V',
138: 87 => 'W',
139: 88 => 'X',
140: 89 => 'Y',
141: 90 => 'Z',
142: 91 => '[',
1.9 ! foxr 143: 92 => '\ensuremath{\setminus}', # \setminus is \ with special spacing.
1.1 foxr 144: 93 => ']',
1.9 ! foxr 145: 94 => '\ensuremath{\wedge}',
! 146: 95 => '\underline{\makebox[2mm]{\strut}}', # Underline 2mm of space for _
1.1 foxr 147: 96 => '`',
148: 97 => 'a',
149: 98 => 'b',
150: 99 => 'c',
151: 100 => 'd',
152: 101 => 'e',
153: 102 => 'f',
154: 103 => 'g',
155: 104 => 'h',
156: 105 => 'i',
157: 106 => 'j',
158: 107 => 'k',
159: 108 => 'l',
160: 109 => 'm',
161: 110 => 'n',
162: 111 => 'o',
163: 112 => 'p',
164: 113 => 'q',
165: 114 => 'r',
166: 115 => 's',
167: 116 => 't',
168: 117 => 'u',
169: 118 => 'v',
170: 119 => 'w',
171: 120 => 'x',
172: 121 => 'y',
173: 122 => 'z',
1.9 ! foxr 174: 123 => '\{',
! 175: 124 => '|',
! 176: 125 => '\}',
1.1 foxr 177: 126 => '\~',
178:
179: # Controls and Latin-1 supplement. Note that some entities that have
180: # visible effect are not printing unicode characters. Specifically
181: # ‚- 
182:
183: 130 => ',',
1.9 ! foxr 184: 131 => '\ensuremath{f}',
1.1 foxr 185: 132 => ',,', # Low double left quotes.
1.9 ! foxr 186: 133 => '\ensuremath{\ldots}',
! 187: 134 => '\ensuremath{\dagger}',
! 188: 135 => '\ensuremath{\ddagger}',
! 189: 136 => '\ensuremath{\wedge}',
! 190: 137 => '\textperthousand ',
! 191: 138 => '\v{S}',
! 192: 139 => '\ensuremath{<}',
! 193: 140 => '{\OE}',
1.1 foxr 194:
195: # There's a gap here in my entity table
196:
1.9 ! foxr 197: 145 => '`',
1.1 foxr 198: 146 => '\'',
1.9 ! foxr 199: 147 => '``',
1.1 foxr 200: 148 => '\'\'',
1.9 ! foxr 201: 149 => '\ensuremath{\bullet}',
1.1 foxr 202: 150 => '--',
203: 151 => '---',
1.9 ! foxr 204: 152 => '\ensuremath{\sim}',
! 205: 153 => '\texttrademark',
! 206: 154 => '\v{s}',
! 207: 155 => '\ensuremath{>}',
! 208: 156 => '\oe ',
1.1 foxr 209:
210: # Another short gap:
211:
1.9 ! foxr 212: 159 => '\"Y',
1.1 foxr 213: 160 => '~',
214: 'nbsp' => '~',
1.9 ! foxr 215: 161 => '\textexclamdown ',
! 216: 'iexcl' => '\textexclamdown ',
! 217: 162 => '\textcent ',
! 218: 'cent' => '\textcent ',
! 219: 163 => '\pounds ',
! 220: 'pound' => '\pounds ',
! 221: 164 => '\textcurrency ',
! 222: 'curren' => '\textcurrency ',
! 223: 165 => '\textyen ',
! 224: 'yen' => '\textyen ',
! 225: 166 => '\textbrokenbar ',
! 226: 'brvbar' => '\textbrokenbar ',
! 227: 167 => '\textsection ',
! 228: 'sect' => '\textsection ',
! 229: 168 => '\"{}',
! 230: 'uml' => '\"{}',
! 231: 169 => '\copyright ',
! 232: 'copy' => '\copyright ',
! 233: 170 => '\textordfeminine ',
! 234: 'ordf' => '\textordfeminine ',
! 235: 171 => '\ensuremath{\ll}', # approximation of left angle quote.
! 236: 'laquo' => '\ensuremath{\ll}', # ""
! 237: 172 => '\ensuremath{\neg}',
! 238: 'not' => '\ensuremath{\neg}',
1.1 foxr 239: 173 => ' - ',
240: 'shy' => ' - ',
1.9 ! foxr 241: 174 => '\textregistered ',
! 242: 'reg' => '\textregistered ',
! 243: 175 => '\ensuremath{^{-}}',
! 244: 'macr' => '\ensuremath{^{-}}',
! 245: 176 => '\ensuremath{^{\circ}}',
! 246: 'deg' => '\ensuremath{^{\circ}}',
! 247: 177 => '\ensuremath{\pm}',
! 248: 'plusmn' => '\ensuremath{\pm}',
! 249: 178 => '\ensuremath{^2}',
! 250: 'sup2' => '\ensuremath{^2}',
! 251: 179 => '\ensuremath{^3}',
! 252: 'sup3' => '\ensuremath{^3}',
! 253: 180 => "\\'{}",
! 254: 'acute' => "\\'{}",
! 255: 181 => '\ensuremath{\mu}',
! 256: 'micro' => '\ensuremath{\mu}',
! 257: 182 => '\P ',
! 258: para => '\P ',
! 259: 183 => '\ensuremath{\cdot}',
! 260: 'middot' => '\ensuremath{\cdot}',
! 261: 184 => '\c{\strut}',
! 262: 'cedil' => '\c{\strut}',
! 263: 185 => '\ensuremath{^1}',
! 264: sup1 => '\ensuremath{^1}',
! 265: 186 => '\textordmasculine ',
! 266: 'ordm' => '\textordmasculine ',
! 267: 187 => '\ensuremath{\gg}',
! 268: 'raquo' => '\ensuremath{\gg}',
! 269: 188 => '\textonequarter ',
! 270: 'frac14' => '\textonequarter ',
! 271: 189 => '\textonehalf' ,
! 272: 'frac12' => '\textonehalf' ,
! 273: 190 => '\textthreequarters ',
! 274: 'frac34' => '\textthreequarters ',
! 275: 191 => '\textquestiondown ',
! 276: 'iquest' => '\textquestiondown ',
! 277: 192 => '\\`{A}',
! 278: 'Agrave' => '\\`{A}',
! 279: 193 => "\\'{A}",
! 280: 'Aacute' => "\\'{A}",
! 281: 194 => '\^{A}',
! 282: 'Acirc' => '\^{A}',
! 283: 195 => '\~{A}',
! 284: 'Atilde'=> '\~{A}',
! 285: 196 => '\\"{A}',
! 286: 'Auml' => '\\"{A}',
! 287: 197 => '{\AA}',
! 288: 'Aring' => '{\AA}',
! 289: 198 => '{\AE}',
! 290: 'AElig' => '{\AE}',
! 291: 199 => '\c{c}',
! 292: 'Ccedil'=> '\c{c}',
! 293: 200 => '\\`{E}',
! 294: 'Egrave'=> '\\`{E}',
! 295: 201 => "\\'{E}",
! 296: 'Eacute'=> "\\'{E}",
! 297: 202 => '\\^{E}',
! 298: 'Ecirc' => '\\^{E}',
! 299: 203 => '\\"{E}',
! 300: 'Euml' => '\\"{E}',
! 301: 204 => '\\`{I}',
! 302: 'Igrave'=> '\\`{I}',
! 303: 205 => "\\'{I}",
! 304: 'Iacute'=> "\\'{I}",
! 305: 206 => '\\^{I}',
! 306: 'Icirc' => '\\^{I}',
! 307: 207 => '\\"{I}',
! 308: 'Iuml' => '\\"{I}',
! 309: 208 => '\DH',
! 310: 'ETH' => '\DH',
! 311: 209 => '\~{N}',
! 312: 'Ntilde'=> '\~{N}',
! 313: 210 => '\\`{O}',
! 314: 'Ograve'=> '\\`{O}',
! 315: 211 => "\\'{O}",
! 316: 'Oacute'=> "\\'{O}",
! 317: 212 => '\\^{O}',
! 318: 'Ocirc' => '\\^{O}',
! 319: 213 => '\~{O}',
! 320: 'Otilde'=> '\~{O}',
! 321: 214 => '\\"{O}',
! 322: 'Ouml' => '\\"{O}',
! 323: 215 => '\ensuremath{\times}',
! 324: 'times' => '\ensuremath{\times}',
! 325: 216 => '\O',
! 326: 'Oslash'=> '\O',
! 327: 217 => '\\`{U}',
! 328: 'Ugrave'=> '\\`{U}',
! 329: 218 => "\\'{U}",
! 330: 'Uacute'=> "\\'{U}",
! 331: 219 => '\\^{U}',
! 332: 'Ucirc' => '\\^{U}',
! 333: 220 => '\\"{U}',
! 334: 'Uuml' => '\\"{U}',
! 335: 221 => "\\'{Y}",
! 336: 'Yacute'=> "\\'{Y}",
! 337: 223 => '{\ss}',
! 338: 'szlig' => '{\ss}',
! 339: 224 => '\\`{a}',
! 340: 'agrave'=> '\\`{a}',
! 341: 225 => "\\'{a}",
! 342: 'aacute'=> "\\'{a}",
! 343: 226 => '\\^{a}',
! 344: 'acirc' => '\\^{a}',
! 345: 227 => '\\~{a}',
! 346: 'atilde'=> '\\~{a}',
! 347: 228 => '\\"{a}',
! 348: 'auml' => '\\"{a}',
! 349: 229 => '\aa',
! 350: 'aring' => '\aa',
! 351: 230 => '\ae',
! 352: 'aelig' => '\ae',
! 353: 231 => '\c{c}',
! 354: 'ccedil'=> '\c{c}',
! 355: 232 => '\\`{e}',
! 356: 'egrave'=> '\\`{e}',
! 357: 233 => "\\'{e}",
! 358: 'eacute'=> "\\'{e}",
! 359: 234 => '\\^{e}',
! 360: 'ecirc' => '\\^{e}',
! 361: 235 => '\\"{e}',
! 362: 'euml' => '\\"{e}',
! 363: 236 => '\\`{i}',
! 364: 'igrave'=> '\\`{i}',
! 365: 237 => "\\'{i}",
! 366: 'iacute'=> "\\'{i}",
! 367: 238 => '\\^{i}',
! 368: 'icirc' => '\\^{i}',
! 369: 239 => '\\"{i}',
! 370: 'iuml' => '\\"{i}',
! 371: 241 => '\\~{n}',
! 372: 'ntilde'=> '\\~{n}',
! 373: 242 => '\\`{o}',
! 374: 'ograve'=> '\\`{o}',
! 375: 243 => "\\'{o}",
! 376: 'oacute'=> "\\'{o}",
! 377: 244 => '\\^{o}',
! 378: 'ocirc' => '\\^{o}',
! 379: 245 => '\\~{o}',
! 380: 'otilde'=> '\\~{o}',
! 381: 246 => '\\"{o}',
! 382: 'ouml' => '\\"{o}',
! 383: 247 => '\ensuremath{\div}',
! 384: 'divide'=> '\ensuremath{\div}',
! 385: 248 => '{\o}',
! 386: 'oslash'=> '{\o}',
! 387: 249 => '\\`{u}',
! 388: 'ugrave'=> '\\`{u}',
! 389: 250 => "\\'{u}",
! 390: 'uacute'=> "\\'{u}",
! 391: 251 => '\\^{u}',
! 392: 'ucirc' => '\\^{u}',
! 393: 252 => '\\"{u}',
! 394: 'uuml' => '\\"{u}',
! 395: 253 => "\\'{y}",
! 396: 'yacute'=> "\\'{y}",
! 397: 255 => '\\"{y}',
! 398: 'yuml' => '\\"{y}',
1.1 foxr 399:
400: # hbar entity number comes from the unicode charater:
401: # see e.g. http://www.unicode.org/charts/PDF/U0100.pdf
402: # ISO also documents a 'planck' entity.
403:
1.9 ! foxr 404: 295 => '\ensuremath{\hbar}',
! 405: 'planck' => '\ensuremath{\hbar}',
1.1 foxr 406:
407: # Latin extended-A HTML 4.01 entities:
408:
1.9 ! foxr 409: 338 => '\OE',
! 410: 'OElig' => '\OE',
! 411: 339 => '\oe',
! 412: 'oelig' => '\oe',
! 413: 352 => '\v{S}',
! 414: 'Scaron' => '\v{S}',
! 415: 353 => '\v{s}',
! 416: 'scaron' => '\v{s}',
! 417: 376 => '\\"{Y}',
! 418: 'Yuml' => '\\"{Y}',
1.1 foxr 419:
420:
421: # Latin extended B HTML 4.01 entities
422:
1.9 ! foxr 423: 402 => '\ensuremath{f}',
! 424: 'fnof' => '\ensuremath{f}',
1.1 foxr 425:
426: # Spacing modifier letters:
427:
428: 710 => '\^{}',
429: 'circ' => '\^{}',
430: 732 => '\~{}',
431: 'tilde' => '\~{}',
432:
433: # Greek uppercase:
434:
1.9 ! foxr 435: 913 => '\ensuremath{\mathrm{A}}',
! 436: 'Alpha' => '\ensuremath{\mathrm{A}}',
! 437: 914 => '\ensuremath{\mathrm{B}}',
! 438: 'Beta' => '\ensuremath{\mathrm{B}}',
! 439: 915 => '\ensuremath{\Gamma}',
! 440: 'Gamma' => '\ensuremath{\Gamma}',
! 441: 916 => '\ensuremath{\Delta}',
! 442: 'Delta' => '\ensuremath{\Delta}',
! 443: 917 => '\ensuremath{\mathrm{E}}',
! 444: 'Epsilon'=> '\ensuremath{\mathrm{E}}',
! 445: 918 => '\ensuremath{\mathrm{Z}}',
! 446: 'Zeta' => '\ensuremath{\mathrm{Z}}',
! 447: 919 => '\ensuremath{\mathrm{H}}',
! 448: 'Eta' => '\ensuremath{\mathrm{H}}',
! 449: 920 => '\ensuremath{\Theta}',
! 450: 'Theta' => '\ensuremath{\Theta}',
! 451: 921 => '\ensuremath{\mathrm{I}}',
! 452: 'Iota' => '\ensuremath{\mathrm{I}}',
! 453: 922 => '\ensuremath{\mathrm{K}}',
! 454: 'Kappa' => '\ensuremath{\mathrm{K}}',
! 455: 923 => '\ensuremath{\Lambda}',
! 456: 'Lambda' => '\ensuremath{\Lambda}',
! 457: 924 => '\ensuremath{\mathrm{M}}',
! 458: 'Mu' => '\ensuremath{\mathrm{M}}',
! 459: 925 => '\ensuremath{\mathrm{N}}',
! 460: 'Nu' => '\ensuremath{\mathrm{N}}',
! 461: 926 => '\ensuremath{\mathrm{\Xi}}',
! 462: 'Xi' => '\ensuremath{\mathrm{\Xi}}',
! 463: 927 => '\ensuremath{\mathrm{O}}',
! 464: 'Omicron'=> '\ensuremath{\mathrm{O}}',
! 465: 928 => '\ensuremath{\Pi}',
! 466: 'Pi' => '\ensuremath{\Pi}',
! 467: 929 => '\ensuremath{\mathrm{P}}',
! 468: 'Rho' => '\ensuremath{\mathrm{P}}',
1.1 foxr 469:
470: # Skips 930
471:
1.9 ! foxr 472: 931 => '\ensuremath{\Sigma}',
! 473: 'Sigma' => '\ensuremath{\Sigma}',
! 474: 932 => '\ensuremath{\mathrm{T}}',
! 475: 'Tau' => '\ensuremath{\mathrm{T}}',
! 476: 933 => '\ensuremath{\Upsilon}',
! 477: 'Upsilon'=> '\ensuremath{\Upsilon}',
! 478: 934 => '\ensuremath{\Phi}',
! 479: 'Phi' => '\ensuremath{\Phi}',
! 480: 935 => '\ensuremath{\mathrm{X}}',
! 481: 'Chi' => '\ensuremath{\mathrm{X}}',
! 482: 936 => '\ensuremath{\Psi}',
! 483: 'Psi' => '\ensuremath{\Psi}',
! 484: 937 => '\ensuremath{\Omega}',
! 485: 'Omega' => '\ensuremath{\Omega}',
1.1 foxr 486:
487:
488: # Greek lowercase:
489:
1.9 ! foxr 490: 945 => '\ensuremath{\alpha}',
! 491: 'alpha' => '\ensuremath{\alpha}',
! 492: 946 => '\ensuremath{\beta}',
! 493: 'beta' => '\ensuremath{\beta}',
! 494: 947 => '\ensuremath{\gamma}',
! 495: 'gamma' => '\ensuremath{\gamma}',
! 496: 948 => '\ensuremath{\delta}',
! 497: 'delta' => '\ensuremath{\delta}',
! 498: 949 => '\ensuremath{\epsilon}',
! 499: 'epsilon'=> '\ensuremath{\epsilon}',
! 500: 950 => '\ensuremath{\zeta}',
! 501: 'zeta' => '\ensuremath{\zeta}',
! 502: 951 => '\ensuremath{\eta}',
! 503: 'eta' => '\ensuremath{\eta}',
! 504: 952 => '\ensuremath{\theta}',
! 505: 'theta' => '\ensuremath{\theta}',
! 506: 953 => '\ensuremath{\iota}',
! 507: 'iota' => '\ensuremath{\iota}',
! 508: 954 => '\ensuremath{\kappa}',
! 509: 'kappa' => '\ensuremath{\kappa}',
! 510: 955 => '\ensuremath{\lambda}',
! 511: 'lambda' => '\ensuremath{\lambda}',
! 512: 956 => '\ensuremath{\mu}',
! 513: 'mu' => '\ensuremath{\mu}',
! 514: 957 => '\ensuremath{\nu}',
! 515: 'nu' => '\ensuremath{\nu}',
! 516: 958 => '\ensuremath{\xi}',
! 517: 'xi' => '\ensuremath{\xi}',
! 518: 959 => '\ensuremath{o}',
! 519: 'omicron'=> '\ensuremath{o}',
! 520: 960 => '\ensuremath{\pi}',
! 521: 'pi' => '\ensuremath{\pi}',
! 522: 961 => '\ensuremath{\rho}',
! 523: 'rho' => '\ensuremath{\rho}',
! 524: 962 => '\ensuremath{\varsigma}',
! 525: 'sigmaf' => '\ensuremath{\varsigma}',
! 526: 963 => '\ensuremath{\sigma}',
! 527: 'sigma' => '\ensuremath{\sigma}',
! 528: 964 => '\ensuremath{\tau}',
! 529: 'tau' => '\ensuremath{\tau}',
! 530: 965 => '\ensuremath{\upsilon}',
! 531: 'upsilon'=> '\ensuremath{\upsilon}',
! 532: 966 => '\ensuremath{\phi}',
! 533: 'phi' => '\ensuremath{\phi}',
! 534: 967 => '\ensuremath{\chi}',
! 535: 'chi' => '\ensuremath{\chi}',
! 536: 968 => '\ensuremath{\psi}',
! 537: 'psi' => '\ensuremath{\psi}',
! 538: 969 => '\ensuremath{\omega}',
! 539: 'omega' => '\ensuremath{\omega}',
! 540: 977 => '\ensuremath{\vartheta}',
! 541: 'thetasym'=>'\ensuremath{\vartheta}',
! 542: 978 => '\ensuremath{\mathit{\Upsilon}}',
! 543: 'upsih' => '\ensuremath{\mathit{\Upsilon}}',
! 544: 982 => '\ensuremath{\varpi}',
! 545: 'piv' => '\ensuremath{\varpi}',
1.2 foxr 546:
547:
548: # The general punctuation set:
549:
1.9 ! foxr 550: 8194, => '\hspace{.5em}',
! 551: 'enspc' => '\hspace{.5em}',
! 552: 8195 => '\hspace{1.0em}',
! 553: 'emspc' => '\hspace{1.0em}',
! 554: 8201 => '\hspace{0.167em}',
! 555: 'thinsp' => '\hspace{0.167em}',
! 556: 8204 => '{}',
! 557: 'zwnj' => '{}',
1.2 foxr 558: 8205 => '',
559: 'zwj' => '',
560: 8206 => '',
561: 'lrm' => '',
562: 8207 => '',
563: 'rlm' => '',
564: 8211 => '--',
565: 'ndash' => '--',
566: 8212 => '---',
567: 'mdash' => '---',
568: 8216 => '`',
569: 'lsquo' => '`',
570: 8217 => "'",
571: 'rsquo' => "'",
1.9 ! foxr 572: 8218 => '\quotesinglbase',
! 573: 'sbquo' => '\quotesinglbase',
1.2 foxr 574: 8220 => '``',
575: 'ldquo' => '``',
576: 8221 => "''",
577: 'rdquo' => "''",
1.9 ! foxr 578: 8222 => '\quotedblbase',
! 579: 'bdquo' => '\quotedblbase',
! 580: 8224 => '\ensuremath{\dagger}',
! 581: 'dagger' => '\ensuremath{\dagger}',
! 582: '8225' => '\ensuremath{\ddag}',
! 583: 'Dagger' => '\ensuremath{\ddag}',
! 584: 8226 => '\textbullet',
! 585: 'bull' => '\textbullet',
! 586: 8230 => '\textellipsis',
! 587: 'hellep' => '\textellipsis',
! 588: 8240 => '\textperthousand',
! 589: permil => '\textperthousand',
! 590: 8242 => '\textquotesingle',
! 591: 'prime' => '\textquotesingle',
! 592: 8243 => '\textquotedbl',
! 593: 'Prime' => '\textquotedbl',
! 594: 8249 => '\guilsinglleft',
! 595: 'lsaquo' => '\guilsinglleft',
! 596: 8250 => '\guilsinglright',
! 597: 'rsaquo' => '\guilsinglright',
! 598: 8254 => '\textasciimacron',
! 599: oline => '\textasciimacron',
! 600: 8260 => '\textfractionsolidus',
! 601: 'frasl' => '\textfractionsolidus',
! 602: 8364 => '\texteuro',
! 603: 'euro' => '\texteuro',
1.2 foxr 604:
605: # Letter like symbols
606:
607:
1.9 ! foxr 608: 8472 => '\ensuremath{\wp}',
! 609: 'weierp' => '\ensuremath{\wp}',
! 610: 8465 => '\ensuremath{\Im}',
! 611: 'image' => '\ensuremath{\Im}',
! 612: 8476 => '\ensuremath{\Re}',
! 613: 'real' => '\ensuremath{\Re}',
! 614: 8482 => '\texttrademark',
! 615: 'trade' => '\texttrademark',
! 616: 8501 => '\ensuremath{\aleph}',
! 617: 'alefsym'=> '\ensuremath{\aleph}',
1.2 foxr 618:
619: # Arrows and then some (harpoons from Hon Kie).
620:
1.9 ! foxr 621: 8592 => '\textleftarrow',
! 622: 'larr' => '\textleftarrow',
! 623: 8593 => '\textuparrow',
! 624: 'uarr' => '\textuparrow',
! 625: 8594 => '\textrightarrow',
! 626: 'rarr' => '\textrightarrow',
! 627: 8595 => '\textdownarrow',
! 628: 'darr' => '\textdownarrow',
! 629: 8596 => '\ensuremath{\leftrightarrow}',
! 630: 'harr' => '\ensuremath{\leftrightarrow}',
! 631: 8598 => '\ensuremath{\nwarrow}',
! 632: 8599 => '\ensuremath{\nearrow}',
! 633: 8600 => '\ensuremath{\searrow}',
! 634: 8601 => '\ensuremath{\swarrow}',
! 635: 8605 => '\ensuremath{\leadsto}',
! 636: 8614 => '\ensuremath{\mapsto}',
! 637: 8617 => '\ensuremath{\hookleftarrow}',
! 638: 8618 => '\ensuremath{\hookrightarrow}',
! 639: 8629 => '\ensuremath{\hookleftarrow}', # not an exact match but best I know.
! 640: 'crarr' => '\ensuremath{\hookleftarrow}', # not an exact match but best I know.
! 641: 8636 => '\ensuremath{\leftharpoonup}',
! 642: 8637 => '\ensuremath{\leftharpoondown}',
! 643: 8640 => '\ensuremath{\rightharpoonup}',
! 644: 8641 => '\ensuremath{\rightharpoondown}',
! 645: 8652 => '\ensuremath{\rightleftharpoons}',
! 646: 8656 => '\ensuremath{\Leftarrow}',
! 647: 'lArr' => '\ensuremath{\Leftarrow}',
! 648: 8657 => '\ensuremath{\Uparrow}',
! 649: 'uArr' => '\ensuremath{\Uparrow}',
! 650: 8658 => '\ensuremath{\Rightarrow}',
! 651: 'rArr' => '\ensuremath{\Rightarrow}',
! 652: 8659 => '\ensuremath{\Downarrow}',
! 653: 'dArr' => '\ensuremath{\Downarrow}',
! 654: 8660 => '\ensuremath{\Leftrightarrow}',
! 655: 'hArr' => '\ensuremath{\Leftrightarrow}',
! 656: 8661 => '\ensuremath{\Updownarrow}',
! 657: 'vArr' => '\ensuremath{\Updownarrow}',
! 658: 8666 => '\ensuremath{\Lleftarrow}',
! 659: 'lAarr' => '\ensuremath{\Lleftarrow}',
! 660: 8667 => '\ensuremath{\Rrightarrow}',
! 661: 'rAarr' => '\ensuremath{\Rrightarrow}',
! 662: 8669 => '\ensuremath{\rightsquigarrow}',
! 663: 'rarrw' => '\ensuremath{\rightsquigarrow}',
1.3 foxr 664:
1.1 foxr 665:
1.2 foxr 666: # Mathematical operators.
667:
1.1 foxr 668:
1.9 ! foxr 669: 'forall' => '\ensuremath{\forall}',
! 670: 8704 => '\ensuremath{\forall}',
! 671: 'comp' => '\ensuremath{\complement}',
! 672: 8705 => '\ensuremath{\complement}',
! 673: 'part' => '\ensuremath{\partial}',
! 674: 8706 => '\ensuremath{\partial}',
! 675: 'exist' => '\ensuremath{\exists}',
! 676: 8707 => '\ensuremath{\exists}',
! 677: 'nexist' => '\ensuremath{\nexists}',
! 678: 8708 => '\ensuremath{\nexists}',
! 679: 'empty' => '\ensuremath{\emptyset}',
! 680: 8709 => '\ensuremath{\emptyset}',
! 681: 8710 => '\ensuremath{\Delta}',
! 682: 'nabla' => '\ensuremath{\nabla}',
! 683: 8711 => '\ensuremath{\nabla}',
! 684: 'isin' => '\ensuremath{\in}',
! 685: 8712 => '\ensuremath{\in}',
! 686: 'notin' => '\ensuremath{\notin}',
! 687: 8713 => '\ensuremath{\notin}',
! 688: ni => '\ensuremath{\ni}',
! 689: 8715 => '\ensuremath{\ni}',
! 690: 8716 => '\ensuremath{\not\ni}',
! 691: 'prod' => '\ensuremath{\prod}',
! 692: 8719 => '\ensuremath{\prod}',
! 693: 8720 => '\ensuremath{\coprod}',
! 694: 'sum' => '\ensuremath{\sum}',
! 695: 8721 => '\ensuremath{\sum}',
! 696: 'minus' => '\ensuremath{-}',
! 697: 8722 => '\ensuremath{-}',
! 698: 8723 => '\ensuremath{\mp}',
! 699: 8724 => '\ensuremath{\dotplus}',
! 700: 8725 => '\ensuremath{\diagup}',
! 701: 8726 => '\ensuremath{\smallsetminus}',
! 702: 'lowast' => '\ensuremath{*}',
! 703: 8727 => '\ensuremath{*}',
! 704: 8728 => '\ensuremath{\circ}',
! 705: 8729 => '\ensuremath{\bullet}',
! 706: 'radic' => '\ensuremath{\surd}',
! 707: 8730 => '\ensuremath{\surd}',
! 708: 8731 => '\ensuremath{\sqrt[3]{}}',
! 709: 8732 => '\ensuremath{\sqrt[4]{}}',
! 710: 'prop' => '\ensuremath{\propto}',
! 711: 8733 => '\ensuremath{\propto}',
! 712: 'infin' => '\ensuremath{\infty}',
! 713: 8734 => '\ensuremath{\infty}',
! 714: # 'ang90' => '\ensuremath{\sqangle}',
! 715: # 8735 => '\ensuremath{\sqangle}',
! 716: 'ang' => '\ensuremath{\angle}',
! 717: 8736 => '\ensuremath{\angle}',
! 718: 'angmsd' => '\ensuremath{\measuredangle}',
! 719: 8737 => '\ensuremath{\measuredangle}',
! 720: 'angsph' => '\ensuremath{\sphericalangle}',
! 721: 8738 => '\ensuremath{\sphericalangle}',
! 722: 8739 => '\ensuremath{\vert}',
! 723: 8740 => '\ensuremath{\Vert}',
! 724: 'and' => '\ensuremath{\land}',
! 725: 8743 => '\ensuremath{\land}',
! 726: 'or' => '\ensuremath{\lor}',
! 727: 8744 => '\ensuremath{\lor}',
! 728: 'cap' => '\ensuremath{\cap}',
! 729: 8745 => '\ensuremath{\cap}',
! 730: 'cup' => '\ensuremath{\cup}',
! 731: 8746 => '\ensuremath{\cup}',
! 732: 'int' => '\ensuremath{\int}',
! 733: 8747 => '\ensuremath{\int}',
! 734: 'conint' => '\ensuremath{\oint}',
! 735: 8750 => '\ensuremath{\oint}',
! 736: 'there4' => '\ensuremath{\therefore}',
! 737: 8756 => '\ensuremath{\therefore}',
! 738: 'becaus' => '\ensuremath{\because}',
! 739: 8757 => '\ensuremath{\because}',
! 740: 8758 => '\ensuremath{:}',
! 741: 8759 => '\ensuremath{::}',
! 742: 'sim' => '\ensuremath{\sim}',
! 743: 8764 => '\ensuremath{\sim}',
! 744: 8765 => '\ensuremath{\backsim}',
! 745: 'wreath' => '\ensuremath{\wr}',
! 746: 8768 => '\ensuremath{\wr}',
! 747: 'nsim' => '\ensuremath{\not\sim}',
! 748: 8769 => '\ensuremath{\not\sim}',
! 749: # 'asymp' => '\ensuremath{\asymp}', ≈ is actually a different glyph.
! 750: 8771 => '\ensuremath{\asymp}',
! 751: 8772 => '\ensuremath{\not\asymp}',
! 752: 'cong' => '\ensuremath{\cong}',
! 753: 8773 => '\ensuremath{\cong}',
! 754: 8775 => '\ensuremath{\ncong}',
! 755: 8778 => '\ensuremath{\approxeq}',
! 756: 8784 => '\ensuremath{\doteq}',
! 757: 8785 => '\ensuremath{\doteqdot}',
! 758: 8786 => '\ensuremath{\fallingdotseq}',
! 759: 8787 => '\ensuremath{\risingdotseq}',
! 760: 8788 => '\ensuremath{:=}',
! 761: 8789 => '\ensuremath{=:}',
! 762: 8790 => '\ensuremath{\eqcirc}',
! 763: 8791 => '\ensuremath{\circeq}',
! 764: 'wedgeq' => '\ensuremath{\stackrel{\wedge}{=}}',
! 765: 8792 => '\ensuremath{\stackrel{\wedge}{=}}',
! 766: 8794 => '\ensuremath{\stackrel{\vee}{=}}',
! 767: 8795 => '\ensuremath{\stackrel{\star}{=}}',
! 768: 8796 => '\ensuremath{\triangleq}',
! 769: 8797 => '\ensuremath{\stackrel{def}{=}}',
! 770: 8798 => '\ensuremath{\stackrel{m}{=}}',
! 771: 8799 => '\ensuremath{\stackrel{?}{=}}',
! 772: 'ne' => '\ensuremath{\neq}',
! 773: 8800 => '\ensuremath{\neq}',
! 774: 'equiv' => '\ensuremath{\equiv}',
! 775: 8801 => '\ensuremath{\equiv}',
! 776: 8802 => '\ensuremath{\not\equiv}',
! 777: 'le' => '\ensuremath{\leq}',
! 778: 8804 => '\ensuremath{\leq}',
! 779: 'ge' => '\ensuremath{\geq}',
! 780: 8805 => '\ensuremath{\geq}',
! 781: 8806 => '\ensuremath{\leqq}',
! 782: 8807 => '\ensuremath{\geqq}',
! 783: 8810 => '\ensuremath{\ll}',
! 784: 8811 => '\ensuremath{\gg}',
! 785: 'twixt' => '\ensuremath{\between}',
! 786: 8812 => '\ensuremath{\between}',
! 787: 8813 => '\ensuremath{\not\asymp}',
! 788: 8814 => '\ensuremath{\not<}',
! 789: 8815 => '\ensuremath{\not>}',
! 790: 8816 => '\ensuremath{\not\leqslant}',
! 791: 8817 => '\ensuremath{\not\geqslant}',
! 792: 8818 => '\ensuremath{\lesssim}',
! 793: 8819 => '\ensuremath{\gtrsim}',
! 794: 8820 => '\ensuremath{\stackrel{<}{>}}',
! 795: 8821 => '\ensuremath{\stackrel{>}{<}}',
! 796: 8826 => '\ensuremath{\prec}',
! 797: 8827 => '\ensuremath{\succ}',
! 798: 8828 => '\ensuremath{\preceq}',
! 799: 8829 => '\ensuremath{\succeq}',
! 800: 8830 => '\ensuremath{\not\prec}',
! 801: 8831 => '\ensuremath{\not\succ}',
! 802: 'sub' => '\ensuremath{\subset}',
! 803: 8834 => '\ensuremath{\subset}',
! 804: 'sup' => '\ensuremath{\supset}',
! 805: 8835 => '\ensuremath{\supset}',
! 806: 'nsub' => '\ensuremath{\not\subset}',
! 807: 8836 => '\ensuremath{\not\subset}',
! 808: 8837 => '\ensuremath{\not\supset}',
! 809: 'sube' => '\ensuremath{\subseteq}',
! 810: 8838 => '\ensuremath{\subseteq}',
! 811: 'supe' => '\ensuremath{\supseteq}',
! 812: 8839 => '\ensuremath{\supseteq}',
! 813: 8840 => '\ensuremath{\nsubseteq}',
! 814: 8841 => '\ensuremath{\nsupseteq}',
! 815: 8842 => '\ensuremath{\subsetneq}',
! 816: 8843 => '\ensuremath{\supsetneq}',
! 817: 8847 => '\ensuremath{\sqsubset}',
! 818: 8848 => '\ensuremath{\sqsupset}',
! 819: 8849 => '\ensuremath{\sqsubseteq}',
! 820: 8850 => '\ensuremath{\sqsupseteq}',
! 821: 8851 => '\ensuremath{\sqcap}',
! 822: 8852 => '\ensuremath{\sqcup}',
! 823: 'oplus' => '\ensuremath{\oplus}',
! 824: 8853 => '\ensuremath{\oplus}',
! 825: 8854 => '\ensuremath{\ominus}',
! 826: 'otimes' => '\ensuremath{\otimes}',
! 827: 8855 => '\ensuremath{\otimes}',
! 828: 8856 => '\ensuremath{\oslash}',
! 829: 8857 => '\ensuremath{\odot}',
! 830: 8858 => '\ensuremath{\circledcirc}',
! 831: 8859 => '\ensuremath{\circledast}',
! 832: 8861 => '\ensuremath{\ominus}', # Close enough for government work.
! 833: 8862 => '\ensuremath{\boxplus}',
! 834: 8863 => '\ensuremath{\boxminus}',
! 835: 8864 => '\ensuremath{\boxtimes}',
! 836: 8865 => '\ensuremath{\boxdot}',
! 837: 'vdash' => '\ensuremath{\vdash}',
! 838: 8866 => '\ensuremath{\vdash}',
! 839: 'dashv' => '\ensuremath{\dashv}',
! 840: 8867 => '\ensuremath{\dashv}',
! 841: 'perp' => '\ensuremath{\perp}',
! 842: 8869 => '\ensuremath{\perp}',
! 843: 8871 => '\ensuremath{\models}',
! 844: 8872 => '\ensuremath{\vDash}',
! 845: 8873 => '\ensuremath{\Vdash}',
! 846: 8874 => '\ensuremath{\Vvdash}',
! 847: 8876 => '\ensuremath{\nvdash}',
! 848: 8877 => '\ensuremath{\nvDash}',
! 849: 8878 => '\ensuremath{\nVdash}',
! 850: 8880 => '\ensuremath{\prec}',
! 851: 8881 => '\ensuremath{\succ}',
! 852: 8882 => '\ensuremath{\vartriangleleft}',
! 853: 8883 => '\ensuremath{\vartriangleright}',
! 854: 8884 => '\ensuremath{\trianglelefteq}',
! 855: 8885 => '\ensuremath{\trianglerighteq}',
! 856: 8891 => '\ensuremath{\veebar}',
! 857: 8896 => '\ensuremath{\land}',
! 858: 8897 => '\ensuremath{\lor}',
! 859: 8898 => '\ensuremath{\cap}',
! 860: 8899 => '\ensuremath{\cup}',
! 861: 8900 => '\ensuremath{\diamond}',
! 862: 'sdot' => '\ensuremath{\cdot}',
! 863: 8901 => '\ensuremath{\cdot}',
! 864: 8902 => '\ensuremath{\star}',
! 865: 8903 => '\ensuremath{\divideontimes}',
! 866: 8904 => '\ensuremath{\bowtie}',
! 867: 8905 => '\ensuremath{\ltimes}',
! 868: 8906 => '\ensuremath{\rtimes}',
! 869: 8907 => '\ensuremath{\leftthreetimes}',
! 870: 8908 => '\ensuremath{\rightthreetimes}',
! 871: 8909 => '\ensuremath{\simeq}',
! 872: 8910 => '\ensuremath{\curlyvee}',
! 873: 8911 => '\ensuremath{\curlywedge}',
! 874: 8912 => '\ensuremath{\Subset}',
! 875: 8913 => '\ensuremath{\Supset}',
! 876: 8914 => '\ensuremath{\Cap}',
! 877: 8915 => '\ensuremath{\Cup}',
! 878: 8916 => '\ensuremath{\pitchfork}',
! 879: 8918 => '\ensuremath{\lessdot}',
! 880: 8919 => '\ensuremath{\gtrdot}',
! 881: 8920 => '\ensuremath{\lll}',
! 882: 8921 => '\ensuremath{\ggg}',
! 883: 8922 => '\ensuremath{\gtreqless}',
! 884: 8923 => '\ensuremath{\lesseqgtr}',
! 885: 8924 => '\ensuremath{\eqslantless}',
! 886: 8925 => '\ensuremath{\eqslantgtr}',
! 887: 8926 => '\ensuremath{\curlyeqprec}',
! 888: 8927 => '\ensuremath{\curlyeqsucc}',
! 889: 8928 => '\ensuremath{\not\preccurlyeq}',
! 890: 8929 => '\ensuremath{\not\succcurlyeq}',
! 891: 8930 => '\ensuremath{\not\sqsupseteq}',
! 892: 8931 => '\ensuremath{\not\sqsubseteq}',
! 893: 8938 => '\ensuremath{\not\vartriangleleft}',
! 894: 8939 => '\ensuremath{\not\vartriangleright}',
! 895: 8940 => '\ensuremath{\not\trianglelefteq}',
! 896: 8941 => '\ensuremath{\not\trianglerighteq}',
! 897: 8942 => '\ensuremath{\vdots}',
! 898: 8960 => '\ensuremath{\varnothing}',
! 899: 'lceil' => '\ensuremath{\lceil}',
! 900: 8968 => '\ensuremath{\lceil}',
! 901: 'rceil' => '\ensuremath{\rceil}',
! 902: 8969 => '\ensuremath{\rceil}',
! 903: 'lfloor' => '\ensuremath{\lfloor}',
! 904: 8970 => '\ensuremath{\lfloor}',
! 905: 'rfloor' => '\ensuremath{\rfloor}',
! 906: 8971 => '\ensuremath{\rfloor}',
! 907: 'lang' => '\ensuremath{\langle}',
! 908: 9001 => '\ensuremath{\langle}',
! 909: 'rang' => '\ensuremath{\rangle}',
! 910: 9002 => '\ensuremath{\rangle}',
! 911: 'loz' => '\ensuremath{\lozenge}',
! 912: 9674 => '\ensuremath{\lozenge}',
! 913: 'spades' => '\ensuremath{\spadesuit}',
! 914: 9824 => '\ensuremath{\spadesuit}',
! 915: 9825 => '\ensuremath{\heartsuit}',
! 916: 9826 => '\ensuremath{\diamondsuit}',
! 917: 'clubs' => '\ensuremath{\clubsuit}',
! 918: 9827 => '\ensuremath{\clubsuit}',
! 919: 'diams' => '\ensuremath{\blacklozenge}',
! 920: 9830 => '\ensuremath{\blacklozenge}'
1.3 foxr 921:
1.7 foxr 922: );
1.3 foxr 923:
1.4 foxr 924: #
925: # Convert a numerical entity (that does not exist in our hash)
926: # to its UTF-8 equivalent representation.
927: # This allows us to support, to some extent, any entity for which
928: # dvipdf can find a gylph (given that LaTeX is now UTF-8 clean).
929: #
1.5 foxr 930: # Parameters:
931: # unicode - The unicode for the character. This is assumed to
932: # be a decimal value
933: # Returns:
934: # The UTF-8 equiavalent of the value.
935: #
1.4 foxr 936: sub entity_to_utf8 {
1.5 foxr 937: my ($unicode) = @_;
938:
939: return pack("U", $unicode);
1.4 foxr 940: }
941:
942:
943: #
944: # Convert an entity to the corresponding LateX if possible.
945: # If not possible, and the entity is numeric,
946: # the entity is treated like a Unicode character and converted
947: # to UTF-8 which should display as long as dvipdf can find the
948: # appropriate glyph.
949: #
1.5 foxr 950: # The entity is assumed to have already had the
951: # &# ; or & ; removed
952: #
953: # Parameters:
954: # entity - Name of entity to convert.
955: # Returns:
956: # One of the following:
957: # - Latex string that produces the entity.
958: # - UTF-8 equivalent of a numeric entity for which we don't have a latex string.
959: # - ' ' for text entities for which there's no latex equivalent.
960: #
1.4 foxr 961: sub entity_to_latex {
1.5 foxr 962: my ($entity) = @_;
963:
964: # Try to look up the entity (text or numeric) in the hash:
965:
1.7 foxr 966:
967: my $latex = $entities{"$entity"};
968: if (defined $latex) {
1.5 foxr 969: return $latex;
970: }
971: # If the text is purely numeric we can do the UTF-8 conversion:
972:
973: if ($entity =~ /^\d$/) {
974: return &entity_to_utf8($entity);
975: }
1.7 foxr 976: # Can't do the conversion`< ...
1.5 foxr 977:
978: return " ";
979: }
980:
981: #
982: # Convert all the entities in a string.
983: # We locate all the entities, pass them into entity_to_latex and
984: # and replace occurences in the input string.
985: # The assumption is that there are few entities in any string/document
986: # so this looping is not too bad. The advantage of looping vs. regexping is
987: # that we now can use lookup tables for the translation in entity_to_latex above.
988: #
989: # Parameters:
990: # input - Input string/document
991: # Returns
992: # input with entities replaced by latexable stuff (UTF-8 encodings or
993: # latex control strings to produce the entity.
994: #
995: #
996: sub replace_entities {
997: my ($input) = @_;
1.6 foxr 998: my $start;
999: my $end;
1000: my $entity;
1001: my $latex;
1002:
1003: # First the &#nnn; entities:
1004:
1005: while ($input =~ /(&\#\d+;)/) {
1006: ($start) = @-;
1007: ($end) = @+;
1008: $entity = substr($input, $start+2, $end-$start-3);
1009: $latex = &entity_to_latex($entity);
1010: substr($input, $start, $end-$start) = $latex;
1011: }
1012: # Now the &text; entites;
1013:
1.7 foxr 1014: while ($input =~/(&\w+;)/) {
1015: ($start) = @-;
1016: ($end) = @+;
1017: $entity = substr($input, $start+1, $end-$start-2);
1018: $latex = &entity_to_latex($entity);
1019: substr($input, $start, $end-$start) = $latex;
1020:
1.6 foxr 1021: }
1.7 foxr 1022: return $input;
1.4 foxr 1023: }
1.3 foxr 1024:
1.7 foxr 1025: 1;
1026:
1027: __END__
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>