rsyntaxtree 1.2.4 → 1.2.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +4 -4
  2. data/.tags +462 -458
  3. data/Dockerfile +19 -0
  4. data/Gemfile +0 -3
  5. data/README.md +16 -14
  6. data/Rakefile +12 -78
  7. data/bin/rsyntaxtree +1 -1
  8. data/dev/generate_examples.rb +107 -0
  9. data/docs/.gitignore +0 -0
  10. data/docs/404.html +0 -0
  11. data/docs/Gemfile +0 -0
  12. data/docs/_config.yml +0 -0
  13. data/docs/_examples/000.md +1 -0
  14. data/docs/_examples/001.md +1 -0
  15. data/docs/_examples/002.md +1 -0
  16. data/docs/_examples/003.md +1 -0
  17. data/docs/_examples/004.md +1 -0
  18. data/docs/_examples/005.md +1 -0
  19. data/docs/_examples/006.md +1 -0
  20. data/docs/_examples/007.md +1 -0
  21. data/docs/_examples/008.md +1 -0
  22. data/docs/_examples/009.md +1 -0
  23. data/docs/_examples/010.md +1 -0
  24. data/docs/_examples/011.md +1 -0
  25. data/docs/_examples/012.md +1 -0
  26. data/docs/_examples/013.md +1 -0
  27. data/docs/_examples/014.md +1 -0
  28. data/docs/_examples/015.md +1 -0
  29. data/docs/_examples/016.md +1 -0
  30. data/docs/_examples/017.md +1 -0
  31. data/docs/_examples/018.md +1 -0
  32. data/docs/_examples/019.md +1 -0
  33. data/docs/_examples/020.md +1 -0
  34. data/docs/_examples/021.md +1 -0
  35. data/docs/_examples/022.md +1 -0
  36. data/docs/_examples/023.md +1 -0
  37. data/docs/_examples/024.md +1 -0
  38. data/docs/_examples/025.md +1 -0
  39. data/docs/_examples/026.md +1 -0
  40. data/docs/_examples/027.md +1 -0
  41. data/docs/_examples/028.md +1 -0
  42. data/docs/_examples/029.md +1 -0
  43. data/docs/_examples/030.md +1 -0
  44. data/docs/_examples/031.md +1 -0
  45. data/docs/_examples/032.md +1 -0
  46. data/docs/_examples/033.md +1 -0
  47. data/docs/_examples/034.md +1 -0
  48. data/docs/_examples/035.md +1 -0
  49. data/docs/_examples/036.md +1 -0
  50. data/docs/_examples/037.md +8 -6
  51. data/docs/_examples/038.md +1 -0
  52. data/docs/_examples/039.md +1 -0
  53. data/docs/_examples/040.md +1 -0
  54. data/docs/_examples/041.md +1 -0
  55. data/docs/_examples/042.md +22 -0
  56. data/docs/_examples/043.md +40 -0
  57. data/docs/_examples/044.md +16 -0
  58. data/docs/_examples/045.md +48 -0
  59. data/docs/_examples/046.md +440 -0
  60. data/docs/_includes/box_and_circle_table.html +0 -0
  61. data/docs/_includes/escape_char_table.html +0 -0
  62. data/docs/_includes/social_media_links.html +0 -0
  63. data/docs/_layouts/default.html +0 -0
  64. data/docs/assets/css/style.scss +0 -0
  65. data/docs/assets/img/000.png +0 -0
  66. data/docs/assets/img/001.png +0 -0
  67. data/docs/assets/img/002.png +0 -0
  68. data/docs/assets/img/003.png +0 -0
  69. data/docs/assets/img/004.png +0 -0
  70. data/docs/assets/img/005.png +0 -0
  71. data/docs/assets/img/006.png +0 -0
  72. data/docs/assets/img/007.png +0 -0
  73. data/docs/assets/img/008.png +0 -0
  74. data/docs/assets/img/009.png +0 -0
  75. data/docs/assets/img/010.png +0 -0
  76. data/docs/assets/img/011.png +0 -0
  77. data/docs/assets/img/012.png +0 -0
  78. data/docs/assets/img/013.png +0 -0
  79. data/docs/assets/img/014.png +0 -0
  80. data/docs/assets/img/015.png +0 -0
  81. data/docs/assets/img/016.png +0 -0
  82. data/docs/assets/img/017.png +0 -0
  83. data/docs/assets/img/018.png +0 -0
  84. data/docs/assets/img/019.png +0 -0
  85. data/docs/assets/img/020.png +0 -0
  86. data/docs/assets/img/021.png +0 -0
  87. data/docs/assets/img/022.png +0 -0
  88. data/docs/assets/img/023.png +0 -0
  89. data/docs/assets/img/024.png +0 -0
  90. data/docs/assets/img/025.png +0 -0
  91. data/docs/assets/img/026.png +0 -0
  92. data/docs/assets/img/027.png +0 -0
  93. data/docs/assets/img/028.png +0 -0
  94. data/docs/assets/img/029.png +0 -0
  95. data/docs/assets/img/030.png +0 -0
  96. data/docs/assets/img/031.png +0 -0
  97. data/docs/assets/img/032.png +0 -0
  98. data/docs/assets/img/033.png +0 -0
  99. data/docs/assets/img/034.png +0 -0
  100. data/docs/assets/img/035.png +0 -0
  101. data/docs/assets/img/036.png +0 -0
  102. data/docs/assets/img/037.png +0 -0
  103. data/docs/assets/img/038.png +0 -0
  104. data/docs/assets/img/039.png +0 -0
  105. data/docs/assets/img/040.png +0 -0
  106. data/docs/assets/img/041.png +0 -0
  107. data/docs/assets/img/042.png +0 -0
  108. data/docs/assets/img/043.png +0 -0
  109. data/docs/assets/img/044.png +0 -0
  110. data/docs/assets/img/045.png +0 -0
  111. data/docs/assets/img/046.png +0 -0
  112. data/docs/assets/img/elements/circle.png +0 -0
  113. data/docs/assets/img/elements/circle_abc.png +0 -0
  114. data/docs/assets/img/elements/circle_bold.png +0 -0
  115. data/docs/assets/img/elements/circle_hatched.png +0 -0
  116. data/docs/assets/img/elements/circle_one.png +0 -0
  117. data/docs/assets/img/elements/connector.png +0 -0
  118. data/docs/assets/img/elements/connector_bold.png +0 -0
  119. data/docs/assets/img/elements/square.png +0 -0
  120. data/docs/assets/img/elements/square_abc.png +0 -0
  121. data/docs/assets/img/elements/square_bold.png +0 -0
  122. data/docs/assets/img/elements/square_hatched.png +0 -0
  123. data/docs/assets/img/elements/square_one.png +0 -0
  124. data/docs/assets/img/favicon/apple-touch-icon.png +0 -0
  125. data/docs/assets/img/favicon/favicon-16x16.png +0 -0
  126. data/docs/assets/img/favicon/favicon-32x32.png +0 -0
  127. data/docs/assets/img/favicon/favicon.ico +0 -0
  128. data/docs/assets/svg/000.svg +32 -32
  129. data/docs/assets/svg/001.svg +14 -14
  130. data/docs/assets/svg/002.svg +32 -32
  131. data/docs/assets/svg/003.svg +24 -24
  132. data/docs/assets/svg/004.svg +35 -35
  133. data/docs/assets/svg/005.svg +15 -15
  134. data/docs/assets/svg/006.svg +20 -20
  135. data/docs/assets/svg/007.svg +26 -26
  136. data/docs/assets/svg/008.svg +30 -30
  137. data/docs/assets/svg/009.svg +29 -29
  138. data/docs/assets/svg/010.svg +47 -47
  139. data/docs/assets/svg/011.svg +24 -24
  140. data/docs/assets/svg/012.svg +29 -29
  141. data/docs/assets/svg/013.svg +119 -119
  142. data/docs/assets/svg/014.svg +83 -83
  143. data/docs/assets/svg/015.svg +28 -28
  144. data/docs/assets/svg/016.svg +375 -375
  145. data/docs/assets/svg/017.svg +44 -44
  146. data/docs/assets/svg/018.svg +32 -32
  147. data/docs/assets/svg/019.svg +168 -168
  148. data/docs/assets/svg/020.svg +57 -57
  149. data/docs/assets/svg/021.svg +52 -52
  150. data/docs/assets/svg/022.svg +90 -90
  151. data/docs/assets/svg/023.svg +51 -51
  152. data/docs/assets/svg/024.svg +18 -18
  153. data/docs/assets/svg/025.svg +116 -116
  154. data/docs/assets/svg/026.svg +18 -18
  155. data/docs/assets/svg/027.svg +58 -58
  156. data/docs/assets/svg/028.svg +16 -16
  157. data/docs/assets/svg/029.svg +72 -72
  158. data/docs/assets/svg/030.svg +35 -35
  159. data/docs/assets/svg/031.svg +10 -10
  160. data/docs/assets/svg/032.svg +45 -45
  161. data/docs/assets/svg/033.svg +35 -35
  162. data/docs/assets/svg/034.svg +43 -43
  163. data/docs/assets/svg/035.svg +37 -37
  164. data/docs/assets/svg/036.svg +14 -14
  165. data/docs/assets/svg/037.svg +26 -45
  166. data/docs/assets/svg/038.svg +39 -39
  167. data/docs/assets/svg/039.svg +2 -2
  168. data/docs/assets/svg/040.svg +89 -89
  169. data/docs/assets/svg/041.svg +49 -49
  170. data/docs/assets/svg/042.svg +42 -0
  171. data/docs/assets/svg/043.svg +304 -0
  172. data/docs/assets/svg/044.svg +32 -0
  173. data/docs/assets/svg/045.svg +107 -0
  174. data/docs/assets/svg/046.svg +990 -0
  175. data/docs/documentation.md +2 -3
  176. data/docs/documentation_ja.md +4 -4
  177. data/docs/examples.html +2 -2
  178. data/docs/index.html +0 -0
  179. data/fonts/OpenMoji-black-glyf.ttf +0 -0
  180. data/lib/rsyntaxtree/element.rb +3 -9
  181. data/lib/rsyntaxtree/string_parser.rb +4 -4
  182. data/lib/rsyntaxtree/svg_graph.rb +26 -25
  183. data/lib/rsyntaxtree/version.rb +1 -1
  184. data/lib/rsyntaxtree.rb +8 -6
  185. data/test/example_verify_test.rb +2 -0
  186. metadata +21 -5
  187. data/fonts/OpenMoji-Black.ttf +0 -0
  188. data/fonts/OpenMoji-Color.ttf +0 -0
