Annotation of loncom/interface/entities.pm, revision 1.7

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'   => '"',
                     83:     35       => '\\\#',
                     84:     36       => '\\\$',
                     85:     37       => '\\%',
                     86:     38       => '\\&',
                     87:     'amp'    => '\\&',
                     88:     39       => '\'',		# Apostrophe
                     89:     40       => '(',
                     90:     41       => ')',
                     91:     42       => '\*',
                     92:     43       => '\+',
                     93:     44       => ',',		#  comma
                     94:     45       => '-',
                     95:     46       => '\.',
                     96:     47       => '\/',
                     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       => ';',
                    109:     60       => '\\ensuremath\{<\}',
                    110:     'lt'     => '\\ensuremath\{<\}',
                    111:     61       => '\\ensuremath\{=\}',
                    112:     62       => '\\ensuremath\{>\}',
                    113:     'gt'     => '\\ensuremath\{>\}',
                    114:     63       => '\?',
                    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       => '[',
                    143:     92       => '\\ensuremath\{\\setminus\}', # \setminus is \ with special spacing.
                    144:     93       => ']',
                    145:     94       => '\\ensuremath\{\\wedge\}',
                    146:     95       => '\\underline\{\\makebox[2mm]\\{\\strut\}\}', # Underline 2mm of space for _
                    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',
                    174:     123      => '\\{',
                    175:     124      => '\|',
                    176:     125      => '\\}',
                    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:     #   &#130;-&#160;
                    182: 
                    183:     130     => ',',
                    184:     131     => '\\textflorin ',
                    185:     132     => ',,',		# Low double left quotes.
