rsyntaxtree 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/.tags +438 -12
  3. data/README.md +75 -35
  4. data/bin/rsyntaxtree +4 -1
  5. data/docs/.gitignore +5 -0
  6. data/docs/404.html +25 -0
  7. data/docs/Gemfile +31 -0
  8. data/docs/_config.yml +77 -0
  9. data/docs/_examples/001.md +22 -0
  10. data/docs/_examples/002.md +31 -0
  11. data/docs/_examples/003.md +25 -0
  12. data/docs/_examples/004.md +25 -0
  13. data/docs/_examples/005.md +22 -0
  14. data/docs/_examples/006.md +25 -0
  15. data/docs/_examples/007.md +26 -0
  16. data/docs/_examples/008.md +28 -0
  17. data/docs/_examples/009.md +24 -0
  18. data/docs/_examples/010.md +48 -0
  19. data/docs/_examples/011.md +37 -0
  20. data/docs/_examples/012.md +40 -0
  21. data/docs/_examples/013.md +62 -0
  22. data/docs/_examples/014.md +47 -0
  23. data/docs/_examples/015.md +30 -0
  24. data/docs/_examples/016.md +82 -0
  25. data/docs/_examples/017.md +22 -0
  26. data/docs/_examples/018.md +28 -0
  27. data/docs/_examples/019.md +59 -0
  28. data/docs/_examples/020.md +39 -0
  29. data/docs/_includes/box_and_circle_table.html +54 -0
  30. data/docs/_includes/escape_char_table.html +28 -0
  31. data/docs/_includes/social_media_links.html +13 -0
  32. data/docs/_layouts/default.html +43 -0
  33. data/docs/assets/css/style.scss +25 -0
  34. data/docs/assets/img/001.png +0 -0
  35. data/docs/assets/img/002.png +0 -0
  36. data/docs/assets/img/003.png +0 -0
  37. data/docs/assets/img/004.png +0 -0
  38. data/docs/assets/img/005.png +0 -0
  39. data/docs/assets/img/006.png +0 -0
  40. data/docs/assets/img/007.png +0 -0
  41. data/docs/assets/img/008.png +0 -0
  42. data/docs/assets/img/009.png +0 -0
  43. data/docs/assets/img/010.png +0 -0
  44. data/docs/assets/img/011.png +0 -0
  45. data/docs/assets/img/012.png +0 -0
  46. data/docs/assets/img/013.png +0 -0
  47. data/docs/assets/img/014.png +0 -0
  48. data/docs/assets/img/015.png +0 -0
  49. data/docs/assets/img/016.png +0 -0
  50. data/docs/assets/img/017.png +0 -0
  51. data/docs/assets/img/018.png +0 -0
  52. data/docs/assets/img/019.png +0 -0
  53. data/docs/assets/img/020.png +0 -0
  54. data/docs/assets/img/elements/circle.png +0 -0
  55. data/docs/assets/img/elements/circle_abc.png +0 -0
  56. data/docs/assets/img/elements/circle_bold.png +0 -0
  57. data/docs/assets/img/elements/circle_hatched.png +0 -0
  58. data/docs/assets/img/elements/circle_one.png +0 -0
  59. data/docs/assets/img/elements/connector.png +0 -0
  60. data/docs/assets/img/elements/connector_bold.png +0 -0
  61. data/docs/assets/img/elements/square.png +0 -0
  62. data/docs/assets/img/elements/square_abc.png +0 -0
  63. data/docs/assets/img/elements/square_bold.png +0 -0
  64. data/docs/assets/img/elements/square_hatched.png +0 -0
  65. data/docs/assets/img/elements/square_one.png +0 -0
  66. data/docs/assets/img/favicon/apple-touch-icon.png +0 -0
  67. data/docs/assets/img/favicon/favicon-16x16.png +0 -0
  68. data/docs/assets/img/favicon/favicon-32x32.png +0 -0
  69. data/docs/assets/img/favicon/favicon.ico +0 -0
  70. data/docs/documentation.md +153 -0
  71. data/docs/documentation_ja.md +166 -0
  72. data/docs/examples.html +68 -0
  73. data/docs/index.html +2 -0
  74. data/img/rsyntaxtree-web-screenshot.png +0 -0
  75. data/img/rsyntaxtree.png +0 -0
  76. data/img/sample.png +0 -0
  77. data/img/sample.svg +38 -0
  78. data/lib/rsyntaxtree/svg_graph.rb +34 -8
  79. data/lib/rsyntaxtree/version.rb +1 -1
  80. data/lib/rsyntaxtree.rb +4 -1
  81. data/rsyntaxtree.gemspec +1 -1
  82. metadata +77 -6
  83. data/syntree.png +0 -0
  84. data/syntree.svg +0 -24