@@ -137,8 +137,7 @@ You can draw any number of paths of three different types:
137
137
  - Directional (rendered as solid line `----▶`)
138
138
  - Bidirectional (rendered as solid line `◀----▶`)
139
139
 
140
- Each path is distinguished by a unique ID number. The ID is specified by putting a plus sign and a number (e.g. `+7`) at the end of the node text. If a greater-than or less-than sign is placed between the plus sign and the number (e.g. `+>7` or `+<7`), an arrowhead will appear at the end of the path. Note that it makes no difference whether `+>` or `+<` is used. The arrow is always directed to the element with one of these ID symbols.
141
-
140
+ Each path is distinguished by a unique ID number. The ID is specified by putting a plus sign and a number (e.g. `+7`) at the end of the node text. If a greater-than `>` or less-than `<` symbol is placed between the plus sign and the number (e.g. `+>7` or `+<7`), an arrowhead will appear at the end of the path. Note that it makes no difference whether `+>` or `+<` is used. The arrow is always directed to the element with one of these ID symbols.
142
141
 
143
142
  A node can have any number of IDs. The same ID must appear in the text of the *two* nodes between which the path is rendered. The same ID number cannot appear in more than two places.
144
143
 
@@ -150,7 +149,7 @@ You can also add extra connector between nodes in the same fasion as you draw pa
150
149
  - Directional (rendered as solid line `--▶--`)