1.7     ! foxr      186:     133     => '\\ensuremath\{\\ldots\}',
1.1       foxr      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\}',
                    194:     
                    195:     #  There's a gap here in my entity table
                    196: 
                    197:     145     => '\`',
                    198:     146     => '\'',
                    199:     147     => '\`\`',
                    200:     148     => '\'\'',
                    201:     149     => '\\ensuremath\{\\bullet\}',
                    202:     150     => '--',
                    203:     151     => '---',
                    204:     152     => '\\ensuremath\{\\sim\}',
                    205:     153     => '\\texttrademark',
                    206:     154     => '\\v\{s\}',
                    207:     155     => '\\ensuremath\{>\}',
                    208:     156     => '\\oe ',
                    209:     
                    210:     # Another short gap:
                    211: 
                    212:     159     => '\\"Y',
                    213:     160     => '~',
                    214:     'nbsp'  => '~',
                    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     => '\\texthighdieresis ',
                    230:     'uml'   => '\\texthighdieresis ',
                    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\}',
                    239:     173     => ' - ',
                    240:     'shy'   => ' - ',
                    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     => '\\textacute ',
                    254:     'acute' => '\\textacute ',
                    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     => '\\OE',
                    310:     'ETH'   => '\\OE',
                    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:     222     => '\\TH',
                    338:     'THORN' => '\\TH',
                    339:     223     => '{\\sz}',
                    340:     'szlig' => '{\\sz}',
                    341:     224     => '\\\`{a}',
                    342:     'agrave'=> '\\\`{a}',
                    343:     225     => '\\\'{a}',
                    344:     'aacute'=> '\\\'{a}',
                    345:     226     => '\\\^{a}',
                    346:     'acirc' => '\\\^{a}',
                    347:     227     => '\\\~{a}',
                    348:     'atilde'=> '\\\~{a}',
                    349:     228     => '\\\"{a}',
                    350:     'auml'  => '\\\"{a}',
                    351:     229     => '\\aa',
                    352:     'aring' => '\\aa',
                    353:     230     => '\\ae',
                    354:     'aelig' => '\\ae',
                    355:     231     => '\\c{c}',
                    356:     'ccedil'=> '\\c{c}',
                    357:     232     => '\\\`{e}',
                    358:     'egrave'=> '\\\`{e}',
                    359:     233     => '\\\'{e}',
                    360:     'eacute'=> '\\\'{e}',
                    361:     234     => '\\\^{e}',
                    362:     'ecirc' => '\\\^{e}',
                    363:     235     => '\\\"{e}',
                    364:     'euml'  => '\\\"{e}',
                    365:     236     => '\\\`{i}',
                    366:     'igrave'=> '\\\`{i}',
                    367:     237     => '\\\'{i}',
                    368:     'iacute'=> '\\\'{i}',
                    369:     238     => '\\\^{i}',
                    370:     'icirc' => '\\\^{i}',
                    371:     239     => '\\\"{i}',
                    372:     'iuml'  => '\\\"{i}',
                    373:     240     => '\\dh',
                    374:     'eth'   => '\\dh',
                    375:     241     => '\\\~{n}',
                    376:     'ntilde'=> '\\\~{n}',
                    377:     242     => '\\\`{o}',
                    378:     'ograve'=> '\\\`{o}',
                    379:     243     => '\\\'{o}',
                    380:     'oacute'=> '\\\'{o}',
                    381:     244     => '\\\^{o}',
                    382:     'ocirc' => '\\\^{o}',
                    383:     245     => '\\\~{o}',
                    384:     'otilde'=> '\\\~{o}',
                    385:     246     => '\\\"{o}',
                    386:     'ouml'  => '\\\"{o}',
                    387:     247     => '\\ensuremath\{\\div\}',
                    388:     'divide'=> '\\ensuremath\{\\div\}',
                    389:     248     => '{\\o}',
                    390:     'oslash'=> '{\\o}',
                    391:     249     => '\\\`{u}',
                    392:     'ugrave'=> '\\\`{u}',
                    393:     250     => '\\\'{u}',
                    394:     'uacute'=> '\\\'{u}',
                    395:     251     => '\\\^{u}',
                    396:     'ucirc' => '\\\^{u}',
                    397:     252     => '\\\"{u}',
                    398:     'uuml'  => '\\\"{u}',
                    399:     253     => '\\\'{y}',
                    400:     'yacute'=> '\\\'{y}',
                    401:     254     => '\\th',
                    402:     'thorn' => '\\th',
                    403:     255     => '\\\"{y}',
                    404:     'yuml'  => '\\\"{y}',
                    405: 
                    406:     # hbar entity number comes from the unicode charater:
                    407:     # see e.g. http://www.unicode.org/charts/PDF/U0100.pdf
                    408:     # ISO also documents a 'planck' entity.
                    409: 
                    410:     295     => '\\ensuremath\{\hbar\}',
                    411:     'plank' => '\\ensuremath\{\hbar\}',
                    412: 
                    413:     # Latin extended-A HTML 4.01 entities:
                    414: 
                    415:     338      => '\\OE',
                    416:     'OElig'  => '\\OE',
                    417:     339      => '\\oe',
                    418:     'oelig'  => '\\oe',
                    419:     352      => '\\v{S}',
                    420:     'Scaron' => '\\v{S}',
                    421:     353      => '\\v{s}',
                    422:     'scaron' => '\\v{s}',
                    423:     376      => '\\\"{Y}',
                    424:     'Yuml'   => '\\\"{Y}', 
                    425: 
                    426: 
                    427:     # Latin extended B HTML 4.01 entities
                    428: 
                    429:     402      => '\\ensuremath{f}',
                    430:     'fnof'   => '\\ensuremath{f}',
                    431: 
                    432:     # Spacing modifier letters:
                    433:     
                    434:     710      => '\^{}',
                    435:     'circ'   => '\^{}',
                    436:     732      => '\~{}',
                    437:     'tilde'  => '\~{}',
                    438: 
                    439:     # Greek uppercase:
                    440: 
                    441:     913      => '\\ensuremath\{\\mathrm\{A\}\}',
                    442:     'Alpha'  => '\\ensuremath\{\\mathrm\{A\}\}',
                    443:     914      => '\\ensuremath\{\\mathrm\{B\}\}',
                    444:     'Beta'   => '\\ensuremath\{\\mathrm\{B\}\}',
                    445:     915      => '\\ensuremath\{\\Gamma\}',
                    446:     'Gamma'  => '\\ensuremath\{\\Gamma\}',
                    447:     916      => '\\ensuremath\{\\Delta\}',
                    448:     'Delta'  => '\\ensuremath\{\\Delta\}',
                    449:     917      => '\\ensuremath\{\\mathrm\{E\}\}',
                    450:     'Epsilon'=> '\\ensuremath\{\\mathrm\{E\}\}',
                    451:     918      => '\\ensuremath\{\\mathrm\{Z\}\}',
                    452:     'Zeta'   => '\\ensuremath\{\\mathrm\{Z\}\}',
                    453:     919      => '\\ensuremath\{\\mathrm\{H\}\}',
                    454:     'Eta'    => '\\ensuremath\{\\mathrm\{H\}\}',
                    455:     920      => '\\ensuremath\{\\Theta\}',
                    456:     'Theta'  => '\\ensuremath\{\\Theta\}',
                    457:     921      => '\\ensuremath\{\\mathrm\{I\}\}',
                    458:     'Iota'   => '\\ensuremath\{\\mathrm\{I\}\}',
                    459:     922      => '\\ensuremath\{\\mathrm\{K\}\}',
                    460:     'Kappa'  => '\\ensuremath\{\\mathrm\{K\}\}',
                    461:     923      => '\\ensuremath\{\\Lambda\}',
                    462:     'Lambda' => '\\ensuremath\{\\Lambda\}',
                    463:     924      => '\\ensuremath\{\\mathrm\{M\}\}',
                    464:     'Mu'     => '\\ensuremath\{\\mathrm\{M\}\}',
                    465:     925      => '\\ensuremath\{\\mathrm\{N\}\}',
                    466:     'Nu'     => '\\ensuremath\{\\mathrm\{N\}\}',
                    467:     926      => '\\ensuremath\{\\mathrm\{\\Xi\}',
                    468:     'Xi'     => '\\ensuremath\{\\mathrm\{\\Xi\}',
                    469:     927      => '\\ensuremath\{\\mathrm\{O\}\}',
                    470:     'Omicron'=> '\\ensuremath\{\\mathrm\{O\}\}',
                    471:     928      => '\\ensuremath\{\\Pi\}',
                    472:     'Pi'     => '\\ensuremath\{\\Pi\}',
                    473:     929      => '\\ensuremath\{\\mathrm\{P\}\}',
                    474:     'Rho'    => '\\ensuremath\{\\mathrm\{P\}\}',
                    475:    
                    476:     # Skips 930
                    477: 
                    478:     931      => '\\ensuremath\{\Sigma\}',
                    479:     'Sigma'  => '\\ensuremath\{\Sigma\}',
                    480:     932      => '\\ensuremath\{\\mathrm\{T\}\}',
                    481:     'Tau'    => '\\ensuremath\{\\mathrm\{T\}\}',
                    482:     933      => '\\ensuremath\{\\Upsilon\}',
                    483:     'Upsilon'=> '\\ensuremath\{\\Upsilon\}',
                    484:     934      => '\\ensuremath\{\\Phi\}',
                    485:     'Phi'    => '\\ensuremath\{\\Phi\}',
                    486:     935      => '\\ensuremath\{\\mathrm\{X\}\}',
                    487:     'Chi'    => '\\ensuremath\{\\mathrm\{X\}\}',
                    488:     936      => '\\ensuremath\{\\Psi\}',
                    489:     'Psi'    => '\\ensuermath\{\\Psi\}',
                    490:     937      => '\\ensuremath\{\\Omega\}',
                    491:     'Omega'  => '\\ensuremath\{\\Omega\}',
                    492: 
                    493: 
                    494:     # Greek lowercase:
                    495: 
                    496:     945      => '\\ensuremath\{\\alpha\}',
                    497:     'alpha'  => '\\ensuremath\{\\alpha\}',
                    498:     946      => '\\ensuremath\{\\beta\}',
                    499:     'beta'   => '\\ensuremath\{\\beta\}',
                    500:     947      => '\\ensuremath\{\\gamma\}',
                    501:     'gamma'  => '\\ensuremath\{\\gamma\}',
                    502:     948      => '\\ensuremath\{\\delta\}',
                    503:     'delta'  => '\\ensuremath\{\\delta\}',
                    504:     949      => '\\ensuremath\{\\epsilon\}',
                    505:     'epsilon'=> '\\ensuremath\{\\epsilon\}',
                    506:     950      => '\\ensuremath\{\\zeta\}',
                    507:     'zeta'   => '\\ensuremath\{\\zeta\}',
                    508:     951      => '\\ensuremath\{\\eta\}',
                    509:     'eta'    => '\\ensuremath\{\\eta\}',
