mahjong-render 0.1.0

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.
Files changed (63) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +12 -0
  3. data/CONTRIBUTING.md +7 -0
  4. data/LICENSE +202 -0
  5. data/LICENSES/CC0-1.0.txt +121 -0
  6. data/README.ja.md +90 -0
  7. data/README.md +112 -0
  8. data/SECURITY.md +5 -0
  9. data/THIRD_PARTY_NOTICES.md +17 -0
  10. data/assets/manifest.json +45 -0
  11. data/assets/tiles/Chun.svg +232 -0
  12. data/assets/tiles/Front.svg +334 -0
  13. data/assets/tiles/Haku.svg +214 -0
  14. data/assets/tiles/Hatsu.svg +309 -0
  15. data/assets/tiles/Man1.svg +276 -0
  16. data/assets/tiles/Man2.svg +286 -0
  17. data/assets/tiles/Man3.svg +292 -0
  18. data/assets/tiles/Man4.svg +292 -0
  19. data/assets/tiles/Man5-Dora.svg +319 -0
  20. data/assets/tiles/Man5.svg +313 -0
  21. data/assets/tiles/Man6.svg +297 -0
  22. data/assets/tiles/Man7.svg +283 -0
  23. data/assets/tiles/Man8.svg +286 -0
  24. data/assets/tiles/Man9.svg +292 -0
  25. data/assets/tiles/Nan.svg +270 -0
  26. data/assets/tiles/Pei.svg +236 -0
  27. data/assets/tiles/Pin1.svg +544 -0
  28. data/assets/tiles/Pin2.svg +400 -0
  29. data/assets/tiles/Pin3.svg +362 -0
  30. data/assets/tiles/Pin4.svg +407 -0
  31. data/assets/tiles/Pin5-Dora.svg +460 -0
  32. data/assets/tiles/Pin5.svg +454 -0
  33. data/assets/tiles/Pin6.svg +477 -0
  34. data/assets/tiles/Pin7.svg +567 -0
  35. data/assets/tiles/Pin8.svg +570 -0
  36. data/assets/tiles/Pin9.svg +623 -0
  37. data/assets/tiles/Shaa.svg +248 -0
  38. data/assets/tiles/Sou1.svg +764 -0
  39. data/assets/tiles/Sou2.svg +372 -0
  40. data/assets/tiles/Sou3.svg +462 -0
  41. data/assets/tiles/Sou4.svg +573 -0
  42. data/assets/tiles/Sou5-Dora.svg +614 -0
  43. data/assets/tiles/Sou5.svg +608 -0
  44. data/assets/tiles/Sou6.svg +688 -0
  45. data/assets/tiles/Sou7.svg +628 -0
  46. data/assets/tiles/Sou8.svg +712 -0
  47. data/assets/tiles/Sou9.svg +748 -0
  48. data/assets/tiles/Ton.svg +242 -0
  49. data/docs/adr/0001-renderer-selection.md +7 -0
  50. data/docs/adr/0002-license.md +5 -0
  51. data/docs/adr/0003-notation.md +5 -0
  52. data/docs/adr/0004-assets.md +5 -0
  53. data/docs/adr/0005-package.md +5 -0
  54. data/docs/release.md +32 -0
  55. data/docs/research/existing-renderers.md +21 -0
  56. data/examples/basic.adoc +13 -0
  57. data/examples/hand.png +0 -0
  58. data/lib/mahjong_render/asciidoctor.rb +32 -0
  59. data/lib/mahjong_render/parser.rb +113 -0
  60. data/lib/mahjong_render/renderer.rb +105 -0
  61. data/lib/mahjong_render/version.rb +8 -0
  62. data/lib/mahjong_render.rb +14 -0
  63. metadata +106 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 71f71da72cf55e3d1d96688ad782b98d01c34adee322e0694a030027c278bb2d
