Skip to content

Commit

Permalink
doc: fix readme: update according to latest changes
Browse files Browse the repository at this point in the history
  • Loading branch information
drmingdrmer committed Jul 15, 2021
1 parent 10824ca commit ea220d5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 23 deletions.
33 changes: 21 additions & 12 deletions README-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/`; 所有文章都会保存在这个目录中,
名为`<article_name>` 的md转换之后保存在`_md2/zhihu/<article_name>/` 目录中,
Expand All @@ -55,6 +50,20 @@ md2zhihu your_great_work.md
默认使用当前目录下的git配置, (作者假设用户用git来保存自己的工作:DDD),
如果没有指定分支名, md2zhihu 将建立一个`_md2zhihu_{cwd_tail}_{md5(cwd)[:8]}`的分支来保存所有图片.
<details>
<summary><b>排查问题</b></summary>
#### 找不到命令: 如 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:...`
</details>
## 使用 github-action 远程转换, 适合 Windows 用户
md2zhihu 不支持windows, 可以通过github-action来实现远程转换:
Expand Down
40 changes: 29 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`:
Expand All @@ -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
<details>
<summary>Action Options</summary>

- `pattern`:

Expand Down Expand Up @@ -81,9 +87,10 @@ https://github.com/drmingdrmer/drmingdrmer.github.io/blob/master/_md2zhihu/dict-
**required**: True
**default**: `zhihu`

</details>


## Use it Locally
### 2. Convert markdown on your laptop

System requirement: MaxOS

Expand All @@ -94,21 +101,32 @@ 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 [email protected]: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
<details>
<summary><b>Trouble shoot</b></summary>

### command not found: md2zhihu

- `pip install --verbose md2zhihu` Confirm that install done successfully.
- `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:...`

</details>

## Features

Expand Down

0 comments on commit ea220d5

Please sign in to comment.