1.2       foxr      510:     952      => '\\ensuremath\{\\theta\}',
                    511:     'theta'  => '\\ensuremath\{\\theta\}',
                    512:     953      => '\\ensuremath\{\\iota\}',
                    513:     'iota'   => '\\ensuremath\{\\iota\}',
                    514:     954      => '\\ensuremath\{\\kappa\}',
                    515:     'kappa'  => '\\ensuremath\{\\kappa\}',
                    516:     955      => '\\ensuremath\{\\lambda\}',
                    517:     'lambda' => '\\ensuremath\{\\lambda\}',
                    518:     956      => '\\ensuremath\{\\mu\}',
                    519:     'mu'     => '\\ensuremath\{\\mu\}',
                    520:     957      => '\\ensuremath\{\\nu\}',
                    521:     'nu'     => '\\ensuremath\{\\nu\}',
                    522:     958      => '\\ensuremath\{\\xi\}',
                    523:     'xi'     => '\\ensuremath\{\\xi\}',
                    524:     959      => '\\ensuremath\{o\}',
                    525:     'omicron'=> '\\ensuremath\{o\}',
                    526:     960      => '\\ensuremath\{\\pi\}',
                    527:     'pi'     => '\\ensuremath\{\\pi\}',
                    528:     961      => '\\ensuremath\{\\rho\}',
                    529:     'rho'    => '\\ensuremath\{\\rho\}',
                    530:     962      => '\\ensuremath\{\\varsigma\}',
                    531:     'sigmaf' => '\\ensuremath\{\\varsigma\}',
                    532:     963      => '\\ensuremath\{\\sigma\}',
                    533:     'sigma'  => '\\ensuremath\{\\sigma\}',
                    534:     964      => '\\ensuremath\{\\tau\}',
                    535:     'tau'    => '\\ensuremath\{\\tau\}',
                    536:     965      => '\\ensuremath\{\\upsilon\}',
                    537:     'upsilon'=> '\\ensuremath\{\\upsilon\}',
                    538:     966      => '\\ensuremath\{\\phi\}',
                    539:     'phi'    => '\\ensuremath\{\\phi\}',
                    540:     967      => '\\ensuremath\{\\chi\}',
                    541:     'chi'    => '\\ensuremath\{\\chi\}',
                    542:     968      => '\\ensuremath\{\\psi\}',
                    543:     'psi'    => '\\ensuremath\{\\psi\}',
                    544:     969      => '\\ensuremath\{\\omega\}',
                    545:     'omega'  => '\\ensuremath\{\\omega\}',
                    546:     977      => '\\ensuremath\{\\vartheta\}',
                    547:     'thetasym'=>'\\ensuremath\{\\vartheta\}',
                    548:     978      => '\\ensuremath\{\\varUpsilon\}',
                    549:     'upsih'  => '\\ensuremath\{\\varUpsilon\}',
                    550:     982      => '\\ensuremath\{\\varpi\}',
                    551:     'piv'    => '\\ensuremath\{\\varpi\}',
                    552: 
                    553:     
                    554:     # The general punctuation set:
                    555: 
                    556:     8194,    => '\\hspace{.5em}',
                    557:     'enspc'  => '\\hspace{.5em}',
                    558:     8195     => '\\hspace{1.0em}',
                    559:     'emspc'  => '\\hspace{1.0em}',
                    560:     8201     => '\\hspace{0.167em}',
                    561:     'thinsp' => '\\hspace{0.167em}',
                    562:     8204     => '\{\}',
                    563:     'zwnj'   => '\{\}',
                    564:     8205     => '',
                    565:     'zwj'    => '',
                    566:     8206     => '',
                    567:     'lrm'    => '',
                    568:     8207     => '',
                    569:     'rlm'    => '',
                    570:     8211     => '--',
                    571:     'ndash'  => '--',
                    572:     8212     => '---',
                    573:     'mdash'  => '---',
                    574:     8216     => '`',
                    575:     'lsquo'  => '`',
                    576:     8217     => "'",
                    577:     'rsquo'  => "'",
                    578:     8218     => '\\quotesinglebase',
                    579:     'sbquo'  => '\\quotesinglebase',
                    580:     8220     => '``',
                    581:     'ldquo'  => '``',
                    582:     8221     => "''",
                    583:     'rdquo'  => "''",
                    584:     8222     => '\\quotedblbase',
                    585:     'bdquo'  => '\\quotedblbase',
                    586:     8224     => '\\dagger',
                    587:     'dagger' => '\\dagger',
                    588:     '8225'   => '\\ddag',
                    589:     'Dagger' => '\\ddag',
                    590:     8226     => '\\textbullet',
                    591:     'bull'   => '\\textbullet',
                    592:     8230     => '\\textellipsis',
                    593:     'hellep' => '\\textellipsis',
                    594:     8240     => '\\textperthousand',
                    595:     permil   => '\\textperthousand',
                    596:     8242     => '\\textquotesingle',
                    597:     'prime'  => '\\textquotesingle',
                    598:     8243     => '\\textquotedbl',
                    599:     'Prime'  => '\\textquotedbl',
                    600:     8249     => '\\guilsingleleft',
                    601:     'lsaquo' => '\\guilsingleleft',
                    602:     8250     => '\\guilsingleright',
                    603:     'rsaquo' => '\\guilsingleright',
                    604:     8254     => '\\textasciimacron',
                    605:     oline    => '\\textasciimacron',
                    606:     8260     => '\\textfractionsolidus',
                    607:     'frasl'  => '\\textfractionsolidus',
                    608:     8364     => '\\texteuro',
                    609:     'euro'   => '\\texteuro',
                    610: 
                    611:     # Letter like symbols
                    612: 
                    613:     
                    614:     8472     => '\\ensuremath\{\\wp\}',
                    615:     'weierp' => '\\ensuremath\{\\wp\}',
                    616:     8465     => '\\ensuremath\{\\Im\}',
                    617:     'image'  => '\\ensuremath\{\\Im\}',
                    618:     8476     => '\\ensuremath{\\Re\}',
                    619:     'real'   => '\\ensuremath{\\Re\}',
                    620:     8482     => '\\texttrademark',
                    621:     'trade'  => '\\texttrademark',
                    622:     8501     => '\\ensuremath{\\aleph\}',
                    623:     'alefsym'=> '\\ensuremath{\\aleph\}',
                    624: 
                    625:     # Arrows and then some (harpoons from Hon Kie).
                    626: 
                    627:     8592     => '\\textleftarrow',
                    628:     'larr'   => '\\textleftarrow',
                    629:     8593     => '\\textuparrow',
                    630:     'uarr'   => '\\textuparrow',
                    631:     8594     => '\\textrightarrow',
                    632:     'rarr'   => '\\textrightarrow',
                    633:     8595     => '\\textdownarrow',
                    634:     'darr'   => '\\textdownarrow',
                    635:     8596     => '\\ensuremath\{\\leftrightarrow\}',
                    636:     'harr'   => '\\ensuremath\{\\leftrightarrow\}',
                    637:     8598     => '\\ensuremath\{\\nwarrow\}',
                    638:     8599     => '\\ensuremath\{\\nearrow\}',
                    639:     8600     => '\\ensuremath\{\\searrow\}',
                    640:     8601     => '\\ensuremath\{\\swarrow\}',
                    641:     8605     => '\\ensuremath\{\\leadsto\}',
                    642:     8614     => '\\ensuremath\{\\mapsto\}',
                    643:     8617     => '\\ensuremath\{\\hookleftarrow\}',
                    644:     8618     => '\\ensuremath\{\\hookrightarrow\}',
                    645:     8629     => '\\ensuremath\{\\hookleftarrow\}', # not an exact match but best I know.
                    646:     'crarr'  => '\\ensuremath\{\\hookleftarrow\}', # not an exact match but best I know.
                    647:     8636     => '\\ensuremath\{\\leftharpoonup\}',
                    648:     8637     => '\\ensuremath\{\\leftharpoondown\}',
                    649:     8640     => '\\ensuremath\{\\rightharpoonup\}',
                    650:     8641     => '\\ensuremath\{\\rightharpoondown\}',
                    651:     8652     => '\\ensuremath\{\\rightleftharpoons\}',
                    652:     8656     => '\\ensuremath\{\\Leftarrow\}',
                    653:     'lArr'   => '\\ensuremath\{\\Leftarrow\}',
                    654:     8657     => '\\ensuremath\{\\Uparrow\}',
                    655:     'uArr'   => '\\ensuremath\{\\Uparrow\}',
                    656:     8658     => '\\ensuremath\{\\Rightarrow\}',
                    657:     'rArr'   => '\\ensuremath\{\\Rightarrow\}',
                    658:     8659     => '\\ensuremath\{\\Downarrow\}',
                    659:     'dArr'   => '\\ensuremath\{\\Downarrow\}',
                    660:     8660     => '\\ensuremath\{\\Leftrightarrow\}',
