rsyntaxtree 0.7.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
 - data/Gemfile +1 -1
 - data/README.md +4 -2
 - data/bin/rsyntaxtree +19 -19
 - data/fonts/NotoSansMath-Regular.ttf +0 -0
 - data/fonts/latinmodern-math.otf +0 -0
 - data/fonts/lmroman10-bold.otf +0 -0
 - data/fonts/lmroman10-bolditalic.otf +0 -0
 - data/fonts/lmroman10-italic.otf +0 -0
 - data/fonts/lmroman10-regular.otf +0 -0
 - data/lib/rsyntaxtree/element.rb +1 -1
 - data/lib/rsyntaxtree/elementlist.rb +1 -1
 - data/lib/rsyntaxtree/error_message.rb +1 -1
 - data/lib/rsyntaxtree/graph.rb +3 -3
 - data/lib/rsyntaxtree/string_parser.rb +20 -15
 - data/lib/rsyntaxtree/svg_graph.rb +6 -11
 - data/lib/rsyntaxtree/tree_graph.rb +39 -35
 - data/lib/rsyntaxtree/utils.rb +1 -1
 - data/lib/rsyntaxtree/version.rb +1 -1
 - data/lib/rsyntaxtree.rb +17 -4
 - data/rsyntaxtree.gemspec +2 -5
 - metadata +29 -12
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 2 
     | 
    
         
            +
            SHA256:
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: a93fb86aba069b61d5095d8cd565153b36ea9cdc0bd9903b2ffc656bae5986cb
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: a11db6cdb80b0ccdc118761a4f2131915bffd3dc1a13343be4df662e13bb88b3
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 8ce0bbb49b1c7207aa5d65958e9185dd2e28c762bf39304077b37d03c8e7a2e32b79f2b490d110a6223d1b1ca7df591f43ec82bbc7532f5f4a6c406107e55d72
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 66849abf7520966907cece66a1f12fc3eb29384911ddda5f518ad23ecdf7249d589edebfec98c42f35f468c1dea7204e285a38ddb37e510610bec08807d6d154
         
     | 
    
        data/Gemfile
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -4,7 +4,7 @@ 
     | 
|
| 
       4 
4 
     | 
    
         | 
| 
       5 
5 
     | 
    
         
             
            ### Web Interface
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 7 
     | 
    
         
            +
            See updates and a working web interface available at <https://yohasebe.com/rsyntaxtree>.
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
9 
     | 
    
         
             
            ### Installation
         
     | 
| 
       10 
10 
     | 
    
         | 
| 
         @@ -25,7 +25,7 @@ where [options] are: 
     | 
|
| 
       25 
25 
     | 
    
         
             
                  -o, --outdir=<s>        Output directory (default: ./)
         
     | 
| 
       26 
26 
     | 
    
         
             
                  -f, --format=<s>        Output format: png, pdf, or svg (default: png)
         
     | 
| 
       27 
27 
     | 
    
         
             
                  -l, --leafstyle=<s>     visual style of tree leaves: auto, triangle, bar, or nothing (default: auto)
         
     | 
| 
       28 
     | 
    
         
            -
                  -n, --fontstyle=<s>     Font style: sans, serif, cjk (default: sans)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  -n, --fontstyle=<s>     Font style: sans, serif, cjk, math (default: sans)
         
     | 
| 
       29 
29 
     | 
    
         
             
                  -t, --font=<s>          Path to a ttf font used to generate tree (optional)
         
     | 
| 
       30 
30 
     | 
    
         
             
                  -s, --fontsize=<i>      Size: 8-26 (default: 16)
         
     | 
| 
       31 
31 
     | 
    
         
             
                  -c, --color=<s>         Color text and bars: on or off (default: on)
         
     | 
| 
         @@ -45,6 +45,8 @@ There are several modes in which the connectors between terminal nodes and their 
     | 
|
| 
       45 
45 
     | 
    
         | 
| 
       46 
46 
     | 
    
         
             
            You can put a subscript to any node by putting the _ character between the main label and the subscript. For example, NP_TOP will be rendered as NP<sub>TOP</sub>. Or you can select the “Auto subscript” option so that nodes of the same label will be automatically numbered. (e.g. NP<sub>1</sub>, NP<sub>2</sub>)</p>
         
     | 
| 
       47 
47 
     | 
    
         | 
| 
      
 48 
     | 
    
         
            +
            See https://yohasebe.com/rsyntaxtree for more detailed info about the syntax.
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
       48 
50 
     | 
    
         
             
            ### Example
         
     | 
| 
       49 
51 
     | 
    
         | 
| 
       50 
52 
     | 
    
         
             
            Bracket notation (auto-subscript-on):
         
     | 
    
        data/bin/rsyntaxtree
    CHANGED
    
    | 
         @@ -4,10 +4,10 @@ 
     | 
|
| 
       4 
4 
     | 
    
         
             
            $LOAD_PATH << File.join( File.dirname(__FILE__), '../lib')
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
6 
     | 
    
         
             
            require 'rsyntaxtree'
         
     | 
| 
       7 
     | 
    
         
            -
            require ' 
     | 
| 
      
 7 
     | 
    
         
            +
            require 'optimist'
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            opts =  
     | 
| 
       10 
     | 
    
         
            -
              version "RSyntaxTree #{RSyntaxTree::VERSION} (c)  
     | 
| 
      
 9 
     | 
    
         
            +
            opts = Optimist::options do
         
     | 
| 
      
 10 
     | 
    
         
            +
              version "RSyntaxTree #{RSyntaxTree::VERSION} (c) 2021 Yoichiro Hasebe"
         
     | 
| 
       11 
11 
     | 
    
         
             
              banner <<-EOS
         
     | 
| 
       12 
12 
     | 
    
         
             
            RSyntaxTree, (linguistic) syntax tree generator written in Ruby.
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
         @@ -20,9 +20,9 @@ EOS 
     | 
|
| 
       20 
20 
     | 
    
         
             
                  :default => "./"
         
     | 
| 
       21 
21 
     | 
    
         
             
              opt :format, "Output format: png, gif, jpg, pdf, or svg",
         
     | 
| 
       22 
22 
     | 
    
         
             
                  :default => "png"
         
     | 
| 
       23 
     | 
    
         
            -
              opt :leafstyle, "visual style of tree leaves: auto, triangle, bar, or nothing", 
     | 
| 
      
 23 
     | 
    
         
            +
              opt :leafstyle, "visual style of tree leaves: auto, triangle, bar, or nothing",
         
     | 
| 
       24 
24 
     | 
    
         
             
                  :default => "auto"
         
     | 
| 
       25 
     | 
    
         
            -
              opt :fontstyle, "Font style (available when ttf font is specified): sans, serif, cjk",
         
     | 
| 
      
 25 
     | 
    
         
            +
              opt :fontstyle, "Font style (available when ttf font is specified): sans, serif, cjk, math",
         
     | 
| 
       26 
26 
     | 
    
         
             
                  :default => "sans"
         
     | 
| 
       27 
27 
     | 
    
         
             
              opt :font, "Path to a ttf font used to generate tree (optional)", :type => String
         
     | 
| 
       28 
28 
     | 
    
         
             
              opt :fontsize, "Size: 8-26",
         
     | 
| 
         @@ -32,24 +32,24 @@ EOS 
     | 
|
| 
       32 
32 
     | 
    
         
             
              opt :vheight, "Connector Height: 0.5-2.0",
         
     | 
| 
       33 
33 
     | 
    
         
             
                :default => 1.0
         
     | 
| 
       34 
34 
     | 
    
         
             
              opt :color, "Color text and bars: on or off",
         
     | 
