rsyntaxtree 1.6.1 → 1.6.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 867e51aad2f9b73b3aeecc016592ed9329a28269266d1caafb2ae42dac9555d0
4
- data.tar.gz: 70c17e7f8aeacd3ad398c81152ad924faa23def26768dca1babce71e6ef867a0
3
+ metadata.gz: f13f7407a77bda563986883ec33eed5c2699305e73428582e0caf2c64c7cdf22
4
+ data.tar.gz: 329f1d4357b0034709bd842f117c14ea401dad18b7ca72e65b917149fcc794a9
5
5
  SHA512:
6
- metadata.gz: cf0c02890fcb35834cbb29b4bad13c764e2e3ec005ffe5207fe9c33f432f406a630abcd9bef0ce05d8e5349ee6b7dc5e1f6c78afdd9411c101015cada35bd58f
7
- data.tar.gz: 9906029477a7d286b98412f462d323060c6e12a79e7a0fb67e6207673f3db23d8a6f02cf771b6d6dc7ad56d6b5bb2c2903e9ac9cefd203de845129374b942e5a
6
+ metadata.gz: 4bab8dc69ae2631ae4818e41a2b986136ab9b40e20a6e9bd2e4793b745e605193f35920e5679e48f5e37bc89211c26e2a1f659a432292c2fd3c027fe35063ae1
7
+ data.tar.gz: 36db33880b172ac48da638dc0de97797481c88ca6af3bddb632cb1e5f7f795d5146ad1cac5d29f242213157bd16a8c44e031c690d55561fd73076be4bb2dde0e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.6.2] - 2026-06
4
+
5
+ ### Fixed
6
+ - Region shade no longer touches the image edge when its padded bounds reach
7
+ past the tree's natural extent (e.g. a deep enclosed/multi-line node): the
8
+ canvas now grows with a margin around the shaded plane.
9
+
3
10
  ## [1.6.1] - 2026-06
4
11
 
5
12
  ### Improved
Binary file
Binary file
@@ -1,6 +1,6 @@
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="743.6000000000001" height="768.375" viewBox="-17.6, 0, 761.2000000000002, 779.625" version="1.1" xmlns="http://www.w3.org/2000/svg">
3
+ <svg width="743.6000000000001" height="782.075" viewBox="-17.6, 0, 761.2000000000002, 793.325" version="1.1" xmlns="http://www.w3.org/2000/svg">
4
4
  <defs>
5
5
  <marker id="arrow" markerUnits="userSpaceOnUse" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="17.6" markerHeight="17.6" orient="auto">
6
6
  <path d="M 0 0 L 10 5 L 0 10" fill="#CC79A7"/>
@@ -24,7 +24,7 @@
24
24
  <line x1="0" y="0" x2="0" y2="10" stroke="#009E73" stroke-width="4"></line>
25
25
  </pattern>
26
26
  </defs>
27
- <rect x="-17.6" y="0" width="761.2000000000002" height="779.625" stroke="none" fill="white" />"
27
+ <rect x="-17.6" y="0" width="761.2000000000002" height="793.325" stroke="none" fill="white" />"
28
28
  <rect x='213.4' y='193.5' width='495.0000000000001' height='581.225' rx='11.25' ry='11.25' fill='lightblue' fill-opacity='0.2' stroke='lightblue' stroke-opacity='0.55' stroke-width='2' />
29
29
  <text white-space='pre' alignment-baseline='text-top' style='fill: #0072B2; storoke-width: 0; font-size: 32px;' x='216.76250000000002' y='67.5'><tspan x='216.76250000000002' y='67.5' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">TP</tspan>
30
30
  </text>
@@ -1,6 +1,6 @@
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="515.2" height="597.375" viewBox="-17.6, 0, 532.8000000000001, 608.625" version="1.1" xmlns="http://www.w3.org/2000/svg">
3
+ <svg width="516.2" height="611.075" viewBox="-18.60000000000001, 0, 533.8000000000001, 622.325" version="1.1" xmlns="http://www.w3.org/2000/svg">
4
4
  <defs>
5
5
  <marker id="arrow" markerUnits="userSpaceOnUse" viewBox="0 0 10 10" refX="10" refY="5" markerWidth="17.6" markerHeight="17.6" orient="auto">
6
6
  <path d="M 0 0 L 10 5 L 0 10" fill="black"/>
