Skip to main content

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 プロファイルでは ~~~ はフェンス扱いせず散文とする。
  • 言語タグが空・pythonpy のブロックを 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdsrc-0.1.0.tar.gz (17.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mdsrc-0.1.0-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

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

Hashes for mdsrc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 57e4b92e561bec76822bce0f846a144b8b3906a36b02cb3beba77e8ac5c85dad
MD5 845cfa5c9b069f686bc8843c5863a194
BLAKE2b-256 bd5d181c66769790d9440df8828b532a7848785c0a1b07aad13698a53e3cd0d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdsrc-0.1.0.tar.gz:

Publisher: release.yml on sasano8/mdsrc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for mdsrc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7c4712ecbc50ddcfca33726466cf2f79a5db2068b89f424dd182b91bd43860e0
MD5 33525c2a1b36c107c9ac725792c32f3a
BLAKE2b-256 daa9ce9abb90a4d289c70f3e6b40592dba7c8dbb032a64c8f61da73ebb0fcdbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for mdsrc-0.1.0-py3-none-any.whl:

Publisher: release.yml on sasano8/mdsrc

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page