Git Product home page Git Product logo

markdown4zhihu's Introduction

Markdown4Zhihu

这是一个可以将您的Markdown文件一键转换为知乎编辑器支持模式的仓库。

它会自动的处理图片,行内公式,多行公式,以及对表格的部分支持。当图片过大时,您可以选择加上--compress选项,对超过大小阈值(这里约为500K)的图片进行自动压缩。如果您的md文件和其图片文件夹在Data文件夹下,您本地的图片会自动转换为github上的raw链接。 上传知乎后一切都是那么美好。

使用方法

  1. 首先,您应当仿照本仓库建立一个类似的您自己的仓库,它包括一个Data文件夹与根目录下的zhihu-publisher.py。当然,您也可以选择直接folk本仓库到您自己的账号下。

  2. 然后,打开zhihu-publisher.py文件,在文件开头有这么一句:GITHUB_REPO_PREFIX = "https://raw.githubusercontent.com/miracleyoo/Markdown4Zhihu/master/Data/"请修改miracleyoo为您自己的GitHub用户名,如果仓库名字也有变化,请做出相应微调。

  3. 这里我们假设您的文件名为C:\Users\xxx\Downloads\一个测试文档.md,接着打开terminal(Linux/MacOS)或Git Bash(Windows)(或其他任何支持Git命令的终端),输入以下命令:

    python zhihu-publisher.py --input="C:\Users\xxx\Downloads\一个测试文档.md"

  4. OK,all set. 在./Data目录下,你可以看到一个一个测试文档_for_zhihu.md的文件,将它上传至知乎编辑器即可。

markdown4zhihu's People

Contributors

huangrt01 avatar miracleyoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

markdown4zhihu's Issues

运行时出现OS错误

您好,非常感谢您提供的工具,但是在按照您的测试用例运行时,出现了这个错误,不知道怎么debug希望指导下,感谢!
OSError: [WinError 123] 文件名、目录名或卷标语法不正确。: 'https:\www.zhihu.com\equation?tex=Sum=\sum_{i=0}^{n}{\sqrt{x_i^2+y_i^2}}'

运行后本应居中的公式无法居中

您好!我本人通过Typora编辑文档,将转化生成的.md文件导入知乎后,对于本应居中的公式无法居中,此时需要手动在公式编辑器中最后部分加入\\方可实现最终效果,请问有没有通过更改源码的方法,从而使这一步简化。

运行出现错误

你好,十分感谢你贡献的工具,我认为这是一个非常好的工具。
我使用电脑尝试转化我自己的一个markdown文件时,出现了这样的问题,不知道如何debug,如果有时间,可以看看,非常感谢!
python3 zhihu-publisher.py --input="./Data/droplet.md" {'encoding': None, 'confidence': 0.0, 'language': None} Traceback (most recent call last): File "zhihu-publisher.py", line 123, in <module> process_for_zhihu() File "zhihu-publisher.py", line 35, in process_for_zhihu lines = image_ops(lines) File "zhihu-publisher.py", line 73, in image_ops _lines = re.sub(r'<img src="(.*?)"',functools.partial(rename_image_ref, original=False), _lines) File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/re.py", line 192, in sub return _compile(pattern, flags).sub(repl, string, count) File "zhihu-publisher.py", line 50, in rename_image_ref if os.path.getsize(image_folder_path.parent/m.group(1+int(original)))>COMPRESS_THRESHOLD: File "/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7/lib/python3.7/genericpath.py", line 50, in getsize return os.stat(filename).st_size FileNotFoundError: [Errno 2] No such file or directory: 'Data/https:/www.zhihu.com/equation?tex=G'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.