rsyntaxtree 1.2.8 → 1.2.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. checksums.yaml +4 -4
  2. data/.tags +1 -0
  3. data/bin/rsyntaxtree +3 -1
  4. data/docs/assets/img/000.png +0 -0
  5. data/docs/assets/img/001.png +0 -0
  6. data/docs/assets/img/002.png +0 -0
  7. data/docs/assets/img/003.png +0 -0
  8. data/docs/assets/img/004.png +0 -0
  9. data/docs/assets/img/005.png +0 -0
  10. data/docs/assets/img/006.png +0 -0
  11. data/docs/assets/img/007.png +0 -0
  12. data/docs/assets/img/008.png +0 -0
  13. data/docs/assets/img/009.png +0 -0
  14. data/docs/assets/img/010.png +0 -0
  15. data/docs/assets/img/011.png +0 -0
  16. data/docs/assets/img/012.png +0 -0
  17. data/docs/assets/img/013.png +0 -0
  18. data/docs/assets/img/014.png +0 -0
  19. data/docs/assets/img/015.png +0 -0
  20. data/docs/assets/img/016.png +0 -0
  21. data/docs/assets/img/017.png +0 -0
  22. data/docs/assets/img/018.png +0 -0
  23. data/docs/assets/img/019.png +0 -0
  24. data/docs/assets/img/020.png +0 -0
  25. data/docs/assets/img/021.png +0 -0
  26. data/docs/assets/img/022.png +0 -0
  27. data/docs/assets/img/023.png +0 -0
  28. data/docs/assets/img/024.png +0 -0
  29. data/docs/assets/img/025.png +0 -0
  30. data/docs/assets/img/026.png +0 -0
  31. data/docs/assets/img/027.png +0 -0
  32. data/docs/assets/img/028.png +0 -0
  33. data/docs/assets/img/029.png +0 -0
  34. data/docs/assets/img/030.png +0 -0
  35. data/docs/assets/img/031.png +0 -0
  36. data/docs/assets/img/032.png +0 -0
  37. data/docs/assets/img/033.png +0 -0
  38. data/docs/assets/img/034.png +0 -0
  39. data/docs/assets/img/035.png +0 -0
  40. data/docs/assets/img/036.png +0 -0
  41. data/docs/assets/img/037.png +0 -0
  42. data/docs/assets/img/038.png +0 -0
  43. data/docs/assets/img/039.png +0 -0
  44. data/docs/assets/img/040.png +0 -0
  45. data/docs/assets/img/041.png +0 -0
  46. data/docs/assets/img/042.png +0 -0
  47. data/docs/assets/img/043.png +0 -0
  48. data/docs/assets/img/044.png +0 -0
  49. data/docs/assets/img/045.png +0 -0
  50. data/docs/assets/img/046.png +0 -0
  51. data/docs/assets/img/047.png +0 -0
  52. data/docs/assets/svg/000.svg +35 -35
  53. data/docs/assets/svg/001.svg +19 -19
  54. data/docs/assets/svg/002.svg +37 -37
  55. data/docs/assets/svg/003.svg +29 -29
  56. data/docs/assets/svg/004.svg +41 -41
  57. data/docs/assets/svg/005.svg +21 -21
  58. data/docs/assets/svg/006.svg +25 -25
  59. data/docs/assets/svg/007.svg +31 -31
  60. data/docs/assets/svg/008.svg +35 -35
  61. data/docs/assets/svg/009.svg +35 -35
  62. data/docs/assets/svg/010.svg +52 -52
  63. data/docs/assets/svg/011.svg +30 -30
  64. data/docs/assets/svg/012.svg +35 -35
  65. data/docs/assets/svg/013.svg +116 -116
  66. data/docs/assets/svg/014.svg +96 -96
  67. data/docs/assets/svg/015.svg +33 -33
  68. data/docs/assets/svg/016.svg +397 -397
  69. data/docs/assets/svg/017.svg +35 -35
  70. data/docs/assets/svg/018.svg +37 -37
  71. data/docs/assets/svg/019.svg +95 -95
  72. data/docs/assets/svg/020.svg +62 -62
  73. data/docs/assets/svg/021.svg +42 -42
  74. data/docs/assets/svg/022.svg +75 -75
  75. data/docs/assets/svg/023.svg +51 -51
  76. data/docs/assets/svg/024.svg +23 -23
  77. data/docs/assets/svg/025.svg +99 -99
  78. data/docs/assets/svg/026.svg +19 -19
  79. data/docs/assets/svg/027.svg +50 -50
  80. data/docs/assets/svg/028.svg +21 -21
  81. data/docs/assets/svg/029.svg +69 -69
  82. data/docs/assets/svg/030.svg +35 -35
  83. data/docs/assets/svg/031.svg +15 -15
  84. data/docs/assets/svg/032.svg +41 -41
  85. data/docs/assets/svg/033.svg +39 -39
  86. data/docs/assets/svg/034.svg +40 -40
  87. data/docs/assets/svg/035.svg +39 -39
  88. data/docs/assets/svg/036.svg +17 -17
  89. data/docs/assets/svg/037.svg +29 -29
  90. data/docs/assets/svg/038.svg +39 -39
  91. data/docs/assets/svg/039.svg +7 -7
  92. data/docs/assets/svg/040.svg +67 -67
  93. data/docs/assets/svg/041.svg +49 -49
  94. data/docs/assets/svg/042.svg +15 -15
  95. data/docs/assets/svg/043.svg +150 -150
  96. data/docs/assets/svg/044.svg +8 -8
  97. data/docs/assets/svg/045.svg +56 -56
  98. data/docs/assets/svg/046.svg +647 -647
  99. data/docs/assets/svg/047.svg +26 -31
  100. data/lib/rsyntaxtree/base_graph.rb +2 -1
  101. data/lib/rsyntaxtree/svg_graph.rb +3 -4
  102. data/lib/rsyntaxtree/version.rb +1 -1
  103. data/lib/rsyntaxtree.rb +10 -3
  104. metadata +1 -1
