Treat Markdown (*.py.md) as Python source: transpile and run.
Project description
mdsrc
Markdown を Python ソースとして扱うツール。拡張子は *.py.md。
mdsrc run tutorials/hello.py.md # python hello.py 相当
mdsrc run -m pkg # python -m pkg 相当
mdsrc run tutorials/app/ # python dir/ 相当(__main__.py を実行)
mdsrc build [path] # 生成のみ(実行しない)
変換ルール
- バッククォートのフェンス付きコードブロック(
```)だけがソースになる。 Python プロファイルでは~~~はフェンス扱いせず散文とする。 - 言語タグが空・
python・pyのブロックを Python として取り込む。 それ以外(bash,json…)は無視。 - 入力拡張子・出力拡張子・ランナー・フェンス文字・言語タグは言語ごとの
「プロファイル」に集約される。スキーマは
mdsrc/languages/base.py、各言語はmdsrc/languages/<lang>/(現状python/のPYTHON)に置き、他言語 (例:*.sh.md用のshell/)を追加できる。 - インラインコード(
`x`)は取り込まない。 - 散文・フェンス行・非 Python ブロックは空行に置換され、生成
.pyの 行番号が.py.mdと 1:1 で一致する(traceback が Markdown の行を指す)。
仕組み
foo.py.md → 同じ場所に foo.py を生成。実行前にツリー内の全 *.py.md を
ビルドするため、Markdown モジュール同士の import も解決される。生成された
.py はビルド成果物なので .gitignore 済み。
チュートリアル
uv run mdsrc run tutorials/app/
uv run mdsrc run tutorials/hello.py.md
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
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 mdsrc-0.1.0.tar.gz.
File metadata
- Download URL: mdsrc-0.1.0.tar.gz
- Upload date:
- Size: 17.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57e4b92e561bec76822bce0f846a144b8b3906a36b02cb3beba77e8ac5c85dad
|
|
| MD5 |
845cfa5c9b069f686bc8843c5863a194
|
|
| BLAKE2b-256 |
bd5d181c66769790d9440df8828b532a7848785c0a1b07aad13698a53e3cd0d8
|
Provenance
The following attestation bundles were made for mdsrc-0.1.0.tar.gz:
Publisher:
release.yml on sasano8/mdsrc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mdsrc-0.1.0.tar.gz -
Subject digest:
57e4b92e561bec76822bce0f846a144b8b3906a36b02cb3beba77e8ac5c85dad - Sigstore transparency entry: 2021623652
- Sigstore integration time:
-
Permalink:
sasano8/mdsrc@49464c1846ffbbd13b8f1f2d70420870bc1d3aa4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sasano8
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@49464c1846ffbbd13b8f1f2d70420870bc1d3aa4 -
Trigger Event:
push
-
Statement type:
File details
Details for the file mdsrc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: mdsrc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7c4712ecbc50ddcfca33726466cf2f79a5db2068b89f424dd182b91bd43860e0
|
|
| MD5 |
33525c2a1b36c107c9ac725792c32f3a
|
|
| BLAKE2b-256 |
daa9ce9abb90a4d289c70f3e6b40592dba7c8dbb032a64c8f61da73ebb0fcdbe
|
Provenance
The following attestation bundles were made for mdsrc-0.1.0-py3-none-any.whl:
Publisher:
release.yml on sasano8/mdsrc
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mdsrc-0.1.0-py3-none-any.whl -
Subject digest:
7c4712ecbc50ddcfca33726466cf2f79a5db2068b89f424dd182b91bd43860e0 - Sigstore transparency entry: 2021623730
- Sigstore integration time:
-
Permalink:
sasano8/mdsrc@49464c1846ffbbd13b8f1f2d70420870bc1d3aa4 -
Branch / Tag:
refs/tags/v0.1.0 - Owner: https://github.com/sasano8
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@49464c1846ffbbd13b8f1f2d70420870bc1d3aa4 -
Trigger Event:
push
-
Statement type: