Compare commits
5
Commits
b06bd0abcd
...
v0.3.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c524e7a24 | ||
|
|
83c2c9e59f | ||
|
|
60a43a42e5 | ||
|
|
fede3320c8 | ||
|
|
4519065a15
|
@@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2026 Yuya KAMATAKI and contributors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
@@ -15,10 +15,11 @@ TSVへ変換したり、Excelからコピーした表を再び構造化データ
|
|||||||
- CSV
|
- CSV
|
||||||
- TSV
|
- TSV
|
||||||
- XLSX
|
- XLSX
|
||||||
|
- Markdown table (`markdown` / `md`)
|
||||||
|
|
||||||
## インストール
|
## インストール
|
||||||
|
|
||||||
Go 1.25以上が必要です。
|
Go 1.25.13以上が必要です。
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
go install git.rumginger.org/agent/dataxl/cmd/dataxl@latest
|
go install git.rumginger.org/agent/dataxl/cmd/dataxl@latest
|
||||||
@@ -55,6 +56,12 @@ JSONからExcel workbookを作成:
|
|||||||
dataxl -from json -to xlsx -i people.json -o people.xlsx
|
dataxl -from json -to xlsx -i people.json -o people.xlsx
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Markdownのテーブルを作成:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
dataxl -from yaml -to markdown -i examples/people.yaml -o people.md
|
||||||
|
```
|
||||||
|
|
||||||
Excel workbookをYAMLへ変換:
|
Excel workbookをYAMLへ変換:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
@@ -86,6 +93,15 @@ Excelから戻す場合は、シート上の範囲をコピーしてstdinへ渡
|
|||||||
dataxl -from tsv -to yaml > restored.yaml
|
dataxl -from tsv -to yaml > restored.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Markdownテーブル
|
||||||
|
|
||||||
|
GitHub Flavored Markdown互換のヘッダー・区切り行を持つテーブルを読み書きできます。
|
||||||
|
外側の `|` は省略可能で、区切り行の `:` による左寄せ・中央寄せ・右寄せ指定も
|
||||||
|
入力時に受け付けます(配置指定自体は保持しません)。
|
||||||
|
|
||||||
|
セル内の `|` とバックスラッシュはMarkdownのbackslash escapeを使用します。
|
||||||
|
改行や前後の空白・タブはHTML文字参照として表し、表形式間の変換で保持します。
|
||||||
|
|
||||||
## 入れ子構造の表現
|
## 入れ子構造の表現
|
||||||
|
|
||||||
構造化データの入れ子は、Excelで編集しやすい列名へ展開されます。
|
構造化データの入れ子は、Excelで編集しやすい列名へ展開されます。
|
||||||
@@ -154,8 +170,8 @@ CSV、TSV、XLSXから構造化形式へ戻す際は、セル文字列を次の
|
|||||||
|
|
||||||
- `-i`: 入力ファイル。省略時はstdin。
|
- `-i`: 入力ファイル。省略時はstdin。
|
||||||
- `-o`: 出力ファイル。省略時はstdout。
|
- `-o`: 出力ファイル。省略時はstdout。
|
||||||
- `-from`: 入力形式。`json`, `yaml`, `toml`, `csv`, `tsv`, `xlsx`。
|
- `-from`: 入力形式。`json`, `yaml`, `toml`, `csv`, `tsv`, `xlsx`, `markdown`。
|
||||||
- `-to`: 出力形式。`json`, `yaml`, `toml`, `csv`, `tsv`, `xlsx`。
|
- `-to`: 出力形式。`json`, `yaml`, `toml`, `csv`, `tsv`, `xlsx`, `markdown`。
|
||||||
- `-sheet`: XLSXの読み書きに使うシート名。既定値は `Sheet1`。
|
- `-sheet`: XLSXの読み書きに使うシート名。既定値は `Sheet1`。
|
||||||
- `-pretty`: JSONなどの構造化出力を整形するか。既定値は `true`。
|
- `-pretty`: JSONなどの構造化出力を整形するか。既定値は `true`。
|
||||||
- `-version`: バージョンを表示して終了します。
|
- `-version`: バージョンを表示して終了します。
|
||||||
@@ -175,3 +191,8 @@ CSV、TSV、XLSXから構造化形式へ戻す際は、セル文字列を次の
|
|||||||
|
|
||||||
- 設計概要: [docs/architecture.md](docs/architecture.md)
|
- 設計概要: [docs/architecture.md](docs/architecture.md)
|
||||||
- 開発手順: [docs/development.md](docs/development.md)
|
- 開発手順: [docs/development.md](docs/development.md)
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
dataxlは[MIT License](LICENSE)で提供します。配布バイナリに含まれる依存ソフトウェアの
|
||||||
|
著作権表示とライセンスは[THIRD_PARTY_LICENSES.txt](THIRD_PARTY_LICENSES.txt)を参照してください。
|
||||||
|
|||||||
@@ -0,0 +1,764 @@
|
|||||||
|
THIRD-PARTY SOFTWARE NOTICES
|
||||||
|
|
||||||
|
This file contains license notices for third-party software included in the distributed binary.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: Go standard library
|
||||||
|
License: BSD-3-Clause
|
||||||
|
Source: https://go.dev/LICENSE
|
||||||
|
|
||||||
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google LLC nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: github.com/BurntSushi/toml
|
||||||
|
License: MIT
|
||||||
|
Source: https://github.com/BurntSushi/toml/blob/v1.6.0/COPYING
|
||||||
|
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2013 TOML authors
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
THE SOFTWARE.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: github.com/richardlehane/mscfb
|
||||||
|
License: Apache-2.0
|
||||||
|
Source: https://github.com/richardlehane/mscfb/blob/v1.0.7/LICENSE.txt
|
||||||
|
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: github.com/richardlehane/msoleps/types
|
||||||
|
License: Apache-2.0
|
||||||
|
Source: https://github.com/richardlehane/msoleps/blob/v1.0.6/LICENSE.txt
|
||||||
|
|
||||||
|
|
||||||
|
Apache License
|
||||||
|
Version 2.0, January 2004
|
||||||
|
http://www.apache.org/licenses/
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||||
|
|
||||||
|
1. Definitions.
|
||||||
|
|
||||||
|
"License" shall mean the terms and conditions for use, reproduction,
|
||||||
|
and distribution as defined by Sections 1 through 9 of this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright owner or entity authorized by
|
||||||
|
the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all
|
||||||
|
other entities that control, are controlled by, or are under common
|
||||||
|
control with that entity. For the purposes of this definition,
|
||||||
|
"control" means (i) the power, direct or indirect, to cause the
|
||||||
|
direction or management of such entity, whether by contract or
|
||||||
|
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||||
|
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You" (or "Your") shall mean an individual or Legal Entity
|
||||||
|
exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications,
|
||||||
|
including but not limited to software source code, documentation
|
||||||
|
source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical
|
||||||
|
transformation or translation of a Source form, including but
|
||||||
|
not limited to compiled object code, generated documentation,
|
||||||
|
and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" shall mean the work of authorship, whether in Source or
|
||||||
|
Object form, made available under the License, as indicated by a
|
||||||
|
copyright notice that is included in or attached to the work
|
||||||
|
(an example is provided in the Appendix below).
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object
|
||||||
|
form, that is based on (or derived from) the Work and for which the
|
||||||
|
editorial revisions, annotations, elaborations, or other modifications
|
||||||
|
represent, as a whole, an original work of authorship. For the purposes
|
||||||
|
of this License, Derivative Works shall not include works that remain
|
||||||
|
separable from, or merely link (or bind by name) to the interfaces of,
|
||||||
|
the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including
|
||||||
|
the original version of the Work and any modifications or additions
|
||||||
|
to that Work or Derivative Works thereof, that is intentionally
|
||||||
|
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||||
|
or by an individual or Legal Entity authorized to submit on behalf of
|
||||||
|
the copyright owner. For the purposes of this definition, "submitted"
|
||||||
|
means any form of electronic, verbal, or written communication sent
|
||||||
|
to the Licensor or its representatives, including but not limited to
|
||||||
|
communication on electronic mailing lists, source code control systems,
|
||||||
|
and issue tracking systems that are managed by, or on behalf of, the
|
||||||
|
Licensor for the purpose of discussing and improving the Work, but
|
||||||
|
excluding communication that is conspicuously marked or otherwise
|
||||||
|
designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||||
|
on behalf of whom a Contribution has been received by Licensor and
|
||||||
|
subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
copyright license to reproduce, prepare Derivative Works of,
|
||||||
|
publicly display, publicly perform, sublicense, and distribute the
|
||||||
|
Work and such Derivative Works in Source or Object form.
|
||||||
|
|
||||||
|
3. Grant of Patent License. Subject to the terms and conditions of
|
||||||
|
this License, each Contributor hereby grants to You a perpetual,
|
||||||
|
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||||
|
(except as stated in this section) patent license to make, have made,
|
||||||
|
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||||
|
where such license applies only to those patent claims licensable
|
||||||
|
by such Contributor that are necessarily infringed by their
|
||||||
|
Contribution(s) alone or by combination of their Contribution(s)
|
||||||
|
with the Work to which such Contribution(s) was submitted. If You
|
||||||
|
institute patent litigation against any entity (including a
|
||||||
|
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||||
|
or a Contribution incorporated within the Work constitutes direct
|
||||||
|
or contributory patent infringement, then any patent licenses
|
||||||
|
granted to You under this License for that Work shall terminate
|
||||||
|
as of the date such litigation is filed.
|
||||||
|
|
||||||
|
4. Redistribution. You may reproduce and distribute copies of the
|
||||||
|
Work or Derivative Works thereof in any medium, with or without
|
||||||
|
modifications, and in Source or Object form, provided that You
|
||||||
|
meet the following conditions:
|
||||||
|
|
||||||
|
(a) You must give any other recipients of the Work or
|
||||||
|
Derivative Works a copy of this License; and
|
||||||
|
|
||||||
|
(b) You must cause any modified files to carry prominent notices
|
||||||
|
stating that You changed the files; and
|
||||||
|
|
||||||
|
(c) You must retain, in the Source form of any Derivative Works
|
||||||
|
that You distribute, all copyright, patent, trademark, and
|
||||||
|
attribution notices from the Source form of the Work,
|
||||||
|
excluding those notices that do not pertain to any part of
|
||||||
|
the Derivative Works; and
|
||||||
|
|
||||||
|
(d) If the Work includes a "NOTICE" text file as part of its
|
||||||
|
distribution, then any Derivative Works that You distribute must
|
||||||
|
include a readable copy of the attribution notices contained
|
||||||
|
within such NOTICE file, excluding those notices that do not
|
||||||
|
pertain to any part of the Derivative Works, in at least one
|
||||||
|
of the following places: within a NOTICE text file distributed
|
||||||
|
as part of the Derivative Works; within the Source form or
|
||||||
|
documentation, if provided along with the Derivative Works; or,
|
||||||
|
within a display generated by the Derivative Works, if and
|
||||||
|
wherever such third-party notices normally appear. The contents
|
||||||
|
of the NOTICE file are for informational purposes only and
|
||||||
|
do not modify the License. You may add Your own attribution
|
||||||
|
notices within Derivative Works that You distribute, alongside
|
||||||
|
or as an addendum to the NOTICE text from the Work, provided
|
||||||
|
that such additional attribution notices cannot be construed
|
||||||
|
as modifying the License.
|
||||||
|
|
||||||
|
You may add Your own copyright statement to Your modifications and
|
||||||
|
may provide additional or different license terms and conditions
|
||||||
|
for use, reproduction, or distribution of Your modifications, or
|
||||||
|
for any such Derivative Works as a whole, provided Your use,
|
||||||
|
reproduction, and distribution of the Work otherwise complies with
|
||||||
|
the conditions stated in this License.
|
||||||
|
|
||||||
|
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||||
|
any Contribution intentionally submitted for inclusion in the Work
|
||||||
|
by You to the Licensor shall be under the terms and conditions of
|
||||||
|
this License, without any additional terms or conditions.
|
||||||
|
Notwithstanding the above, nothing herein shall supersede or modify
|
||||||
|
the terms of any separate license agreement you may have executed
|
||||||
|
with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
6. Trademarks. This License does not grant permission to use the trade
|
||||||
|
names, trademarks, service marks, or product names of the Licensor,
|
||||||
|
except as required for reasonable and customary use in describing the
|
||||||
|
origin of the Work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||||
|
agreed to in writing, Licensor provides the Work (and each
|
||||||
|
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||||
|
implied, including, without limitation, any warranties or conditions
|
||||||
|
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||||
|
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||||
|
appropriateness of using or redistributing the Work and assume any
|
||||||
|
risks associated with Your exercise of permissions under this License.
|
||||||
|
|
||||||
|
8. Limitation of Liability. In no event and under no legal theory,
|
||||||
|
whether in tort (including negligence), contract, or otherwise,
|
||||||
|
unless required by applicable law (such as deliberate and grossly
|
||||||
|
negligent acts) or agreed to in writing, shall any Contributor be
|
||||||
|
liable to You for damages, including any direct, indirect, special,
|
||||||
|
incidental, or consequential damages of any character arising as a
|
||||||
|
result of this License or out of the use or inability to use the
|
||||||
|
Work (including but not limited to damages for loss of goodwill,
|
||||||
|
work stoppage, computer failure or malfunction, or any and all
|
||||||
|
other commercial damages or losses), even if such Contributor
|
||||||
|
has been advised of the possibility of such damages.
|
||||||
|
|
||||||
|
9. Accepting Warranty or Additional Liability. While redistributing
|
||||||
|
the Work or Derivative Works thereof, You may choose to offer,
|
||||||
|
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||||
|
or other liability obligations and/or rights consistent with this
|
||||||
|
License. However, in accepting such obligations, You may act only
|
||||||
|
on Your own behalf and on Your sole responsibility, not on behalf
|
||||||
|
of any other Contributor, and only if You agree to indemnify,
|
||||||
|
defend, and hold each Contributor harmless for any liability
|
||||||
|
incurred by, or claims asserted against, such Contributor by reason
|
||||||
|
of your accepting any such warranty or additional liability.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
APPENDIX: How to apply the Apache License to your work.
|
||||||
|
|
||||||
|
To apply the Apache License to your work, attach the following
|
||||||
|
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||||
|
replaced with your own identifying information. (Don't include
|
||||||
|
the brackets!) The text should be enclosed in the appropriate
|
||||||
|
comment syntax for the file format. We also recommend that a
|
||||||
|
file or class name and description of purpose be included on the
|
||||||
|
same "printed page" as the copyright notice for easier
|
||||||
|
identification within third-party archives.
|
||||||
|
|
||||||
|
Copyright [yyyy] [name of copyright owner]
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: github.com/tiendc/go-deepcopy
|
||||||
|
License: MIT
|
||||||
|
Source: https://github.com/tiendc/go-deepcopy/blob/v1.7.2/LICENSE
|
||||||
|
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2023 tiendc
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: github.com/xuri/efp
|
||||||
|
License: BSD-3-Clause
|
||||||
|
Source: https://github.com/xuri/efp/blob/v0.0.1/LICENSE
|
||||||
|
|
||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2017 - 2025 Ri Xu All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of efp nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: github.com/xuri/excelize/v2
|
||||||
|
License: BSD-3-Clause
|
||||||
|
Source: https://github.com/xuri/excelize/blob/v2.11.0/LICENSE
|
||||||
|
|
||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2016-2026 The excelize Authors.
|
||||||
|
Copyright (c) 2011-2017 Geoffrey J. Teale
|
||||||
|
All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: github.com/xuri/nfp
|
||||||
|
License: BSD-3-Clause
|
||||||
|
Source: https://github.com/xuri/nfp/blob/2ddeb826f9a9/LICENSE
|
||||||
|
|
||||||
|
BSD 3-Clause License
|
||||||
|
|
||||||
|
Copyright (c) 2022-2025 Ri Xu All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
* Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
* Neither the name of nfp nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
================================================================================
|
||||||
|
Package: golang.org/x/crypto
|
||||||
|
License: BSD-3-Clause
|
||||||
|
Source: https://cs.opensource.google/go/x/crypto/+/v0.53.0:LICENSE
|
||||||
|
|
||||||
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google LLC nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: golang.org/x/net/html
|
||||||
|
License: BSD-3-Clause
|
||||||
|
Source: https://cs.opensource.google/go/x/net/+/v0.56.0:LICENSE
|
||||||
|
|
||||||
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google LLC nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: golang.org/x/text
|
||||||
|
License: BSD-3-Clause
|
||||||
|
Source: https://cs.opensource.google/go/x/text/+/v0.39.0:LICENSE
|
||||||
|
|
||||||
|
Copyright 2009 The Go Authors.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are
|
||||||
|
met:
|
||||||
|
|
||||||
|
* Redistributions of source code must retain the above copyright
|
||||||
|
notice, this list of conditions and the following disclaimer.
|
||||||
|
* Redistributions in binary form must reproduce the above
|
||||||
|
copyright notice, this list of conditions and the following disclaimer
|
||||||
|
in the documentation and/or other materials provided with the
|
||||||
|
distribution.
|
||||||
|
* Neither the name of Google LLC nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: gopkg.in/yaml.v3
|
||||||
|
License: MIT
|
||||||
|
Source: https://github.com/go-yaml/yaml/blob/v3.0.1/LICENSE
|
||||||
|
|
||||||
|
|
||||||
|
This project is covered by two different licenses: MIT and Apache.
|
||||||
|
|
||||||
|
#### MIT License ####
|
||||||
|
|
||||||
|
The following files were ported to Go from C files of libyaml, and thus
|
||||||
|
are still covered by their original MIT license, with the additional
|
||||||
|
copyright staring in 2011 when the project was ported over:
|
||||||
|
|
||||||
|
apic.go emitterc.go parserc.go readerc.go scannerc.go
|
||||||
|
writerc.go yamlh.go yamlprivateh.go
|
||||||
|
|
||||||
|
Copyright (c) 2006-2010 Kirill Simonov
|
||||||
|
Copyright (c) 2006-2011 Kirill Simonov
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||||
|
this software and associated documentation files (the "Software"), to deal in
|
||||||
|
the Software without restriction, including without limitation the rights to
|
||||||
|
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
||||||
|
of the Software, and to permit persons to whom the Software is furnished to do
|
||||||
|
so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
||||||
|
|
||||||
|
### Apache License ###
|
||||||
|
|
||||||
|
All the remaining project files are covered by the Apache license:
|
||||||
|
|
||||||
|
Copyright (c) 2011-2019 Canonical Ltd
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
@@ -51,6 +51,8 @@ func normalizeFormat(format string) string {
|
|||||||
switch format {
|
switch format {
|
||||||
case "yml":
|
case "yml":
|
||||||
return "yaml"
|
return "yaml"
|
||||||
|
case "md", "mdown", "mkd":
|
||||||
|
return "markdown"
|
||||||
case "xlsm", "xls":
|
case "xlsm", "xls":
|
||||||
return "xlsx"
|
return "xlsx"
|
||||||
default:
|
default:
|
||||||
@@ -67,7 +69,7 @@ func inferFormat(path string) string {
|
|||||||
|
|
||||||
func validateFormat(format string) error {
|
func validateFormat(format string) error {
|
||||||
switch format {
|
switch format {
|
||||||
case "json", "yaml", "toml", "csv", "tsv", "xlsx":
|
case "json", "yaml", "toml", "csv", "tsv", "xlsx", "markdown":
|
||||||
return nil
|
return nil
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unsupported format %q", format)
|
return fmt.Errorf("unsupported format %q", format)
|
||||||
@@ -75,5 +77,5 @@ func validateFormat(format string) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func isTabular(format string) bool {
|
func isTabular(format string) bool {
|
||||||
return format == "csv" || format == "tsv" || format == "xlsx"
|
return format == "csv" || format == "tsv" || format == "xlsx" || format == "markdown"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func TestConversionMatrixPreservesRepresentativeTable(t *testing.T) {
|
func TestConversionMatrixPreservesRepresentativeTable(t *testing.T) {
|
||||||
formats := []string{"json", "yaml", "toml", "csv", "tsv", "xlsx"}
|
formats := []string{"json", "yaml", "toml", "csv", "tsv", "xlsx", "markdown"}
|
||||||
records := []any{
|
records := []any{
|
||||||
map[string]any{
|
map[string]any{
|
||||||
"active": true,
|
"active": true,
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ func TestDelimitedSingleEmptyCellRowRoundTrip(t *testing.T) {
|
|||||||
|
|
||||||
func TestStructuredRecordsWithoutScalarFieldsAreRejectedForTables(t *testing.T) {
|
func TestStructuredRecordsWithoutScalarFieldsAreRejectedForTables(t *testing.T) {
|
||||||
for _, input := range []string{`{}`, `[{}]`} {
|
for _, input := range []string{`{}`, `[{}]`} {
|
||||||
for _, format := range []string{"csv", "tsv", "xlsx"} {
|
for _, format := range []string{"csv", "tsv", "xlsx", "markdown"} {
|
||||||
t.Run(format+"_"+input, func(t *testing.T) {
|
t.Run(format+"_"+input, func(t *testing.T) {
|
||||||
_, err := convert([]byte(input), "json", format, "Sheet1", false)
|
_, err := convert([]byte(input), "json", format, "Sheet1", false)
|
||||||
if err == nil || !strings.Contains(err.Error(), "no scalar fields") {
|
if err == nil || !strings.Contains(err.Error(), "no scalar fields") {
|
||||||
@@ -232,7 +232,7 @@ func TestStructuredRecordsWithoutScalarFieldsAreRejectedForTables(t *testing.T)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestEmptyRecordListCanRoundTripThroughDelimitedFormats(t *testing.T) {
|
func TestEmptyRecordListCanRoundTripThroughDelimitedFormats(t *testing.T) {
|
||||||
for _, format := range []string{"csv", "tsv"} {
|
for _, format := range []string{"csv", "tsv", "markdown"} {
|
||||||
t.Run(format, func(t *testing.T) {
|
t.Run(format, func(t *testing.T) {
|
||||||
tabular, err := convert([]byte(`[]`), "json", format, "Sheet1", false)
|
tabular, err := convert([]byte(`[]`), "json", format, "Sheet1", false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
// Package main implements the dataxl command-line converter.
|
// Package main implements the dataxl command-line converter.
|
||||||
//
|
//
|
||||||
// Conversion uses two internal representations: structured Go values for
|
// Conversion uses two internal representations: structured Go values for
|
||||||
// JSON/YAML/TOML and table for CSV/TSV/XLSX. Nested structured values cross the
|
// JSON/YAML/TOML and table for CSV/TSV/XLSX/Markdown. Nested structured values cross the
|
||||||
// boundary through dotted and indexed column paths such as user.name and
|
// boundary through dotted and indexed column paths such as user.name and
|
||||||
// items[0].sku.
|
// items[0].sku.
|
||||||
package main
|
package main
|
||||||
|
|||||||
+3
-3
@@ -60,8 +60,8 @@ func parseOptions(args []string, stderr io.Writer) (options, error) {
|
|||||||
fs.SetOutput(stderr)
|
fs.SetOutput(stderr)
|
||||||
fs.StringVar(&opt.inFile, "i", "", "input file, defaults to stdin")
|
fs.StringVar(&opt.inFile, "i", "", "input file, defaults to stdin")
|
||||||
fs.StringVar(&opt.outFile, "o", "", "output file, defaults to stdout")
|
fs.StringVar(&opt.outFile, "o", "", "output file, defaults to stdout")
|
||||||
fs.StringVar(&opt.from, "from", "", "input format: json, yaml, toml, csv, tsv, xlsx")
|
fs.StringVar(&opt.from, "from", "", "input format: json, yaml, toml, csv, tsv, xlsx, markdown")
|
||||||
fs.StringVar(&opt.to, "to", "", "output format: json, yaml, toml, csv, tsv, xlsx")
|
fs.StringVar(&opt.to, "to", "", "output format: json, yaml, toml, csv, tsv, xlsx, markdown")
|
||||||
fs.StringVar(&opt.sheet, "sheet", "Sheet1", "worksheet name for xlsx input/output")
|
fs.StringVar(&opt.sheet, "sheet", "Sheet1", "worksheet name for xlsx input/output")
|
||||||
fs.BoolVar(&opt.pretty, "pretty", true, "pretty-print structured output")
|
fs.BoolVar(&opt.pretty, "pretty", true, "pretty-print structured output")
|
||||||
fs.BoolVar(&opt.version, "version", false, "print version and exit")
|
fs.BoolVar(&opt.version, "version", false, "print version and exit")
|
||||||
@@ -72,7 +72,7 @@ func parseOptions(args []string, stderr io.Writer) (options, error) {
|
|||||||
dataxl -from json -to xlsx -i data.json -o data.xlsx
|
dataxl -from json -to xlsx -i data.json -o data.xlsx
|
||||||
|
|
||||||
Formats:
|
Formats:
|
||||||
json, yaml/yml, toml, csv, tsv, xlsx
|
json, yaml/yml, toml, csv, tsv, xlsx, markdown/md
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
Structured records are flattened into spreadsheet columns such as user.name
|
Structured records are flattened into spreadsheet columns such as user.name
|
||||||
|
|||||||
@@ -129,6 +129,49 @@ func TestResolveFormatsFromFileExtensions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestResolveMarkdownFormatFromFileExtension(t *testing.T) {
|
||||||
|
opt := options{inFile: "input.json", outFile: "output.md"}
|
||||||
|
if err := opt.resolveFormats(); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if opt.from != "json" || opt.to != "markdown" {
|
||||||
|
t.Fatalf("resolved formats = %q -> %q, want json -> markdown", opt.from, opt.to)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarkdownTableRoundTrip(t *testing.T) {
|
||||||
|
want := table{
|
||||||
|
Header: []string{"id", "name", "note"},
|
||||||
|
Rows: [][]string{{"1", "Alice | Bob", "line 1\nline 2\\n"}},
|
||||||
|
}
|
||||||
|
encoded, err := encodeTable(want, "markdown", "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
got, err := parseTable(encoded, "markdown", "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("parse generated Markdown: %v\n%s", err, encoded)
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(got, want) {
|
||||||
|
t.Fatalf("table = %#v, want %#v\n%s", got, want, encoded)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarkdownTableAcceptsAlignmentAndOptionalOuterPipes(t *testing.T) {
|
||||||
|
input := []byte("id | name | note\n---: | :--- | :---:\n1 | Alice \\| Bob | ok\n")
|
||||||
|
got, err := parseTable(input, "markdown", "")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
want := table{
|
||||||
|
Header: []string{"id", "name", "note"},
|
||||||
|
Rows: [][]string{{"1", "Alice | Bob", "ok"}},
|
||||||
|
}
|
||||||
|
if !reflect.DeepEqual(got, want) {
|
||||||
|
t.Fatalf("table = %#v, want %#v", got, want)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestVersionFlagDoesNotRequireFormats(t *testing.T) {
|
func TestVersionFlagDoesNotRequireFormats(t *testing.T) {
|
||||||
oldVersion := buildVersion
|
oldVersion := buildVersion
|
||||||
buildVersion = "v9.8.7-test"
|
buildVersion = "v9.8.7-test"
|
||||||
|
|||||||
+200
-1
@@ -5,14 +5,16 @@ import (
|
|||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"html"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
"unicode/utf8"
|
"unicode/utf8"
|
||||||
|
|
||||||
"github.com/xuri/excelize/v2"
|
"github.com/xuri/excelize/v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
// table is the common representation for CSV, TSV and XLSX. Rows are padded
|
// table is the common representation for CSV, TSV, XLSX and Markdown. Rows are padded
|
||||||
// to Header width when read, which keeps subsequent conversions rectangular.
|
// to Header width when read, which keeps subsequent conversions rectangular.
|
||||||
type table struct {
|
type table struct {
|
||||||
Header []string
|
Header []string
|
||||||
@@ -36,6 +38,8 @@ func parseTable(input []byte, format, sheet string) (table, error) {
|
|||||||
return table{}, err
|
return table{}, err
|
||||||
}
|
}
|
||||||
return rowsToTable(rows)
|
return rowsToTable(rows)
|
||||||
|
case "markdown":
|
||||||
|
return readMarkdown(input)
|
||||||
default:
|
default:
|
||||||
return table{}, fmt.Errorf("format %q is not tabular", format)
|
return table{}, fmt.Errorf("format %q is not tabular", format)
|
||||||
}
|
}
|
||||||
@@ -93,11 +97,206 @@ func encodeTable(t table, format, sheet string) ([]byte, error) {
|
|||||||
return writeDelimited(t, '\t')
|
return writeDelimited(t, '\t')
|
||||||
case "xlsx":
|
case "xlsx":
|
||||||
return writeXLSX(t, sheet)
|
return writeXLSX(t, sheet)
|
||||||
|
case "markdown":
|
||||||
|
return writeMarkdown(t)
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("format %q is not tabular", format)
|
return nil, fmt.Errorf("format %q is not tabular", format)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func readMarkdown(input []byte) (table, error) {
|
||||||
|
input = bytes.TrimPrefix(input, []byte{0xEF, 0xBB, 0xBF})
|
||||||
|
if !utf8.Valid(input) {
|
||||||
|
return table{}, fmt.Errorf("markdown input is not valid UTF-8")
|
||||||
|
}
|
||||||
|
text := strings.ReplaceAll(string(input), "\r\n", "\n")
|
||||||
|
text = strings.TrimSpace(text)
|
||||||
|
if text == "" {
|
||||||
|
return table{}, nil
|
||||||
|
}
|
||||||
|
lines := strings.Split(text, "\n")
|
||||||
|
if len(lines) < 2 {
|
||||||
|
return table{}, fmt.Errorf("markdown table requires a header and separator row")
|
||||||
|
}
|
||||||
|
header, err := parseMarkdownRow(lines[0])
|
||||||
|
if err != nil {
|
||||||
|
return table{}, fmt.Errorf("markdown header: %w", err)
|
||||||
|
}
|
||||||
|
separator, err := parseMarkdownRow(lines[1])
|
||||||
|
if err != nil {
|
||||||
|
return table{}, fmt.Errorf("markdown separator: %w", err)
|
||||||
|
}
|
||||||
|
if len(separator) != len(header) {
|
||||||
|
return table{}, fmt.Errorf("markdown separator has %d fields but the header has %d", len(separator), len(header))
|
||||||
|
}
|
||||||
|
for i, cell := range separator {
|
||||||
|
value := strings.TrimSpace(cell)
|
||||||
|
value = strings.TrimPrefix(value, ":")
|
||||||
|
value = strings.TrimSuffix(value, ":")
|
||||||
|
if len(value) < 3 || strings.Trim(value, "-") != "" {
|
||||||
|
return table{}, fmt.Errorf("markdown separator field %d is invalid", i+1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rows := make([][]string, 0, len(lines)-2)
|
||||||
|
for i, line := range lines[2:] {
|
||||||
|
if strings.TrimSpace(line) == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
row, err := parseMarkdownRow(line)
|
||||||
|
if err != nil {
|
||||||
|
return table{}, fmt.Errorf("markdown row %d: %w", i+3, err)
|
||||||
|
}
|
||||||
|
if len(row) > len(header) {
|
||||||
|
return table{}, fmt.Errorf("row %d has %d fields but the header has %d", i+3, len(row), len(header))
|
||||||
|
}
|
||||||
|
rows = append(rows, padRow(row, len(header)))
|
||||||
|
}
|
||||||
|
return table{Header: header, Rows: rows}, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseMarkdownRow(line string) ([]string, error) {
|
||||||
|
line = strings.TrimSpace(strings.TrimSuffix(line, "\r"))
|
||||||
|
if strings.HasPrefix(line, "|") {
|
||||||
|
line = line[1:]
|
||||||
|
}
|
||||||
|
if hasUnescapedTrailingPipe(line) {
|
||||||
|
line = strings.TrimSpace(line[:len(line)-1])
|
||||||
|
}
|
||||||
|
var cells []string
|
||||||
|
var cell strings.Builder
|
||||||
|
escaped := false
|
||||||
|
for _, r := range line {
|
||||||
|
if escaped {
|
||||||
|
cell.WriteRune('\\')
|
||||||
|
cell.WriteRune(r)
|
||||||
|
escaped = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if r == '\\' {
|
||||||
|
escaped = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if r == '|' {
|
||||||
|
cells = append(cells, decodeMarkdownCell(strings.Trim(cell.String(), " \t")))
|
||||||
|
cell.Reset()
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
cell.WriteRune(r)
|
||||||
|
}
|
||||||
|
if escaped {
|
||||||
|
return nil, fmt.Errorf("row ends with an incomplete escape")
|
||||||
|
}
|
||||||
|
cells = append(cells, decodeMarkdownCell(strings.Trim(cell.String(), " \t")))
|
||||||
|
return cells, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func decodeMarkdownCell(value string) string {
|
||||||
|
var b strings.Builder
|
||||||
|
escaped := false
|
||||||
|
for _, r := range value {
|
||||||
|
if escaped {
|
||||||
|
if r == '\\' || r == '|' {
|
||||||
|
b.WriteRune(r)
|
||||||
|
} else {
|
||||||
|
b.WriteRune('\\')
|
||||||
|
b.WriteRune(r)
|
||||||
|
}
|
||||||
|
escaped = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if r == '\\' {
|
||||||
|
escaped = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
b.WriteRune(r)
|
||||||
|
}
|
||||||
|
return html.UnescapeString(b.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
func hasUnescapedTrailingPipe(line string) bool {
|
||||||
|
line = strings.TrimSpace(line)
|
||||||
|
if !strings.HasSuffix(line, "|") {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
backslashes := 0
|
||||||
|
for i := len(line) - 2; i >= 0 && line[i] == '\\'; i-- {
|
||||||
|
backslashes++
|
||||||
|
}
|
||||||
|
return backslashes%2 == 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func writeMarkdown(t table) ([]byte, error) {
|
||||||
|
if len(t.Header) == 0 && len(t.Rows) == 0 {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
if len(t.Header) == 0 {
|
||||||
|
return nil, fmt.Errorf("markdown table has rows but no header")
|
||||||
|
}
|
||||||
|
var b strings.Builder
|
||||||
|
writeRow := func(row []string) {
|
||||||
|
b.WriteString("| ")
|
||||||
|
for i, value := range row {
|
||||||
|
if i > 0 {
|
||||||
|
b.WriteString(" | ")
|
||||||
|
}
|
||||||
|
b.WriteString(escapeMarkdownCell(value))
|
||||||
|
}
|
||||||
|
b.WriteString(" |\n")
|
||||||
|
}
|
||||||
|
writeRow(t.Header)
|
||||||
|
b.WriteString("|")
|
||||||
|
for range t.Header {
|
||||||
|
b.WriteString(" --- |")
|
||||||
|
}
|
||||||
|
b.WriteByte('\n')
|
||||||
|
for _, row := range t.Rows {
|
||||||
|
writeRow(padRow(row, len(t.Header)))
|
||||||
|
}
|
||||||
|
return []byte(b.String()), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func escapeMarkdownCell(value string) string {
|
||||||
|
leadingEnd := len(value) - len(strings.TrimLeft(value, " \t"))
|
||||||
|
trailingStart := len(strings.TrimRight(value, " \t"))
|
||||||
|
var b strings.Builder
|
||||||
|
for i, r := range value {
|
||||||
|
switch r {
|
||||||
|
case '\\':
|
||||||
|
b.WriteString("\\\\")
|
||||||
|
case '|':
|
||||||
|
b.WriteString("\\|")
|
||||||
|
case '\r':
|
||||||
|
b.WriteString(" ")
|
||||||
|
case '\n':
|
||||||
|
b.WriteString(" ")
|
||||||
|
case ' ':
|
||||||
|
if i < leadingEnd || i >= trailingStart {
|
||||||
|
b.WriteString(" ")
|
||||||
|
} else {
|
||||||
|
b.WriteByte(' ')
|
||||||
|
}
|
||||||
|
case '\t':
|
||||||
|
if i < leadingEnd || i >= trailingStart {
|
||||||
|
b.WriteString("	")
|
||||||
|
} else {
|
||||||
|
b.WriteByte('\t')
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
switch r {
|
||||||
|
case '&':
|
||||||
|
b.WriteString("&")
|
||||||
|
case '<':
|
||||||
|
b.WriteString("<")
|
||||||
|
case '>':
|
||||||
|
b.WriteString(">")
|
||||||
|
default:
|
||||||
|
b.WriteRune(r)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return b.String()
|
||||||
|
}
|
||||||
|
|
||||||
func writeDelimited(t table, comma rune) ([]byte, error) {
|
func writeDelimited(t table, comma rune) ([]byte, error) {
|
||||||
var b bytes.Buffer
|
var b bytes.Buffer
|
||||||
w := csv.NewWriter(&b)
|
w := csv.NewWriter(&b)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
`dataxl` は、ファイル形式ごとの差を小さくするために、内部表現を2つに分けています。
|
`dataxl` は、ファイル形式ごとの差を小さくするために、内部表現を2つに分けています。
|
||||||
|
|
||||||
- structured value: JSON/YAML/TOMLから読める `map[string]any`, `[]any`, scalar
|
- structured value: JSON/YAML/TOMLから読める `map[string]any`, `[]any`, scalar
|
||||||
- table: Excel/CSV/TSVに近い `Header []string` と `Rows [][]string`
|
- table: Excel/CSV/TSV/Markdownに近い `Header []string` と `Rows [][]string`
|
||||||
|
|
||||||
変換は原則として次のどれかです。
|
変換は原則として次のどれかです。
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@
|
|||||||
- `main.go`: CLI option、stdin/stdout、ファイル入出力
|
- `main.go`: CLI option、stdin/stdout、ファイル入出力
|
||||||
- `conversion.go`: 変換経路の選択、形式名の正規化・推定
|
- `conversion.go`: 変換経路の選択、形式名の正規化・推定
|
||||||
- `structured.go`: JSON/YAML/TOML adapter
|
- `structured.go`: JSON/YAML/TOML adapter
|
||||||
- `table.go`: CSV/TSV/XLSX adapter、table model、flatten
|
- `table.go`: CSV/TSV/XLSX/Markdown adapter、table model、flatten
|
||||||
- `path.go`: セル値の型推定、列パスのparse、unflatten
|
- `path.go`: セル値の型推定、列パスのparse、unflatten
|
||||||
|
|
||||||
`convert` はファイル入出力から独立しているため、CLIを経由せず変換matrixをテストできます。
|
`convert` はファイル入出力から独立しているため、CLIを経由せず変換matrixをテストできます。
|
||||||
@@ -40,9 +40,12 @@ type table struct {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
CSV/TSV/XLSXの読み込みでは、短い行を空文字で埋めて列数を揃えます。ヘッダーより
|
CSV/TSV/XLSX/Markdownの読み込みでは、短い行を空文字で埋めて列数を揃えます。ヘッダーより
|
||||||
長い行は、名前のない値を破棄しないようエラーにします。
|
長い行は、名前のない値を破棄しないようエラーにします。
|
||||||
XLSXの書き出しではヘッダーを太字にし、1行目を固定します。
|
XLSXの書き出しではヘッダーを太字にし、1行目を固定します。
|
||||||
|
Markdownでは区切り行のalignment markerを受け付けますが、table modelには保持しません。
|
||||||
|
セル内のdelimiterとバックスラッシュはbackslash escape、改行と前後空白はHTML文字参照で
|
||||||
|
可逆化します。
|
||||||
|
|
||||||
## Flattening
|
## Flattening
|
||||||
|
|
||||||
@@ -129,11 +132,11 @@ TOMLはトップレベル配列を直接表せないため、表からTOMLへ出
|
|||||||
- `gopkg.in/yaml.v3`: YAML読み書き
|
- `gopkg.in/yaml.v3`: YAML読み書き
|
||||||
- `github.com/BurntSushi/toml`: TOML読み書き
|
- `github.com/BurntSushi/toml`: TOML読み書き
|
||||||
|
|
||||||
Go 1.25以上を前提にしています。
|
Go 1.25.13以上を前提にしています。
|
||||||
|
|
||||||
## Error handling
|
## Error handling
|
||||||
|
|
||||||
- 未対応形式、decode失敗、workbook/sheet操作失敗は呼び出し元へerrorを返します。
|
- 未対応形式、decode失敗、workbook/sheet操作失敗は呼び出し元へerrorを返します。
|
||||||
- CSV/TSVのinvalid UTF-8、headerより長い行、値を持つ空header列を拒否します。
|
- CSV/TSV/Markdownのinvalid UTF-8、headerより長い行、値を持つ空header列を拒否します。
|
||||||
- path復元中の重複header、構文エラー、型競合は変換全体をerrorにします。
|
- path復元中の重複header、構文エラー、型競合は変換全体をerrorにします。
|
||||||
- XLSXのstyle・pane設定も通常の変換errorとして扱い、不完全なworkbookを成功扱いしません。
|
- XLSXのstyle・pane設定も通常の変換errorとして扱い、不完全なworkbookを成功扱いしません。
|
||||||
|
|||||||
+12
-1
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
## Requirements
|
## Requirements
|
||||||
|
|
||||||
- Go 1.25 or later
|
- Go 1.25.13 or later
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
|
|
||||||
@@ -44,6 +44,13 @@ Build release archives locally:
|
|||||||
scripts/build-release.sh
|
scripts/build-release.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Refresh the checked-in third-party notices after changing dependencies:
|
||||||
|
|
||||||
|
```sh
|
||||||
|
scripts/update-third-party-licenses.sh
|
||||||
|
git diff --exit-code -- THIRD_PARTY_LICENSES.txt
|
||||||
|
```
|
||||||
|
|
||||||
## Test Coverage
|
## Test Coverage
|
||||||
|
|
||||||
The current tests cover:
|
The current tests cover:
|
||||||
@@ -51,6 +58,7 @@ The current tests cover:
|
|||||||
- YAML -> TSV flattening
|
- YAML -> TSV flattening
|
||||||
- TSV -> JSON path restoration
|
- TSV -> JSON path restoration
|
||||||
- JSON -> XLSX -> JSON round trip
|
- JSON -> XLSX -> JSON round trip
|
||||||
|
- Markdown table parsing, escaping, and all-format conversion round trips
|
||||||
- structured -> structured conversion without CLI/file I/O
|
- structured -> structured conversion without CLI/file I/O
|
||||||
- extension normalization and format inference
|
- extension normalization and format inference
|
||||||
- short table row padding and wider-row rejection
|
- short table row padding and wider-row rejection
|
||||||
@@ -81,6 +89,9 @@ macOS, and Windows on amd64/arm64, writes `checksums.txt`, creates or reuses a
|
|||||||
Gitea Release, and uploads the generated assets. It uses the built-in
|
Gitea Release, and uploads the generated assets. It uses the built-in
|
||||||
`${{ secrets.GITEA_TOKEN }}` provided by Gitea Actions.
|
`${{ secrets.GITEA_TOKEN }}` provided by Gitea Actions.
|
||||||
|
|
||||||
|
Each release archive contains the project `LICENSE` and
|
||||||
|
`THIRD_PARTY_LICENSES.txt` in addition to the binary and README.
|
||||||
|
|
||||||
Release binaries receive their tag through the `main.buildVersion` linker
|
Release binaries receive their tag through the `main.buildVersion` linker
|
||||||
variable. Verify an extracted native binary with `dataxl -version`.
|
variable. Verify an extracted native binary with `dataxl -version`.
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
module git.rumginger.org/agent/dataxl
|
module git.rumginger.org/agent/dataxl
|
||||||
|
|
||||||
go 1.25.0
|
go 1.25.13
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v1.6.0
|
github.com/BurntSushi/toml v1.6.0
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ for target in "${targets[@]}"; do
|
|||||||
-o "$workdir/$binary" \
|
-o "$workdir/$binary" \
|
||||||
./cmd/dataxl
|
./cmd/dataxl
|
||||||
|
|
||||||
cp README.md "$workdir/"
|
cp README.md LICENSE THIRD_PARTY_LICENSES.txt "$workdir/"
|
||||||
|
|
||||||
if [ "$goos" = "windows" ]; then
|
if [ "$goos" = "windows" ]; then
|
||||||
(cd dist && zip -qr "${name}.zip" "$name")
|
(cd dist && zip -qr "${name}.zip" "$name")
|
||||||
|
|||||||
Executable
+57
@@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||||
|
temp_dir="$(mktemp -d)"
|
||||||
|
trap 'rm -rf "$temp_dir"' EXIT
|
||||||
|
|
||||||
|
go_license="$(go env GOROOT)/LICENSE"
|
||||||
|
if [ ! -f "$go_license" ] && [ -f /usr/share/licenses/go/LICENSE ]; then
|
||||||
|
go_license=/usr/share/licenses/go/LICENSE
|
||||||
|
fi
|
||||||
|
if [ ! -f "$go_license" ]; then
|
||||||
|
echo "Go license file was not found" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat >"$temp_dir/template.txt" <<'EOF'
|
||||||
|
{{ range . }}================================================================================
|
||||||
|
Package: {{ .Name }}
|
||||||
|
License: {{ .LicenseName }}
|
||||||
|
Source: {{ .LicenseURL }}
|
||||||
|
|
||||||
|
{{ .LicenseText }}
|
||||||
|
{{ end }}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
{
|
||||||
|
cat <<'EOF'
|
||||||
|
THIRD-PARTY SOFTWARE NOTICES
|
||||||
|
|
||||||
|
This file contains license notices for third-party software included in the distributed binary.
|
||||||
|
|
||||||
|
================================================================================
|
||||||
|
Package: Go standard library
|
||||||
|
License: BSD-3-Clause
|
||||||
|
Source: https://go.dev/LICENSE
|
||||||
|
|
||||||
|
EOF
|
||||||
|
cat "$go_license"
|
||||||
|
printf '\n'
|
||||||
|
cd "$repo_root"
|
||||||
|
go run github.com/google/go-licenses/[email protected] report ./cmd/dataxl \
|
||||||
|
--ignore=git.rumginger.org/agent/dataxl \
|
||||||
|
--template="$temp_dir/template.txt"
|
||||||
|
} >"$temp_dir/THIRD_PARTY_LICENSES.txt"
|
||||||
|
|
||||||
|
awk '
|
||||||
|
{ lines[NR] = $0 }
|
||||||
|
$0 !~ /^[[:space:]]*$/ { last_content_line = NR }
|
||||||
|
END {
|
||||||
|
for (line_number = 1; line_number <= last_content_line; line_number++) {
|
||||||
|
print lines[line_number]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
' "$temp_dir/THIRD_PARTY_LICENSES.txt" >"$temp_dir/THIRD_PARTY_LICENSES.normalized.txt"
|
||||||
|
|
||||||
|
mv "$temp_dir/THIRD_PARTY_LICENSES.normalized.txt" "$repo_root/THIRD_PARTY_LICENSES.txt"
|
||||||
Reference in New Issue
Block a user