Skip to main content

zhihu_md: 把 markdown 转换为知乎编辑器支持的格式,并自动处理好图片和公式

用法

# 安装
pip install zhihu_md -U

# 帮助
python -m zhihu_md --help  # 或者 zhihu_md --help

# 使用
python -m zhihu_md your_markdown.md  # 或者 zhihu_md xxx.md
# 自动生成 your_markdown_for_zhihu.md
  • 如果包含本地图片,请确保图片和 markdown 文件都 git push 到公开的 GitHub repo。
  • zhihu_md 会自动通过 git remote -v 获取 GitHub repo 地址
  • 然后把 markdown 中的本地 img 转换为知乎能访问的 GitHub 代理地址

原理

图片上传

  • 知乎无法通过 https://github.com/{user-name}/{repo-name}/blob/main/img.png?raw=true 这种 URL 形式上传 Github 图像
  • 但可以走各式各样的 GitHub 镜像站 来中转 repo 中的 image URL
    • 默认方案,用的 https://bgithub.xyz/,失效了可自行更换 GitHub 镜像站
  • 这些 URL 只需让 知乎 服务器访问一次,就可以完成上传

相似项目

  • Markdown4Zhihu(失去维护)
    • 失去维护,不支持图片 (知乎无法访问 github 服务器) 和公式了
    • Markdown4Zhihu 对 repo 中的 md file 和图片的文件结构有琐碎的要求。还有比较麻烦的配置步骤
    • 本项目 zhihu_md 是基于 Markdown4Zhihu 完善而来,改进如下:
      • 一键安装,无需配置
      • 通过镜像站来支持 GitHub 图片上传
      • 对文件结构无要求,更加灵活
  • VSCode-Zhihu(失去维护)

Metadata

Release files for zhihu-md 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for zhihu-md 0.1.1
File Size Uploaded
zhihu_md-0.1.1.tar.gz 9.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for zhihu-md 0.1.1
File Interpreter ABI Platform
zhihu_md-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 18.0 kB

Release files / zhihu_md-0.1.1.tar.gz

Download URL zhihu_md-0.1.1.tar.gz
Size 9.0 kB
Tags Source
SHA-256 checksum
How to use checksums
4ee1af6a4af6c0d26f69b24202d9c8465af333a96febcaefd5a91eefbfe10b11
BLAKE2b-256 checksum
How to use checksums
f64cf4b046d4179a0d8121b0c4e64032ee02a3580417f276b58f9e60ed731dd6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Release files / zhihu_md-0.1.1-py3-none-any.whl

Download URL zhihu_md-0.1.1-py3-none-any.whl
Size 9.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c6edb4ab584d768f8e3700a009ed02719475208b12b200eee88ad9e29001898
BLAKE2b-256 checksum
How to use checksums
6a95e73ad9208f24ff538d6dde844ae5a7d8662847801ca5a0a4aaf7afccc2c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.11.7

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page