151
150
  - Bidirectional (rendered as solid line `-◀-▶-`)
152
151
 
153
- Each additional connectors is distinguished by an ID number. The ID is specified by putting a a number after a sequence of a plus and a minus symbols (e.g. `+-8`) at the end of the node text. If a greater-than sign is placed between the minus sign and the number (e.g. `+->8`), an arrowhead will appear at the end of the connector. Note that it makes no difference whether `+->` or `+-<` is used. The arrow is always directed to the element with one of these ID symbols.
152
+ Each additional connectors is distinguished by an ID number. The ID is specified by putting a a number after a sequence of a plus and a minus symbols (e.g. `+-8`) at the end of the node text. If a greater-than `>` or less-than `<` symbol is placed between the minus sign and the number (e.g. `+->8`), an arrowhead will appear at the end of the connector. Note that it makes no difference whether `+->` or `+-<` is used. The arrow is always directed to the element with one of these ID symbols.
154
153
 
155
154
  A node can have any number of IDs. The same ID must appear in the text of the *two* nodes between which the additional connector is rendered. The same ID number cannot appear in more than two places.
156
155
 
@@ -144,11 +144,11 @@ SVG形式を用いる場合,期待通りの表示を得るためには,ご
144
144
  下の3種類の形式でノードからノードへのパスを表示することができます.
145
145
 
146
146
  - 方向(矢印)のないパス(`- - -`)
147
- - 方向(矢印)のあるパス(`-----▶`)
148
- - 両方向の矢印のあるパス(`◀----▶`)
147
+ - 方向(矢印)のあるパス(`----▶`)
148
+ - 両方向の矢印のあるパス(`◀---▶`)
149
149
 
150
150
  樹形図の中でパスを表示したいとき,パスの両端を数字のIDで指定します.数字をプラス(`+`)記号と共にノードのテキストの最後で指定してください(例:`+7`).
151
- プラス記号とID番号の間に `>` 記号を入れると(例:`+>7`),パスの終端に矢印が付きます.その際、`+>` と `+<` のどちらを用いるかで結果は変わりません。矢印の先は常にこれらのいずれかを用いたIDが指定された要素に向けられます。
151
+ プラス記号とID番号の間に `>` 記号または `<` 記号を入れると(例:`+>7`),パスの終端に矢印が付きます.その際、`+>` と `+<` のどちらを用いるかで結果は変わりません。矢印の先は常にこれらのいずれかを用いたIDが指定された要素に向けられます。
152
152
 
153
153
  IDにはどのような数字を用いても構いませんが,必ず **2箇所** で同じIDを指定することが必要です.同じIDを3箇所以上で指定することはできません.
154
154
 
@@ -156,7 +156,7 @@ IDにはどのような数字を用いても構いませんが,必ず **2箇
156
156
 
