Skip to main content

把 markdown 转换为知乎能正常导入的 markdown。支持自动处理图片、公式

Project description

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(失去维护)

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

zhihu_md-0.1.1.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

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

zhihu_md-0.1.1-py3-none-any.whl (9.0 kB view details)

Uploaded Python 3

File details

Details for the file zhihu_md-0.1.1.tar.gz.

File metadata

  • Download URL: zhihu_md-0.1.1.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for zhihu_md-0.1.1.tar.gz
Algorithm Hash digest
SHA256 4ee1af6a4af6c0d26f69b24202d9c8465af333a96febcaefd5a91eefbfe10b11
MD5 a056d3b0701937a1dc14a01c8574f64f
BLAKE2b-256 f64cf4b046d4179a0d8121b0c4e64032ee02a3580417f276b58f9e60ed731dd6

See more details on using hashes here.

File details

Details for the file zhihu_md-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: zhihu_md-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.7

File hashes

Hashes for zhihu_md-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c6edb4ab584d768f8e3700a009ed02719475208b12b200eee88ad9e29001898
MD5 f3be58dc347a81d1545d2681277cef29
BLAKE2b-256 6a95e73ad9208f24ff538d6dde844ae5a7d8662847801ca5a0a4aaf7afccc2c8

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