Skip to main content

HOS M2F: Markdown→DOCX/PDF/XML/JSON + Mermaid/Matplotlib/Table→PNG

Project description

HOS_M2F

Markdown 多格式转换与图形渲染:支持 DOCX/PDF/XML/JSON,以及将 Mermaid/Matplotlib/表格渲染为图片(PNG)。

功能

  • Markdown → DOCX/PDF/XML/JSON
  • Mermaid → PNG
  • 自动识别 python/matplotlib 代码块并生成图像
  • 自动识别 Markdown 表格,优先渲染为 PNG,失败回退为结构或文本

安装

python -m pip install HOS_M2F
# 首次使用需安装浏览器内核
python -m playwright install chromium

命令行

  • 点号脚本(推荐):
    HOS_M2F.2docx input.md output.docx
    HOS_M2F.2pdf  input.md output.pdf
    HOS_M2F.2xml  input.md output.xml
    HOS_M2F.2json input.md output.json
    HOS_M2F.2png  input.mmd output.png
    
  • 模块方式:
    python -m hos_m2f.md2docx_mermaid input.md output.docx
    python -m hos_m2f.md2pdf          input.md output.pdf
    python -m hos_m2f.md2xml          input.md output.xml
    python -m hos_m2f.md2json         input.md output.json
    python -m hos_m2f.render_mermaid  input.mmd output.png
    

使用提示

  • Mermaid 块以三引号代码块标注:
    ```mermaid
    graph TD
      A --> B
    
  • 若使用内联 Mermaid(不加代码块围栏),包也会自动检测并渲染。
  • 识别 python/matplotlib 代码块并保存为 PNG;表格将优先渲染为 PNG,失败时在 XML/JSON 中以结构形式呈现,在 PDF 中以简洁文本呈现。

发布流程(PyPI/TestPyPI)

按照 Python Packaging 官方教程进行(Packaging Python Projects)。本项目已配置:

  • pyproject.toml 使用 Setuptools 后端
  • 入口脚本以 HOS_M2F.2* 点号样式注册
  • README.mdLICENSE 纳入包元数据

本地构建

python -m pip install -U build twine
python -m build

上传到 TestPyPI(推荐先试跑)

  • 使用 API Token 文件,例如 c:\Users\LXCXJXHX\Desktop\QUESTION\PYPI.txt,内容以 pypi- 开头。
  • 通过脚本:
    ./scripts/publish_testpypi.ps1 -TokenPath "c:\Users\LXCXJXHX\Desktop\QUESTION\PYPI.txt"
    
    脚本将使用用户名 __token__ 和文件中的 Token 上传。

上传到 PyPI(正式)

./scripts/publish_pypi.ps1 -TokenPath "c:\Users\LXCXJXHX\Desktop\QUESTION\PYPI.txt"

如果使用账户口令而非 API Token,可将脚本中的用户名参数改为你的用户名(示例:security_hyacinth),并以口令作为密码。

许可证

MIT License,详见 LICENSE

致谢

  • Python Packaging User Guide: Packaging Python Projects
  • Playwright, python-docx, Mermaid

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

hos_m2f-0.3.4.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

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

hos_m2f-0.3.4-py3-none-any.whl (21.8 kB view details)

Uploaded Python 3

File details

Details for the file hos_m2f-0.3.4.tar.gz.

File metadata

  • Download URL: hos_m2f-0.3.4.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for hos_m2f-0.3.4.tar.gz
Algorithm Hash digest
SHA256 cdba10e0aedc7ceb9c13897ec13e611908847c57256e8de86a10ba457d9d41d3
MD5 65fccd9c640f14f3b2ebcb792cc15061
BLAKE2b-256 e887e5d7cc4076912e3ce4666163dd70f510b0f5e5b80dc2daafcaa8b83e4390

See more details on using hashes here.

File details

Details for the file hos_m2f-0.3.4-py3-none-any.whl.

File metadata

  • Download URL: hos_m2f-0.3.4-py3-none-any.whl
  • Upload date:
  • Size: 21.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for hos_m2f-0.3.4-py3-none-any.whl
Algorithm Hash digest
SHA256 db7ef2f96e86a5a27f7ffd840a5fe8c6c73121abb1edb7ff1fe252d39aeddbc3
MD5 581f8a0a2fc7a723fdd7a3e633968d03
BLAKE2b-256 aecbab5a23df77557b85b41d6398b91ce9c6068c2336d0d78c847d91cbb7879a

See more details on using hashes here.

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