157
157
  パスの指定と類似した方式でノードからノードへのコネクターを追加することができます.追加的なコネクターは直線で描画されます(`polyline`にはなりません).追加的なコネクターを描画する際,デフォルトのコネクターを非表示(透明)にしたいときには `Hide default connectors`オプションをオンにすると良いでしょう.
158
158
 
159
- 追加のコネクターは数字のIDで指定します,プラスとマイナスを連続させた(`+-`)後にIDを指定してください(例:`+-8`).マイナス記号とID番号の間に `>` 記号を入れると(例:`+->8`),コネクターの終端に矢印が付きます.その際、`+->` と `+-<` のどちらを用いるかで結果は変わりません。矢印の先は常にこれらのいずれかを用いたIDが指定された要素に向けられます。
159
+ 追加のコネクターは数字のIDで指定します,プラスとマイナスを連続させた(`+-`)後にIDを指定してください(例:`+-8`).マイナス記号とID番号の間に `>` 記号または `<` 記号を入れると(例:`+->8`),コネクターの終端に矢印が付きます.その際、`+->` と `+-<` のどちらを用いるかで結果は変わりません。矢印の先は常にこれらのいずれかを用いたIDが指定された要素に向けられます。
160
160
 
161
161
  - 方向(矢印)のないコネクター(`-----`)
162
162
  - 方向(矢印)のあるコネクター(`--▶--`)
data/docs/examples.html CHANGED
@@ -8,14 +8,14 @@ layout: default
8
8
  {% assign categories = all_examples | map: 'category' | join: ',' | split: ',' | group_by: category %}
9
9
  <ul>
10
10
  {%- for category in categories -%}
11
- {%- if category.name != "Test" -%}
11
+ {%- if category.name != "Test" and category.name != "Error" -%}
12
12
  <li><a href="#category-{{ category.name | slugify }}">{{ category.name }}</a> [{{category.size}}]</li>
13
13
  {%- endif -%}
14
14
  {%- endfor -%}
15
15
  </ul>
16
16
 
17
17
  {%- for category in categories -%}
18
- {%- if category.name != "Test" -%}
18
+ {%- if category.name != "Test" and category.name != "Error" -%}
19
19
  <hr />
20
20
  <h2 id="category-{{category.name | slugify }}"><b>{{ category.name }}</b></h2>
21
21
  {%- for example in all_examples -%}
data/docs/index.html CHANGED
File without changes
Binary file
@@ -41,7 +41,7 @@ module RSyntaxTree
41
41
  if parsed[:status] == :success
42
42
  results = parsed[:results]
43
43
  else
44
- error_text = "Error: input text contains an invalid string"
44
+ error_text = +"Error: input text contains an invalid string"
45
45
  error_text += "\n > " + content
46
46
  raise RSTError, error_text
47
47
  end
@@ -139,20 +139,14 @@ module RSyntaxTree
139
139
  elements_height << height
140
140
  else
141
141
  one_bvm_given = true
142
- elements_height << height + @global[:box_vertical_margin] / 2
142
+ elements_height << height + @global[:box_vertical_margin]
143
143
  end
144
144
 
145
145
  e[:width] = width
146
146
  row_width += width
147
147
  end
148
148
 
149
- total_height += if @parent.zero? && @children.empty? && @enclosure == :none
150
- elements_height.max + @global[:height_connector_to_text] * 2
151
- elsif @parent.zero? && @children.empty?
152
- elements_height.max + @global[:height_connector_to_text] / 2
153
- else
154
- elements_height.max + @global[:height_connector_to_text]
155
- end
149
+ total_height += elements_height.max
156
150
  content_width += row_width
157
151
  end
158
152
  total_width = content_width if total_width < content_width
@@ -51,10 +51,10 @@ module RSyntaxTree
51
51
  end
52
52
 
53
53
  def self.valid?(data)
54
- raise RSTError, "Error: input text is empty" if data.empty?
54
+ raise RSTError, +"Error: input text is empty" if data.empty?
55
55
 
56
56
  if /\[\s*\]/m =~ data
57
- raise RSTError, "Error: inside the brackets is empty"
57
+ raise RSTError, +"Error: inside the brackets is empty"
58
58
  end
59
59
 
60
60
  text = data.strip
@@ -85,11 +85,11 @@ module RSyntaxTree
85
85
  end
86
86
 
87
87
  if open_br.empty? && close_br.empty?
88
- raise RSTError, "Error: input text does not contain paired brackets"
88
+ raise RSTError, +"Error: input text does not contain paired brackets"
89
89
  elsif open_br.length == close_br.length
90
90
  true
91
91
  else
92
- raise RSTError, "Error: open and close brackets do not match"
92
+ raise RSTError, +"Error: open and close brackets do not match"
93
93
  end
94
94
  end
95
95
 
@@ -28,10 +28,10 @@ module RSyntaxTree
28
28
  @fontstyle = params[:fontstyle]
29
29
  @margin = params[:margin].to_i