@@ -1,17 +1,17 @@
1
1
  <?xml version="1.0" standalone="no"?>
2
2
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
3
- <svg width="138.4" height="708.4" viewBox="0, 0, 155.20000000000002, 730.4" version="1.1" xmlns="http://www.w3.org/2000/svg">
3
+ <svg width="95.4" height="317.25" viewBox="-16.8, 0, 112.2, 328.5" version="1.1" xmlns="http://www.w3.org/2000/svg">
4
4
  <defs>
5
- <marker id="arrow" markerUnits="userSpaceOnUse" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="33.6" markerHeight="33.6" orient="auto">
5
+ <marker id="arrow" markerUnits="userSpaceOnUse" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="16.8" markerHeight="16.8" orient="auto">
6
6
  <path d="M 0 0 L 10 5 L 0 10" fill="black"/>
7
7
  </marker>
8
- <marker id="arrowBackward" markerUnits="userSpaceOnUse" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="33.6" markerHeight="33.6" orient="auto">
8
+ <marker id="arrowBackward" markerUnits="userSpaceOnUse" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="16.8" markerHeight="16.8" orient="auto">
9
9
  <path d="M 0 0 L 10 5 L 0 10 z" fill="black"/>
10
10
  </marker>
11
- <marker id="arrowForward" markerUnits="userSpaceOnUse" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="33.6" markerHeight="33.6" orient="auto">
11
+ <marker id="arrowForward" markerUnits="userSpaceOnUse" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="16.8" markerHeight="16.8" orient="auto">
12
12
  <path d="M 10 0 L 0 5 L 10 10 z" fill="black"/>
13
13
  </marker>
14
- <marker id="arrowBothways" markerUnits="userSpaceOnUse" viewBox="0 0 30 10" refX="15" refY="5" markerWidth="100.80000000000001" markerHeight="33.6" orient="auto">
14
+ <marker id="arrowBothways" markerUnits="userSpaceOnUse" viewBox="0 0 30 10" refX="15" refY="5" markerWidth="50.400000000000006" markerHeight="16.8" orient="auto">
15
15
  <path d="M 0 5 L 10 0 L 10 5 L 20 5 L 20 0 L 30 5 L 20 10 L 20 5 L 10 5 L 10 10 z" fill="black"/>
16
16
  </marker>
17
17
  <pattern id="hatchBlack" x="10" y="10" width="10" height="10" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