1.3       foxr      661:     'vArr'   => '\\ensuremath\{\\Updownarrow\}',
                    662:     8661     => '\\ensuremath\{\\Updownarrow\}',
                    663:     'lAarr'   => '\\ensuremath\{\\Lleftarrow\}',
                    664:     8666     => '\\ensuremath\{\\Lleftarrow\}',
                    665:     'rAarr'  => '\\ensuremath\{\\Rrightarrow\}',
                    666:     8667     => '\\ensuremath\{\\Rrightarrow\}',
                    667:     'rarrw'  => '\\ensuremath\{\\rightsquigarrow\}',
                    668:     8669     => '\\ensuremath\{\\rightsquigarrow\}',
                    669:     
1.1       foxr      670: 
1.2       foxr      671:     # Mathematical operators.
                    672: 	
1.1       foxr      673:     
1.3       foxr      674:     'forall' => '\\ensuremath\{\\forall\}',
                    675:     8704     => '\\ensuremath\{\\forall\}',
                    676:     'comp'   => '\\ensuremath\{\\complement\}',
                    677:     8705     => '\\ensuremath\{\\complement\}',
                    678:     'part'   => '\\ensuremath\{\\partial\}',
                    679:     8706     => '\\ensuremath\{\\partial\}',
                    680:     'exist'  => '\\ensuremath\{\\exists\}',
                    681:     8707     => '\\ensuremath\{\\exists\}',
                    682:     'nexist' => '\\ensuremath\{\\nexists\}',
                    683:     8708     => '\\ensuremath\{\\nexists\}',
                    684:     'empty'  => '\\ensuremath\{\\emptysset\}',
                    685:     8709     => '\\ensuremath\{\\emptysset\}',
                    686:     8710     => '\\ensuremath\{\\Delta\}',
                    687:     'nabla'  => '\\ensuremath\{\\nabla\}',
                    688:     8711     => '\\ensuremath\{\\nabla\}',
                    689:     'isin'   => '\\ensuremath\{\\in\}',
                    690:     8712     => '\\ensuremath\{\\in\}',
                    691:     'notin'  => '\\ensuremath\{\\notin\}',
                    692:     8713     => '\\ensuremath\{\\notin\}',
                    693:     ni       => '\\ensuremath\{\\ni\}',
                    694:     8715     => '\\ensuremath\{\\ni\}',
                    695:     8716     => '\\ensuremath\{\\not\\ni\}',
                    696:     'prod'   => '\\ensuremath\{\\prod\}',
                    697:     8719     => '\\ensuremath\{\\prod\}',
                    698:     8720     => '\\ensuremath\{\\coprod\}',
                    699:     'sum'    => '\\ensuremath\{\\sum\}',
                    700:     8721     => '\\ensuremath\{\\sum\}',
                    701:     'minus'  => '\\ensuremath\{-\}',
                    702:     8722     => '\\ensuremath\{-\}',
                    703:     8723     => '\\ensuremath\{\\mp\}',
                    704:     8724     => '\\ensuremath\{\\dotplus\}',
                    705:     8725     => '\\ensuremath\{\\diagup\}',
                    706:     8726     => '\\ensuremath\{\\smallsetminus\}',
                    707:     'lowast' => '\\ensuremath\{*\}',
                    708:     8727     => '\\ensuremath\{*\}',
                    709:     8728     => '\\ensuremath\{\\circ\}',
                    710:     8729     => '\\ensuremath\{\\bullet\}',
                    711:     'radic'  => '\\ensuremath\{\\surd\}',
                    712:     8730     => '\\ensuremath\{\\surd\}',
                    713:     8731     => '\\ensuremath\{\\sqrt[3]\{\}\}',
                    714:     8732     => '\\ensuremath\{\\sqrt[4]\{\}\}',
                    715:     'prop'   => '\\ensuremath\{\\propto\}',
                    716:     8733     => '\\ensuremath\{\\propto\}',
                    717:     'infin'  => '\\ensuremath\{\\infty\}',
                    718:     8734     => '\\ensuremath\{\\infty\}',
                    719:     'ang90'  => '\\ensuremath\{\\sqangle\}',
                    720:     8735     => '\\ensuremath\{\\sqangle\}',
                    721:     'ang'    => '\\ensuremath\{\\angle\}',
                    722:     8736     => '\\ensuremath\{\\angle\}',
                    723:     'angmsd' => '\\ensuremath\{\\measuredangle\}',
                    724:     8737     => '\\ensuremath\{\\measuredangle\}',
                    725:     'angsph' => '\\ensuremath\{\\sphiericalangle\}',
                    726:     8738     => '\\ensuremath\{\\sphiericalangle\}',
                    727:     8739     => '\\ensuremath\{\\vert\}',
                    728:     8740     => '\\ensuremath\{\\Vert\}',
                    729:     'and'    => '\\ensuremath\{\\land\}',
                    730:     8743     => '\\ensuremath\{\\land\}',
                    731:     'or'     => '\\ensuremath\{\\lor\}',
                    732:     8744     => '\\ensuremath\{\\lor\}',
                    733:     'cap'    => '\\ensuremath\{\\cap\}',
                    734:     8745     => '\\ensuremath\{\\cap\}',
                    735:     'cup'    => '\\ensuremath\{\\cup\}',
                    736:     8746     => '\\ensuremath\{\\cup\}',
                    737:     'int'    => '\\ensuremath\{\\int\}',
                    738:     8747     => '\\ensuremath\{\\int\}',