30
30
  @polyline = params[:polyline]
31
- @line_styles = "<line style='stroke:#{@col_line}; stroke-width:#{@linewidth + LINE_SCALING}; stroke-linecap:round;' x1='X1' y1='Y1' x2='X2' y2='Y2' />\n"
32
- @polyline_styles = "<polyline style='stroke:#{@col_line}; stroke-width:#{@linewidth + LINE_SCALING}; fill:none; stroke-linejoin:round;'
31
+ @line_styles = "<line style='stroke:#{@col_line}; stroke-width:#{@linewidth + LINE_SCALING}; stroke-linejoin:round; stroke-linecap:round;' x1='X1' y1='Y1' x2='X2' y2='Y2' />\n"
32
+ @polyline_styles = "<polyline style='stroke:#{@col_line}; stroke-width:#{@linewidth + LINE_SCALING}; fill:none; stroke-linejoin:round; stroke-linecap:round;'
33
33
  points='CHIX CHIY MIDX1 MIDY1 MIDX2 MIDY2 PARX PARY' />\n"
34
- @polygon_styles = "<polygon style='fill: none; stroke: black; stroke-width:#{@linewidth + LINE_SCALING}; stroke-linejoin:round;' points='X1 Y1 X2 Y2 X3 Y3' />\n"
34
+ @polygon_styles = "<polygon style='fill: none; stroke: black; stroke-width:#{@linewidth + LINE_SCALING}; stroke-linejoin:round;stroke-linecap:round;' points='X1 Y1 X2 Y2 X3 Y3' />\n"
35
35
  @text_styles = "<text white-space='pre' alignment-baseline='text-top' style='fill: COLOR; font-size: fontsize' x='X_VALUE' y='Y_VALUE'>CONTENT</text>\n"
36
36
  @tree_data = String.new
37
37
  @visited_x = {}
@@ -41,23 +41,15 @@ module RSyntaxTree
41
41
 
42
42
  def svg_data
43
43
  metrics = parse_list
44
- @height = if @element_list.elements.size == 1
45
- metrics[:height]
46
- else
47
- metrics[:height] + @margin * 2
48
- end
44
+ @height = metrics[:height] + @margin * 2
49
45
  @width = metrics[:width] + @margin * 2
50
46
 
51
47
  x1 = 0 - @margin
52
48
  y1 = 0 - @margin
53
- x2 = @width + @margin
54
- y2 = @height + @margin
49
+ x2 = @width + @margin * 2
50
+ y2 = @height + @margin * 2
55
51
  extra_lines = @extra_lines.join("\n")
56
52
 
57
- # as = @global[:h_gap_between_nodes] / 4 * 0.8
58
- # as2 = @global[:h_gap_between_nodes] / 2 * 0.8
59
- # as4 = @global[:h_gap_between_nodes] * 1.2
60
-
61
53
  as2 = @global[:h_gap_between_nodes] * 1.0
62
54
  as4 = as2 * 3
63
55
 
@@ -190,7 +182,7 @@ module RSyntaxTree
190
182
  when :bborder
191
183
  stroke_width = @linewidth + BLINE_SCALING
192
184
  end
193
- @extra_lines << "<line style=\"stroke:#{col}; stroke-width:#{stroke_width}; \" x1=\"#{x1}\" y1=\"#{y1}\" x2=\"#{x2}\" y2=\"#{y2}\"></line>"
185
+ @extra_lines << "<line style=\"stroke:#{col}; stroke-linecap:round; stroke-width:#{stroke_width}; \" x1=\"#{x1}\" y1=\"#{y1}\" x2=\"#{x2}\" y2=\"#{y2}\"></line>"
194
186
  else
195
187
  if element.enclosure == :brackets
196
188
  this_x = txt_pos - element.content_width / 2
@@ -286,7 +278,7 @@ module RSyntaxTree
286
278
  end
287
279
 
288
280
  if e[:decoration].include?(:box)
289
- enc = "<rect style='stroke: #{col}; stroke-width:#{stroke_width};'
281
+ enc = "<rect style='stroke: #{col}; stroke-linejoin:round; stroke-width:#{stroke_width};'
290
282
  x='#{enc_x}' y='#{enc_y}'
291
283
  width='#{enc_width}' height='#{enc_height}'
292
284
  fill='#{fill}' />\n"
@@ -301,16 +293,16 @@ module RSyntaxTree
301
293
  x2 = enc_x + enc_width
302
294
  y2 = y1
303
295
  ar_hwidth = e[:width] / 4.0
304
- bar = "<line style='stroke:#{col}; stroke-width:#{stroke_width};' x1='#{x1}' y1='#{y1}' x2='#{x2}' y2='#{y2}'></line>\n"
296
+ bar = "<line style='stroke:#{col}; stroke-linejoin:round; stroke-linecap:round; stroke-width:#{stroke_width};' x1='#{x1}' y1='#{y1}' x2='#{x2 - stroke_width / 2}' y2='#{y2}'></line>\n"
305
297
  @extra_lines << bar