@@ -24,44 +24,39 @@
24
24
  <line x1="0" y="0" x2="0" y2="10" stroke="black" stroke-width="4"></line>
25
25
  </pattern>
26
26
  </defs>
27
- <rect x="0" y="0" width="155.20000000000002" height="730.4" stroke="none" fill="white" />"
28
- <text white-space='pre' alignment-baseline='text-top' style='fill: black; storoke-width: 0; font-size: 64px;' x='33.599999999999994' y='132.0'><tspan x='58.599999999999994' y='132.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
29
- <tspan x='58.599999999999994' y='220.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
30
- <tspan x='58.599999999999994' y='308.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
31
- <tspan x='58.599999999999994' y='396.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
32
- <tspan x='58.599999999999994' y='484.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
33
- <tspan x='58.599999999999994' y='572.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
34
- <tspan x='58.599999999999994' y='660.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
27
+ <rect x="-16.8" y="0" width="112.2" height="328.5" stroke="none" fill="white" />"
28
+ <text white-space='pre' alignment-baseline='text-top' style='fill: black; storoke-width: 0; font-size: 32px;' x='16.799999999999997' y='67.5'><tspan x='29.799999999999997' y='67.5' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
29
+ <tspan x='29.799999999999997' y='112.5' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
30
+ <tspan x='29.799999999999997' y='157.5' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
31
+ <tspan x='29.799999999999997' y='202.5' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
32
+ <tspan x='29.799999999999997' y='247.5' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
33
+ <tspan x='29.799999999999997' y='292.5' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif"> </tspan>
35
34
  </text>
36
- <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:2;' x1='34.599999999999994' y1='105.6' x2='120.6' y2='105.6'></line>
35
+ <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:2;' x1='17.799999999999997' y1='54.0' x2='60.8' y2='54.0'></line>
37
36
 
38
- <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='2' points='99.6,94.6 120.6,105.6 99.6,116.6' />
37
+ <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='2' points='50.55,48.375 60.8,54.0 50.55,59.625' />
39
38
 
40
- <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:3;' x1='34.599999999999994' y1='193.6' x2='120.6' y2='193.6'></line>
39
+ <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:3;' x1='17.799999999999997' y1='99.0' x2='60.8' y2='99.0'></line>
41
40
 
42
- <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='3' points='99.6,182.6 120.6,193.6 99.6,204.6' />
41
+ <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='3' points='50.55,93.375 60.8,99.0 50.55,104.625' />
43
42
 
44
- <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:2;' x1='34.599999999999994' y1='281.6' x2='120.6' y2='281.6'></line>
43
+ <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:2;' x1='17.799999999999997' y1='144.0' x2='60.8' y2='144.0'></line>
45
44
 
46
- <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='2' points='55.599999999999994,292.6 34.599999999999994,281.6 55.599999999999994,270.6' />
45
+ <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='2' points='28.049999999999997,149.625 17.799999999999997,144.0 28.049999999999997,138.375' />
47
46
 
48
- <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:3;' x1='34.599999999999994' y1='369.6' x2='120.6' y2='369.6'></line>
47
+ <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:3;' x1='17.799999999999997' y1='189.0' x2='60.8' y2='189.0'></line>
49
48
 
50
- <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='3' points='55.599999999999994,380.6 34.599999999999994,369.6 55.599999999999994,358.6' />
49
+ <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='3' points='28.049999999999997,194.625 17.799999999999997,189.0 28.049999999999997,183.375' />
51
50
 
52
- <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:2;' x1='34.599999999999994' y1='457.6' x2='120.6' y2='457.6'></line>
51
+ <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:2;' x1='17.799999999999997' y1='234.0' x2='60.8' y2='234.0'></line>
53
52
 
54
- <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='2' points='55.599999999999994,468.6 34.599999999999994,457.6 55.599999999999994,446.6' />
53
+ <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='2' points='28.049999999999997,239.625 17.799999999999997,234.0 28.049999999999997,228.375' />
55
54
 
56
- <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='2' points='99.6,446.6 120.6,457.6 99.6,468.6' />
55
+ <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='2' points='50.55,228.375 60.8,234.0 50.55,239.625' />
57
56
 
58
- <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:3;' x1='34.599999999999994' y1='545.6' x2='120.6' y2='545.6'></line>
57
+ <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:3;' x1='17.799999999999997' y1='279.0' x2='60.8' y2='279.0'></line>
59
58
 
