rsyntaxtree 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tags +64 -0
- data/README.md +3 -2
- data/bin/rsyntaxtree +5 -5
- data/dev/generate_examples.rb +1 -13
- data/docs/_examples/000.md +1 -1
- data/docs/_examples/001.md +1 -1
- data/docs/_examples/002.md +1 -1
- data/docs/_examples/003.md +1 -1
- data/docs/_examples/004.md +1 -1
- data/docs/_examples/005.md +1 -1
- data/docs/_examples/006.md +1 -1
- data/docs/_examples/007.md +1 -1
- data/docs/_examples/008.md +1 -1
- data/docs/_examples/009.md +1 -1
- data/docs/_examples/010.md +1 -1
- data/docs/_examples/011.md +1 -1
- data/docs/_examples/012.md +1 -1
- data/docs/_examples/014.md +1 -1
- data/docs/_examples/015.md +1 -1
- data/docs/_examples/016.md +1 -1
- data/docs/_examples/019.md +1 -1
- data/docs/_examples/021.md +1 -1
- data/docs/_examples/024.md +1 -1
- data/docs/_examples/025.md +1 -1
- data/docs/_examples/026.md +1 -1
- data/docs/_examples/027.md +1 -1
- data/docs/_examples/030.md +1 -1
- data/docs/_examples/031.md +1 -1
- data/docs/_examples/032.md +1 -1
- data/docs/_examples/034.md +1 -1
- data/docs/_examples/035.md +2 -2
- data/docs/_examples/040.md +1 -1
- data/docs/_examples/042.md +1 -1
- data/docs/_examples/047.md +21 -0
- data/docs/_includes/box_and_circle_table.html +24 -0
- data/docs/assets/css/style.scss +6 -0
- data/docs/assets/img/000.png +0 -0
- data/docs/assets/img/001.png +0 -0
- data/docs/assets/img/002.png +0 -0
- data/docs/assets/img/003.png +0 -0
- data/docs/assets/img/004.png +0 -0
- data/docs/assets/img/005.png +0 -0
- data/docs/assets/img/006.png +0 -0
- data/docs/assets/img/007.png +0 -0
- data/docs/assets/img/008.png +0 -0
- data/docs/assets/img/009.png +0 -0
- data/docs/assets/img/010.png +0 -0
- data/docs/assets/img/011.png +0 -0
- data/docs/assets/img/012.png +0 -0
- data/docs/assets/img/013.png +0 -0
- data/docs/assets/img/014.png +0 -0
- data/docs/assets/img/015.png +0 -0
- data/docs/assets/img/016.png +0 -0
- data/docs/assets/img/017.png +0 -0
- data/docs/assets/img/018.png +0 -0
- data/docs/assets/img/019.png +0 -0
- data/docs/assets/img/020.png +0 -0
- data/docs/assets/img/021.png +0 -0
- data/docs/assets/img/022.png +0 -0
- data/docs/assets/img/023.png +0 -0
- data/docs/assets/img/024.png +0 -0
- data/docs/assets/img/025.png +0 -0
- data/docs/assets/img/026.png +0 -0
- data/docs/assets/img/027.png +0 -0
- data/docs/assets/img/028.png +0 -0
- data/docs/assets/img/029.png +0 -0
- data/docs/assets/img/030.png +0 -0
- data/docs/assets/img/031.png +0 -0
- data/docs/assets/img/032.png +0 -0
- data/docs/assets/img/033.png +0 -0
- data/docs/assets/img/034.png +0 -0
- data/docs/assets/img/035.png +0 -0
- data/docs/assets/img/036.png +0 -0
- data/docs/assets/img/037.png +0 -0
- data/docs/assets/img/038.png +0 -0
- data/docs/assets/img/040.png +0 -0
- data/docs/assets/img/041.png +0 -0
- data/docs/assets/img/042.png +0 -0
- data/docs/assets/img/043.png +0 -0
- data/docs/assets/img/044.png +0 -0
- data/docs/assets/img/045.png +0 -0
- data/docs/assets/img/047.png +0 -0
- data/docs/assets/img/elements/arrow_both.png +0 -0
- data/docs/assets/img/elements/arrow_both_bold.png +0 -0
- data/docs/assets/img/elements/arrow_left.png +0 -0
- data/docs/assets/img/elements/arrow_left_bold.png +0 -0
- data/docs/assets/img/elements/arrow_right.png +0 -0
- data/docs/assets/img/elements/arrow_right_bold.png +0 -0
- data/docs/assets/svg/000.svg +33 -33
- data/docs/assets/svg/001.svg +13 -13
- data/docs/assets/svg/002.svg +33 -33
- data/docs/assets/svg/003.svg +25 -25
- data/docs/assets/svg/004.svg +36 -36
- data/docs/assets/svg/005.svg +16 -16
- data/docs/assets/svg/006.svg +21 -21
- data/docs/assets/svg/007.svg +27 -27
- data/docs/assets/svg/008.svg +31 -31
- data/docs/assets/svg/009.svg +30 -30
- data/docs/assets/svg/010.svg +48 -48
- data/docs/assets/svg/011.svg +25 -25
- data/docs/assets/svg/012.svg +30 -30
- data/docs/assets/svg/013.svg +71 -71
- data/docs/assets/svg/014.svg +93 -93
- data/docs/assets/svg/015.svg +29 -29
- data/docs/assets/svg/016.svg +378 -378
- data/docs/assets/svg/017.svg +29 -29
- data/docs/assets/svg/018.svg +31 -31
- data/docs/assets/svg/019.svg +149 -149
- data/docs/assets/svg/020.svg +56 -56
- data/docs/assets/svg/021.svg +69 -69
- data/docs/assets/svg/022.svg +69 -69
- data/docs/assets/svg/023.svg +45 -45
- data/docs/assets/svg/024.svg +19 -19
- data/docs/assets/svg/025.svg +117 -117
- data/docs/assets/svg/026.svg +19 -19
- data/docs/assets/svg/027.svg +59 -59
- data/docs/assets/svg/028.svg +15 -15
- data/docs/assets/svg/029.svg +49 -49
- data/docs/assets/svg/030.svg +36 -36
- data/docs/assets/svg/031.svg +11 -11
- data/docs/assets/svg/032.svg +33 -33
- data/docs/assets/svg/033.svg +30 -30
- data/docs/assets/svg/034.svg +44 -44
- data/docs/assets/svg/035.svg +18 -18
- data/docs/assets/svg/036.svg +11 -11
- data/docs/assets/svg/037.svg +14 -14
- data/docs/assets/svg/038.svg +33 -33
- data/docs/assets/svg/039.svg +1 -1
- data/docs/assets/svg/040.svg +90 -90
- data/docs/assets/svg/041.svg +43 -43
- data/docs/assets/svg/042.svg +11 -11
- data/docs/assets/svg/043.svg +121 -121
- data/docs/assets/svg/044.svg +2 -2
- data/docs/assets/svg/045.svg +36 -36
- data/docs/assets/svg/046.svg +641 -641
- data/docs/assets/svg/047.svg +67 -0
- data/docs/documentation.md +1 -1
- data/docs/documentation_ja.md +1 -1
- data/docs/examples.html +5 -4
- data/lib/rsyntaxtree/svg_graph.rb +8 -7
- data/lib/rsyntaxtree/version.rb +1 -1
- data/lib/rsyntaxtree.rb +30 -23
- data/test/example_verify_test.rb +1 -13
- metadata +12 -3
@@ -0,0 +1,67 @@
|
|
1
|
+
<?xml version="1.0" standalone="no"?>
|
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">
|
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">
|
6
|
+
<path d="M 0 0 L 10 5 L 0 10" fill="black"/>
|
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">
|
9
|
+
<path d="M 0 0 L 10 5 L 0 10 z" fill="black"/>
|
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">
|
12
|
+
<path d="M 10 0 L 0 5 L 10 10 z" fill="black"/>
|
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">
|
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
|
+
</marker>
|
17
|
+
<pattern id="hatchBlack" x="10" y="10" width="10" height="10" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
|
18
|
+
<line x1="0" y="0" x2="0" y2="10" stroke="black" stroke-width="4"></line>
|
19
|
+
</pattern>
|
20
|
+
<pattern id="hatchForNode" x="10" y="10" width="10" height="10" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
|
21
|
+
<line x1="0" y="0" x2="0" y2="10" stroke="black" stroke-width="4"></line>
|
22
|
+
</pattern>
|
23
|
+
<pattern id="hatchForLeaf" x="10" y="10" width="10" height="10" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
|
24
|
+
<line x1="0" y="0" x2="0" y2="10" stroke="black" stroke-width="4"></line>
|
25
|
+
</pattern>
|
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>
|
35
|
+
</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>
|
37
|
+
|
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' />
|
39
|
+
|
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>
|
41
|
+
|
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' />
|
43
|
+
|
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>
|
45
|
+
|
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' />
|
47
|
+
|
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>
|
49
|
+
|
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' />
|
51
|
+
|
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>
|
53
|
+
|
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' />
|
55
|
+
|
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' />
|
57
|
+
|
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>
|
59
|
+
|
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' />
|
61
|
+
|
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' />
|
67
|
+
</svg>
|
data/docs/documentation.md
CHANGED
@@ -80,7 +80,7 @@ Note: Currently, overline is displayed in SVG, but not in PNG.
|
|
80
80
|
|`normal_subscript_` |normal<sub>subscript</sub> |
|
81
81
|
|`normal__superscript__`|normal<sup>superscript</sup>|
|
82
82
|
|
83
|
-
#### Box and
|
83
|
+
#### Box, Circle, Bar, and Arrow
|
84
84
|
|
85
85
|
{% include box_and_circle_table.html %}
|
86
86
|
|
data/docs/documentation_ja.md
CHANGED
data/docs/examples.html
CHANGED
@@ -27,8 +27,8 @@ layout: default
|
|
27
27
|
</button>
|
28
28
|
</div>
|
29
29
|
<div class='grid'>
|
30
|
-
<div style='margin-top: 0; margin-bottom: auto;'>
|
31
|
-
<div id="text-{{example.name}}" style='max-height: 600px; overflow-y: auto; margin-bottom: 20px;'>
|
30
|
+
<div style='margin-top: 0; margin-bottom: auto; '>
|
31
|
+
<div id="text-{{example.name}}" style='max-height: 600px; overflow-x: auto; overflow-y: auto; margin-bottom: 20px;'>
|
32
32
|
{{ example.content | markdownify }}
|
33
33
|
</div>
|
34
34
|
<table style='line-height: 110%; font-size: 0.85em; margin-bottom: 20px;'>
|
@@ -36,6 +36,7 @@ layout: default
|
|
36
36
|
<tbody>
|
37
37
|
<tr><td>Category</td><td>{{ example.category}}</td></tr>
|
38
38
|
<tr><td>Connector</td><td>{{ example.connector }}</td></tr>
|
39
|
+
<tr><td>Connector Height</td><td>{{ example.connector_height }}</td></tr>
|
39
40
|
<tr><td>Line Width</td><td>{{ example.linewidth }}</td></tr>
|
40
41
|
<tr><td>Hide Default Connectors</td><td>{{ example.hide_default_connectors }}</td></tr>
|
41
42
|
<tr><td>Polyline</td><td>{{ example.polyline }}</td></tr>
|
@@ -48,9 +49,9 @@ layout: default
|
|
48
49
|
</tbody>
|
49
50
|
</table>
|
50
51
|
</div>
|
51
|
-
<div style='margin-top: 0; margin-bottom: auto;'>
|
52
|
+
<div style='margin-top: 0; padding: 10px; margin-bottom: auto;'>
|
52
53
|
<a href='assets/img/{{ example.name }}.png' data-lightbox='{{ example.name }}'>
|
53
|
-
<img src='assets/img/{{ example.name}}.png'/>
|
54
|
+
<img src='assets/img/{{ example.name}}.png' />
|
54
55
|
</a>
|
55
56
|
</div>
|
56
57
|
</div>
|
@@ -27,11 +27,11 @@ module RSyntaxTree
|
|
27
27
|
@color = params[:color]
|
28
28
|
@fontstyle = params[:fontstyle]
|
29
29
|
@polyline = params[:polyline]
|
30
|
-
@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"
|
30
|
+
@line_styles = "<line style='fill: none; stroke:#{@col_line}; stroke-width:#{@linewidth + LINE_SCALING}; stroke-linejoin:round; stroke-linecap:round;' x1='X1' y1='Y1' x2='X2' y2='Y2' />\n"
|
31
31
|
@polyline_styles = "<polyline style='stroke:#{@col_line}; stroke-width:#{@linewidth + LINE_SCALING}; fill:none; stroke-linejoin:round; stroke-linecap:round;'
|
32
32
|
points='CHIX CHIY MIDX1 MIDY1 MIDX2 MIDY2 PARX PARY' />\n"
|
33
33
|
@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"
|
34
|
-
@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"
|
34
|
+
@text_styles = "<text white-space='pre' alignment-baseline='text-top' style='fill: COLOR; storoke-width: 0; font-size: fontsize' x='X_VALUE' y='Y_VALUE'>CONTENT</text>\n"
|
35
35
|
@tree_data = String.new
|
36
36
|
@visited_x = {}
|
37
37
|
@visited_y = {}
|
@@ -183,7 +183,7 @@ module RSyntaxTree
|
|
183
183
|
when :bborder
|
184
184
|
stroke_width = @linewidth + BLINE_SCALING
|
185
185
|
end
|
186
|
-
@extra_lines << "<line style=\"stroke:#{col}; stroke-linecap:round; stroke-width:#{stroke_width}; \" x1=\"#{x1}\" y1=\"#{y1}\" x2=\"#{x2}\" y2=\"#{y2}\"></line>"
|
186
|
+
@extra_lines << "<line style=\"stroke:#{col}; fill:none; stroke-linecap:round; stroke-width:#{stroke_width}; \" x1=\"#{x1}\" y1=\"#{y1}\" x2=\"#{x2}\" y2=\"#{y2}\"></line>"
|
187
187
|
else
|
188
188
|
if element.enclosure == :brackets
|
189
189
|
this_x = txt_pos - element.content_width / 2
|
@@ -247,7 +247,8 @@ 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
|
250
|
+
# enc_y = this_y - e[:height] * 0.8 + FONT_SCALING
|
251
|
+
enc_y = this_y - e[:height] * 0.8
|
251
252
|
enc_width = e[:width]
|
252
253
|
enc_x = this_x
|
253
254
|
|
@@ -279,12 +280,12 @@ module RSyntaxTree
|
|
279
280
|
end
|
280
281
|
|
281
282
|
if e[:decoration].include?(:box)
|
282
|
-
enc = "<rect style='stroke: #{col}; stroke-linejoin:round; stroke-width:#{stroke_width};'
|
283
|
+
enc = "<rect style='fill: none; stroke: #{col}; stroke-linejoin:round; stroke-width:#{stroke_width};'
|
283
284
|
x='#{enc_x}' y='#{enc_y}'
|
284
285
|
width='#{enc_width}' height='#{enc_height}'
|
285
286
|
fill='#{fill}' />\n"
|
286
287
|
elsif e[:decoration].include?(:circle)
|
287
|
-
enc = "<rect style='stroke: #{col}; stroke-width:#{stroke_width};'
|
288
|
+
enc = "<rect style='fill: none; stroke: #{col}; stroke-width:#{stroke_width};'
|
288
289
|
x='#{enc_x}' y='#{enc_y}' rx='#{enc_height / 2}' ry='#{enc_height / 2}'
|
289
290
|
width='#{enc_width}' height='#{enc_height}'
|
290
291
|
fill='#{fill}' />\n"
|
@@ -294,7 +295,7 @@ module RSyntaxTree
|
|
294
295
|
x2 = enc_x + enc_width
|
295
296
|
y2 = y1
|
296
297
|
ar_hwidth = e[:width] / 4.0
|
297
|
-
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"
|
298
|
+
bar = "<line style='fill:none; stroke:#{col}; stroke-linejoin:round; stroke-linecap:round; stroke-width:#{stroke_width};' x1='#{x1 + stroke_width / 2}' y1='#{y1}' x2='#{x2 - stroke_width / 2}' y2='#{y2}'></line>\n"
|
298
299
|
@extra_lines << bar
|
299
300
|
|
300
301
|
if e[:decoration].include?(:arrow_to_l)
|
data/lib/rsyntaxtree/version.rb
CHANGED
data/lib/rsyntaxtree.rb
CHANGED
@@ -13,9 +13,22 @@ ETYPE_NODE = 1
|
|
13
13
|
ETYPE_LEAF = 2
|
14
14
|
SUBSCRIPT_CONST = 0.7
|
15
15
|
FONT_SCALING = 2
|
16
|
-
LINE_SCALING =
|
17
|
-
BLINE_SCALING =
|
16
|
+
LINE_SCALING = 1
|
17
|
+
BLINE_SCALING = 2
|
18
18
|
WHITESPACE_BLOCK = "■"
|
19
|
+
DEFAULT_OPTS = {
|
20
|
+
format: "png",
|
21
|
+
leafstyle: "auto",
|
22
|
+
fontstyle: "sans",
|
23
|
+
fontsize: 16,
|
24
|
+
linewidth: 1,
|
25
|
+
vheight: 2.0,
|
26
|
+
color: "modern",
|
27
|
+
symmetrize: "on",
|
28
|
+
transparent: "off",
|
29
|
+
polyline: "off",
|
30
|
+
hide_default_connectors: "off"
|
31
|
+
}.freeze
|
19
32
|
|
20
33
|
class RSTError < StandardError
|
21
34
|
def initialize(msg = "Error: something unexpected occurred")
|
@@ -117,21 +130,7 @@ module RSyntaxTree
|
|
117
130
|
end
|
118
131
|
|
119
132
|
# defaults to the following
|
120
|
-
@params =
|
121
|
-
symmetrize: true,
|
122
|
-
color: "modern",
|
123
|
-
transparent: false,
|
124
|
-
fontsize: 16,
|
125
|
-
linewidth: 2,
|
126
|
-
format: "png",
|
127
|
-
leafstyle: "auto",
|
128
|
-
filename: "syntree",
|
129
|
-
data: "",
|
130
|
-
vheight: 1.0,
|
131
|
-
polyline: false,
|
132
|
-
hide_default_connectors: false
|
133
|
-
}
|
134
|
-
|
133
|
+
@params = DEFAULT_OPTS.dup
|
135
134
|
@params.merge! new_params
|
136
135
|
@params[:fontsize] = @params[:fontsize] * FONT_SCALING
|
137
136
|
@params[:fontset] = fontset
|
@@ -170,6 +169,17 @@ module RSyntaxTree
|
|
170
169
|
raise RSTError, +"Error: the result syntree is too big"
|
171
170
|
end
|
172
171
|
|
172
|
+
def draw_pdf(filename)
|
173
|
+
svg = draw_svg
|
174
|
+
rsvg = RSVG::Handle.new_from_data(svg)
|
175
|
+
dim = rsvg.dimensions
|
176
|
+
surface = Cairo::PDFSurface.new(filename, dim.width, dim.height)
|
177
|
+
context = Cairo::Context.new(surface)
|
178
|
+
context.render_rsvg_handle(rsvg)
|
179
|
+
rescue Cairo::InvalidSize
|
180
|
+
raise RSTError, +"Error: the result syntree is too big"
|
181
|
+
end
|
182
|
+
|
173
183
|
def draw_svg
|
174
184
|
sp = StringParser.new(@params[:data].gsub('&', '&'), @params[:fontset], @params[:fontsize], @global)
|
175
185
|
sp.parse
|
@@ -177,17 +187,14 @@ module RSyntaxTree
|
|
177
187
|
graph.svg_data
|
178
188
|
end
|
179
189
|
|
190
|
+
# Currently not used
|
180
191
|
def draw_tree
|
181
192
|
svg = draw_svg
|
182
193
|
image, _data = Magick::Image.from_blob(svg) do |im|
|
183
194
|
im.format = 'svg'
|
184
195
|
end
|
185
|
-
|
186
|
-
|
187
|
-
else
|
188
|
-
image.to_blob do |im|
|
189
|
-
im.format = @params[:format].upcase
|
190
|
-
end
|
196
|
+
image.to_blob do |im|
|
197
|
+
im.format = @params[:format].upcase
|
191
198
|
end
|
192
199
|
image
|
193
200
|
end
|
data/test/example_verify_test.rb
CHANGED
@@ -15,19 +15,7 @@ class ExampleParserTest < Minitest::Test
|
|
15
15
|
config = YAML.load_file(md)
|
16
16
|
rst = File.read(md).scan(/```([^`]+)```/m).last.first
|
17
17
|
|
18
|
-
opts =
|
19
|
-
format: "png",
|
20
|
-
leafstyle: "auto",
|
21
|
-
fontstyle: "sans",
|
22
|
-
fontsize: 16,
|
23
|
-
linewidth: 1,
|
24
|
-
vheight: 2.0,
|
25
|
-
color: "on",
|
26
|
-
symmetrize: "on",
|
27
|
-
transparent: "off",
|
28
|
-
polyline: "off",
|
29
|
-
hide_default_connectors: "off"
|
30
|
-
}
|
18
|
+
opts = DEFAULT_OPTS.dup
|
31
19
|
name = nil
|
32
20
|
config.each do |key, value|
|
33
21
|
next if value.to_s == ""
|
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
|
+
version: 1.2.8
|
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-
|
11
|
+
date: 2023-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: optimist
|
@@ -161,6 +161,7 @@ files:
|
|
161
161
|
- docs/_examples/044.md
|
162
162
|
- docs/_examples/045.md
|
163
163
|
- docs/_examples/046.md
|
164
|
+
- docs/_examples/047.md
|
164
165
|
- docs/_includes/box_and_circle_table.html
|
165
166
|
- docs/_includes/escape_char_table.html
|
166
167
|
- docs/_includes/social_media_links.html
|
@@ -213,6 +214,13 @@ files:
|
|
213
214
|
- docs/assets/img/044.png
|
214
215
|
- docs/assets/img/045.png
|
215
216
|
- docs/assets/img/046.png
|
217
|
+
- docs/assets/img/047.png
|
218
|
+
- docs/assets/img/elements/arrow_both.png
|
219
|
+
- docs/assets/img/elements/arrow_both_bold.png
|
220
|
+
- docs/assets/img/elements/arrow_left.png
|
221
|
+
- docs/assets/img/elements/arrow_left_bold.png
|
222
|
+
- docs/assets/img/elements/arrow_right.png
|
223
|
+
- docs/assets/img/elements/arrow_right_bold.png
|
216
224
|
- docs/assets/img/elements/circle.png
|
217
225
|
- docs/assets/img/elements/circle_abc.png
|
218
226
|
- docs/assets/img/elements/circle_bold.png
|
@@ -276,6 +284,7 @@ files:
|
|
276
284
|
- docs/assets/svg/044.svg
|
277
285
|
- docs/assets/svg/045.svg
|
278
286
|
- docs/assets/svg/046.svg
|
287
|
+
- docs/assets/svg/047.svg
|
279
288
|
- docs/documentation.md
|
280
289
|
- docs/documentation_ja.md
|
281
290
|
- docs/examples.html
|
@@ -332,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
332
341
|
- !ruby/object:Gem::Version
|
333
342
|
version: '0'
|
334
343
|
requirements: []
|
335
|
-
rubygems_version: 3.
|
344
|
+
rubygems_version: 3.4.2
|
336
345
|
signing_key:
|
337
346
|
specification_version: 4
|
338
347
|
summary: RSyntaxTree is a graphical syntax tree generator written in Ruby
|