306
298
 
307
299
  if e[:decoration].include?(:arrow_to_l)
308
- l_arrowhead = "<polyline stroke-linejoin='round' fill='none' stroke='#{col}' stroke-width='#{stroke_width}' points='#{x1 + ar_hwidth},#{y1 + ar_hwidth / 2} #{x1},#{y1} #{x1 + ar_hwidth},#{y1 - ar_hwidth / 2}' />\n"
300
+ l_arrowhead = "<polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='#{col}' stroke-width='#{stroke_width}' points='#{x1 + ar_hwidth},#{y1 + ar_hwidth / 2} #{x1 + stroke_width / 2},#{y1} #{x1 + ar_hwidth},#{y1 - ar_hwidth / 2}' />\n"
309
301
  @extra_lines << l_arrowhead
310
302
  end
311
303
 
312
304
  if e[:decoration].include?(:arrow_to_r)
313
- r_arrowhead = "<polyline stroke-linejoin='round' fill='none' stroke='#{col}' stroke-width='#{stroke_width}' points='#{x2 - ar_hwidth},#{y2 - ar_hwidth / 2} #{x2},#{y2} #{x2 - ar_hwidth},#{y2 + ar_hwidth / 2}' />\n"
305
+ r_arrowhead = "<polyline stroke-linejoin='round' stroke-linecap='round' fill='none' stroke='#{col}' stroke-width='#{stroke_width}' points='#{x2 - ar_hwidth},#{y2 - ar_hwidth / 2} #{x2 - stroke_width / 2},#{y2} #{x2 - ar_hwidth},#{y2 + ar_hwidth / 2}' />\n"
314
306
  @extra_lines << r_arrowhead
315
307
  end
316
308
  end
@@ -341,6 +333,7 @@ module RSyntaxTree
341
333
  end
342
334
  @height = text_y if text_y > @height
343
335
  end
336
+
344
337
  bc[:y] = bc[:y] + @global[:height_connector_to_text] * 3 / 4
345
338
  bc[:height] = text_y - bc[:y] + @global[:height_connector_to_text]
346
339
  case element.enclosure
@@ -358,16 +351,16 @@ module RSyntaxTree
358
351
 
359
352
  def draw_rectangle(x1, y1, width, height, col, bline = false)
360
353
  swidth = bline ? @linewidth + BLINE_SCALING : @linewidth + LINE_SCALING
361
- @extra_lines << "<polygon style='stroke:#{col}; stroke-width:#{swidth}; fill:none; stroke-linejoin:round;'
354
+ @extra_lines << "<polygon style='stroke:#{col}; stroke-width:#{swidth}; fill:none; stroke-linejoin:round; stroke-linecap:round;'
362
355
  points='#{x1},#{y1} #{x1 + width},#{y1} #{x1 + width},#{y1 + height} #{x1},#{y1 + height}' />\n"
363
356
  end
364
357
 
365
358
  def draw_bracket(x1, y1, width, height, col, bline = false)
366
359
  swidth = bline ? @linewidth + BLINE_SCALING : @linewidth + LINE_SCALING
367
360
  slwidth = @global[:h_gap_between_nodes] / 2
368
- @extra_lines << "<polyline style='stroke:#{col}; stroke-width:#{swidth}; fill:none; stroke-linejoin:round;'
361
+ @extra_lines << "<polyline style='stroke:#{col}; stroke-width:#{swidth}; fill:none; stroke-linejoin:round; stroke-linecap:round;'
369
362
  points='#{x1 + slwidth},#{y1} #{x1},#{y1} #{x1},#{y1 + height} #{x1 + slwidth},#{y1 + height}' />\n"
370
- @extra_lines << "<polyline style='stroke:#{col}; stroke-width:#{swidth}; fill:none; stroke-linejoin:round;'
363
+ @extra_lines << "<polyline style='stroke:#{col}; stroke-width:#{swidth}; fill:none; stroke-linejoin:round; stroke-linecap:round;'
371
364
  points='#{x1 + width - slwidth},#{y1} #{x1 + width},#{y1} #{x1 + width},#{y1 + height} #{x1 + width - slwidth},#{y1 + height}' />\n"
372
365
  end
373
366
 
@@ -427,12 +420,12 @@ module RSyntaxTree
427
420
  path_pool_source[tr] = [x1, y1]
428
421
  path_flags << tr
429
422
  end
430
- raise RSTError, "Error: input text contains a path having more than two ends:\n > #{tr}" if path_flags.tally.any? { |_k, v| v > 2 } || line_flags.tally.any? { |_k, v| v > 2 }
423
+ raise RSTError, +"Error: input text contains a path having more than two ends:\n > #{tr}" if path_flags.tally.any? { |_k, v| v > 2 } || line_flags.tally.any? { |_k, v| v > 2 }
431
424
  end
432
425
  end
433
426
 
434
427
  path_flags.tally.each do |k, v|
