Last active
April 15, 2023 01:15
-
-
Save hotoo/9866720 to your computer and use it in GitHub Desktop.
convert vimwiki to markdown: `sed -f ex -i *.md`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
for x | |
do | |
filename=$(echo $x|sed -e "s/\.wiki$/.md/") | |
sed -f ex $x > $filename | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
s/# \(.*\)$/* \1/g | |
s/^= \(.*\) =$/# \1/g | |
s/^== \(.*\) ==$/## \1/g | |
s/^=== \(.*\) ===$/### \1/g | |
s/^==== \(.*\) ====$/#### \1/g | |
s/^===== \(.*\) =====$/##### \1/g | |
s/^====== \(.*\) ======$/###### \1/g | |
s/{{{class="brush: *\([^"]*\)"/\`\`\`\1/g | |
s/{{{class="\([^"]*\)"/\`\`\`\1/g | |
s/{{{/\`\`\`/g | |
s/}}}/\`\`\`/g | |
s/\[\([^] ]\{1,\}\)\]\([^](]\)/![pic](\1)\2/g | |
s/\[\([^] ]\{1,\}\)\]$/![pic](\1)/g | |
s/\[\[\(\([^|]\{1,\}\)\|\)\([^]]\{1,\}\)\]\]/[\3](\2.md)/g | |
s/\[\[\([^]]\{1,\}\)\]\]/[\1](\1.md)/g | |
s/\[\(https\{0,1\}:\/\/[^ ]*\) \([^]]*\)\]/[\2](\1)/g | |
s/%% \(.*\)/<!-- \1 -->/g | |
/%toc.*/d | |
s/%title \(.*\)/# \1/g | |
s/%nohtml/- status: draft/g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
" vim 8.2取消了对'|'需要escape的要求,这个算是对其它类似命令一致性的改进/修复,但是也造成之前习惯\code的不兼容
" 更新如下:
%s/\[\[\(\([^|]\{1,\}\)|\)\([^]]\{1,\}\)\]\]/[\3](\2)/ge