| 
       35 
     | 
    
         
            -
                  :default => "on" 
     | 
| 
      
 35 
     | 
    
         
            +
                  :default => "on"
         
     | 
| 
       36 
36 
     | 
    
         
             
              opt :symmetrize, "Generate symmetrical, balanced tree: on or off",
         
     | 
| 
       37 
     | 
    
         
            -
                  :default => "on" 
     | 
| 
      
 37 
     | 
    
         
            +
                  :default => "on"
         
     | 
| 
       38 
38 
     | 
    
         
             
              opt :autosub, "Put subscript numbers to nodes: on or off",
         
     | 
| 
       39 
     | 
    
         
            -
                  :default => "off" 
     | 
| 
      
 39 
     | 
    
         
            +
                  :default => "off"
         
     | 
| 
       40 
40 
     | 
    
         
             
            end
         
     | 
| 
       41 
41 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 42 
     | 
    
         
            +
            Optimist::die :outdir, "must be an exsting directory path" unless FileTest::directory?(opts[:outdir])
         
     | 
| 
      
 43 
     | 
    
         
            +
            Optimist::die :format, "must be png, jpg, gif, or svg" unless /\A(png|jpg|gif|pdf|svg)\z/ =~ opts[:format]
         
     | 
| 
      
 44 
     | 
    
         
            +
            Optimist::die :leafstyle, "must be auto, triangle, bar, or nothing" unless /\A(auto|triangle|bar|nothing)\z/ =~ opts[:leafstyle]
         
     | 
| 
      
 45 
     | 
    
         
            +
            Optimist::die :fontstyle, "must be sans, serif, cjk, math" unless /\A(sans|serif|cjk|math)\z/ =~ opts[:fontstyle]
         
     | 
| 
      
 46 
     | 
    
         
            +
            Optimist::die :font, "must be path to an existing ttf font" if opts[:font] && !File::exists?(opts[:font])
         
     | 
| 
      
 47 
     | 
    
         
            +
            Optimist::die :fontsize, "must be in the range of 8-26" unless opts[:fontsize] >= 8 && opts[:fontsize] <= 26
         
     | 
| 
      
 48 
     | 
    
         
            +
            Optimist::die :color, "must be either on or off" unless /\A(on|off)\z/ =~ opts[:color]
         
     | 
| 
      
 49 
     | 
    
         
            +
            Optimist::die :symmetrize, "must be either on or off" unless /\A(on|off)\z/ =~ opts[:symmetrize]
         
     | 
| 
      
 50 
     | 
    
         
            +
            Optimist::die :autosub, "must be either on or off" unless /\A(on|off)\z/ =~ opts[:autosub]
         
     | 
| 
      
 51 
     | 
    
         
            +
            Optimist::die :margin, "must be in the range of 0-120" if opts[:margin] < 0 || opts[:margin] > 120
         
     | 
| 
      
 52 
     | 
    
         
            +
            Optimist::die :vheight, "must be in the range of 0.5-2.0" if opts[:vheight] < 0.5 || opts[:vheight] > 2.0
         
     | 
| 
       53 
53 
     | 
    
         | 
| 
       54 
54 
     | 
    
         
             
            string_opts = {}
         
     | 
| 
       55 
55 
     | 
    
         
             
            opts.each do |key, value|
         
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
| 
         Binary file 
     | 
    
        data/lib/rsyntaxtree/element.rb
    CHANGED
    
    | 
         @@ -10,7 +10,7 @@ 
     | 
|
| 
       10 
10 
     | 
    
         
             
            # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
         
     | 
| 
       11 
11 
     | 
    
         
             
            # excellent program phpSyntaxTree.
         
     | 
| 
       12 
12 
     | 
    
         
             
            #
         
     | 
| 
       13 
     | 
    
         
            -
            # Copyright (c) 2007- 
     | 
| 
      
 13 
     | 
    
         
            +
            # Copyright (c) 2007-2021 Yoichiro Hasebe <yohasebe@gmail.com>
         
     | 
| 
       14 
14 
     | 
    
         
             
            # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
            class Element
         
     | 
| 
         @@ -10,7 +10,7 @@ 
     | 
|
| 
       10 
10 
     | 
    
         
             
            # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
         
     | 
| 
       11 
11 
     | 
    
         
             
            # excellent program phpSyntaxTree.
         
     | 
| 
       12 
12 
     | 
    
         
             
            #
         
     | 
| 
       13 
     | 
    
         
            -
            # Copyright (c) 2007- 
     | 
| 
      
 13 
     | 
    
         
            +
            # Copyright (c) 2007-2021 Yoichiro Hasebe <yohasebe@gmail.com>
         
     | 
| 
       14 
14 
     | 
    
         
             
            # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
            require 'element'
         
     | 
| 
         @@ -10,7 +10,7 @@ 
     | 
|
| 
       10 
10 
     | 
    
         
             
            # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
         
     | 
| 
       11 
11 
     | 
    
         
             
            # excellent program phpSyntaxTree.
         
     | 
| 
       12 
12 
     | 
    
         
             
            #
         
     | 
| 
       13 
     | 
    
         
            -
            # Copyright (c) 2007- 
     | 
| 
      
 13 
     | 
    
         
            +
            # Copyright (c) 2007-2021 Yoichiro Hasebe <yohasebe@gmail.com>
         
     | 
| 
       14 
14 
     | 
    
         
             
            # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
            class ErrorMessage
         
     | 
    
        data/lib/rsyntaxtree/graph.rb
    CHANGED
    
    | 
         @@ -10,7 +10,7 @@ 
     | 
|
| 
       10 
10 
     | 
    
         
             
            # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
         
     | 
| 
       11 
11 
     | 
    
         
             
            # excellent program phpSyntaxTree.
         
     | 
| 
       12 
12 
     | 
    
         
             
            #
         
     | 
| 
       13 
     | 
    
         
            -
            # Copyright (c) 2007- 
     | 
| 
      
 13 
     | 
    
         
            +
            # Copyright (c) 2007-2021 Yoichiro Hasebe <yohasebe@gmail.com>
         
     | 
| 
       14 
14 
     | 
    
         
             
            # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
            require 'rmagick'
         
     | 
| 
         @@ -62,7 +62,7 @@ class Graph 
     | 
|
| 
       62 
62 
     | 
    
         | 
| 
       63 
63 
     | 
    
         
             
                gc = Draw.new
         
     | 
| 
       64 
64 
     | 
    
         
             
                gc.annotate(background, 0, 0, 0, 0, text) do |gc|
         
     | 
| 
       65 
     | 
    
         
            -
                  gc.font = font
         
     | 
| 
      
 65 
     | 
    
         
            +
                  gc.font = font 
         
     | 
| 
       66 
66 
     | 
    
         
             
                  gc.pointsize = font_size
         
     | 
| 
       67 
67 
     | 
    
         
             
                  gc.gravity = CenterGravity
         
     | 
| 
       68 
68 
     | 
    
         
             
                  gc.stroke = 'none'
         
     | 
| 
         @@ -286,7 +286,7 @@ class Graph 
     | 
|
| 
       286 
286 
     | 
    
         | 
| 
       287 
287 
     | 
    
         
             
              def get_txt_only(text)
         
     | 
| 
       288 
288 
     | 
    
         
             
                text = text.strip
         
     | 