435
- raise RSTError, "Error: input text contains a path having only one end:\n > #{k}" if v == 1
428
+ raise RSTError, +"Error: input text contains a path having only one end:\n > #{k}" if v == 1
436
429
  end
437
430
 
438
431
  path_pool_source.each do |k, v|
@@ -469,7 +462,15 @@ module RSyntaxTree
469
462
  elsif a[:y][:bottom] < b[:y][:top]
470
463
  generate_connectors(b[:x][:center], b[:y][:top], a[:x][:center], a[:y][:bottom], @col_extra, false, b[:arrow], a[:arrow])
471
464
  elsif a[:x][:center] < b[:x][:center]
472
- generate_connectors(a[:x][:right], a[:y][:center], b[:x][:left], b[:y][:center], @col_extra, false, a[:arrow], b[:arrow])
465
+ if a[:y][:top] == b[:y][:top]
466
+ upper_y = a[:y][:center] < b[:y][:center] ? a[:y][:center] : b[:y][:center]
467
+ generate_connectors(a[:x][:right], upper_y, b[:x][:left], upper_y, @col_extra, false, a[:arrow], b[:arrow])
468
+ else
469
+ generate_connectors(a[:x][:right], a[:y][:center], b[:x][:left], b[:y][:center], @col_extra, false, a[:arrow], b[:arrow])
470
+ end
471
+ elsif a[:y][:top] == b[:y][:top]
472
+ upper_y = a[:y][:center] < b[:y][:center] ? a[:y][:center] : b[:y][:center]
473
+ generate_connectors(b[:x][:right], upper_y, a[:x][:left], upper_y, @col_extra, false, b[:arrow], a[:arrow])
473
474
  else
474
475
  generate_connectors(b[:x][:right], b[:y][:center], a[:x][:left], a[:y][:center], @col_extra, false, b[:arrow], a[:arrow])
475
476
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSyntaxTree
4
- VERSION = "1.2.4"
4
+ VERSION = "1.2.6"
5
5
  end
data/lib/rsyntaxtree.rb CHANGED
@@ -83,7 +83,7 @@ module RSyntaxTree
83
83
  fontset[:bolditalic] = FONT_DIR + "/NotoSansMono_SemiCondensed-Bold.ttf"
84
84
  fontset[:math] = FONT_DIR + "/latinmodern-math.otf"
85
85
  fontset[:cjk] = FONT_DIR + "/NotoSansJP-Regular.otf"
86
- fontset[:emoji] = FONT_DIR + "/OpenMoji-Black.ttf"
86
+ fontset[:emoji] = FONT_DIR + "/OpenMoji-black-glyf.ttf"
87
87
  new_params[:fontstyle] = "mono"
88
88
  when "noto-sans", "sans"
89
89
  fontset[:normal] = FONT_DIR + "/NotoSans-Regular.ttf"
@@ -92,7 +92,7 @@ module RSyntaxTree
92
92
  fontset[:bolditalic] = FONT_DIR + "/NotoSans-BoldItalic.ttf"
93
93
  fontset[:math] = FONT_DIR + "/NotoSansMath-Regular.ttf"
94
94
  fontset[:cjk] = FONT_DIR + "/NotoSansJP-Regular.otf"
95
- fontset[:emoji] = FONT_DIR + "/OpenMoji-Black.ttf"
95
+ fontset[:emoji] = FONT_DIR + "/OpenMoji-black-glyf.ttf"
96
96
  new_params[:fontstyle] = "sans"
97
97
  when "noto-serif", "serif"
98
98
  fontset[:normal] = FONT_DIR + "/NotoSerif-Regular.ttf"
@@ -101,7 +101,7 @@ module RSyntaxTree
101
101
  fontset[:bolditalic] = FONT_DIR + "/NotoSerif-BoldItalic.ttf"
102
102
  fontset[:math] = FONT_DIR + "/latinmodern-math.otf"
103
103
  fontset[:cjk] = FONT_DIR + "/NotoSerifJP-Regular.otf"
104
- fontset[:emoji] = FONT_DIR + "/OpenMoji-Black.ttf"
104
+ fontset[:emoji] = FONT_DIR + "/OpenMoji-black-glyf.ttf"
105
105
  new_params[:fontstyle] = "serif"
106
106
  when "cjk zenhei", "cjk"
107
107
  fontset[:normal] = FONT_DIR + "/wqy-zenhei.ttf"
@@ -110,7 +110,7 @@ module RSyntaxTree
110
110
  fontset[:bolditalic] = FONT_DIR + "/NotoSans-BoldItalic.ttf"
111
111
  fontset[:math] = FONT_DIR + "/NotoSansMath-Regular.ttf"
112
112
  fontset[:cjk] = FONT_DIR + "/wqy-zenhei.ttf"
113
- fontset[:emoji] = FONT_DIR + "/OpenMoji-Black.ttf"
113
+ fontset[:emoji] = FONT_DIR + "/OpenMoji-black-glyf.ttf"
114
114
  new_params[:fontstyle] = "cjk"
