Convert HTML tables embedded in JSON to Markdown extended table syntax
Project description
jsontable2md
jsontable2mdは、JSON内に埋め込まれたHTMLテーブルをMarkdown拡張記法(> / ^ によるセル結合表現)へ変換するPythonライブラリです。rowspan / colspan を解析し、元のJSON構造を保持したままテーブル部分のみMarkdownへ置換します。
特徴
- JSON内の複雑な
rowspan/colspanを含むHTMLテーブルをMarkdown化 <caption>は太字行として取り込み- クロスプラットフォーム対応(Windows/Linux/Mac)
インストール
pip install jsontable2md
使用方法
from jsontable2md import convert_file
# 基本的な使用方法
converted = convert_file(
input_path="input.json",
output_path="output.json"
)
# 上書きを許可する場合
converted = convert_file(
input_path="input.json",
output_path="output.json",
overwrite=True
)
パラメータ(convert_file)
input_path(str | Path): 入力JSONファイルパスoutput_path(str | Path): 出力先ファイルパスoverwrite(bool): 既存出力を上書きするか(デフォルト: False)
戻り値(convert_file)
戻り値は変換後の JSON オブジェクト(dict)。
エラーハンドリング
from jsontable2md import convert_file
import logging
# ログレベルの設定
logging.basicConfig(level=logging.INFO)
try:
converted = convert_file(input_path="input.json",output_path="output.json")
print("JSON内に埋め込まれたHTMLテーブルをMarkdown拡張記法に変換完了しました")
except Exception as e:
print(f"エラーが発生しました: {e}")
ライセンス
本プロジェクトはMITライセンスの下で公開されています。詳細はLICENSEファイルをご覧ください。
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
jsontable2md-0.1.0.tar.gz
(8.6 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file jsontable2md-0.1.0.tar.gz.
File metadata
- Download URL: jsontable2md-0.1.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
03dbeb6d6bab8c8eb92d4a0b827254fbf43882a1142ab6c91224f6bb8b38eb03
|
|
| MD5 |
d0cf7782fb7149adcc7d80126faf41c2
|
|
| BLAKE2b-256 |
2a1b207059c58390fe7756dd5e5c5e5641148bccd25f2c2973e96784bb4b3764
|
File details
Details for the file jsontable2md-0.1.0-py3-none-any.whl.
File metadata
- Download URL: jsontable2md-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f9fde922032229398eec67c6867bc6fd7af259e12acaea7b01c561015b35007a
|
|
| MD5 |
71e5223bcb6eaaf5162137359b9cb376
|
|
| BLAKE2b-256 |
7a7463298037153f4b5a67a45546e780dea344f845aebe94ac43d224b3e42495
|