60
- <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='3' points='55.599999999999994,556.6 34.599999999999994,545.6 55.599999999999994,534.6' />
59
+ <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='3' points='28.049999999999997,284.625 17.799999999999997,279.0 28.049999999999997,273.375' />
61
60
 
62
- <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='3' points='99.6,534.6 120.6,545.6 99.6,556.6' />
63
-
64
- <line style='fill:none; stroke:black; stroke-linejoin:round; stroke-linecap:round; stroke-width:2;' x1='34.599999999999994' y1='633.6' x2='120.6' y2='633.6'></line>
65
-
66
- <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='2' points='55.599999999999994,644.6 34.599999999999994,633.6 55.599999999999994,622.6' />
61
+ <polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='black' stroke-width='3' points='50.55,273.375 60.8,279.0 50.55,284.625' />
67
62
  </svg>
@@ -57,7 +57,8 @@ module RSyntaxTree
57
57
 
58
58
  def calculate_level
59
59
  @element_list.get_elements.select { |e| e.type == 2 }.each do |e|
60
- e.level = @element_list.get_id(e.parent).level + 1
60
+ parent = @element_list.get_id(e.parent)
61
+ e.level = @element_list.get_id(e.parent).level + 1 if parent
61
62
  end
62
63
  end
63
64
 
@@ -41,12 +41,12 @@ module RSyntaxTree
41
41
  def svg_data
42
42
  metrics = parse_list
43
43
 
44
+ @width = metrics[:width] + @global[:h_gap_between_nodes] * 2
44
45
  @height = metrics[:height] + @global[:height_connector_to_text] / 2
45
- @width = metrics[:width] + @global[:h_gap_between_nodes] / 2
46
46
 
47
- x1 = 0
47
+ x1 = 0 - @global[:h_gap_between_nodes]
48
48
  y1 = 0
49
- x2 = @width + @global[:h_gap_between_nodes] / 2
49
+ x2 = @width + @global[:h_gap_between_nodes]
50
50
  y2 = @height + @global[:height_connector_to_text] / 2
51
51
 
52
52
  extra_lines = @extra_lines.join("\n")
@@ -247,7 +247,6 @@ module RSyntaxTree
247
247
 
248
248
  if e[:decoration].include?(:box) || e[:decoration].include?(:circle) || e[:decoration].include?(:bar)
249
249
  enc_height = e[:height]
250
- # enc_y = this_y - e[:height] * 0.8 + FONT_SCALING
251
250
  enc_y = this_y - e[:height] * 0.8
252
251
  enc_width = e[:width]
253
252
  enc_x = this_x
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSyntaxTree
4
- VERSION = "1.2.8"
4
+ VERSION = "1.2.9"
5
5
  end
data/lib/rsyntaxtree.rb CHANGED
@@ -80,7 +80,7 @@ module RSyntaxTree
80
80
  "off"
81
81
  end
82
82
  when :fontsize
83
- new_params[key] = value.to_i * FONT_SCALING
83
+ new_params[key] = value.to_i
84
84
  when :linewidth
85
85
  new_params[key] = value.to_i
86
86
  when :vheight
@@ -169,13 +169,20 @@ module RSyntaxTree
169
169
  raise RSTError, +"Error: the result syntree is too big"
170
170
  end
171
171
 
172
- def draw_pdf(filename)
172
+ def draw_pdf(binary = false)
173
+ b = StringIO.new
173
174
  svg = draw_svg
174
175
  rsvg = RSVG::Handle.new_from_data(svg)
175
176
  dim = rsvg.dimensions
176
- surface = Cairo::PDFSurface.new(filename, dim.width, dim.height)
177
+ surface = Cairo::PDFSurface.new(b, dim.width, dim.height)
177
178
  context = Cairo::Context.new(surface)
178
179
  context.render_rsvg_handle(rsvg)
180
+ surface.finish
181
+ if binary
182
+ b
183
+ else
184
+ b.string
185
+ end
179
186
  rescue Cairo::InvalidSize
180
187
  raise RSTError, +"Error: the result syntree is too big"
181
188
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsyntaxtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.8
4
+ version: 1.2.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichiro Hasebe