115
115
  end
116
116
  else
@@ -145,13 +145,13 @@ module RSyntaxTree
145
145
  @global[:height_connector_to_text] = single_x_metrics.height / 2.0
146
146
  @global[:single_line_height] = single_x_metrics.height * 2.0
147
147
  @global[:width_half_x] = single_x_metrics.width / 2.0
148
- @global[:height_connector] = single_x_metrics.height * 1.0 * @params[:vheight]
148
+ @global[:height_connector] = single_x_metrics.height * @params[:vheight]
149
149
  @global[:h_gap_between_nodes] = single_x_metrics.width * 0.8
150
150
  @global[:box_vertical_margin] = single_x_metrics.height * 0.8
151
151
  end
152
152
 
153
153
  def self.check_data(text)
154
- raise RSTError, "Error: input text is empty" if text.to_s == ""
154
+ raise RSTError, +"Error: input text is empty" if text.to_s == ""
155
155
 
156
156
  StringParser.valid?(text)
157
157
  end
@@ -170,6 +170,8 @@ module RSyntaxTree
170
170
  else
171
171
  b.string
172
172
  end
173
+ rescue Cairo::InvalidSize
174
+ raise RSTError, +"Error: the result syntree is too big"
173
175
  end
174
176
 
175
177
  def draw_svg
@@ -49,6 +49,8 @@ class ExampleParserTest < Minitest::Test
49
49
  opts[:polyline] = value
50
50
  when "hide_default_connectors"
51
51
  opts[:hide_default_connectors] = value
52
+ when "connector_height"
53
+ opts[:vheight] = value
52
54
  when "symmetrization"
53
55
  opts[:symmetrize] = value
54
56
  when "connector"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsyntaxtree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.4
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichiro Hasebe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-04 00:00:00.000000000 Z
11
+ date: 2023-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: optimist
@@ -104,10 +104,12 @@ files:
104
104
  - ".rubocop.yml"
105
105
  - ".solargraph.yml"
106
106
  - ".tags"
107
+ - Dockerfile
107
108
  - Gemfile
108
109
  - README.md
109
110
  - Rakefile
110
111
  - bin/rsyntaxtree
112
+ - dev/generate_examples.rb
111
113
  - docs/.gitignore
112
114
  - docs/404.html
113
115
  - docs/Gemfile
@@ -154,6 +156,11 @@ files:
154
156
  - docs/_examples/039.md
155
157
  - docs/_examples/040.md
156
158
  - docs/_examples/041.md
159
+ - docs/_examples/042.md
160
+ - docs/_examples/043.md
161
+ - docs/_examples/044.md
162
+ - docs/_examples/045.md
163
+ - docs/_examples/046.md
157
164
  - docs/_includes/box_and_circle_table.html
158
165
  - docs/_includes/escape_char_table.html
159
166
  - docs/_includes/social_media_links.html
@@ -201,6 +208,11 @@ files:
201
208
  - docs/assets/img/039.png
202
209
  - docs/assets/img/040.png
203
210
  - docs/assets/img/041.png
211
+ - docs/assets/img/042.png
212
+ - docs/assets/img/043.png
213
+ - docs/assets/img/044.png
214
+ - docs/assets/img/045.png
215
+ - docs/assets/img/046.png
204
216
  - docs/assets/img/elements/circle.png
205
217
  - docs/assets/img/elements/circle_abc.png
206
218
  - docs/assets/img/elements/circle_bold.png
@@ -259,6 +271,11 @@ files:
259
271
  - docs/assets/svg/039.svg
260
272
  - docs/assets/svg/040.svg
261
273
  - docs/assets/svg/041.svg
274
+ - docs/assets/svg/042.svg
275
+ - docs/assets/svg/043.svg
276
+ - docs/assets/svg/044.svg
277
+ - docs/assets/svg/045.svg
278
+ - docs/assets/svg/046.svg
262
279
  - docs/documentation.md
263
280
  - docs/documentation_ja.md
264
281
  - docs/examples.html
@@ -278,8 +295,7 @@ files:
278
295
  - fonts/NotoSerif-Regular.ttf
279
296
  - fonts/NotoSerifJP-Bold.otf
280
297
  - fonts/NotoSerifJP-Regular.otf
281
- - fonts/OpenMoji-Black.ttf
282
- - fonts/OpenMoji-Color.ttf
298
+ - fonts/OpenMoji-black-glyf.ttf
283
299
  - fonts/wqy-zenhei.ttf
284
300
  - img/rsyntaxtree-web-screenshot.png
285
301
  - img/rsyntaxtree.png
@@ -316,7 +332,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
332
  - !ruby/object:Gem::Version
317
333
  version: '0'
318
334
  requirements: []
319
- rubygems_version: 3.4.2
335
+ rubygems_version: 3.3.3
320
336
  signing_key:
321
337
  specification_version: 4
322
338
  summary: RSyntaxTree is a graphical syntax tree generator written in Ruby
Binary file
Binary file