1.4       foxr      739:     'conint' => '\\ensuremath\{\\oint\}',
1.3       foxr      740:     8750     => '\\ensuremath\{\\oint\}',
                    741:     'there4' => '\\ensuremath\{\\therefore\}',
                    742:     8756     => '\\ensuremath\{\\therefore\}',
                    743:     'becaus' => '\\ensuremath\{\\because\}',
                    744:     8757     => '\\ensuremath\{\\because\}',
                    745:     8758     => '\\ensuremath\{:\}',
                    746:     8759     => '\\ensuremath\{::\}',
                    747:     'sim'    => '\\ensuremath\{\\sim\}',
                    748:     8764     => '\\ensuremath\{\\sim\}',
1.4       foxr      749:     8765     => '\\ensuremath\{\\backsim\}',
                    750:     'wreath' => '\\ensuremath\{\\wr\}',
                    751:     8768     => '\\ensuremath\{\\wr\}',
                    752:     'nsim'   => '\\ensuremath\{\\not\sim\}',
                    753:     8769     => '\\ensuremath\{\\not\sim\}',
                    754: #    'asymp'  => '\\ensuremath\{\\asymp\}',  &asymp; is actually a different glyph.
                    755:     8771     => '\\ensuremath\{\\asymp\}',
                    756:     8772     => '\\ensuremath\{\\not\\asymp\}',
                    757:     'cong'   => '\\ensuremath\{\\cong\}',
                    758:     8773     => '\\ensuremath\{\\cong\}',
                    759:     8775     => '\\ensuremath\{\\ncong\}',
                    760:     8778     => '\\ensuremath\{\\approxeq\}',
                    761:     8784     => '\\ensuremath\{\\doteq\}',
                    762:     8785     => '\\ensuremath\{\\doteqdot\}',
                    763:     8786     => '\\ensuremath\{\\fallingdotseq\}',
                    764:     8787     => '\\ensuremath\{\\risingdotseq\}',
                    765:     8788     => '\\ensuremath\{:=\}',
                    766:     8789     => '\\ensuremath\{=:\}',
                    767:     8790     => '\\ensuremath\{\\eqcirc\}',
                    768:     8791     => '\\ensuremath\{\\circeq\}',
                    769:     'wedgeq' => '\\ensuremath\{\\stackrel\{\\wedge\}\{=\}\}',
                    770:     8792     => '\\ensuremath\{\\stackrel\{\\wedge\}\{=\}\}',
                    771:     8794     => '\\ensuremath\{\\stackrel\{\\vee\}\{=\}\}',
                    772:     8795     => '\\ensuremath\{\\stackrel\{\\star}\{=\}\}',
                    773:     8796     => '\\ensuremath\{\\triangleeq\}',
                    774:     8797     => '\\ensuremath\{\\stackrel\{def\}\{=\}\}',
                    775:     8798     => '\\ensuremath\{\\stackrel\{m\}\{=\}\}',
                    776:     8799     => '\\ensuremath\{\\stackrel\{?\}\{=\}\}',
                    777:     'ne'     => '\\ensuremath\{\\neq\}',
                    778:     8800     => '\\ensuremath\{\\neq\}',
                    779:     'equiv'  => '\\ensuremath\{\\equiv\}',
                    780:     8801     => '\\ensuremath\{\\equiv\}',
                    781:     8802     => '\\ensuremath\{\\not\\equiv\}',
                    782:     'le'     => '\\ensuremath\{\\leq\}',
                    783:     8804     => '\\ensuremath\{\\leq\}',
                    784:     'ge'     => '\\ensuremath\{\\geq\}',
                    785:     8805     => '\\ensuremath\{\\geq\}',
                    786:     8806     => '\\ensuremath\{\\leqq\}',
                    787:     8807     => '\\ensuremath\{\\geqq\}',
                    788:     8810     => '\\ensuremath\{\\ll\}',
                    789:     8811     => '\\ensuremath\{\\gg\}',
                    790:     'twixt'  => '\\ensuremath\{\\between\}',
                    791:     8812     => '\\ensuremath\{\\between\}',
                    792:     8813     => '\\ensuremath\{\\not\\asymp\}',
                    793:     8814     => '\\ensuremath\{\\not<\}',
                    794:     8815     => '\\ensuremath\{\\not>\}',
                    795:     8816     => '\\ensuremath\{\\not\\leqslant\}',
                    796:     8817     => '\\ensuremath\{\\not\\geqslant\}',
                    797:     8818     => '\\ensuremath\{\\lessim\}',
                    798:     8819     => '\\ensuremath\{\\gtrsim\}',
                    799:     8820     => '\\ensuremath\{\\stackrel\{<\}\{>\}\}',
                    800:     8821     => '\\ensuremath\{\\stackrel\{>\}\{<\}\}',
                    801:     8826     => '\\ensuremath\{\\prec\}',
                    802:     8827     => '\\ensuremath\{\\succ\}',
                    803:     8828     => '\\ensuremath\{\\preceq\}',
                    804:     8829     => '\\ensuremath\{\\succeq\}',
                    805:     8830     => '\\ensuremath\{\\not\\prec\}',
                    806:     8831     => '\\ensuremath\{\\not\\succ\}',
                    807:     'sub'    => '\\ensuremath\{\\subset\}',
                    808:     8834     => '\\ensuremath\{\\subset\}',
                    809:     'sup'    => '\\ensuremath\{\\supset\}',
                    810:     8835     => '\\ensuremath\{\\supset\}',
                    811:     'nsub'   => '\\ensuremath\{\\not\\subset\}',
                    812:     8836     => '\\ensuremath\{\\not\\subset\}',
                    813:     8837     => '\\ensuremath\{\\not\\supset\}',
                    814:     'sube'   => '\\ensuremath\{\\subseteq\}',
                    815:     8838     => '\\ensuremath\{\\subseteq\}',
                    816:     'supe'   => '\\ensuermath\{\\supseteq\}',
                    817:     8839     => '\\ensuermath\{\\supseteq\}',
                    818:     8840     => '\\ensuremath\{\\nsubseteq\}',
                    819:     8841     => '\\ensuremath\{\\nsupseteq\}',
                    820:     8842     => '\\ensuremath\{\\subsetneq\}',
                    821:     8843     => '\\ensuremath\{\\supsetneq\}',
                    822:     8847     => '\\ensuremath\{\\sqsubset\}',
                    823:     8848     => '\\ensuremath\{\\sqsupset\}',
                    824:     8849     => '\\ensuremath\{\\sqsubseteq\}',
                    825:     8850     => '\\ensuremath\{\\sqsupseteq\}',
                    826:     8851     => '\\ensuremath\{\\sqcap\}',
                    827:     8852     => '\\ensuremath\{\\sqcup\}',
                    828:     'oplus'  => '\\ensuremath\{\\oplus\}',
                    829:     8853     => '\\ensuremath\{\\oplus\}',
                    830:     8854     => '\\ensuremath\{\\ominus\}',
                    831:     'otimes' => '\\ensuremath\{\\otimes\}',
                    832:     8855     => '\\ensuremath\{\\otimes\}',
                    833:     8856     => '\\ensuremath\{\\oslash\}',
                    834:     8857     => '\\ensuremath\{\\odot\}',
                    835:     8858     => '\\ensuremath\{\\circledcirc\}',
                    836:     8859     => '\\ensuremath\{\\circledast\}',
                    837:     8861     => '\\ensuremath\{\\ominus\}', # Close enough for government work.
                    838:     8862     => '\\ensuremath\{\\boxplus\}',
                    839:     8863     => '\\ensuremath\{\\boxminus\}',
                    840:     8864     => '\\ensuremath\{\\boxtimes\}',
                    841:     8865     => '\\ensuremath\{\\boxdot\}',
