/itexToMML

To download this project, use:
bzr branch http://golem.ph.utexas.edu/~distler/code/itexToMML/

« back to all changes in this revision

Viewing changes to itex-src/itex_stringsupport.rb

  • Committer: Jacques Distler
  • Date: 2016-08-14 21:56:27 UTC
  • Revision ID: distler@golem.ph.utexas.edu-20160814215627-s85ojfrb4unki05t
Tags: 1.5.3
itex2MML 1.5.3

Build fixes for Bison3 and Ruby.
Buffer length type: unsigned long => size_t.
Fix an issue on Windows (and possibly other) Ruby platforms.
  (Thanks to Rod McGuire and David Aaron Fendley)
Clean up itex_stringsupport.rb.
Update tests.

Show diffs side-by-side

added added

removed removed

1
1
# Some useful additions to the String class
2
 
# Copyright (C) 2010, Jacques Distler. All rights reserved.
 
2
# Copyright (C) 2010-16, Jacques Distler. All rights reserved.
3
3
# Licensed under a triple GPL/MPL/LGPL License.
4
4
 
5
5
class String
564
564
        'daleth' => 'ℸ',
565
565
        'demptyv' => '⦱',
566
566
        'ell' => 'ℓ',
567
 
        'empty' => '∅',
568
567
        'emptyv' => '∅',
569
568
        'gimel' => 'ℷ',
570
569
        'iiota' => '℩',
813
812
        'upsi' => 'υ',
814
813
        'Xi' => 'Ξ',
815
814
        'xi' => 'ξ',
816
 
        'zeta' => 'ζ',
817
815
        'Afr' => '𝔄',
818
816
        'afr' => '𝔞',
819
817
        'Bfr' => '𝔅',
1521
1519
        'clubs' => '♣',
1522
1520
        'copysr' => '℗',
1523
1521
        'cross' => '✗',
1524
 
        'Dagger' => '‡',
1525
 
        'dagger' => '†',
1526
1522
        'dash' => '‐',
1527
1523
        'diams' => '♦',
1528
1524
        'dlcrop' => '⌍',
2002
1998
        'NotExists' => '∄',
2003
1999
        'NotGreater' => '≯',
2004
2000
        'NotGreaterEqual' => '≱',
2005
 
        'NotGreaterFullEqual' => '≦̸',
 
2001
        'NotGreaterFullEqual' => '≧̸',
2006
2002
        'NotGreaterGreater' => '≫̸',
2007
2003
        'NotGreaterLess' => '≹',
2008
2004
        'NotGreaterSlantEqual' => '⩾̸',
2315
2311
      "'" => ''',
2316
2312
      '"' => '"',
2317
2313
    }
2318
 
    TO_ESCAPE_PATTERN = Regexp.union(TO_ESCAPE.keys)
 
2314
    TO_ESCAPE_PATTERN = Regexp.union(*TO_ESCAPE.keys)
2319
2315
    
2320
2316
    def escapeHTML
2321
2317
      self.gsub(TO_ESCAPE_PATTERN){|m| TO_ESCAPE[m]}
2331
2327
      when /\Aquot\z/ni            then '"'
2332
2328
      when /\Aapos\z/ni            then "'"
2333
2329
      when /\A#0*(\d+)\z/n       then
2334
 
        if Integer($1) < 256
2335
 
          Integer($1).chr
 
2330
        if Integer($1) < 1114111
 
2331
          [Integer($1)].pack("U")
2336
2332
        else
2337
 
          if Integer($1) < 1114111
2338
 
            [Integer($1)].pack("U")
2339
 
          else
2340
 
            "&##{$1};"
2341
 
          end
 
2333
          "&##{$1};"
2342
2334
        end
2343
2335
      when /\A#x([0-9a-f]+)\z/ni then
2344
 
        if $1.hex < 256
 
2336
        if $1.hex < 1114111
2345
2337
          [$1.hex].pack("U")
2346
2338
        else
2347
 
          if $1.hex < 1114111
2348
 
            [$1.hex].pack("U")
2349
 
          else
2350
 
            "&#x#{$1};"
2351
 
          end
 
2339
          "&#x#{$1};"
2352
2340
        end
2353
2341
      else
2354
2342
        "&#{match};"