@@ -0,0 +1,153 @@
1
+ ---
2
+ title: RSyntaxTree
3
+ layout: default
4
+ ---
5
+
6
+ # Documentation
7
+ {:.no_toc}
8
+
9
+ [English](https://yohasebe.github.io/rsyntaxtree/documentation) |
10
+ [日本語](https://yohasebe.github.io/rsyntaxtree/documentation_ja)
11
+
12
+ ### Table of Contents
13
+ {:.no_toc}
14
+
15
+ 1. toc
16
+ {:toc}
17
+
18
+ ### Basic Usage
19
+
20
+ Type your text in the editor area using labeled bracket notation and click the Draw PNG or Draw SVG button.
21
+
22
+ Every branch or leaf of the syntax tree must belong to a node. To create a node, place the label text right next to the start bracket. Any number of branches may follow, separated by a whitespace. (Node labels containing whitespaces can be created using the `<>` symbol. For example, `Modal<>Aux` will be rendered as `Modal Aux`).
23
+
24
+ There are three different types of `connector` drawn between a terminal node and its leaves (`auto`, `bar` and `none`). `auto` draws a triangle for leaves containing one or more whitespaces (= phrases). If the leaf does not contain any spaces (= single word), a straight bar is drawn instead (unless the leaf contains a `^` symbol at the beginning, which specifies the leaf to be a phrase).
25
+
26
+ The newline character `\n` can be used within the text of both node lables and leaves.
27
+
28
+ RSyntaxTree can generate `PNG` and `SVG`, SVG can be used with third party vector graphics software such as Adobe Illustrator, Microsoft Visio, [BOXY SVG](https://boxy-svg.com/), etc. It is very useful if you want to modify the output image.
29
+
30
+ The `Radical symmetrization` option affects the way branch nodes are drawn. The options `Font style`, `Font size`, `Connector height`, and `Color` need no explanation. By changing the values of these options, you can change the appearance of the resulting image.
31
+
32
+ ### Fonts Used to Generate PNG
33
+
34
+ Currently, you can choose between the font styles `Noto Sans`, `Noto Serif`, and `WQY Zen Hei`.
35
+
36
+ - `Noto Sans` can display basic Unicode characters (including Japanese hiragana/katakana/kanji).
37
+ - `Noto Serif` can display basic Unicode characters (including Japanese hiragana/katakana/kanji).
38
+ - `WQY Zen Hei` can display a wide range of Chinese/Japanese/Korean (CJK) characters.
39
+
40
+
41
+ ### Install Fonts for SVG
42
+
43
+ SVG images are dependent on the fonts installed locally on your computer. In order for the images to display as intended, the following fonts should be installed beforehand (click on the links). If these fonts are not installed, other available fonts will be used, resulting in a somewhat unbalanced display of the text.
44
+
45
+ - [Noto Sans](https://fonts.google.com/noto/specimen/Noto+Sans): for latin and other basic Unicode characters in sans serif
46
+ - [Noto Sans JP](https://fonts.google.com/noto/specimen/Noto+Sans+JP): for Japanese characters in sans serif
47
+ - [Noto Serif](https://fonts.google.com/noto/specimen/Noto+Serif): for latin and other basic Unicode characters in serif
48
+ - [Noto Serif JP](https://fonts.google.com/noto/specimen/Noto+Serif+JP): for Japanese characters in serif
49
+ - [WQY Zen Hei](https://packages.ubuntu.com/bionic/fonts/fonts-wqy-zenhei): for CJK characters
50
+ - [OpenMoji](https://openmoji.org/): for emoji characters.
51
+
52
+
53
+ ### Font Styles, Text Decoration, and Sub/Superscripts
54
+
55
+ You can apply font styles (italic/bold/bold-italic), text decoration (overline/underline/line-through), subscript/superscript font rendering, and more. These markups can be nested within each other.
56
+
57
+ #### Font Styles
58
+
59
+ |Style |Symbol |Sample Input |Output |
60
+ |-----------|------------|-------------------|-----------------|
61
+ |Italic |`*TEXT*` |`*italic*` |*italic* |
62
+ |Bold |`**TEXT**` |`**bold**` |**bold** |
63
+ |Italic+bold|`***TEXT***`|`***italic bold***`|***italic bold***|
64
+
65
+ #### Text Decoration
66
+
67
+ |Decoration |Symbol |Sample Input |Output |
68
+ |------------|--------|---------------|-------------------------------------------------------------|
69
+ |Overline |`=TEXT=`|`=overline=` |<span style='text-decoration:overline'>overline</span> |
70
+ |Underline |`-TEXT-`|`-underline-` |<span style='text-decoration:underline'>underline</span> |
71
+ |Line-through|`~TEXT~`|`~linethrough~`|<span style='text-decoration:line-through'>linethrough</span>|
72
+
73
+ Note: Currently, overline is displayed in SVG, but not in PNG.
74
+
75
+ #### Subscript and Superscript
76
+
77
+ |Sample Input |Output |
78
+ |-----------------------|----------------------------|
79
+ |`normal_subscript_` |normal<sub>subscript</sub> |
80
+ |`normal__superscript__`|normal<sup>superscript</sup>|
81
+
82
+ #### Box and Circle
83
+
84
+ {% include box_and_circle_table.html %}
85
+
86
+ #### Whitespace inside Label
87
+
88
+ |Sample Input|Output |
89
+ |------------|--------|
90
+ |`X<>Y` |X&nbsp;Y|
91
+
92
+ #### Newline
93
+
94
+ |Sample Input |Output |
95
+ |-------------------------------|--------------------|
96
+ |`str1\`<br />`str2` |str1<br />str2 |
97
+ |`str1\`<br />` \`<br />`str2`|str1<br /><br />str2|
98
+ |`str1\ str2` |str1<br />str2 |
99
+ |`str1\ \ str2` |str1<br /><br />str2|
100
+ |`str1\nstr2` |str1<br />str2 |
101
+ |`str1\n\nstr2` |str1<br /><br />str2|
102
+
103
+ #### Horizontal Line
104
+
105
+ |Sample Input |Output |
106
+ |-------------------------------|----------------------|
107
+ |`str1\`<br />`---\`<br />`str2`|str1<br />——<br />str2|
108
+ |`str1\ ---\ str2` |str1<br />——<br />str2|
109
+ |`str1\n---\nstr2` |str1<br />——<br />str2|
110
+
111
+ Here, `---` represents `-` repeated three times or more consecutively.
112
+
113
+ ### Triangle, Square Brackets, Rectangle
114
+
115
+ In `auto` mode, the triangle connector shape is applied when the terminal node contains words separated by whitespace. In `bar` and `none` modes, triangles are drawn for the nodes with `^` at the beginning of the leaf text, lie `[NP ^syntax-trees]`.
116
+
117
+ If a `#` character is placed at the beginning of the leaf text (right after `^` if there is one), the leaf text is enclosed in a paire of square brackets (e.g. `[NP #text]` or `[NP ^#text]`). If `##` is placed at the beginning of the leaf text, a rectangle is drawn instead of brackets.
118
+
119
+ ### Escape Special Characters
120
+
121
+ The backslash character `\` must be used to print certain characters used in the markup. If you do not have the `\` key on your keyboard, you can also use the yen/yuan character `¥` to escape.
122
+
123
+ {% include escape_char_table.html %}
124
+
125
+ **Note:** A newline character `↩️` is treated just as a whitespace. Thus 1) `\n`, 2) `\↩️`, and 3) `\` followed by a whitespace character are all rendered as a newline `↩️` in the resulting image. Note also that a `↩️` or a whitespace repeated more than once is reduced to a single whitespace.
126
+
127
+ ### Draw Paths between Nodes (experimental)
128
+
129
+ You can draw any number of paths of three different types:
130
+
131
+ - Non-directional (rendered `- - -`)
132
+ - Directional (rendered `----->`)
133
+ - Bidirectional (rendered `<----->`)
134
+
135
+ Each path is distinguished by a path ID number. The path 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 sign is placed between the plus sign and the number (e.g. `+>7`), an arrowhead will appear at the end of the path.
136
+ A node can have any number of path IDs. The same path 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.
137
+
138
+ <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.0/dist/jquery.min.js"></script>
139
+ <script src="https://cdn.jsdelivr.net/npm/lightbox2@2.11.3/src/js/lightbox.js"></script>
140
+
141
+ ---
142
+
143
+ <script>
144
+ function copyToClipBoard(id){
145
+ var copyText = document.getElementById(id).innerText;
146
+ document.addEventListener('copy', function(e) {
147
+ e.clipboardData.setData('text/plain', copyText);
148
+ e.preventDefault();
149
+ }, true);
150
+ document.execCommand('copy');
151
+ alert('copied');
152
+ }
153
+ </script>
@@ -0,0 +1,166 @@
1
+ ---
2
+ title: RSyntaxTree
3
+ layout: default
4
+ ---
5
+
6
+ # ドキュメンテーション
7
+ {:.no_toc}
8
+
9
+ [English](https://yohasebe.github.io/rsyntaxtree/documentation) |
10
+ [日本語](https://yohasebe.github.io/rsyntaxtree/documentation_ja)
11
+
12
+ ### 目次
13
+ {:.no_toc}
14
+
15
+ 1. toc
16
+ {:toc}
17
+
18
+ ### 基本的な使い方
19
+
20
+ エディターエリアにラベル付き括弧表記でテキストを入力し,`Draw PNG`または`Draw SVG`ボタンをクリックします.
21
+
22
+ 樹形図のすべてのブランチ(枝)やリーフ(葉)は,ノード(節点)に属します.ノードを作成するには,ラベルテキストを開始括弧の直後に配置します.ブランチは,空白で区切っていくつでも設定できます.リーフのテキストに1つ以上の空白が含まれているとき、空白はそのまま表示されます。ノードのラベルに空白を含めたいときには `<>` 記号を使って表します.例えば `Modal<>Aux` とすれば `Modal Aux` と表示されます.
23
+
24
+ 終端ノードとリーフの間に描かれるコネクターの描画方法は3種の中から選べます(`auto`,`bar`,`none`).`auto` では,1つ以上の空白を含むリーフ(要するに「句」)に対しては終端ノードを頂点とした三角形を描画します.リーフが空白を含まない場合(つまり「単語」の場合),垂直線が描かれます .なお,リーフの先頭に `^` をつけると,そのリーフが句であると宣言することになります.したがって必ず三角形が描かれます. `bar` では,すべてのリーフに関して垂直線が描かれます. `none` では終端ノードとリーフの間にコネクターは描かれません.
25
+
26
+ ノードを表すテキストやリーフを表すテキストの中で改行を行たい場合,改行文字 `\n` を用いることができます.
27
+
28
+ RSyntaxTreeではPNG形式またはSVG形式で画像を生成します.どちらもMicrosoft Wordで作った書類などに貼り付けることができます.PNG形式の方が一般的ですが,SVG形式の画像は拡大しても描画品質が変わらないため,高品質なグラフィックが必要な場合に便利です.SVG形式の画像は,Adobe Illustrator,Microsoft Visio, [BOXY SVG](https://boxy-svg.com/) などのソフトウェアで読み込んで編集することができます.
29
+
30
+ `Radical symmetrization` オプションは,ブランチ(枝)の描画方法に影響します.`Font style` , `Font size` ,`Connector height` ,`Color` の各オプションについては説明の必要はないでしょう.これらのオプションの値を変更することで,樹形図の外観を変えることができます.
31
+
32
+ ### PNG形式を用いる場合
33
+
34
+ PNG形式の場合,`Noto Sans`,`Noto Serif`,`WQY Zen Hei` のいずれかを選ぶと,そのフォントを使って樹形図が描画されます.
35
+
36
+ - `Noto Sans` は基本的なUnicode文字をゴシック体に近い書体で表示します(日本語のひらがな/カタカナ/漢字を含む).
37
+ - `Noto Serif` は基本的なUnicode文字を明朝体に近い書体で表示します(日本語のひらがな/カタカナ/漢字を含む).
38
+ - `WQY Zen Hei` は中国語/日本語/コリア語(CJK)の幅広い文字を表示可能です.
39
+
40
+ ### SVG形式を用いる場合
41
+
42
+ SVG形式を用いる場合,期待通りの表示を得るためには,ご使用のコンピュータに適切なフォントがインストールされている必要があります.下記のフォントをあらかじめインストールしておいてください.必要なフォントがインストールされていない場合は,別のフォントで表示されるため,見た目のバランスをやや欠くことがあります.
43
+
44
+ - [Noto Sans](https://fonts.google.com/noto/specimen/Noto+Sans): ラテン文字と基本的なUnicode文字(サンセリフ)の表示
45
+ - [Noto Sans JP](https://fonts.google.com/noto/specimen/Noto+Sans+JP): 日本語のひらがな/カタカナ/漢字(サンセリフ)の表示
46
+ - [Noto Serif](https://fonts.google.com/noto/specimen/Noto+Serif): ラテン文字と基本的なUnicode文字(セリフ) の表示
47
+ - [Noto Serif JP](https://fonts.google.com/noto/specimen/Noto+Serif+JP):日本語のひらがな/カタカナ/漢字(セリフ)の表示
48
+ - [WQY Zen Hei](https://packages.ubuntu.com/bionic/fonts/fonts-wqy-zenhei): 中国語/日本語/コリア語(CJK)の文字の表示
49
+ - [OpenMoji](https://openmoji.org/): 様々な絵文字の表示
50
+
51
+ ### テキストの描画
52
+
53
+ フォントのスタイルとしてイタリック/ボールド/ボールド+イタリックを指定できます.テキスト装飾としては,上線,下線,取り消し線を指定できます.また上付き文字と下付き文字を指定できます.これらは組み合わせて使用することもできます.
54
+
55
+ #### フォント・スタイル
56
+
57
+ |Style |Symbol |Sample Input |Output |
58
+ |-----------|------------|-------------------|-----------------|
59
+ |Italic |`*TEXT*` |`*italic*` |*italic* |
60
+ |Bold |`**TEXT**` |`**bold**` |**bold** |
61
+ |Italic+bold|`***TEXT***`|`***italic bold***`|***italic bold***|
62
+
63
+ #### テキスト装飾
64
+
65
+ |Decoration |Symbol |Sample Input |Output |
66
+ |------------|--------|---------------|-------------------------------------------------------------|
67
+ |Overline |`=TEXT=`|`=overline=` |<span style='text-decoration:overline'>overline</span> |
68
+ |Underline |`-TEXT-`|`-underline-` |<span style='text-decoration:underline'>underline</span> |
69
+ |Line-through|`~TEXT~`|`~linethrough~`|<span style='text-decoration:line-through'>linethrough</span>|
70
+
71
+ **注意:** 上線はSVGでは使用できますがPNG形式の画像では表示されません.
72
+
73
+ #### 上付き文字と下付き文字
74
+
75
+ |Sample Input |Output |
76
+ |-----------------------|----------------------------|
77
+ |`normal_subscript_` |normal<sub>subscript</sub> |
78
+ |`normal__superscript__`|normal<sup>superscript</sup>|
79
+
80
+
81
+ ### スペースと改行
82
+
83
+ #### ラベル内のスペース
84
+
85
+ |Sample Input|Output |
86
+ |------------|--------|
87
+ |`X<>Y` |X&nbsp;Y|
88
+
89
+ リーフのテキスト中の半角スペースはそのままスペースとして表示されます。`<>`は基本的にはラベル内でスペースを表示したいときに使いますが、リーフ内のテキストでも有効です。
90
+
91
+ #### 改行
92
+
93
+ |Sample Input |Output |
94
+ |-------------------------------|--------------------|
95
+ |`str1\`<br />`str2` |str1<br />str2 |
96
+ |`str1\`<br />` \`<br />`str2`|str1<br /><br />str2|
97
+ |`str1\ str2` |str1<br />str2 |
98
+ |`str1\ \ str2` |str1<br /><br />str2|
99
+ |`str1\nstr2` |str1<br />str2 |
100
+ |`str1\n\nstr2` |str1<br /><br />str2|
101
+
102
+ ### テキスト以外の要素の描画
103
+
104
+ テキストと組み合わせてサークル○,ボックス□,水平線などを描画することができます.
105
+
106
+ #### ボックスとサークル
107
+
108
+ {% include box_and_circle_table.html %}
109
+
110
+ #### 水平線
111
+
112
+ |Sample Input |Output |
113
+ |-------------------------------|----------------------|
114
+ |`str1\`<br />`---\`<br />`str2`|str1<br />——<br />str2|
115
+ |`str1\ ---\ str2` |str1<br />——<br />str2|
116
+ |`str1\n---\nstr2` |str1<br />——<br />str2|
117
+
118
+ ここで `---` は `-` の3つ以上の連続を意味します.
119
+
120
+ ### コネクター
121
+
122
+ 終端ノードとリーフの間に描かれるコネクターの描画方法は3種の中から選べます(`auto`,`bar`,`none`).`auto` では,1つ以上の空白を含むリーフ(要するに「句」)に対しては終端ノードを頂点とした三角形を描画します.リーフが空白を含まない場合(つまり「単語」の場合),垂直の直線が描かれます .なお,リーフの先頭に `^` をつけると,そのリーフが句であると宣言することになります.したがって必ず三角形が描かれます. `bar` では,すべてのリーフに関して垂直の直線が描かれます. `none` では終端ノードとリーフの間にコネクターは描かれません.
123
+
124
+ ### リーフを囲む括弧と矩形の描画
125
+
126
+ リーフとなるテキストの最初に(`^` が存在する場合はその直後に) `#` を付けると,そのテキスト全体を角括弧([ ])で囲みます(例:`[NP #text]` or `[NP ^#text]`). テキストの最初に `##` を付けると,テキスト全体を矩形(ボックス)で囲みます.
127
+
128
+ ### 一部の文字を表示するためのエスケープ
129
+
130
+ 文字装飾などのマークアップに使用される一部の文字をテキストとして表示するためには `\` によってエスケープする必要があります。使用している環境で `\` が使えない場合は `¥` で代用することができます。
131
+
132
+ {% include escape_char_table.html %}
133
+
134
+ **注意:** 単なる改行 `↩️` はスペースとして扱われます.`↩️` を1つ以上連続させた場合も1つのスペースとして扱われます.
135
+
136
+ テキスト中で改行したいときには,1) `\n`,2) `\↩️`,3) `\ + whitespace ` のいずれかを用いてください.そうすると出力される画像の中で改行 `↩️` が行われます.
137
+
138
+ ### ノードからノードへのパスの描画(試験的機能)
139
+
140
+ 下の3種類の形式でノードからノードへのパスを表示することができます.
141
+
142
+ - 方向(矢印)のないパス(`- - -`)
143
+ - 方向(矢印)のあるパス(`----->`)
144
+ - 両方向の矢印のあるパス(`<----->`)
145
+
146
+ 樹形図の中でパスを表示したいとき,パスの両端をIDで指定します.パスIDをプラス(`+`)記号と共にノードのテキストの最後で指定してください(例:`+7`).
147
+ プラス記号とパスIDの間に `>` 記号を入れると(例:`+>7`),パスの終端に矢印が付きます.
148
+
149
+ パスIDにはどのような数字を用いても構いませんが,必ず **2箇所** で同じIDを指定することが必要です.同じIDを2箇所以上で指定することはできません.
150
+
151
+ <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.0/dist/jquery.min.js"></script>
152
+ <script src="https://cdn.jsdelivr.net/npm/lightbox2@2.11.3/src/js/lightbox.js"></script>
153
+
154
+ ---
155
+
156
+ <script>
157
+ function copyToClipBoard(id){
158
+ var copyText = document.getElementById(id).innerText;
159
+ document.addEventListener('copy', function(e) {
160
+ e.clipboardData.setData('text/plain', copyText);
161
+ e.preventDefault();
162
+ }, true);
163
+ document.execCommand('copy');
164
+ alert('copied');
165
+ }
166
+ </script>
@@ -0,0 +1,68 @@
1
+ ---
2
+ title: RSyntaxTree
3
+ layout: default
4
+ ---
5
+
6
+ <h1 id="examples">Example Gallery</h1>
7
+ {% assign all_examples = site.examples %}
8
+ {% assign categories = all_examples | map: 'category' | join: ',' | split: ',' | group_by: category %}
9
+ <ul>
10
+ {%- for category in categories -%}
11
+ <li><a href="#category-{{ category.name | slugify }}">{{ category.name }}</a> [{{category.size}}]</li>
12
+ {%- endfor -%}
13
+ </ul>
14
+
15
+ {%- for category in categories -%}
16
+ <hr />
17
+ <h2 id="category-{{category.name | slugify }}"><b>{{ category.name }}</b></h2>
18
+ {%- for example in all_examples -%}
19
+ {% if example.category contains category.name %}
20
+ <br />
21
+ <div style='text-align:left;'>
22
+ <button onclick="copyToClipBoard('text-{{ example.name }}')" style='margin: 20px 0; font-size: 0.85em;'>
23
+ Copy to Clipboard
24
+ </button>
25
+ </div>
26
+ <div class='grid'>
27
+ <div style='margin-top: 0; margin-bottom: auto;'>
28
+ <div id="text-{{example.name}}" style='max-height: 600px; overflow-y: auto; margin-bottom: 20px;'>
29
+ {{ example.content | markdownify }}
30
+ </div>
31
+ <table style='line-height: 110%; font-size: 0.85em; margin-bottom: 20px;'>
32
+ <thead></thead>
33
+ <tbody>
34
+ <tr><td>Category</td><td>{{ example.category}}</td></tr>
35
+ <tr><td>Connector</td><td>{{ example.connector }}</td></tr>
36
+ <tr><td>Polyline</td><td>{{ example.polyline }}</td></tr>
37
+ <tr><td>Colorization</td><td>{{ example.colorization }}</td></tr>
38
+ <tr><td>Radical Symmetirization</td><td>{{ example.symmetrization }}</td></tr>
39
+ <tr><td>Font</td><td>{{ example.font }}</td></tr>
40
+ <tr><td>Reference</td><td>{{ example.reference }}</td></tr>
41
+ </tbody>
42
+ </table>
43
+ </div>
44
+ <div style='margin-top: 0; margin-bottom: auto;'>
45
+ <a href='assets/img/{{ example.name }}.png' data-lightbox='{{ example.name }}'>
46
+ <img src='assets/img/{{ example.name}}.png'/>
47
+ </a>
48
+ </div>
49
+ </div>
50
+ <div><a href="#examples">🔝</a></div>
51
+ {% endif %}
52
+ {%- endfor -%}
53
+ {%- endfor -%}
54
+
55
+ <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.0/dist/jquery.min.js"></script>
56
+ <script src="https://cdn.jsdelivr.net/npm/lightbox2@2.11.3/src/js/lightbox.js"></script>
57
+
58
+ <script>
59
+ function copyToClipBoard(id){
60
+ var copyText = document.getElementById(id).innerText;
61
+ document.addEventListener('copy', function(e) {
62
+ e.clipboardData.setData('text/plain', copyText);
63
+ e.preventDefault();
64
+ }, true);
65
+ document.execCommand('copy');
66
+ alert('copied');
67
+ }
68
+ </script>
data/docs/index.html ADDED
@@ -0,0 +1,2 @@
1
+ <meta http-equiv="Refresh" content="0; url=https://yohasebe.com/rsyntaxtree" />
2
+
Binary file
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
- x1 = child.horizontal_indent + child.content_width / 2
479
- y1 = child.vertical_indent + $height_connector_to_text / 2
480
- x2 = parent.horizontal_indent + parent.content_width / 2
481
- y2 = parent.vertical_indent + parent.content_height + $height_connector_to_text
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
- line_data = @line_styles.sub(/X1/, x1.to_s)
484
- line_data = line_data.sub(/Y1/, y1.to_s)
485
- line_data = line_data.sub(/X2/, x2.to_s)
486
- @tree_data += line_data.sub(/Y2/, y2.to_s)
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
@@ -1,4 +1,4 @@
1
1
  module RSyntaxTree
2
- VERSION = "1.0.5"
2
+ VERSION = "1.0.7"
3
3
  end
4
4
 
data/lib/rsyntaxtree.rb CHANGED
@@ -53,9 +53,11 @@ module RSyntaxTree
53
53
  .gsub('-SCOLON-', ';')
54
54
  .gsub('-OABRACKET-', '<')
55
55
  .gsub('-CABRACKET-', '>')
56
+ .gsub('¥¥', '\¥')
57
+ .gsub(/(?<!\\)¥/, "\\")
56
58
  new_params[key] = data
57
59
 
58
- when :symmetrize, :color, :transparent
60
+ when :symmetrize, :color, :transparent, :polyline
59
61
  new_params[key] = value && (value != "off" && value != "false") ? true : false
60
62
  when :fontsize
61
63
  new_params[key] = value.to_i * FONT_SCALING
@@ -109,6 +111,7 @@ module RSyntaxTree
109
111
  :data => "",
110
112
  :margin => 0,
111
113
  :vheight => 1.0,
114
+ :polyline => false,
112
115
  }
113
116
 
114
117
  @params.merge! new_params
data/rsyntaxtree.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
10
10
  s.email = ["yohasebe@gmail.com"]
11
11
  s.homepage = "http://github.com/yohasebe/rsyntaxtree"
12
12
  s.summary = %q{RSyntaxTree is a graphical syntax tree generator written in Ruby}
13
- s.description = %q{Yet another syntax tree generator made with Ruby and RMagick}
13
+ s.description = %q{Syntax tree generator made with Ruby}
14
14
  s.licenses = ["MIT"]
15
15
  s.files = `git ls-files`.split("\n")
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }