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

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

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