4
+ data.tar.gz: 57a54b42c5b6b88f59fb62654ef691612764c7907cda74669174a7b65b0fb0af
5
+ SHA512:
6
+ metadata.gz: 193c72bd69c349827e920e9aef8421b1be93a8db6748f35082f414be8b207ceb781bd566e55104f11a22c4a59a475b28e2cfcedd52f18c05967a5e50e6c2c55f
7
+ data.tar.gz: 941dea74ea618f41f7f591026a237cc14891100d4e13dda3b6df0e7eed9784599d9d8118a5fe90a498e7f045ee20e5ffcfdf2a207f706075ccb303d4d4196e1e
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ # Changelog
2
+
3
+ All notable changes will be recorded here. Versions follow Semantic Versioning.
4
+
5
+ ## 0.1.0 — 2026-09-24
6
+
7
+ - Render compact manzu, pinzu, souzu, honor, and red-five notation to self-contained SVG.
8
+ - Support adjustable spacing between tile groups in compact notation.
9
+ - Add an HTML5 block macro for Ruby Asciidoctor.
10
+ - Bundle pinned CC0 tile artwork and record its provenance.
11
+ - Prepare Apache-2.0 project licensing, bilingual documentation, and complete gem metadata for publication.
12
+ - Add manual and tag-triggered RubyGems Trusted Publishing preparation.
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,7 @@
1
+ # Contributing
2
+
3
+ Bug reports and pull requests are welcome. Describe the notation or AsciiDoc input, the expected result, and the actual result. Include a minimal sample when possible.
4
+
5
+ Run `bundle exec rake lint test assets:check licenses:check example:build` before submitting a change. Add focused tests for changes to parsing, SVG output, or the Asciidoctor adapter. Document changes to public behavior in the README and CHANGELOG.
6
+
7
+ Do not add third-party code or artwork without recording its origin, license, redistribution conditions, and any required notices. New artwork must be audited for active SVG content and external references. Keep the core renderer independent of Asciidoctor and of runtime network services.
data/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,121 @@
1
+ Creative Commons Legal Code
2
+
3
+ CC0 1.0 Universal
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
data/README.ja.md ADDED
@@ -0,0 +1,90 @@
1
+ # mahjong-render
2
+
3
+ [English README](README.md)
4
+
5
+ `mahjong-render` は、麻雀牌の compact notation から自己完結した SVG を作る Ruby ライブラリです。Ruby 版 Asciidoctor 向けの block macro も使えます。描画時に Node.js、ブラウザ、フォント、ネットワーク接続は不要です。
6
+
7
+ ## 表示例
8
+
9
+ `405m456p789s12344z` の描画結果です。`405m` の `0m` は赤五萬を表します。
10
+
11
+ ![萬子・筒子・索子と風牌を並べた手牌。2枚目は赤五萬。](examples/hand.png)
12
+
13
+ このプレビューはライブラリが出力した SVG から生成しています。
14
+
15
+ ## インストールと描画
16
+
17
+ Ruby 3.2 以上が必要です。RubyGems からインストールします。
18
+
19
+ ```sh
20
+ gem install mahjong-render
21
+ ```
22
+
23
+ このリポジトリのローカルビルドをインストールする場合は、次のコマンドを使います。
24
+
25
+ ```sh
26
+ gem build mahjong-render.gemspec
27
+ gem install --local ./mahjong-render-0.1.0.gem
28
+ ```
29
+
30
+ インストール後、次のコマンドで `hand.svg` を作成できます。
31
+
32
+ ```sh
33
+ ruby -rmahjong_render -e 'print MahjongRender.render("405m456p789s12344z")' > hand.svg
34
+ ```
35
+
36
+ Ruby コードからは次のように呼び出します。
37
+
38
+ ```ruby
39
+ require "mahjong_render"
40
+
41
+ svg = MahjongRender.render("405m456p789s12344z")
42
+ File.write("hand.svg", svg)
43
+ ```
44
+
45
+ 返り値は牌画像をデータ URI で埋め込んだ SVG 文字列です。牌数や和了形の妥当性は判定しません。
46
+
47
+ ## AsciiDoc で使う
48
+
49
+ Asciidoctor は gem 本体の実行時依存ではないため、別途インストールします。以下は単独の AsciiDoc 文書から `hand.html` を作る例です。
50
+
51
+ ```sh
52
+ gem install asciidoctor
53
+ printf '= Mahjong hand\n\nmahjong::405m456p789s12344z[]\n' > hand.adoc
54
+ asciidoctor -r mahjong_render/asciidoctor hand.adoc
55
+ ```
56
+
57
+ 間隔の違う牌列を含む [AsciiDoc の例](examples/basic.adoc) もあります。v0.1.0 の拡張は HTML5 の block macro に対応します。macro 属性、inline macro、PDF 出力には対応しません。
58
+
59
+ 牌のまとまりを少し離して見せるには、完成したグループの間に `|` を入れます。たとえば `mahjong::123m|456p|789s[]` と書きます。`|` は牌幅の4分の1の空白を追加し、`|(0.25)` と同じ幅です。幅を変える場合は `mahjong::123m|(0.5)456p[]` のように書けます。
60
+
61
+ ## 記法とエラー
62
+
63
+ | 記法 | 意味 |
64
+ | --- | --- |
65
+ | `1m`~`9m` | 萬子 |
66
+ | `1p`~`9p` | 筒子 |
67
+ | `1s`~`9s` | 索子 |
68
+ | `1z`~`4z` | 東・南・西・北 |
69
+ | `5z`~`7z` | 白・發・中 |
70
+ | `0m`、`0p`、`0s` | 各色の赤五 |
71
+
72
+ 同じ色の数字は `123m` のようにまとめられます。`10m` は `1m 0m` の2牌です。空白は完成したグループの間に入れられますが、見た目の間隔は変わりません。通常の牌間は SVG の12単位のままで、`|` は75単位を追加します。`|(0)` は追加幅0です。数値指定には0以上の十進数を使い、区切りは完成したグループの間に置きます。
73
+
74
+ 不正な記法は `MahjongRender::NotationError` になります。`token`、先頭から0起算の文字位置 `position`、理由 `reason` を参照できます。たとえば `8z` は無効です。
75
+
76
+ ## 開発とライセンス
77
+
78
+ devcontainer、または Ruby 3.2 以上・Bundler・`rsvg-convert` を用意して検証します。
79
+
80
+ ```sh
81
+ bundle install
82
+ bundle exec rake lint test assets:check licenses:check example:build
83
+ gem build mahjong-render.gemspec
84
+ ruby script/check_package.rb mahjong-render-0.1.0.gem
85
+ ```
86
+
87
+ 設計の経緯は [既存ライブラリの調査](docs/research/existing-renderers.md) と [ADR](docs/adr/) に記録しています。
88
+ [公開手順](docs/release.md) には、Trusted Publishing の設定と手動・タグによる公開方法を記載しています。
89
+
90
+ Copyright 2026 Maejima Kenya。Ruby コードとテキスト文書には [Apache-2.0](LICENSE) を適用します。同梱の牌画像と [README のプレビュー](examples/hand.png) は CC0-1.0 です。牌画像は [FluffyStuff/riichi-mahjong-tiles](https://github.com/FluffyStuff/riichi-mahjong-tiles) から採用しました。詳細は [第三者素材の告知](THIRD_PARTY_NOTICES.md)、[素材マニフェスト](assets/manifest.json)、[CC0 のライセンス本文](LICENSES/CC0-1.0.txt) を参照してください。
data/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # mahjong-render
2
+
3
+ [日本語版 README](README.ja.md)
4
+
5
+ `mahjong-render` is a Ruby library that turns compact riichi mahjong notation into a self-contained SVG. It also provides an optional block macro for Ruby Asciidoctor. Rendering works offline and does not require Node.js, a browser, a font, or a network service.
6
+
7
+ ## Example output
8
+
9
+ `405m456p789s12344z` renders as:
10
+
11
+ ![A mahjong hand showing three character tiles, three circle tiles, three bamboo tiles, and five wind tiles. The second tile is a red five.](examples/hand.png)
12
+
13
+ The `0m` in `405m` is a red five. The preview is generated from the library's SVG output.
14
+
15
+ ## Install and render
16
+
17
+ Requirements: Ruby 3.2 or newer.
18
+
19
+ Install the published gem from RubyGems:
20
+
21
+ ```sh
22
+ gem install mahjong-render
23
+ ```
24
+
25
+ To install a build from a local checkout:
26
+
27
+ ```sh
28
+ gem build mahjong-render.gemspec
29
+ gem install --local ./mahjong-render-0.1.0.gem
30
+ ```
31
+
32
+ Render a hand from the command line or from Ruby:
33
+
34
+ ```sh
35
+ ruby -rmahjong_render -e 'print MahjongRender.render("405m456p789s12344z")' > hand.svg
36
+ ```
37
+
38
+ ```ruby
39
+ require "mahjong_render"
40
+
41
+ svg = MahjongRender.render("405m456p789s12344z")
42
+ File.write("hand.svg", svg)
43
+ ```
44
+
45
+ The result is one SVG string with tile images embedded as data URIs. It can be saved as a file or inserted into HTML. The tile count is unrestricted; the library draws the sequence and does not check whether it is a legal hand.
46
+
47
+ ## AsciiDoc usage
48
+
49
+ Install Asciidoctor separately, then load the adapter using the usual Ruby Asciidoctor `-r` option. These commands create `hand.html` from a standalone document:
50
+
51
+ ```sh
52
+ gem install asciidoctor
53
+ printf '= Mahjong hand\n\nmahjong::405m456p789s12344z[]\n' > hand.adoc
54
+ asciidoctor -r mahjong_render/asciidoctor hand.adoc
55
+ ```
56
+
57
+ See [the complete AsciiDoc example](examples/basic.adoc) for hands with and without extra space.
58
+
59
+ To show separate groups, insert `|` between complete tile groups: `mahjong::123m|456p|789s[]`. Each `|` adds a quarter tile width of empty space, the same as `|(0.25)`. Use `|(0.5)` for half a tile width or `|(1)` for a full tile width, for example `mahjong::123m|(0.5)456p[]`.
60
+
61
+ The adapter supports the HTML5 backend. Macro attributes, inline macros, and PDF output are not part of v0.1.0. The Ruby rendering API does not load Asciidoctor.
62
+
63
+ ## Supported notation
64
+
65
+ | Form | Meaning |
66
+ | --- | --- |
67
+ | `1m`–`9m` | Characters (manzu) |
68
+ | `1p`–`9p` | Circles (pinzu) |
69
+ | `1s`–`9s` | Bamboo (souzu) |
70
+ | `1z`–`4z` | East, South, West, North |
71
+ | `5z`–`7z` | White, Green, Red dragon |
72
+ | `0m`, `0p`, `0s` | Red five in the corresponding suit |
73
+
74
+ Digits can share a suit suffix: `123m` means `1m 2m 3m`, and `405m` means `4m 0m 5m`. Therefore `10m` is two tiles (`1m 0m`), not a rank-ten tile. Whitespace is allowed between complete groups but does not change their spacing. The normal gap remains 12 SVG units; `|` adds 75 units, and `|(0)` adds nothing. Numeric widths must be nonnegative decimal values. Separators must be between complete groups.
75
+
76
+ Invalid notation raises `MahjongRender::NotationError`, with `token`, zero-based character `position`, and `reason` readers. Examples include `8z`, `123x`, `1m!`, a missing suit, and empty input. For example, `MahjongRender.render("8z")` raises an error with `token == "8z"` and `position == 0`.
77
+
78
+ ## Architecture
79
+
80
+ ```text
81
+ notation → strict Ruby parser → ordered tile codes → SVG composer
82
+ ↑
83
+ pinned CC0 tile artwork
84
+
85
+ AsciiDoc → Ruby Asciidoctor block macro → MahjongRender.render
86
+ ```
87
+
88
+ The parser and SVG composer are intentionally small. Existing renderers were evaluated before this choice; [the research](docs/research/existing-renderers.md) and [decision records](docs/adr/) explain why they were not used as Ruby runtime dependencies.
89
+
90
+ ## Development
91
+
92
+ Open this repository in a devcontainer, or use Ruby 3.2 or newer with Bundler and `rsvg-convert` installed:
93
+
94
+ ```sh
95
+ bundle install
96
+ bundle exec rake lint test assets:check licenses:check example:build
97
+ gem build mahjong-render.gemspec
98
+ ruby script/check_package.rb mahjong-render-0.1.0.gem
99
+ ```
100
+
101
+ The example HTML is written to `tmp/basic.html`. The test suite rasterizes a sample SVG to confirm the embedded vector artwork renders.
102
+ The [release guide](docs/release.md) describes the manual and tag-triggered Trusted Publishing workflows.
103
+
104
+ To regenerate the README preview with `rsvg-convert`:
105
+
106
+ ```sh
107
+ ruby -Ilib -rmahjong_render -e 'print MahjongRender.render("405m456p789s12344z")' | rsvg-convert -w 1200 -o examples/hand.png
108
+ ```
109
+
110
+ ## Third-party components and license
111
+
112
+ Copyright 2026 Maejima Kenya. The project Ruby code and text documentation are licensed under [Apache-2.0](LICENSE). The bundled tile artwork and the [README preview](examples/hand.png) are CC0-1.0. The artwork comes from [FluffyStuff/riichi-mahjong-tiles](https://github.com/FluffyStuff/riichi-mahjong-tiles); see [third-party notices](THIRD_PARTY_NOTICES.md), [the asset manifest](assets/manifest.json), and [the CC0 legal text](LICENSES/CC0-1.0.txt). The gem metadata lists both licenses; each applies to the components described here.
data/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security policy
2
+
3
+ The v0.1.0 release line is supported for security fixes. Report vulnerabilities privately through GitHub's **Report a vulnerability** feature after the repository is published. Do not post exploit details in a public issue.
4
+
5
+ The renderer accepts only compact tile notation. SVG asset files are pinned and checked for active content and external references. Please include a minimal input and affected version when reporting a security issue.
@@ -0,0 +1,17 @@
1
+ # Third-party notices
2
+
3
+ ## Tile artwork
4
+
5
+ - Component: 37 regular-variant tile-face SVGs and one tile-front SVG
6
+ - Upstream: [FluffyStuff/riichi-mahjong-tiles](https://github.com/FluffyStuff/riichi-mahjong-tiles)
7
+ - Revision: `26e127ba2117f45cdce5ea0225748cc0cfad3169`
8
+ - License: CC0-1.0; see [the upstream declaration](https://github.com/FluffyStuff/riichi-mahjong-tiles/blob/26e127ba2117f45cdce5ea0225748cc0cfad3169/LICENSE.md) and [the legal code](LICENSES/CC0-1.0.txt)
9
+ - Purpose: tile fronts and faces embedded in rendered SVGs
10
+
11
+ The original file names and SHA-256 hashes are recorded in [the asset manifest](assets/manifest.json). The files are copied without modification.
12
+
13
+ The README preview at `examples/hand.png` is generated from these CC0 tile images and is also distributed under CC0-1.0. The project Ruby code and text documentation are Apache-2.0; neither license changes the terms of the other component.
14
+
15
+ ## Optional integration and development dependencies
16
+
17
+ The gem has no runtime dependencies. Asciidoctor is installed separately when the AsciiDoc adapter is used. Development dependencies and their licenses are checked from the locked bundle in CI; they are not bundled with this gem.
@@ -0,0 +1,45 @@
1
+ {
2
+ "source": "https://github.com/FluffyStuff/riichi-mahjong-tiles",
3
+ "commit": "26e127ba2117f45cdce5ea0225748cc0cfad3169",
4
+ "license": "CC0-1.0",
5
+ "files": {
6
+ "Chun.svg": "7aecefcb257e5278cf3d4d0d9d03b16c3c6e3ba4080d54f60d424c3f35ffd5bb",
7
+ "Front.svg": "eb74c1e7de77ffed744c345decafe42671e8aadfbac1dd39304195d8070db24b",
8
+ "Haku.svg": "d6023d8cf3b810b74b2f7c14a4254dd7a65c57b9389e63f90aed8f6cd3607032",
9
+ "Hatsu.svg": "9197066680636f5d6b43e49b687103e7b347334f5ea838220edb41ec803e3ad9",
10
+ "Man1.svg": "9b8c52bef39c94b3fac5b1f2a4b6193cd7d8736f79d2c2ae764dd7342f7190b3",
11
+ "Man2.svg": "db430b747ebe8e3ad8bc152c6381a0a71c40f94da27be702a2a2aa8e8924cd10",
12
+ "Man3.svg": "6c8b4af104169189305f2c0eb465a0ac98a7d7c70dc7d40a70f840d780bbd92e",
13
+ "Man4.svg": "a65cde442a6b15e5f33a8dbe753f5d8a30ec1d07f917edc784186e0bdf3abb2e",
14
+ "Man5-Dora.svg": "8fbe07ba977dbaf7644b13514d89084a41fab9ad828a9b9d7be73066fb84a5be",
15
+ "Man5.svg": "88687841beb6eda143d2a973aaa9e2af9a8896472a9b0260d5c4d198a160bba5",
16
+ "Man6.svg": "279df4110edaee428a00df4115df4de7f99829cc9e4f4b259e61036cae8fe0d3",
17
+ "Man7.svg": "a5a1a19ef1156d4bc33d5ae0551806f683cf959b90b244f9fa90ae1bf6402485",
18
+ "Man8.svg": "28babd56acfb1f710c78a50e962edc48af5f739035fbf1f5f5ce62da9c196ec5",
19
+ "Man9.svg": "0b31a26657af8ecfd330332068c22c69516e43ac31a8f3bdfeff19a994088c23",
20
+ "Nan.svg": "28a3fe9e6226016c09539150bd40c22af6e006ed1ae23ef8f7e8dccd7d891f9b",
21
+ "Pei.svg": "a8efd3f32aa46c70a04233d499097ab75ec221635bdf68e8ee2817cb0c45d824",
22
+ "Pin1.svg": "477c6311f8c3e8456a8ca510a6b6ee4d146ecc4ef2d51cb801575e5b55122175",
23
+ "Pin2.svg": "518a4f1831a7743a12898a81c14b91edad909f264dcd410ff7a074975ee0188a",
24
+ "Pin3.svg": "0d57651db6c2d96a99d65a44bdd21e5f550336580310edec029428494326759f",
25
+ "Pin4.svg": "c9231df1f9a83b90ca3e7c333ca56a11bc323a9e765702714a273a58797aaef0",
26
+ "Pin5-Dora.svg": "39808d4a76fd303b55bf77bdffca8b57049dc4dbea67ca374a1399397544da21",
27
+ "Pin5.svg": "5574c14b911befee26b821147d54f6d92cafd66f272e1da5c12a63a0143bc213",
28
+ "Pin6.svg": "38605c2f30a762fada49d4d4ba1b2beb8a707469478ec173b800be06b95562ad",
29
+ "Pin7.svg": "97efa9eec79944518511a4f461f1468490a95ca13b3d952eff1ca02bb05b4589",
30
+ "Pin8.svg": "523b82c7c4a7cd8999780a7b3b5a7b6670eaf86eb1a8e9ad1317b43c6d8f81d8",
31
+ "Pin9.svg": "ffd648051b26c2afd770120c9405d7eec550fdb7f7b42406feadb0969f277087",
32
+ "Shaa.svg": "10d4b6e7e8cbe8410f376c28b8892ecab5b03c1f8d89db93acf0da2302523577",
33
+ "Sou1.svg": "2c50459c118560dbbe90f38006d636c1cf83c7e31128fed32e4df30f3c543d6c",
34
+ "Sou2.svg": "fdc5a6860051ae60f815c4acfaa3ade2b2a067a3b7518b6096f8e9356a650e04",
35
+ "Sou3.svg": "d0f26555368992a285f0ae3f3588d6229518a25fa212466627134f54cc6a3bac",
36
+ "Sou4.svg": "c0861613ee9a6eda77f29a7e685068dd0619bc7aefcc6fcd8d7356782043a518",
37
+ "Sou5-Dora.svg": "b39b163d23b4bbf14ecad232bee7fd09947913a136989b004e44203dfd39b023",
38
+ "Sou5.svg": "cbd9b02c63976954d44b373966c886c457a5903262a2fb9ea958450d86746144",
39
+ "Sou6.svg": "cf6489ecb0ff073efd94d76b4281e91711e74e3b5eb14c641f8c5e71c2d335b5",
40
+ "Sou7.svg": "9afdfc3cef41b3012895d90c1fc34c7c33111171d2a3ea248fbb8ec441009426",
41
+ "Sou8.svg": "dccec0736c9855c6ccc628238b49afb343f68797302f4129861cb3fc451f8d61",
42
+ "Sou9.svg": "5a3369477214b72ddc727130abd0a97126cbaf703eb5ad3226a5b1083dc6635b",
43
+ "Ton.svg": "955eba50b3de787ffad2eaa09a1f7ecaae487bc0afef253fd29e4a93e7dd76df"
44
+ }
45
+ }