1.5       foxr      842:     'vdash'  => '\\ensuremath\{\\vdash\}',
                    843:     8866     => '\\ensuremath\{\\vdash\}',
                    844:     'dashv'  => '\\ensuremath\{\\dashv\}',
                    845:     8867     => '\\ensuremath\{\\dashv\}',
                    846:     'perp'   => '\\ensuremath\{\\perp\}',
                    847:     8869     => '\\ensuremath\{\\perp\}',
                    848:     8871     => '\\ensuremath\{\\models\}',
                    849:     8872     => '\\ensuremath\{\\vDash\}',    
                    850:     8873     => '\\ensuremath\{\\Vdash\}',
                    851:     8874     => '\\ensuremath\{\\Vvdash\}',
                    852:     8876     => '\\ensuremath\{\\nvdash\}',
                    853:     8877     => '\\ensuremath\{\\nvDash\}',
                    854:     8878     => '\\ensuremath\{\\nVdash\}',
                    855:     8880     => '\\ensuremath\{\\prec\}',
                    856:     8881     => '\\ensuremath\{\\succ\}',
                    857:     8882     => '\\ensuremath\{\\vartriangleleft\}',
                    858:     8883     => '\\ensuremath\{\\vartriangleright\}',
                    859:     8884     => '\\ensuremath\{\\trianglelefteq\}',
                    860:     8885     => '\\ensuremath\{\\trianglerighteq\}',
                    861:     8891     => '\\ensuremath\{\\veebar\}',
                    862:     8896     => '\\ensuremath\{\\land\}',
                    863:     8897     => '\\ensuremath\{\\lor\}',
                    864:     8898     => '\\ensuremath\{\\cap\}',
                    865:     8899     => '\\ensuremath\{\\cup\}',
                    866:     8900     => '\\ensuremath\{\\diamond\}',
                    867:     'sdot'   => '\\ensuremath\{\\cdot\}',
                    868:     8901     => '\\ensuremath\{\\cdot\}',
                    869:     8902     => '\\ensuremath\{\\star\}',
                    870:     8903     => '\\ensuremath\{\\divideontimes\}',
                    871:     8904     => '\\ensuremath\{\\bowtie\}',
                    872:     8905     => '\\ensuremath\{\\ltimes\}',
                    873:     8906     => '\\ensuremath\{\\rtimes\}',
                    874:     8907     => '\\ensuremath\{\\leftthreetimes\}',
                    875:     8908     => '\\ensuremath\{\\rightthreetimes\}',
                    876:     8909     => '\\ensuremath\{\\simeq\}',
                    877:     8910     => '\\ensuremath\{\\curlyvee\}',
                    878:     8911     => '\\ensuremath\{\\curlywedge\}',
                    879:     8912     => '\\ensuremath\{\\Subset\}',
                    880:     8913     => '\\ensuremath\{\\Supset\}',
                    881:     8914     => '\\ensuremath\{\\Cap\}',
                    882:     8915     => '\\ensuremath\{\\Cup\}',
                    883:     8916     => '\\ensuremath\{\\pitchfork\}',
                    884:     8918     => '\\ensuremath\{\\lessdot\}',
                    885:     8919     => '\\ensuremath\{\\gtrdot\}',
                    886:     8920     => '\\ensuremath\{\\lll\}',
                    887:     8921     => '\\ensuremath\{\\ggg\}',
                    888:     8922     => '\\ensuremath\{\\gtreqless\}',
                    889:     8923     => '\\ensuremath\{\\lesseqgtr\}',
                    890:     8924     => '\\ensuremath\{\\eqslantless\}',
                    891:     8925     => '\\ensuremath\{\\eqslantgtr\}',
                    892:     8926     => '\\ensuremath\{\\curlyeqprec\}',
                    893:     8927     => '\\ensuremath\{\\curlyeqsucc\}',
                    894:     8928     => '\\ensuremath\{\\not\\preccurlyeq\}',
                    895:     8929     => '\\ensuremath\{\\not\\succurlyeq\}',
                    896:     8930     => '\\ensuremath\{\\not\\sqsupseteq\}',
                    897:     8931     => '\\ensuremath\{\\not\\sqsubseteq\}',
                    898:     8938     => '\\ensuremath\{\\not\\vartriangleleft\}',
                    899:     8939     => '\\ensuremath\{\\not\vartriangleright\}',
                    900:     8940     => '\\ensuremath\{\\not\trianglelefteq\}',
                    901:     8941     => '\\ensuremath\{\\not\trianglerighteq\}',
                    902:     8942     => '\\ensuremath\{\\vdots\}',
                    903:     8960     => '\\ensuremath\{\\varnothing\}',
                    904:     'lceil'  => '\\ensuremath\{\\lceil\}',
                    905:     8968     => '\\ensuremath\{\\lceil\}',
                    906:     'rceil'  => '\\ensuremath\{\\rceil\}',
                    907:     8969     => '\\ensuremath\{\\rceil\}',
                    908:     'lfloor' => '\\ensuremath\{\\lfloor\}',
                    909:     8970     => '\\ensuremath\{\\lfloor\}',
                    910:     'rfloor' => '\\ensuremath\{\\rfloor}',
                    911:     8971     => '\\ensuremath\{\\rfloor}',
                    912:     'lang'   => '\\ensuremath\{\\langle\}',
                    913:     9001     => '\\ensuremath\{\\langle\}',
                    914:     'rang'   => '\\ensuremath\{\\rangle\}',
                    915:     9002     => '\\ensuremath\{\\rangle\}',
                    916:     'loz'    => '\\ensuremath\{\\lozenge\}',
                    917:     9674     => '\\ensuremath\{\\lozenge\}',
                    918:     'spades' => '\\ensuremath\{\\spadesuit\}',
                    919:     9824     => '\\ensuremath\{\\spadesuit\}',
                    920:     9825     => '\\ensuremath\{\\heartsuit\}',
                    921:     9826     => '\\ensuremath\{\\diamondsuit\}',
                    922:     'clubs'  => '\\ensuremath\{\\clubsuit\}',
                    923:     9827     => '\\ensuremath\{\\clubsuit\}',
                    924:     'diams'  => '\\ensuremath\{\\blacklozenge\}',
                    925:     9830     => '\\ensuremath\{\\blacklozenge\}'