@@ -24,7 +24,7 @@
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="-17.6" y="0" width="532.8000000000001" height="608.625" stroke="none" fill="white" />"
27
+ <rect x="-18.60000000000001" y="0" width="533.8000000000001" height="622.325" stroke="none" fill="white" />"
28
28
  <rect x='-7.105427357601002e-15' y='22.5' width='480.0' height='581.225' rx='11.25' ry='11.25' fill='#888888' fill-opacity='0.2' stroke='#888888' stroke-opacity='0.55' stroke-width='2' />
29
29
  <rect x='213.4' y='193.5' width='266.6' height='410.225' rx='11.25' ry='11.25' fill='#888888' fill-opacity='0.2' stroke='#888888' stroke-opacity='0.55' stroke-width='2' />
30
30
  <rect x='362.79999999999995' y='364.5' width='117.20000000000005' height='239.22500000000002' rx='11.25' ry='11.25' fill='#888888' fill-opacity='0.2' stroke='#888888' stroke-opacity='0.55' stroke-width='2' />
@@ -69,14 +69,17 @@ module RSyntaxTree
69
69
  y2 = @height + @global[:height_connector_to_text] / 2
70
70
 
71
71
  # Grow the canvas so region shades that reach past the tree's own bounds
72
- # (e.g. a region on the root node, whose top sits above y=0) are not
73
- # clipped. x2/y2 are the viewBox width/height, so right = x1 + x2.
72
+ # (e.g. a region on the root node, or one whose padded edge extends beyond
73
+ # the deepest leaf) keep a margin instead of touching the image edge. A
74
+ # margin is added around the region extents before unioning with the tree
75
+ # bounds. x2/y2 are the viewBox width/height, so right = x1 + x2.
74
76
  if @region_bounds
75
77
  rb = @region_bounds
76
- left = [x1, rb[:min_x]].min
77
- top = [y1, rb[:min_y]].min
78
- right = [x1 + x2, rb[:max_x]].max
79
- bottom = [y1 + y2, rb[:max_y]].max
78
+ m = @global[:h_gap_between_nodes]
79
+ left = [x1, rb[:min_x] - m].min
80
+ top = [y1, rb[:min_y] - m].min
81
+ right = [x1 + x2, rb[:max_x] + m].max
82
+ bottom = [y1 + y2, rb[:max_y] + m].max
80
83
  new_x2 = right - left
81
84
  new_y2 = bottom - top
82
85
  @width += new_x2 - x2
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RSyntaxTree
4
- VERSION = "1.6.1"
4
+ VERSION = "1.6.2"
5
5
  end
@@ -322,6 +322,27 @@ class NodeStylingTest < Minitest::Test
322
322
  assert rx + rw <= minx + vbw + eps, "region right clipped beyond viewBox"
323
323
  end
324
324
 
325
+ def test_region_keeps_margin_from_canvas_edge
326
+ # Regression: when a region's padded bounds extend past the tree's natural
327
+ # extent (here an enclosed multi-line node deep in the shaded subtree), the
328
+ # canvas must grow with a margin so the plane does not touch the image edge.
329
+ opts = @base_opts.merge(color: "modern", data: "[S [A x] [%B [C #\\+one\\ \\+two]]]")
330
+ svg = RSyntaxTree::RSGenerator.new(opts).draw_svg
331
+
332
+ minx, miny, vbw, vbh = svg[/viewBox="([^"]*)"/, 1].split(",").map(&:to_f)
333
+ shade = svg[/<rect[^>]*fill-opacity[^>]*>/]
334
+ refute_nil shade
335
+ rx = shade[/\bx='([\-0-9.]+)'/, 1].to_f
336
+ ry = shade[/\by='([\-0-9.]+)'/, 1].to_f
337
+ rw = shade[/width='([\-0-9.]+)'/, 1].to_f
338
+ rh = shade[/height='([\-0-9.]+)'/, 1].to_f
339
+
340
+ bottom_margin = (miny + vbh) - (ry + rh)
341
+ right_margin = (minx + vbw) - (rx + rw)
342
+ assert bottom_margin > 8, "Region must keep a bottom margin from the canvas edge (got #{bottom_margin.round(1)})"
343
+ assert right_margin > 8, "Region must keep a right margin from the canvas edge (got #{right_margin.round(1)})"
344
+ end
345
+
325
346
  def test_smart_apostrophe_in_label
326
347
  # A straight ASCII apostrophe (U+0027) in a label is rendered as a
327
348
  # typographic apostrophe (U+2019) for smarter typography (e.g. X-bar "T'").
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.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yoichiro Hasebe