| 
       289 
     | 
    
         
            -
                if /\A([ 
     | 
| 
      
 289 
     | 
    
         
            +
                if /\A([\+\-\=\*\~]+).+/ =~ text
         
     | 
| 
       290 
290 
     | 
    
         
             
                  prefix = $1
         
     | 
| 
       291 
291 
     | 
    
         
             
                  prefix_l = Regexp.escape(prefix)
         
     | 
| 
       292 
292 
     | 
    
         
             
                  prefix_r = Regexp.escape(prefix.reverse)
         
     | 
| 
         @@ -11,24 +11,24 @@ 
     | 
|
| 
       11 
11 
     | 
    
         
             
            # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
         
     | 
| 
       12 
12 
     | 
    
         
             
            # excellent program phpSyntaxTree.
         
     | 
| 
       13 
13 
     | 
    
         
             
            #
         
     | 
| 
       14 
     | 
    
         
            -
            # Copyright (c) 2007- 
     | 
| 
      
 14 
     | 
    
         
            +
            # Copyright (c) 2007-2021 Yoichiro Hasebe <yohasebe@gmail.com>
         
     | 
| 
       15 
15 
     | 
    
         
             
            # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
17 
     | 
    
         
             
            require 'elementlist'
         
     | 
| 
       18 
18 
     | 
    
         
             
            require 'element'
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
            def escape_high_ascii(string)
         
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
            end
         
     | 
| 
      
 20 
     | 
    
         
            +
            # def escape_high_ascii(string)
         
     | 
| 
      
 21 
     | 
    
         
            +
            #   html = ""
         
     | 
| 
      
 22 
     | 
    
         
            +
            #   string.length.times do |i|
         
     | 
| 
      
 23 
     | 
    
         
            +
            #     ch = string[i]
         
     | 
| 
      
 24 
     | 
    
         
            +
            #     if(ch < 127)
         
     | 
| 
      
 25 
     | 
    
         
            +
            #       html += ch.chr
         
     | 
| 
      
 26 
     | 
    
         
            +
            #     else
         
     | 
| 
      
 27 
     | 
    
         
            +
            #       html += sprintf("&#%d;", ch)
         
     | 
| 
      
 28 
     | 
    
         
            +
            #     end
         
     | 
| 
      
 29 
     | 
    
         
            +
            #   end  
         
     | 
| 
      
 30 
     | 
    
         
            +
            #   html
         
     | 
| 
      
 31 
     | 
    
         
            +
            # end
         
     | 
| 
       32 
32 
     | 
    
         | 
| 
       33 
33 
     | 
    
         
             
            class StringParser
         
     | 
| 
       34 
34 
     | 
    
         | 
| 
         @@ -203,8 +203,12 @@ class StringParser 
     | 
|
| 
       203 
203 
     | 
    
         | 
| 
       204 
204 
     | 
    
         
             
                    if spaceat
         
     | 
| 
       205 
205 
     | 
    
         
             
                      parts[0] = token_r[0, spaceat].join
         
     | 
| 
      
 206 
     | 
    
         
            +
                      parts[0] = parts[0].gsub("<>", " ")
         
     | 
| 
      
 207 
     | 
    
         
            +
             
     | 
| 
       206 
208 
     | 
    
         
             
                      tl =token_r.length
         
     | 
| 
       207 
209 
     | 
    
         
             
                      parts[1] = token_r[spaceat, tl - spaceat].join
         
     | 
| 
      
 210 
     | 
    
         
            +
                      parts[1] = parts[1].gsub("<>", " ")
         
     | 
| 
      
 211 
     | 
    
         
            +
             
     | 
| 
       208 
212 
     | 
    
         
             
                      element = Element.new(@id, parent, parts[0], @level)
         
     | 
| 
       209 
213 
     | 
    
         
             
                      @id += 1
         
     | 
| 
       210 
214 
     | 
    
         
             
                      @elist.add(element)
         
     | 
| 
         @@ -215,11 +219,12 @@ class StringParser 
     | 
|
| 
       215 
219 
     | 
    
         
             
                      @id += 1          
         
     | 
| 
       216 
220 
     | 
    
         
             
                      @elist.add(element)
         
     | 
| 
       217 
221 
     | 
    
         
             
                    else
         
     | 
| 
       218 
     | 
    
         
            -
                       
     | 
| 
      
 222 
     | 
    
         
            +
                      joined = token_r.join.gsub("<>", " ")
         
     | 
| 
      
 223 
     | 
    
         
            +
                      element = Element.new(@id, parent, joined, @level)
         
     | 
| 
       219 
224 
     | 
    
         
             
                      @id += 1          
         
     | 
| 
       220 
225 
     | 
    
         
             
                      newparent = element.id
         
     | 
| 
       221 
226 
     | 
    
         
             
                      @elist.add(element)
         
     | 
| 
       222 
     | 
    
         
            -
                      count_node( 
     | 
| 
      
 227 
     | 
    
         
            +
                      count_node(joined)
         
     | 
| 
       223 
228 
     | 
    
         
             
                    end 
         
     | 
| 
       224 
229 
     | 
    
         | 
| 
       225 
230 
     | 
    
         
             
                    @level += 1
         
     | 
| 
         @@ -10,7 +10,7 @@ 
     | 
|
| 
       10 
10 
     | 
    
         
             
            # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
         
     | 
| 
       11 
11 
     | 
    
         
             
            # excellent program phpSyntaxTree.
         
     | 
| 
       12 
12 
     | 
    
         
             
            #
         
     | 
| 
       13 
     | 
    
         
            -
            # Copyright (c) 2007- 
     | 
| 
      
 13 
     | 
    
         
            +
            # Copyright (c) 2007-2021 Yoichiro Hasebe <yohasebe@gmail.com>
         
     | 
| 
       14 
14 
     | 
    
         
             
            # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
            require "tempfile"
         
     | 
| 
         @@ -18,10 +18,11 @@ require 'graph' 
     | 
|
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            class SVGGraph < Graph
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
              def initialize(e_list, metrics, symmetrize, color, leafstyle, multibyte, fontstyle, font_size)
         
     | 
| 
      
 21 
     | 
    
         
            +
              def initialize(e_list, metrics, symmetrize, color, leafstyle, multibyte, fontstyle, font, font_size)
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
                # Store class-specific parameters
         
     | 
| 
       24 
     | 
    
         
            -
                @ 
     | 
| 
      
 24 
     | 
    
         
            +
                @fontstyle  = fontstyle
         
     | 
| 
      
 25 
     | 
    
         
            +
                @font       = multibyte ? font_cjk : font
         
     | 
| 
       25 
26 
     | 
    
         
             
                @font_size  = font_size
         
     | 
| 
       26 
27 
     | 
    
         | 
| 
       27 
28 
     | 
    
         
             
                super(e_list, metrics, symmetrize, color, leafstyle, multibyte, @font, @font_size)
         
     | 
| 
         @@ -87,15 +88,12 @@ EOD 
     | 
|
| 
       87 
88 
     | 
    
         
             
                  sub  = ""
         
     | 
| 
       88 
89 
     | 
    
         
             
                end
         
     | 
| 
       89 
90 
     | 
    
         | 
| 
       90 
     | 
    
         
            -
                if /\A 
     | 
| 
      
 91 
     | 
    
         
            +
                if /\A\=(.+)\=\z/ =~ main
         
     | 
| 
       91 
92 
     | 
    
         
             
                  main = $1
         
     | 
| 
       92 
93 
     | 
    
         
             
                  main_decoration= "overline"
         
     | 
| 
       93 
94 
     | 
    
         
             
                elsif /\A\-(.+)\-\z/ =~ main
         
     | 
| 
       94 
95 
     | 
    
         
             
                  main = $1
         
     | 
| 
       95 
96 
     | 
    
         
             
                  main_decoration= "underline"
         
     | 
| 
       96 
     | 
    
         
            -
                elsif /\A\=(.+)\=\z/ =~ main
         
     | 
| 
       97 
     | 
    
         
            -
                  main = $1
         
     | 
| 
       98 
     | 
    
         
            -
                  main_decoration= "line-through"
         
     | 
| 
       99 
97 
     | 
    
         
             
                else
         
     | 
| 
       100 
98 
     | 
    
         
             
                  main_decoration= ""
         
     | 
| 
       101 
99 
     | 
    
         
             
                end
         
     | 
| 
         @@ -124,15 +122,12 @@ EOD 
     | 
|
| 
       124 
122 
     | 
    
         
             
                main_width = img_get_txt_width(main, @font, @font_size)
         
     | 
| 
       125 
123 
     | 
    
         | 
| 
       126 
124 
     | 
    
         
             
                if sub != ""
         
     | 
| 
       127 
     | 
    
         
            -
                  if /\A 
     | 
| 
      
 125 
     | 
    
         
            +
                  if /\A\=(.+)\=\z/ =~ sub
         
     | 
| 
       128 
126 
     | 
    
         
             
                    sub = $1
         
     | 
| 
       129 
127 
     | 
    
         
             
                    sub_decoration= "overline"
         
     | 
| 
       130 
128 
     | 
    
         
             
                  elsif /\A\-(.+)\-\z/ =~ sub
         
     | 
| 
       131 
129 
     | 
    
         
             
                    sub = $1
         
     | 
| 
       132 
130 
     | 
    
         
             
                    sub_decoration= "underline"
         
     | 
| 
       133 
     | 
    
         
            -
                  elsif /\A\=(.+)\=\z/ =~ sub
         
     | 
| 
       134 
     | 
    
         
            -
                    sub = $1
         
     | 
| 
       135 
     | 
    
         
            -
                    sub_decoration= "line-through"
         
     | 
| 
       136 
131 
     | 
    
         
             
                  else
         
     | 
| 
       137 
132 
     | 
    
         
             
                    sub_decoration= ""
         
     | 
| 
       138 
133 
     | 
    
         
             
                  end
         
     | 
| 
         @@ -10,7 +10,7 @@ 
     | 
|
| 
       10 
10 
     | 
    
         
             
            # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
         
     | 
| 
       11 
11 
     | 
    
         
             
            # excellent program phpSyntaxTree.
         
     | 
| 
       12 
12 
     | 
    
         
             
            #
         
     | 
| 
       13 
     | 
    
         
            -
            # Copyright (c) 2007- 
     | 
| 
      
 13 
     | 
    
         
            +
            # Copyright (c) 2007-2021 Yoichiro Hasebe <yohasebe@gmail.com>
         
     | 
| 
       14 
14 
     | 
    
         
             
            # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
            require 'graph'
         
     | 
| 
         @@ -20,7 +20,7 @@ include Magick 
     | 
|
| 
       20 
20 
     | 
    
         
             
            class TreeGraph < Graph
         
     | 
| 
       21 
21 
     | 
    
         | 
| 
       22 
22 
     | 
    
         
             
              def initialize(e_list, metrics, symmetrize, color, leafstyle, multibyte,
         
     | 
| 
       23 
     | 
    
         
            -
                             fontstyle, font, font_it, font_bd, font_itbd, font_cjk, font_size,
         
     | 
| 
      
 23 
     | 
    
         
            +
                             fontstyle, font, font_it, font_bd, font_itbd, font_math, font_cjk, font_size,
         
     | 
| 
       24 
24 
     | 
    
         
             
                             margin)
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                # Store class-specific parameters
         
     | 
| 
         @@ -30,6 +30,7 @@ class TreeGraph < Graph 
     | 
|
| 
       30 
30 
     | 
    
         
             
                @font_it    = font_it
         
     | 
| 
       31 
31 
     | 
    
         
             
                @font_bd    = font_bd
         
     | 
| 
       32 
32 
     | 
    
         
             
                @font_itbd  = font_itbd
         
     | 
| 
      
 33 
     | 
    
         
            +
                @font_math  = font_math
         
     | 
| 
       33 
34 
     | 
    
         
             
                @font_cjk   = font_cjk
         
     | 
| 
       34 
35 
     | 
    
         
             
                @margin     = margin
         
     | 
| 
       35 
36 
     | 
    
         | 
| 
         @@ -62,28 +63,31 @@ class TreeGraph < Graph 
     | 
|
| 
       62 
63 
     | 
    
         
             
              def to_blob(fileformat='PNG')
         
     | 
| 
       63 
64 
     | 
    
         
             
                draw
         
     | 
| 
       64 
65 
     | 
    
         
             
                @im.border!(@margin, @margin, "white")
         
     | 
| 
       65 
     | 
    
         
            -
                return @im.to_blob do
         
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                end
         
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
      
 66 
     | 
    
         
            +
                # return @im.to_blob do
         
     | 
| 
      
 67 
     | 
    
         
            +
                #   self.format = fileformat
         
     | 
| 
      
 68 
     | 
    
         
            +
                #   self.interlace = PlaneInterlace
         
     | 
| 
      
 69 
     | 
    
         
            +
                # end
         
     | 
| 
      
 70 
     | 
    
         
            +
                @im.format = fileformat
         
     | 
| 
      
 71 
     | 
    
         
            +
                @im.interlace = PlaneInterlace
         
     | 
| 
      
 72 
     | 
    
         
            +
                return @im.to_blob
         
     | 
| 
      
 73 
     | 
    
         
            +
              end
         
     | 
| 
       70 
74 
     | 
    
         | 
| 
       71 
75 
     | 
    
         
             
              :private
         
     | 
| 
       72 
76 
     | 
    
         | 
| 
       73 
77 
     | 
    
         
             
              # Add the element into the tree (draw it)
         
     | 
| 
       74 
78 
     | 
    
         
             
              def draw_element(x, y, w, string, type)
         
     | 
| 
       75 
     | 
    
         
            -
                string = string.sub(/\^\z/){""} 
     | 
| 
      
 79 
     | 
    
         
            +
                string = string.sub(/\^\z/){""}
         
     | 
| 
       76 
80 
     | 
    
         
             
                # Calculate element dimensions and position
         
     | 
| 
       77 
81 
     | 
    
         
             
                if (type == ETYPE_LEAF) and @leafstyle == "nothing"
         
     | 
| 
       78 
82 
     | 
    
         
             
                  top = row2px(y - 1) + (@font_size * 1.5)
         
     | 
| 
       79 
     | 
    
         
            -
                else 
     | 
| 
      
 83 
     | 
    
         
            +
                else
         
     | 
| 
       80 
84 
     | 
    
         
             
                  top   = row2px(y)
         
     | 
| 
       81 
85 
     | 
    
         
             
                end
         
     | 
| 
       82 
86 
     | 
    
         
             
                left   = x + @m[:b_side]
         
     | 
| 
       83 
87 
     | 
    
         
             
                bottom = top  + @e_height
         
     | 
| 
       84 
88 
     | 
    
         
             
                right  = left + w
         
     | 
| 
       85 
89 
     | 
    
         | 
| 
       86 
     | 
    
         
            -
                # Split the string into the main part and the 
     | 
| 
      
 90 
     | 
    
         
            +
                # Split the string into the main part and the
         
     | 
| 
       87 
91 
     | 
    
         
             
                # subscript part of the element (if any)
         
     | 
| 
       88 
92 
     | 
    
         
             
                parts = string.split("_", 2)
         
     | 
| 
       89 
93 
     | 
    
         
             
                if(parts.length > 1 )
         
     | 
| 
         @@ -94,77 +98,77 @@ class TreeGraph < Graph 
     | 
|
| 
       94 
98 
     | 
    
         
             
                  sub  = ""
         
     | 
| 
       95 
99 
     | 
    
         
             
                end
         
     | 
| 
       96 
100 
     | 
    
         | 
| 
       97 
     | 
    
         
            -
                if /\A 
     | 
| 
      
 101 
     | 
    
         
            +
                if /\A\=(.+)\=\z/ =~ main
         
     | 
| 
       98 
102 
     | 
    
         
             
                  main = $1
         
     | 
| 
       99 
103 
     | 
    
         
             
                  main_decoration = OverlineDecoration
         
     | 
| 
       100 
104 
     | 
    
         
             
                elsif /\A\-(.+)\-\z/ =~ main
         
     | 
| 
       101 
105 
     | 
    
         
             
                  main = $1
         
     | 
| 
       102 
106 
     | 
    
         
             
                  main_decoration = UnderlineDecoration
         
     | 
| 
       103 
     | 
    
         
            -
                elsif /\A\=(.+)\=\z/ =~ main
         
     | 
| 
       104 
     | 
    
         
            -
                  main = $1
         
     | 
| 
       105 
     | 
    
         
            -
                  main_decoration = LineThroughDecoration
         
     | 
| 
       106 
107 
     | 
    
         
             
                else
         
     | 
| 
       107 
108 
     | 
    
         
             
                  main_decoration = NoDecoration
         
     | 
| 
       108 
109 
     | 
    
         
             
                end
         
     | 
| 
       109 
110 
     | 
    
         | 
| 
      
 111 
     | 
    
         
            +
                main_font = @font
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
       110 
113 
     | 
    
         
             
                if /\A\*\*\*(.+)\*\*\*\z/ =~ main
         
     | 
| 
       111 
114 
     | 
    
         
             
                  main = $1
         
     | 
| 
       112 
     | 
    
         
            -
                  if !@multibyte 
     | 
| 
      
 115 
     | 
    
         
            +
                  if !@multibyte
         
     | 
| 
       113 
116 
     | 
    
         
             
                    main_font = @font_itbd
         
     | 
| 
       114 
117 
     | 
    
         
             
                  end
         
     | 
| 
       115 
118 
     | 
    
         
             
                elsif /\A\*\*(.+)\*\*\z/ =~ main
         
     | 
| 
       116 
119 
     | 
    
         
             
                  main = $1
         
     | 
| 
       117 
     | 
    
         
            -
                  if !@multibyte 
     | 
| 
      
 120 
     | 
    
         
            +
                  if !@multibyte
         
     | 
| 
       118 
121 
     | 
    
         
             
                    main_font = @font_bd
         
     | 
| 
       119 
122 
     | 
    
         
             
                  end
         
     | 
| 
       120 
123 
     | 
    
         
             
                elsif /\A\*(.+)\*\z/ =~ main
         
     | 
| 
       121 
124 
     | 
    
         
             
                  main = $1
         
     | 
| 
       122 
     | 
    
         
            -
                  if !@multibyte 
     | 
| 
      
 125 
     | 
    
         
            +
                  if !@multibyte
         
     | 
| 
       123 
126 
     | 
    
         
             
                    main_font = @font_it
         
     | 
| 
       124 
127 
     | 
    
         
             
                  end
         
     | 
| 
       125 
     | 
    
         
            -
                else
         
     | 
| 
       126 
     | 
    
         
            -
                  main_font = @font
         
     | 
| 
       127 
128 
     | 
    
         
             
                end
         
     | 
| 
       128 
129 
     | 
    
         | 
| 
       129 
     | 
    
         
            -
                 
     | 
| 
      
 130 
     | 
    
         
            +
                if /\A\~(.+)\~\z/ =~ main
         
     | 
| 
      
 131 
     | 
    
         
            +
                  main = $1
         
     | 
| 
      
 132 
     | 
    
         
            +
                  main_font = @font_math
         
     | 
| 
      
 133 
     | 
    
         
            +
                end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                # Calculate text size for the main and the
         
     | 
| 
       130 
136 
     | 
    
         
             
                # subscript part of the element
         
     | 
| 
       131 
     | 
    
         
            -
                # symbols for underline/overline removed temporarily
         
     | 
| 
       132 
137 
     | 
    
         | 
| 
       133 
138 
     | 
    
         
             
                main_width = img_get_txt_width(main, main_font, @font_size)
         
     | 
| 
       134 
139 
     | 
    
         | 
| 
       135 
     | 
    
         
            -
                if /\A 
     | 
| 
      
 140 
     | 
    
         
            +
                if /\A\=(.+)\=\z/ =~ sub
         
     | 
| 
       136 
141 
     | 
    
         
             
                  sub = $1
         
     | 
| 
       137 
142 
     | 
    
         
             
                  sub_decoration = OverlineDecoration
         
     | 
| 
       138 
143 
     | 
    
         
             
                elsif /\A\-(.+)\-\z/ =~ sub
         
     | 
| 
       139 
144 
     | 
    
         
             
                  sub = $1
         
     | 
| 
       140 
145 
     | 
    
         
             
                  @gc.decorate(UnderlineDecoration)
         
     | 
| 
       141 
146 
     | 
    
         
             
                  sub_decoration = UnderlineDecoration
         
     | 
| 
       142 
     | 
    
         
            -
                elsif /\A\=(.+)\=\z/ =~ sub
         
     | 
| 
       143 
     | 
    
         
            -
                  sub = $1
         
     | 
| 
       144 
     | 
    
         
            -
                  sub_decoration = LineThroughDecoration
         
     | 
| 
       145 
147 
     | 
    
         
             
                else
         
     | 
| 
       146 
148 
     | 
    
         
             
                  sub_decoration = NoDecoration
         
     | 
| 
       147 
149 
     | 
    
         
             
                end
         
     | 
| 
       148 
150 
     | 
    
         | 
| 
       149 
151 
     | 
    
         
             
                sub_font = @font
         
     | 
| 
       150 
     | 
    
         
            -
             
     | 
| 
       151 
152 
     | 
    
         
             
                if /\A\*\*\*(.+)\*\*\*\z/ =~ sub
         
     | 
| 
       152 
153 
     | 
    
         
             
                  sub = $1
         
     | 
| 
       153 
     | 
    
         
            -
                  if !@multibyte 
     | 
| 
      
 154 
     | 
    
         
            +
                  if !@multibyte
         
     | 
| 
       154 
155 
     | 
    
         
             
                    sub_font = @font_itbd
         
     | 
| 
       155 
156 
     | 
    
         
             
                  end
         
     | 
| 
       156 
157 
     | 
    
         
             
                elsif /\A\*\*(.+)\*\*\z/ =~ sub
         
     | 
| 
       157 
158 
     | 
    
         
             
                  sub = $1
         
     | 
| 
       158 
     | 
    
         
            -
                  if !@multibyte 
     | 
| 
      
 159 
     | 
    
         
            +
                  if !@multibyte
         
     | 
| 
       159 
160 
     | 
    
         
             
                    sub_font = @font_bd
         
     | 
| 
       160 
161 
     | 
    
         
             
                  end
         
     | 
| 
       161 
162 
     | 
    
         
             
                elsif /\A\*(.+)\*\z/ =~ sub
         
     | 
| 
       162 
163 
     | 
    
         
             
                  sub = $1
         
     | 
| 
       163 
     | 
    
         
            -
                  if !@multibyte 
     | 
| 
      
 164 
     | 
    
         
            +
                  if !@multibyte
         
     | 
| 
       164 
165 
     | 
    
         
             
                    sub_font = @font_it
         
     | 
| 
       165 
166 
     | 
    
         
             
                  end
         
     | 
| 
       166 
     | 
    
         
            -
                 
     | 
| 
       167 
     | 
    
         
            -
             
     | 
| 
      
 167 
     | 
    
         
            +
                end
         
     | 
| 
      
 168 
     | 
    
         
            +
             
     | 
| 
      
 169 
     | 
    
         
            +
                if /\A~(.+)~\z/ =~ sub
         
     | 
| 
      
 170 
     | 
    
         
            +
                  sub = $1
         
     | 
| 
      
 171 
     | 
    
         
            +
                  sub_font = @font_math
         
     | 
| 
       168 
172 
     | 
    
         
             
                end
         
     | 
| 
       169 
173 
     | 
    
         | 
| 
       170 
174 
     | 
    
         
             
                if sub != ""
         
     | 
| 
         @@ -182,7 +186,7 @@ class TreeGraph < Graph 
     | 
|
| 
       182 
186 
     | 
    
         
             
                if(type == ETYPE_LEAF)
         
     | 
| 
       183 
187 
     | 
    
         
             
                  col = @col_leaf
         
     | 
| 
       184 
188 
     | 
    
         
             
                else
         
     | 
| 
       185 
     | 
    
         
            -
                  col = @col_node 
     | 
| 
      
 189 
     | 
    
         
            +
                  col = @col_node
         
     | 
| 
       186 
190 
     | 
    
         
             
                end
         
     | 
| 
       187 
191 
     | 
    
         | 
| 
       188 
192 
     | 
    
         
             
                if(main[0].chr == "<" && main[-1].chr == ">")
         
     | 
| 
         @@ -252,7 +256,7 @@ class TreeGraph < Graph 
     | 
|
| 
       252 
256 
     | 
    
         | 
| 
       253 
257 
     | 
    
         
             
                @gc.fill("none")
         
     | 
| 
       254 
258 
     | 
    
         
             
                @gc.stroke @col_line
         
     | 
| 
       255 
     | 
    
         
            -
                @gc.stroke_width 1 
     | 
| 
      
 259 
     | 
    
         
            +
                @gc.stroke_width 1
         
     | 
| 
       256 
260 
     | 
    
         
             
                @gc.line(fromLeft1, fromTop, toLeft, toBot)
         
     | 
| 
       257 
261 
     | 
    
         
             
                @gc.line(fromLeft2, fromTop, toLeft, toBot)
         
     | 
| 
       258 
262 
     | 
    
         
             
                @gc.line(fromLeft1, fromTop, fromLeft2, fromTop)
         
     | 
| 
         @@ -267,9 +271,9 @@ class TreeGraph < Graph 
     | 
|
| 
       267 
271 
     | 
    
         
             
                children = @e_list.get_children(id)
         
     | 
| 
       268 
272 
     | 
    
         
             
                @e_list.set_element_width(id, target)
         
     | 
| 
       269 
273 
     | 
    
         | 
| 
       270 
     | 
    
         
            -
                if(children.length > 0 ) 
     | 
| 
      
 274 
     | 
    
         
            +
                if(children.length > 0 )
         
     | 
| 
       271 
275 
     | 
    
         
             
                  delta = target - current
         
     | 
| 
       272 
     | 
    
         
            -
                  target_delta = delta / children.length 
     | 
| 
      
 276 
     | 
    
         
            +
                  target_delta = delta / children.length
         
     | 
| 
       273 
277 
     | 
    
         | 
| 
       274 
278 
     | 
    
         
             
                  children.each do |child|
         
     | 
| 
       275 
279 
     | 
    
         
             
                    child_width = @e_list.get_element_width(child)
         
     | 
    
        data/lib/rsyntaxtree/utils.rb
    CHANGED
    
    | 
         @@ -10,7 +10,7 @@ 
     | 
|
| 
       10 
10 
     | 
    
         
             
            # This file is part of RSyntaxTree, which is a ruby port of Andre Eisenbach's
         
     | 
| 
       11 
11 
     | 
    
         
             
            # excellent program phpSyntaxTree.
         
     | 
| 
       12 
12 
     | 
    
         
             
            #
         
     | 
| 
       13 
     | 
    
         
            -
            # Copyright (c) 2007- 
     | 
| 
      
 13 
     | 
    
         
            +
            # Copyright (c) 2007-2021 Yoichiro Hasebe <yohasebe@gmail.com>
         
     | 
| 
       14 
14 
     | 
    
         
             
            # Copyright (c) 2003-2004 Andre Eisenbach <andre@ironcreek.net>
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
            class String
         
     | 
    
        data/lib/rsyntaxtree/version.rb
    CHANGED
    
    
    
        data/lib/rsyntaxtree.rb
    CHANGED
    
    | 
         @@ -15,7 +15,7 @@ 
     | 
|
| 
       15 
15 
     | 
    
         | 
| 
       16 
16 
     | 
    
         
             
            $LOAD_PATH << File.join( File.dirname(__FILE__), 'rsyntaxtree')
         
     | 
| 
       17 
17 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            require ' 
     | 
| 
      
 18 
     | 
    
         
            +
            require 'cgi'
         
     | 
| 
       19 
19 
     | 
    
         
             
            require 'utils'
         
     | 
| 
       20 
20 
     | 
    
         
             
            require 'element'
         
     | 
| 
       21 
21 
     | 
    
         
             
            require 'elementlist'
         
     | 
| 
         @@ -39,7 +39,7 @@ class RSGenerator 
     | 
|
| 
       39 
39 
     | 
    
         
             
                  key = keystr.to_sym
         
     | 
| 
       40 
40 
     | 
    
         
             
                  case key
         
     | 
| 
       41 
41 
     | 
    
         
             
                  when :data
         
     | 
| 
       42 
     | 
    
         
            -
                    data =  
     | 
| 
      
 42 
     | 
    
         
            +
                    data = CGI.unescape(value)
         
     | 
| 
       43 
43 
     | 
    
         
             
                    data  = data.gsub('-AMP-', '&')
         
     | 
| 
       44 
44 
     | 
    
         
             
                      .gsub('-PERCENT-', "%")
         
     | 
| 
       45 
45 
     | 
    
         
             
                      .gsub('-PRIME-', "'")
         
     | 
| 
         @@ -62,6 +62,7 @@ class RSGenerator 
     | 
|
| 
       62 
62 
     | 
    
         
             
                      new_params[:font_it] = FONT_DIR + "/NotoSans-Italic.ttf"
         
     | 
| 
       63 
63 
     | 
    
         
             
                      new_params[:font_bd] = FONT_DIR + "/NotoSans-Bold.ttf"
         
     | 
| 
       64 
64 
     | 
    
         
             
                      new_params[:font_bdit] = FONT_DIR + "/NotoSans-BoldItalic.ttf"
         
     | 
| 
      
 65 
     | 
    
         
            +
                      new_params[:font_math] = FONT_DIR + "/NotoSansMath-Regular.ttf"
         
     | 
| 
       65 
66 
     | 
    
         
             
                      new_params[:font_cjk] = FONT_DIR + "/NotoSansCJKjp-Regular.otf"
         
     | 
| 
       66 
67 
     | 
    
         
             
                      new_params[:fontstyle] = "sans"
         
     | 
| 
       67 
68 
     | 
    
         
             
                    elsif value == "noto-serif" || value == "serif"
         
     | 
| 
         @@ -69,6 +70,7 @@ class RSGenerator 
     | 
|
| 
       69 
70 
     | 
    
         
             
                      new_params[:font_it] = FONT_DIR + "/NotoSerif-Italic.ttf"
         
     | 
| 
       70 
71 
     | 
    
         
             
                      new_params[:font_bd] = FONT_DIR + "/NotoSerif-Bold.ttf"
         
     | 
| 
       71 
72 
     | 
    
         
             
                      new_params[:font_bdit] = FONT_DIR + "/NotoSerif-BoldItalic.ttf"
         
     | 
| 
      
 73 
     | 
    
         
            +
                      new_params[:font_math] = FONT_DIR + "/NotoSansMath-Regular.ttf"
         
     | 
| 
       72 
74 
     | 
    
         
             
                      new_params[:font_cjk] = FONT_DIR + "/NotoSerifCJKjp-Regular.otf"
         
     | 
| 
       73 
75 
     | 
    
         
             
                      new_params[:fontstyle] = "serif"
         
     | 
| 
       74 
76 
     | 
    
         
             
                    elsif value == "cjk zenhei" || value == "cjk"
         
     | 
| 
         @@ -76,14 +78,24 @@ class RSGenerator 
     | 
|
| 
       76 
78 
     | 
    
         
             
                      new_params[:font_it] = FONT_DIR + "/NotoSans-Italic.ttf"
         
     | 
| 
       77 
79 
     | 
    
         
             
                      new_params[:font_bd] = FONT_DIR + "/NotoSans-Bold.ttf"
         
     | 
| 
       78 
80 
     | 
    
         
             
                      new_params[:font_bdit] = FONT_DIR + "/NotoSans-BoldItalic.ttf"
         
     | 
| 
      
 81 
     | 
    
         
            +
                      new_params[:font_math] = FONT_DIR + "/NotoSansMath-Regular.ttf"
         
     | 
| 
       79 
82 
     | 
    
         
             
                      new_params[:font_cjk] = FONT_DIR + "/wqy-zenhei.ttf"
         
     | 
| 
       80 
83 
     | 
    
         
             
                      new_params[:fontstyle] = "sans"
         
     | 
| 
      
 84 
     | 
    
         
            +
                    elsif value == "modern-math" || value == "math"
         
     | 
| 
      
 85 
     | 
    
         
            +
                      new_params[:font] = FONT_DIR + "/latinmodern-math.otf" 
         
     | 
| 
      
 86 
     | 
    
         
            +
                      new_params[:font_it] = FONT_DIR + "/lmroman10-italic.otf" 
         
     | 
| 
      
 87 
     | 
    
         
            +
                      new_params[:font_bd] = FONT_DIR + "/lmroman10-bold.otf" 
         
     | 
| 
      
 88 
     | 
    
         
            +
                      new_params[:font_bdit] = FONT_DIR + "/lmroman10-bolditalic.otf" 
         
     | 
| 
      
 89 
     | 
    
         
            +
                      new_params[:font_math] = FONT_DIR + "/latinmodern-math.otf" 
         
     | 
| 
      
 90 
     | 
    
         
            +
                      new_params[:font_cjk] = FONT_DIR + "/NotoSerifCJKjp-Regular.otf"
         
     | 
| 
      
 91 
     | 
    
         
            +
                      new_params[:fontstyle] = "math"
         
     | 
| 
       81 
92 
     | 
    
         
             
                    end
         
     | 
| 
       82 
93 
     | 
    
         
             
                  else
         
     | 
| 
       83 
94 
     | 
    
         
             
                    new_params[key] = value
         
     | 
| 
       84 
95 
     | 
    
         
             
                  end
         
     | 
| 
       85 
96 
     | 
    
         
             
                end
         
     | 
| 
       86 
97 
     | 
    
         | 
| 
      
 98 
     | 
    
         
            +
                # defaults to the following
         
     | 
| 
       87 
99 
     | 
    
         
             
                @params = {
         
     | 
| 
       88 
100 
     | 
    
         
             
                  :symmetrize => true,
         
     | 
| 
       89 
101 
     | 
    
         
             
                  :color      => true,
         
     | 
| 
         @@ -100,6 +112,7 @@ class RSGenerator 
     | 
|
| 
       100 
112 
     | 
    
         
             
                  :font_it    => "/NotoSans-Italic.ttf",
         
     | 
| 
       101 
113 
     | 
    
         
             
                  :font_bd    => "/NotoSans-Bold.ttf",
         
     | 
| 
       102 
114 
     | 
    
         
             
                  :font_bdit  => "/NotoSans-BoldItalic.ttf",
         
     | 
| 
      
 115 
     | 
    
         
            +
                  :font_math  => "/NotoSansMath-Regular.ttf" 
         
     | 
| 
       103 
116 
     | 
    
         
             
                }
         
     | 
| 
       104 
117 
     | 
    
         
             
                @metrics = {
         
     | 
| 
       105 
118 
     | 
    
         
             
                  :e_width  => 120,
         
     | 
| 
         @@ -149,7 +162,7 @@ class RSGenerator 
     | 
|
| 
       149 
162 
     | 
    
         
             
                elist = sp.get_elementlist
         
     | 
| 
       150 
163 
     | 
    
         
             
                graph = SVGGraph.new(elist, @metrics,
         
     | 
| 
       151 
164 
     | 
    
         
             
                  @params[:symmetrize], @params[:color], @params[:leafstyle], @params[:multibyte], 
         
     | 
| 
       152 
     | 
    
         
            -
                  @params[:fontstyle], @params[:fontsize],
         
     | 
| 
      
 165 
     | 
    
         
            +
                  @params[:fontstyle], @params[:font], @params[:fontsize],
         
     | 
| 
       153 
166 
     | 
    
         
             
                )
         
     | 
| 
       154 
167 
     | 
    
         
             
                graph.svg_data
         
     | 
| 
       155 
168 
     | 
    
         
             
              end
         
     | 
| 
         @@ -161,7 +174,7 @@ class RSGenerator 
     | 
|
| 
       161 
174 
     | 
    
         
             
                elist = sp.get_elementlist
         
     | 
| 
       162 
175 
     | 
    
         
             
                graph = TreeGraph.new(elist, @metrics,
         
     | 
| 
       163 
176 
     | 
    
         
             
                  @params[:symmetrize], @params[:color], @params[:leafstyle], @params[:multibyte],
         
     | 
| 
       164 
     | 
    
         
            -
                  @params[:fontstyle], @params[:font], @params[:font_it], @params[:font_bd], @params[:font_bdit], 
         
     | 
| 
      
 177 
     | 
    
         
            +
                  @params[:fontstyle], @params[:font], @params[:font_it], @params[:font_bd], @params[:font_bdit], @params[:font_math],
         
     | 
| 
       165 
178 
     | 
    
         
             
                  @params[:font_cjk], @params[:fontsize], @params[:margin], 
         
     | 
| 
       166 
179 
     | 
    
         
             
                )
         
     | 
| 
       167 
180 
     | 
    
         
             
                graph.to_blob(@params[:format])
         
     | 
    
        data/rsyntaxtree.gemspec
    CHANGED
    
    | 
         @@ -12,14 +12,11 @@ Gem::Specification.new do |s| 
     | 
|
| 
       12 
12 
     | 
    
         
             
              s.summary     = %q{RSyntaxTree is a graphical syntax tree generator written in Ruby}
         
     | 
| 
       13 
13 
     | 
    
         
             
              s.description = %q{Yet another syntax tree generator made with Ruby and RMagick}
         
     | 
| 
       14 
14 
     | 
    
         
             
              s.licenses    = ["MIT"]
         
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
              s.rubyforge_project = "rsyntaxtree"
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
15 
     | 
    
         
             
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
       19 
16 
     | 
    
         
             
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         
     | 
| 
       20 
17 
     | 
    
         
             
              s.require_paths = ["lib"]
         
     | 
| 
       21 
18 
     | 
    
         | 
| 
       22 
19 
     | 
    
         
             
              # specify any dependencies here; for example:
         
     | 
| 
       23 
     | 
    
         
            -
              s.add_runtime_dependency 
     | 
| 
       24 
     | 
    
         
            -
              s.add_runtime_dependency 
     | 
| 
      
 20 
     | 
    
         
            +
              s.add_runtime_dependency 'rmagick', '~> 4.2', '>= 4.2.3'
         
     | 
| 
      
 21 
     | 
    
         
            +
              s.add_runtime_dependency 'optimist', '~> 3.0', '>= 3.0.1'
         
     | 
| 
       25 
22 
     | 
    
         
             
            end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,43 +1,55 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: rsyntaxtree
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.8.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Yoichiro Hasebe
         
     | 
| 
       8 
     | 
    
         
            -
            autorequire: 
     | 
| 
      
 8 
     | 
    
         
            +
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date:  
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2021-11-29 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rmagick
         
     | 
| 
       15 
15 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       16 
16 
     | 
    
         
             
                requirements:
         
     | 
| 
      
 17 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 18 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 19 
     | 
    
         
            +
                    version: '4.2'
         
     | 
| 
       17 
20 
     | 
    
         
             
                - - ">="
         
     | 
| 
       18 
21 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       19 
     | 
    
         
            -
                    version: 2. 
     | 
| 
      
 22 
     | 
    
         
            +
                    version: 4.2.3
         
     | 
| 
       20 
23 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       21 
24 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       22 
25 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       23 
26 
     | 
    
         
             
                requirements:
         
     | 
| 
      
 27 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 28 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 29 
     | 
    
         
            +
                    version: '4.2'
         
     | 
| 
       24 
30 
     | 
    
         
             
                - - ">="
         
     | 
| 
       25 
31 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       26 
     | 
    
         
            -
                    version: 2. 
     | 
| 
      
 32 
     | 
    
         
            +
                    version: 4.2.3
         
     | 
| 
       27 
33 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       28 
     | 
    
         
            -
              name:  
     | 
| 
      
 34 
     | 
    
         
            +
              name: optimist
         
     | 
| 
       29 
35 
     | 
    
         
             
              requirement: !ruby/object:Gem::Requirement
         
     | 
| 
       30 
36 
     | 
    
         
             
                requirements:
         
     | 
| 
      
 37 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 38 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 39 
     | 
    
         
            +
                    version: '3.0'
         
     | 
| 
       31 
40 
     | 
    
         
             
                - - ">="
         
     | 
| 
       32 
41 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       33 
     | 
    
         
            -
                    version:  
     | 
| 
      
 42 
     | 
    
         
            +
                    version: 3.0.1
         
     | 
| 
       34 
43 
     | 
    
         
             
              type: :runtime
         
     | 
| 
       35 
44 
     | 
    
         
             
              prerelease: false
         
     | 
| 
       36 
45 
     | 
    
         
             
              version_requirements: !ruby/object:Gem::Requirement
         
     | 
| 
       37 
46 
     | 
    
         
             
                requirements:
         
     | 
| 
      
 47 
     | 
    
         
            +
                - - "~>"
         
     | 
| 
      
 48 
     | 
    
         
            +
                  - !ruby/object:Gem::Version
         
     | 
| 
      
 49 
     | 
    
         
            +
                    version: '3.0'
         
     | 
| 
       38 
50 
     | 
    
         
             
                - - ">="
         
     | 
| 
       39 
51 
     | 
    
         
             
                  - !ruby/object:Gem::Version
         
     | 
| 
       40 
     | 
    
         
            -
                    version:  
     | 
| 
      
 52 
     | 
    
         
            +
                    version: 3.0.1
         
     | 
| 
       41 
53 
     | 
    
         
             
            description: Yet another syntax tree generator made with Ruby and RMagick
         
     | 
| 
       42 
54 
     | 
    
         
             
            email:
         
     | 
| 
       43 
55 
     | 
    
         
             
            - yohasebe@gmail.com
         
     | 
| 
         @@ -56,11 +68,17 @@ files: 
     | 
|
| 
       56 
68 
     | 
    
         
             
            - fonts/NotoSans-Italic.ttf
         
     | 
| 
       57 
69 
     | 
    
         
             
            - fonts/NotoSans-Regular.ttf
         
     | 
| 
       58 
70 
     | 
    
         
             
            - fonts/NotoSansCJKjp-Regular.otf
         
     | 
| 
      
 71 
     | 
    
         
            +
            - fonts/NotoSansMath-Regular.ttf
         
     | 
| 
       59 
72 
     | 
    
         
             
            - fonts/NotoSerif-Bold.ttf
         
     | 
| 
       60 
73 
     | 
    
         
             
            - fonts/NotoSerif-BoldItalic.ttf
         
     | 
| 
       61 
74 
     | 
    
         
             
            - fonts/NotoSerif-Italic.ttf
         
     | 
| 
       62 
75 
     | 
    
         
             
            - fonts/NotoSerif-Regular.ttf
         
     | 
| 
       63 
76 
     | 
    
         
             
            - fonts/NotoSerifCJKjp-Regular.otf
         
     | 
| 
      
 77 
     | 
    
         
            +
            - fonts/latinmodern-math.otf
         
     | 
| 
      
 78 
     | 
    
         
            +
            - fonts/lmroman10-bold.otf
         
     | 
| 
      
 79 
     | 
    
         
            +
            - fonts/lmroman10-bolditalic.otf
         
     | 
| 
      
 80 
     | 
    
         
            +
            - fonts/lmroman10-italic.otf
         
     | 
| 
      
 81 
     | 
    
         
            +
            - fonts/lmroman10-regular.otf
         
     | 
| 
       64 
82 
     | 
    
         
             
            - fonts/wqy-zenhei.ttf
         
     | 
| 
       65 
83 
     | 
    
         
             
            - lib/rsyntaxtree.rb
         
     | 
| 
       66 
84 
     | 
    
         
             
            - lib/rsyntaxtree/element.rb
         
     | 
| 
         @@ -77,7 +95,7 @@ homepage: http://github.com/yohasebe/rsyntaxtree 
     | 
|
| 
       77 
95 
     | 
    
         
             
            licenses:
         
     | 
| 
       78 
96 
     | 
    
         
             
            - MIT
         
     | 
| 
       79 
97 
     | 
    
         
             
            metadata: {}
         
     | 
| 
       80 
     | 
    
         
            -
            post_install_message: 
     | 
| 
      
 98 
     | 
    
         
            +
            post_install_message:
         
     | 
| 
       81 
99 
     | 
    
         
             
            rdoc_options: []
         
     | 
| 
       82 
100 
     | 
    
         
             
            require_paths:
         
     | 
| 
       83 
101 
     | 
    
         
             
            - lib
         
     | 
| 
         @@ -92,9 +110,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       92 
110 
     | 
    
         
             
                - !ruby/object:Gem::Version
         
     | 
| 
       93 
111 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       94 
112 
     | 
    
         
             
            requirements: []
         
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
            signing_key: 
         
     | 
| 
      
 113 
     | 
    
         
            +
            rubygems_version: 3.2.11
         
     | 
| 
      
 114 
     | 
    
         
            +
            signing_key:
         
     | 
| 
       98 
115 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       99 
116 
     | 
    
         
             
            summary: RSyntaxTree is a graphical syntax tree generator written in Ruby
         
     | 
| 
       100 
117 
     | 
    
         
             
            test_files: []
         
     |