From ea220d5f8edff18b90ef0b9d00c3d66d7660de15 Mon Sep 17 00:00:00 2001 From: drdr xp Date: Thu, 15 Jul 2021 12:28:21 +0800 Subject: [PATCH] doc: fix readme: update according to latest changes --- README-cn.md | 33 +++++++++++++++++++++------------ README.md | 40 +++++++++++++++++++++++++++++----------- 2 files changed, 50 insertions(+), 23 deletions(-) diff --git a/README-cn.md b/README-cn.md index 1d2bfd4..3c4fc26 100644 --- a/README-cn.md +++ b/README-cn.md @@ -21,23 +21,18 @@ npm install -g @mermaid-js/mermaid-cli pip install md2zhihu ``` -### 排查问题 - -#### 找不到命令: 如 command not found: md2zhihu - -看下这几个命令是否正常: - -- `pip install --verbose md2zhihu` 安装时应该会提示按照成功的字样. -- `which md2zhihu` 如果能到应该会输出它的路径, 例如我的是安装在: `/Users/drdrxp/xp/py3virtual/p38/bin/md2zhihu` -- `echo $PATH` 确认安装的路径在PATH环境变量中: `...:/Users/drdrxp/xp/py3virtual/p38/bin:...` - ## Usage +在git工作目录中: + ```sh -md2zhihu your_great_work.md +md2zhihu your_great_work.md -r . ``` -这个命令将markdown 转换成 知乎 文章编辑器可直接导入的格式, 存储到 `_md2/your_great_work/your_great_work.md`, 然后将图片等资源上传到**当前目录所在的git**的`_md2zhihu`分支. 转换后的markdown文档不依赖任何本地的图片文件或其他文件. +这个命令将markdown 转换成 知乎 文章编辑器可直接导入的格式, +存储到 `_md2/your_great_work.md`, +然后将图片等资源上传到**当前目录所在的git**的`_md2zhihu`分支. +转换后的markdown文档不依赖任何本地的图片文件或其他文件. - `-d` 指定输出目录, 默认为`./_md2/`; 所有文章都会保存在这个目录中, 名为`` 的md转换之后保存在`_md2/zhihu//` 目录中, @@ -55,6 +50,20 @@ md2zhihu your_great_work.md 默认使用当前目录下的git配置, (作者假设用户用git来保存自己的工作:DDD), 如果没有指定分支名, md2zhihu 将建立一个`_md2zhihu_{cwd_tail}_{md5(cwd)[:8]}`的分支来保存所有图片. +
+排查问题 + +#### 找不到命令: 如 command not found: md2zhihu + +看下这几个命令是否正常: + +- `pip install --verbose md2zhihu` 安装时应该会提示按照成功的字样. +- `which md2zhihu` 如果能到应该会输出它的路径, 例如我的是安装在: `/Users/drdrxp/xp/py3virtual/p38/bin/md2zhihu` +- `echo $PATH` 确认安装的路径在PATH环境变量中: `...:/Users/drdrxp/xp/py3virtual/p38/bin:...` + +
+ + ## 使用 github-action 远程转换, 适合 Windows 用户 md2zhihu 不支持windows, 可以通过github-action来实现远程转换: diff --git a/README.md b/README.md index 7ebd35c..5599274 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,12 @@ and can be imported into zhihu.com with just one click. ## Usage -Action: https://github.com/marketplace/actions/md2zhihu +### 1. Convert markdown remotely with github-action: + +This is the recommended way since you do not need install anything locally, just +a `git` is quite enough. + +`md2zhihu` action: https://github.com/marketplace/actions/md2zhihu Add action definition into the git repo you have markdowns to convert: `.github/workflows/md2zhihu.yml`: @@ -36,15 +41,16 @@ jobs: The next push github converts markdowns in `_posts/` and creates a new commit that contains the converted markdowns in folder `_md2zhihu`. -E.g., the single-file version of all of my blog posts: -https://github.com/drmingdrmer/drmingdrmer.github.io/tree/master/_md2zhihu +E.g., the single-file version of one of my blog posts: +https://github.com/drmingdrmer/drmingdrmer.github.io/blob/master/_md2zhihu/dict-cmp.md To retrieve the converted markdowns, merge branch `_md2zhihu/md`, -or access the branch on the web: +or access the branch directly on the web: https://github.com/drmingdrmer/drmingdrmer.github.io/blob/master/_md2zhihu/dict-cmp.md +Since all external assets are uploaded copy-paste this page will work as expected. - -### Options +
+Action Options - `pattern`: @@ -81,9 +87,10 @@ https://github.com/drmingdrmer/drmingdrmer.github.io/blob/master/_md2zhihu/dict- **required**: True **default**: `zhihu` +
-## Use it Locally +### 2. Convert markdown on your laptop System requirement: MaxOS @@ -94,14 +101,24 @@ npm install -g @mermaid-js/mermaid-cli pip install md2zhihu ``` +In a git work dir: + ```sh -md2zhihu your_great_work.md +md2zhihu your_great_work.md -r . +``` + +This command convert `your_great_work.md` to `_md2/your_great_work.md`. +And the assets it references are uploaded to the default git remote. + +Or using another git to store assets, e.g.: +``` +md2zhihu your_great_work.md -r git@github.com:drmingdrmer/md2test.git@test ``` -This command convert `your_great_work.md` to -`_md2/zhihu/your_great_work/your_great_work.md`. +**You must have write access to the git repo** -### Trouble shoot +
+Trouble shoot ### command not found: md2zhihu @@ -109,6 +126,7 @@ This command convert `your_great_work.md` to - `which md2zhihu` Confirm that the binary can be found: e.g.: `/Users/drdrxp/xp/py3virtual/p38/bin/md2zhihu`. - `echo $PATH` Confirmat that the install path is included in `PATH`: `...:/Users/drdrxp/xp/py3virtual/p38/bin:...` +
## Features