1.3       foxr      926:     
1.7     ! foxr      927: );
1.3       foxr      928: 
1.4       foxr      929: # 
                    930: #  Convert a numerical entity (that does not exist in our hash)
                    931: #  to its UTF-8 equivalent representation.
                    932: #  This allows us to support, to some extent, any entity for which
                    933: #  dvipdf can find a gylph (given that LaTeX is now UTF-8 clean).
                    934: #
1.5       foxr      935: # Parameters:
                    936: #   unicode  - The unicode for the character.  This is assumed to
                    937: #              be a decimal value
                    938: # Returns:
                    939: #   The UTF-8 equiavalent of the value.
                    940: #
1.4       foxr      941: sub entity_to_utf8 {
1.5       foxr      942:     my ($unicode) = @_;
                    943: 
                    944:     return pack("U", $unicode);
1.4       foxr      945: }
                    946: 
                    947: 
                    948: #
                    949: #  Convert an entity to the corresponding LateX if possible.
                    950: #  If not possible, and the entity is numeric,
                    951: #  the entity is treated like a Unicode character and converted
                    952: #  to UTF-8 which should display as long as dvipdf can find the
                    953: #  appropriate glyph.
                    954: #
1.5       foxr      955: #  The entity is assumed to have already had the 
                    956: #  &# ;  or & ; removed
                    957: #
                    958: # Parameters:
                    959: #   entity    - Name of entity to convert.
                    960: # Returns:
                    961: #  One of the following:
                    962: #   - Latex string that produces the entity.
                    963: #   - UTF-8 equivalent of a numeric entity for which we don't have a latex string.
                    964: #   - ' ' for text entities for which there's no latex equivalent.
                    965: #
