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

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

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