rsyntaxtree 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.tags +8 -0
- data/README.md +35 -28
- data/bin/rsyntaxtree +4 -0
- data/img/elements/circle.png +0 -0
- data/img/elements/circle_abc.png +0 -0
- data/img/elements/circle_bold.png +0 -0
- data/img/elements/circle_hatched.png +0 -0
- data/img/elements/circle_one.png +0 -0
- data/img/elements/connector.png +0 -0
- data/img/elements/connector_bold.png +0 -0
- data/img/elements/square.png +0 -0
- data/img/elements/square_abc.png +0 -0
- data/img/elements/square_bold.png +0 -0
- data/img/elements/square_hatched.png +0 -0
- data/img/elements/square_one.png +0 -0
- data/img/rsyntaxtree.png +0 -0
- data/img/sample.png +0 -0
- data/img/sample.svg +38 -0
- data/lib/rsyntaxtree/svg_graph.rb +34 -8
- data/lib/rsyntaxtree/version.rb +1 -1
- data/lib/rsyntaxtree.rb +2 -1
- metadata +16 -3
- data/syntree.png +0 -0
- data/syntree.svg +0 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82885cdb8bb5fac82224d762cf2244ad8e5c5400d96ffd2f4857f16ad7293827
|
4
|
+
data.tar.gz: 5c00b9970c323030cc0ea9a5e9db35e83bc34ecbe82501e022d2ec1b957b0182
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92e0e77a86d01b0c366c9bfd769349652b6773c61937ddc24e9097fe282e76a90d9de91ee931ee73bb1af49535887385e23d10e2d466a47f22abaa6299d6fcdb
|
7
|
+
data.tar.gz: ba0163a1abe6d56c26a82dd5a9e13e85a03f23d5119aed67e32913d99a61e08f1b42889b4b18de3e92add60e64ad52cd2b67451c697d3d2c638b1ab15150146f
|
data/.tags
CHANGED
@@ -108,13 +108,18 @@ iterator= lib/rsyntaxtree/elementlist.rb /^ attr_accessor :elements, :iterato
|
|
108
108
|
level lib/rsyntaxtree/string_parser.rb /^ attr_accessor :data, :elist, :pos, :id, :level$/;" A class:RSyntaxTree.StringParser
|
109
109
|
level= lib/rsyntaxtree/string_parser.rb /^ attr_accessor :data, :elist, :pos, :id, :level$/;" A class:RSyntaxTree.StringParser
|
110
110
|
line_to_parent lib/rsyntaxtree/svg_graph.rb /^ def line_to_parent(parent, child)$/;" f class:RSyntaxTree.SVGGraph
|
111
|
+
line_to_parent lib/rsyntaxtree/svg_graph.rb /^ def line_to_parent(parent, child)$/;" f class:RSyntaxTree
|
112
|
+
line_to_parent2 lib/rsyntaxtree/svg_graph.rb /^ def line_to_parent2(parent, child)$/;" f class:RSyntaxTree.SVGGraph
|
111
113
|
make_balance lib/rsyntaxtree/base_graph.rb /^ def make_balance(id = 1)$/;" f class:RSyntaxTree.BaseGraph
|
112
114
|
make_tree lib/rsyntaxtree/string_parser.rb /^ def make_tree(parent)$/;" f class:RSyntaxTree.StringParser
|
115
|
+
monoline_to_parent lib/rsyntaxtree/svg_graph.rb /^ def monoline_to_parent(parent, child)$/;" f class:RSyntaxTree.SVGGraph
|
113
116
|
node_centering lib/rsyntaxtree/base_graph.rb /^ def node_centering$/;" f class:RSyntaxTree.BaseGraph
|
114
117
|
parse lib/rsyntaxtree/markup_parser.rb /^ def parse(txt)$/;" f class:Markup
|
115
118
|
parse lib/rsyntaxtree/markup_parser.rb /^ def parse(txt)$/;" f module:Markup
|
116
119
|
parse lib/rsyntaxtree/string_parser.rb /^ def parse$/;" f class:RSyntaxTree.StringParser
|
117
120
|
parse_list lib/rsyntaxtree/base_graph.rb /^ def parse_list$/;" f class:RSyntaxTree.BaseGraph
|
121
|
+
polyline_to_parent lib/rsyntaxtree/svg_graph.rb /^ def polyline_to_parent(parent, child)$/;" f class:RSyntaxTree.SVGGraph
|
122
|
+
polyline_to_parent lib/rsyntaxtree/svg_graph.rb /^ def polyline_to_parent(parent, child)$/;" f class:RSyntaxTree.SVGGraph.line_to_parent
|
118
123
|
pos lib/rsyntaxtree/string_parser.rb /^ attr_accessor :data, :elist, :pos, :id, :level$/;" A class:RSyntaxTree.StringParser
|
119
124
|
pos= lib/rsyntaxtree/string_parser.rb /^ attr_accessor :data, :elist, :pos, :id, :level$/;" A class:RSyntaxTree.StringParser
|
120
125
|
rsyntaxtree rsyntaxtree.gemspec /^ s.name = "rsyntaxtree"$/;" g
|
@@ -164,6 +169,9 @@ test_rule_triangle test/markup_parser_test.rb /^ def test_rule_triangle$/;" f c
|
|
164
169
|
test_rule_underline test/markup_parser_test.rb /^ def test_rule_underline$/;" f
|
165
170
|
test_rule_underline test/markup_parser_test.rb /^ def test_rule_underline$/;" f class:MarkupParserTest
|
166
171
|
triangle_to_parent lib/rsyntaxtree/svg_graph.rb /^ def triangle_to_parent(parent, child)$/;" f class:RSyntaxTree.SVGGraph
|
172
|
+
triangle_to_parent lib/rsyntaxtree/svg_graph.rb /^ def triangle_to_parent(parent, child)$/;" f class:RSyntaxTree.SVGGraph.line_to_parent
|
173
|
+
triangle_to_parent lib/rsyntaxtree/svg_graph.rb /^ def triangle_to_parent(parent, child)$/;" f class:RSyntaxTree
|
174
|
+
triangle_to_parent2 lib/rsyntaxtree/svg_graph.rb /^ def triangle_to_parent2(parent, child)$/;" f class:RSyntaxTree.SVGGraph
|
167
175
|
valid lib/rsyntaxtree/string_parser.rb /^ def self.valid?(data)$/;" F class:RSyntaxTree.StringParser
|
168
176
|
valid? lib/rsyntaxtree/string_parser.rb /^ def self.valid?(data)$/;" S class:RSyntaxTree.StringParser
|
169
177
|
width lib/rsyntaxtree/svg_graph.rb /^ attr_accessor :width, :height$/;" A class:RSyntaxTree.SVGGraph
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# 🌲 RSyntaxTree
|
1
|
+
# 🌲 RSyntaxTree
|
2
2
|
|
3
3
|
**RSyntaxTree** is a graphical syntax tree generator written in the Ruby programming language inspired by [phpSyntaxTree](http://ironcreek.net/phpsyntaxtree/).
|
4
4
|
|
@@ -17,50 +17,57 @@ For the web interface, see Usage section of <https://yohasebe.com/rsyntaxtree>.
|
|
17
17
|
For the command-line interface, type `$rsyntaxtree -h` after installation. Here's what you get:
|
18
18
|
|
19
19
|
```text
|
20
|
-
|
20
|
+
SyntaxTree, (linguistic) syntax tree generator written in Ruby.
|
21
21
|
|
22
22
|
Usage:
|
23
23
|
rsyntaxtree [options] "[VP [VP [V set] [NP bracket notation]] [ADV here]]"
|
24
24
|
where [options] are:
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
25
|
+
-o, --outdir=<s> Output directory (default: ./)
|
26
|
+
-f, --format=<s> Output format: png, gif, jpg, pdf, or svg (default: png)
|
27
|
+
-l, --leafstyle=<s> visual style of tree leaves: auto, triangle, bar, or nothing (default: auto)
|
28
|
+
-n, --fontstyle=<s> Font style (available when ttf font is specified): sans, serif, cjk (default: sans)
|
29
|
+
-t, --font=<s> Path to a ttf font used to generate tree (optional)
|
30
|
+
-s, --fontsize=<i> Size: 8-26 (default: 16)
|
31
|
+
-m, --margin=<i> Margin: 0-10 (default: 1)
|
32
|
+
-v, --vheight=<f> Connector Height: 0.5-5.0 (default: 2.0)
|
33
|
+
-c, --color=<s> Color text and bars: on or off (default: on)
|
34
|
+
-y, --symmetrize=<s> Generate radically symmetrical, balanced tree: on or off (default: off)
|
35
|
+
-r, --transparent=<s> Make background transparent: on or off (default: off)
|
36
|
+
-p, --polyline=<s> draw polyline connectors: on or off (default: off)
|
37
|
+
-e, --version Print version and exit
|
38
|
+
-h, --help Show this message```
|
37
39
|
```
|
38
40
|
|
39
|
-
|
40
|
-
|
41
|
-
Every branch or leaf of a tree must belong to a node. To create a node, place a label right next to the opening bracket. Arbitrary number of branches can follow with a preceding space.
|
42
|
-
|
43
|
-
There are several modes in which the connectors between terminal nodes and their leaves are drawn differently (auto, triangle, bar, and nothing). In auto mode, a triangle is used if the leaf contains one or more spaces inside (i.e. if it’s a phrase), but if it contains no spaces (i.e. if it is just a word), a straight bar will be drawn instead (unless the leaf contains a "^" symbol at the end which makes it a single-word phrase).
|
44
|
-
|
45
|
-
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>
|
46
|
-
|
47
|
-
See https://yohasebe.com/rsyntaxtree for more detailed info about the syntax.
|
41
|
+
See [the documentation](https://yohasebe.com/rsyntaxtree/#documentation) for more detailed info about the syntax.
|
48
42
|
|
49
43
|
### Example
|
50
44
|
|
51
|
-
|
45
|
+
**Input text**
|
52
46
|
|
53
47
|
```text
|
54
|
-
[S
|
48
|
+
[S
|
49
|
+
[NP |R|<>SyntaxTree]
|
50
|
+
[VP
|
51
|
+
[V generates]
|
52
|
+
[NP
|
53
|
+
[Adj #\+multilingual\
|
54
|
+
\+beautiful]
|
55
|
+
[NP syntax\
|
56
|
+
trees]
|
57
|
+
]
|
58
|
+
]
|
59
|
+
]
|
55
60
|
```
|
56
61
|
|
57
|
-
|
62
|
+
**Output (PNG or SVG)**
|
63
|
+
|
64
|
+
<img src='https://github.com/yohasebe/rsyntaxtree/blob/master/img/sample.png?raw=true' width='600' />
|
58
65
|
|
59
|
-
|
66
|
+
See [RSyntaxTree Examples](https://yohasebe.notion.site/yohasebe/RSyntaxTree-Examples-006baf3ac6e84e7193b538a5bf02ad07) for more examples
|
60
67
|
|
61
68
|
### Development
|
62
69
|
|
63
|
-
For the latest updates and downloads please visit http://github.com/yohasebe/rsyntaxtree
|
70
|
+
For the latest updates and downloads please visit <http://github.com/yohasebe/rsyntaxtree>
|
64
71
|
|
65
72
|
### Author
|
66
73
|
|
data/bin/rsyntaxtree
CHANGED
@@ -38,6 +38,8 @@ EOS
|
|
38
38
|
:default => "off"
|
39
39
|
opt :transparent, "Make background transparent: on or off",
|
40
40
|
:default => "off"
|
41
|
+
opt :polyline, "draw polyline connectors: on or off",
|
42
|
+
:default => "off"
|
41
43
|
end
|
42
44
|
|
43
45
|
Optimist::die :outdir, "must be an exsting directory path" unless FileTest::directory?(opts[:outdir])
|
@@ -51,6 +53,7 @@ Optimist::die :symmetrize, "must be either on or off" unless /\A(on|off|true|fal
|
|
51
53
|
Optimist::die :margin, "must be in the range of 0-10" if opts[:margin] < 0 || opts[:margin] > 10
|
52
54
|
Optimist::die :vheight, "must be in the range of 0.5-5.0" if opts[:vheight] < 0.5 || opts[:vheight] > 5.0
|
53
55
|
Optimist::die :transparent, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:transparent]
|
56
|
+
Optimist::die :polyline, "must be either on or off" unless /\A(on|off|true|false)\z/ =~ opts[:polyline]
|
54
57
|
|
55
58
|
string_opts = {}
|
56
59
|
opts.each do |key, value|
|
@@ -88,6 +91,7 @@ rescue RSTError => e
|
|
88
91
|
puts e
|
89
92
|
exit
|
90
93
|
rescue => e
|
94
|
+
p e
|
91
95
|
puts "Error: something unexpected occurred"
|
92
96
|
exit
|
93
97
|
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/img/rsyntaxtree.png
ADDED
Binary file
|
data/img/sample.png
ADDED
Binary file
|
data/img/sample.svg
ADDED
@@ -0,0 +1,38 @@
|
|
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="1211.119140625" height="941.0" viewBox="-40, -40, 1251.119140625, 981.0" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
4
|
+
<defs>
|
5
|
+
<marker id="arrow" markerUnits="strokeWidth" markerWidth="7.823437500000001" markerHeight="7.823437500000001" viewBox="0 0 7.823437500000001 7.823437500000001" refX="3.9117187500000004" refY="0">
|
6
|
+
<polyline fill="none" stroke="purple" stroke-width="1" points="0,7.823437500000001,3.9117187500000004,0,7.823437500000001,7.823437500000001" />
|
7
|
+
</marker>
|
8
|
+
</defs>
|
9
|
+
<rect x="-40" y="-40" width="1251.119140625" height="981.0" stroke="none" fill="white" />"
|
10
|
+
<text white-space='pre' alignment-baseline='text-top' style='fill: blue; font-size: 40px;' x='418.73779296875' y='70.0'><tspan x='418.73779296875' y='70.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">S</tspan></text>
|
11
|
+
<text white-space='pre' alignment-baseline='text-top' style='fill: blue; font-size: 40px;' x='136.2080078125' y='254.0'><tspan x='136.2080078125' y='254.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">NP</tspan></text>
|
12
|
+
<text white-space='pre' alignment-baseline='text-top' style='fill: green; font-size: 40px;' x='19.55859375' y='438.0'><tspan x='33.81640625' y='438.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">R</tspan><tspan x='90.857421875' y='438.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">SyntaxTree</tspan></text>
|
13
|
+
<text white-space='pre' alignment-baseline='text-top' style='fill: blue; font-size: 40px;' x='670.267578125' y='254.0'><tspan x='670.267578125' y='254.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">VP</tspan></text>
|
14
|
+
<text white-space='pre' alignment-baseline='text-top' style='fill: blue; font-size: 40px;' x='465.091796875' y='438.0'><tspan x='465.091796875' y='438.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">V</tspan></text>
|
15
|
+
<text white-space='pre' alignment-baseline='text-top' style='fill: green; font-size: 40px;' x='386.091796875' y='622.0'><tspan x='386.091796875' y='622.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">generates</tspan></text>
|
16
|
+
<text white-space='pre' alignment-baseline='text-top' style='fill: blue; font-size: 40px;' x='885.443359375' y='438.0'><tspan x='885.443359375' y='438.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">NP</tspan></text>
|
17
|
+
<text white-space='pre' alignment-baseline='text-top' style='fill: blue; font-size: 40px;' x='745.326171875' y='622.0'><tspan x='745.326171875' y='622.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">Adj</tspan></text>
|
18
|
+
<text white-space='pre' alignment-baseline='text-top' style='fill: green; font-size: 40px;' x='649.326171875' y='806.0'><tspan x='649.326171875' y='806.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">+multilingual</tspan><tspan x='649.326171875' y='861.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">+beautiful</tspan></text>
|
19
|
+
<text white-space='pre' alignment-baseline='text-top' style='fill: blue; font-size: 40px;' x='1020.560546875' y='622.0'><tspan x='1020.560546875' y='622.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">NP</tspan></text>
|
20
|
+
<text white-space='pre' alignment-baseline='text-top' style='fill: green; font-size: 40px;' x='984.560546875' y='806.0'><tspan x='984.560546875' y='806.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">syntax</tspan><tspan x='1001.560546875' y='861.0' style="" text-decoration="" font-family="'Noto Serif', 'Noto Serif JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', serif">trees</tspan></text>
|
21
|
+
<line style='stroke:black; stroke-width:2;' x1='163.7080078125' y1='184.0' x2='429.73779296875' y2='93.0' />
|
22
|
+
<line style='stroke:black; stroke-width:2;' x1='695.767578125' y1='184.0' x2='429.73779296875' y2='93.0' />
|
23
|
+
<polygon style='fill: none; stroke: black; stroke-width:2;' points='19.55859375 368.0 307.857421875 368.0 163.7080078125 277.0' />
|
24
|
+
<line style='stroke:black; stroke-width:2;' x1='478.591796875' y1='368.0' x2='695.767578125' y2='277.0' />
|
25
|
+
<line style='stroke:black; stroke-width:2;' x1='912.943359375' y1='368.0' x2='695.767578125' y2='277.0' />
|
26
|
+
<line style='stroke:black; stroke-width:2;' x1='478.591796875' y1='552.0' x2='478.591796875' y2='461.0' />
|
27
|
+
<line style='stroke:black; stroke-width:2;' x1='777.826171875' y1='552.0' x2='912.943359375' y2='461.0' />
|
28
|
+
<line style='stroke:black; stroke-width:2;' x1='1048.060546875' y1='552.0' x2='912.943359375' y2='461.0' />
|
29
|
+
<line style='stroke:black; stroke-width:2;' x1='777.826171875' y1='736.0' x2='777.826171875' y2='645.0' />
|
30
|
+
<line style='stroke:black; stroke-width:2;' x1='1048.060546875' y1='736.0' x2='1048.060546875' y2='645.0' />
|
31
|
+
<rect style='fill: none; stroke: green; stroke-width:2;' x='19.55859375' y='396.0' width='55.0' height='53.0' />
|
32
|
+
|
33
|
+
<line x1='639.546875' y1='743.0' x2='649.326171875' y2='743.0' style='fill: none; stroke: green; stroke-width:2' />
|
34
|
+
<line x1='639.546875' y1='743.0' x2='639.546875' y2='891.0' style='fill: none; stroke: green; stroke-width:2' />
|
35
|
+
<line x1='639.546875' y1='891.0' x2='649.326171875' y2='891.0' style='fill: none; stroke: green; stroke-width:2' />
|
36
|
+
<line x1='916.10546875' y1='743.0' x2='906.326171875' y2='743.0' style='fill: none; stroke: green; stroke-width:2' />
|
37
|
+
<line x1='916.10546875' y1='743.0' x2='916.10546875' y2='891.0' style='fill: none; stroke: green; stroke-width:2' />
|
38
|
+
<line x1='916.10546875' y1='891.0' x2='906.326171875' y2='891.0' style='fill: none; stroke: green; stroke-width:2' /></svg>
|
@@ -26,7 +26,10 @@ module RSyntaxTree
|
|
26
26
|
@color = params[:color]
|
27
27
|
@fontstyle = params[:fontstyle]
|
28
28
|
@margin = params[:margin].to_i
|
29
|
+
@polyline = params[:polyline]
|
29
30
|
@line_styles = "<line style='stroke:black; stroke-width:#{FONT_SCALING};' x1='X1' y1='Y1' x2='X2' y2='Y2' />\n"
|
31
|
+
@polyline_styles = "<polyline style='stroke:black; stroke-width:#{FONT_SCALING}; fill:none;'
|
32
|
+
points='CHIX CHIY MIDX1 MIDY1 MIDX2 MIDY2 PARX PARY' />\n"
|
30
33
|
@polygon_styles = "<polygon style='fill: none; stroke: black; stroke-width:#{FONT_SCALING};' points='X1 Y1 X2 Y2 X3 Y3' />\n"
|
31
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"
|
32
35
|
@tree_data = String.new
|
@@ -475,15 +478,38 @@ EOD
|
|
475
478
|
return
|
476
479
|
end
|
477
480
|
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
481
|
+
if @polyline
|
482
|
+
chi_x = child.horizontal_indent + child.content_width / 2
|
483
|
+
chi_y = child.vertical_indent + $height_connector_to_text / 2
|
484
|
+
|
485
|
+
par_x = parent.horizontal_indent + parent.content_width / 2
|
486
|
+
par_y = parent.vertical_indent + parent.content_height + $height_connector_to_text
|
487
|
+
|
488
|
+
mid_x1 = chi_x
|
489
|
+
mid_y1 = par_y + (chi_y - par_y) / 2
|
482
490
|
|
483
|
-
|
484
|
-
|
485
|
-
|
486
|
-
|
491
|
+
mid_x2 = par_x
|
492
|
+
mid_y2 = mid_y1
|
493
|
+
|
494
|
+
@tree_data += @polyline_styles.sub(/CHIX/, chi_x.to_s)
|
495
|
+
.sub(/CHIY/, chi_y.to_s)
|
496
|
+
.sub(/MIDX1/, mid_x1.to_s)
|
497
|
+
.sub(/MIDY1/, mid_y1.to_s)
|
498
|
+
.sub(/MIDX2/, mid_x2.to_s)
|
499
|
+
.sub(/MIDY2/, mid_y2.to_s)
|
500
|
+
.sub(/PARX/, par_x.to_s)
|
501
|
+
.sub(/PARY/, par_y.to_s)
|
502
|
+
else
|
503
|
+
x1 = child.horizontal_indent + child.content_width / 2
|
504
|
+
y1 = child.vertical_indent + $height_connector_to_text / 2
|
505
|
+
x2 = parent.horizontal_indent + parent.content_width / 2
|
506
|
+
y2 = parent.vertical_indent + parent.content_height + $height_connector_to_text
|
507
|
+
|
508
|
+
line_data = @line_styles.sub(/X1/, x1.to_s)
|
509
|
+
line_data = line_data.sub(/Y1/, y1.to_s)
|
510
|
+
line_data = line_data.sub(/X2/, x2.to_s)
|
511
|
+
@tree_data += line_data.sub(/Y2/, y2.to_s)
|
512
|
+
end
|
487
513
|
end
|
488
514
|
|
489
515
|
# Draw a triangle between child/parent elements
|
data/lib/rsyntaxtree/version.rb
CHANGED
data/lib/rsyntaxtree.rb
CHANGED
@@ -55,7 +55,7 @@ module RSyntaxTree
|
|
55
55
|
.gsub('-CABRACKET-', '>')
|
56
56
|
new_params[key] = data
|
57
57
|
|
58
|
-
when :symmetrize, :color, :transparent
|
58
|
+
when :symmetrize, :color, :transparent, :polyline
|
59
59
|
new_params[key] = value && (value != "off" && value != "false") ? true : false
|
60
60
|
when :fontsize
|
61
61
|
new_params[key] = value.to_i * FONT_SCALING
|
@@ -109,6 +109,7 @@ module RSyntaxTree
|
|
109
109
|
:data => "",
|
110
110
|
:margin => 0,
|
111
111
|
:vheight => 1.0,
|
112
|
+
:polyline => false,
|
112
113
|
}
|
113
114
|
|
114
115
|
@params.merge! new_params
|
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.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yoichiro Hasebe
|
@@ -108,6 +108,21 @@ files:
|
|
108
108
|
- fonts/OpenMoji-Black.ttf
|
109
109
|
- fonts/OpenMoji-Color.ttf
|
110
110
|
- fonts/wqy-zenhei.ttf
|
111
|
+
- img/elements/circle.png
|
112
|
+
- img/elements/circle_abc.png
|
113
|
+
- img/elements/circle_bold.png
|
114
|
+
- img/elements/circle_hatched.png
|
115
|
+
- img/elements/circle_one.png
|
116
|
+
- img/elements/connector.png
|
117
|
+
- img/elements/connector_bold.png
|
118
|
+
- img/elements/square.png
|
119
|
+
- img/elements/square_abc.png
|
120
|
+
- img/elements/square_bold.png
|
121
|
+
- img/elements/square_hatched.png
|
122
|
+
- img/elements/square_one.png
|
123
|
+
- img/rsyntaxtree.png
|
124
|
+
- img/sample.png
|
125
|
+
- img/sample.svg
|
111
126
|
- lib/rsyntaxtree.rb
|
112
127
|
- lib/rsyntaxtree/base_graph.rb
|
113
128
|
- lib/rsyntaxtree/element.rb
|
@@ -118,8 +133,6 @@ files:
|
|
118
133
|
- lib/rsyntaxtree/utils.rb
|
119
134
|
- lib/rsyntaxtree/version.rb
|
120
135
|
- rsyntaxtree.gemspec
|
121
|
-
- syntree.png
|
122
|
-
- syntree.svg
|
123
136
|
- test/markup_parser_test.rb
|
124
137
|
homepage: http://github.com/yohasebe/rsyntaxtree
|
125
138
|
licenses:
|
data/syntree.png
DELETED
Binary file
|
data/syntree.svg
DELETED
@@ -1,24 +0,0 @@
|
|
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="722.4" height="471.2" viewBox="-20, -20, 742.4, 491.2" version="1.1" xmlns="http://www.w3.org/2000/svg">
|
4
|
-
<defs>
|
5
|
-
<marker id="arrow" markerUnits="strokeWidth" markerWidth="12.160000000000002" markerHeight="12.160000000000002" viewBox="0 0 12.160000000000002 12.160000000000002" refX="6.080000000000001" refY="0">
|
6
|
-
<polyline fill="none" stroke="purple" stroke-width="1" points="0,12.160000000000002,6.080000000000001,0,12.160000000000002,12.160000000000002" />
|
7
|
-
</marker>
|
8
|
-
<pattern id="hatchBlack" x="10" y="10" width="10" height="10" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
|
9
|
-
<line x1="0" y="0" x2="0" y2="10" stroke="black" stroke-width="4"></line>
|
10
|
-
</pattern>
|
11
|
-
<pattern id="hatchForNode" x="10" y="10" width="10" height="10" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
|
12
|
-
<line x1="0" y="0" x2="0" y2="10" stroke="blue" stroke-width="4"></line>
|
13
|
-
</pattern>
|
14
|
-
<pattern id="hatchForLeaf" x="10" y="10" width="10" height="10" patternUnits="userSpaceOnUse" patternTransform="rotate(45)">
|
15
|
-
<line x1="0" y="0" x2="0" y2="10" stroke="green" stroke-width="4"></line>
|
16
|
-
</pattern>
|
17
|
-
</defs>
|
18
|
-
<rect x="-20" y="-20" width="742.4" height="491.2" stroke="none" fill="white" />"
|
19
|
-
<text white-space='pre' alignment-baseline='text-top' style='fill: blue; font-size: 64px;' x='319.4' y='132.0'><tspan x='319.4' y='132.0' style="" text-decoration="" font-family="'Noto Sans', 'Noto Sans JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', sans-serif">%X</tspan>
|
20
|
-
</text>
|
21
|
-
<text white-space='pre' alignment-baseline='text-top' style='fill: green; font-size: 64px;' x='30.399999999999977' y='431.2'><tspan x='30.399999999999977' y='431.2' style="" text-decoration="" font-family="'Noto Sans', 'Noto Sans JP', OpenMoji, 'OpenMoji Color', 'OpenMoji Black', sans-serif">%Yxxxxxxxxxxxxxxxxx</tspan>
|
22
|
-
</text>
|
23
|
-
<line style='stroke:black; stroke-width:2;' x1='356.4' y1='321.2' x2='356.4' y2='187.0' />
|
24
|
-
</svg>
|