1.4       foxr      966: sub entity_to_latex {
1.5       foxr      967:     my ($entity) = @_;
                    968: 
                    969:     # Try to look up the entity (text or numeric) in the hash:
                    970: 
1.7     ! foxr      971: 
        !           972:     my $latex = $entities{"$entity"};
        !           973:     if (defined $latex) {
1.5       foxr      974: 	return $latex;
                    975:     }
                    976:     # If the text is purely numeric we can do the UTF-8 conversion:
                    977: 
                    978:     if ($entity =~ /^\d$/) {
                    979: 	return &entity_to_utf8($entity);
                    980:     }
1.7     ! foxr      981:     #  Can't do the conversion`< ...
1.5       foxr      982: 
                    983:     return " ";
                    984: }
                    985: 
                    986: #
                    987: #  Convert all the entities in a string.
                    988: #  We locate all the entities, pass them into entity_to_latex and 
                    989: #  and replace occurences in the input string.
                    990: #  The assumption is that there are few entities in any string/document
                    991: #  so this looping is not too bad.  The advantage of looping vs. regexping is
                    992: #  that we now can use lookup tables for the translation in entity_to_latex above.
                    993: #
                    994: # Parameters:
                    995: #   input   - Input string/document
                    996: # Returns
                    997: #   input with entities replaced by latexable stuff (UTF-8 encodings or
                    998: #   latex control strings to produce the entity.
                    999: #
                   1000: #
                   1001: sub replace_entities {
                   1002:     my ($input)  = @_;
1.6       foxr     1003:     my $start;
                   1004:     my $end;
                   1005:     my $entity;
                   1006:     my $latex;
                   1007:     
                   1008:     # First the &#nnn; entities:
                   1009: 
                   1010:     while ($input =~ /(&\#\d+;)/) {
                   1011: 	($start) = @-;
                   1012: 	($end)   = @+;
                   1013: 	$entity  = substr($input, $start+2, $end-$start-3);
                   1014: 	$latex = &entity_to_latex($entity);
                   1015: 	substr($input, $start, $end-$start) = $latex;
                   1016:     }
                   1017:     # Now the &text; entites;
                   1018:     
1.7     ! foxr     1019:     while ($input =~/(&\w+;)/) {
        !          1020: 	($start) = @-;
        !          1021: 	($end)   = @+;
        !          1022: 	$entity   = substr($input, $start+1, $end-$start-2);
        !          1023: 	$latex    = &entity_to_latex($entity);
        !          1024: 	substr($input, $start, $end-$start) = $latex;
        !          1025: 	
1.6       foxr     1026:    }
1.7     ! foxr     1027:     return $input;
1.4       foxr     1028: }
1.3       foxr     1029: 
1.7     ! foxr     1030: 1; 
        !          1031: 
        !          1032: __END__

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>