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

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

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