wordpress导出markdown
近期需要尝试搭建本地的知识库的内容,没有素材,所以从博客中转出来md文件做实验。
下面是记录的基本过程
1. 基本流程
- 安装 nodejs
- npx 安装插件nodejs 插件 wordpress-export-to-markdown
- wordpress导出xml
- xml用插件转成markdown
2. 实施操作
下载安装
nodejs下载
按平台选择,我用的linux
下载看下,不好用就要来回换几个源看下,源就是using fnm的部分
ivo@x79debian:~$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 16563 100 16563 0 0 36946 0 --:--:-- --:--:-- --:--:-- 36970
=> Downloading nvm from git to '/home/ivo/.nvm'
=> Cloning into '/home/ivo/.nvm'...
remote: Enumerating objects: 381, done.
remote: Counting objects: 100% (381/381), done.
remote: Compressing objects: 100% (324/324), done.
remote: Total 381 (delta 43), reused 178 (delta 29), pack-reused 0 (from 0)
Receiving objects: 100% (381/381), 383.70 KiB | 420.00 KiB/s, done.
Resolving deltas: 100% (43/43), done.
* (HEAD detached at FETCH_HEAD)
master
=> Compressing and cleaning up git repository
=> Appending nvm source string to /home/ivo/.bashrc
=> Appending bash_completion source string to /home/ivo/.bashrc
=> Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
ivo@x79debian:~$ nvm install 22
-bash: nvm: command not found
ivo@x79debian:~$ source .bashrc
ivo@x79debian:~$ nvm install 22
Downloading and installing node v22.13.1...
Downloading https://nodejs.org/dist/v22.13.1/node-v22.13.1-linux-x64.tar.xz...
################################################################################################ 100.0%
Computing checksum with sha256sum
Checksums matched!
Now using node v22.13.1 (npm v10.9.2)
Creating default alias: default -> 22 (-> v22.13.1)
ivo@x79debian:~$ node -v
v22.13.1
ivo@x79debian:~$ npm -v
10.9.2
插件所在地址 github
https://github.com/lonekorean/wordpress-export-to-markdown
使用 npx命令下载
npx wordpress-export-to-markdown
然后选择输出的xml的路径
之后就可以 转换了,之间会有几个问题,根据自己的需求选择
ivo@x79debian:~/workd$ npx wordpress-export-to-markdown
Starting wizard...
? Path to WordPress export file? /home/ivo/workd/WordPress.2025-02-05.xml
? Path to output folder? output
? Create year folders? No
? Create month folders? No
? Create a folder for each post? No
? Prefix post folders/files with date? No
? Save images attached to posts? No
? Save images scraped from post body content? No
? Include custom post types and pages? No
Parsing...
403 posts found.
Saving 403 posts (0 already exist)...