diff options
Diffstat (limited to 'mypath/md2html.sh')
-rwxr-xr-x | mypath/md2html.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/mypath/md2html.sh b/mypath/md2html.sh new file mode 100755 index 0000000..bb316f1 --- /dev/null +++ b/mypath/md2html.sh | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/bash | ||
2 | |||
3 | ########################################################################## | ||
4 | # File Name : md2html.sh | ||
5 | # Encoding : utf-8 | ||
6 | # Author : We-unite | ||
7 | # Email : weunite1848@gmail.com | ||
8 | # Created Time : 2023-12-15 | ||
9 | ########################################################################## | ||
10 | |||
11 | # origin是输入的第一个参数,指源文件名 | ||
12 | # src是原文件名前边加一个.,是源文件的复制 | ||
13 | # dst是原文件名的md后缀改成html | ||
14 | origin=$1 | ||
15 | src="."$origin | ||
16 | dst=${origin%.*}".html" | ||
17 | title="$2" | ||
18 | |||
19 | cp $origin $src | ||
20 | # src中所有的“```...”替换成“```”,其中...指换行前的所有内容 | ||
21 | sed -i 's/```.*$/```/g' $src | ||
22 | pandoc -s $src -o $dst --metadata title="$title" | ||
23 | rm $src | ||
24 | |||
25 | sed -i '/<style/,/<\/style>/d' $dst | ||
26 | sed -i 's/<body>/<body>\n<div class="pandoc">\n<div class="main">/' $dst | ||
27 | sed -i 's/<\/body>/<script src="https:\/\/www.qin-juan-ge-zhu.top\/common\/js\/comment.js"><\/script>\n<\/div>\n<\/div>\n<\/body>/' $dst | ||
28 | sed -i 's/\t/ /g' $dst | ||
29 | sed -i 's/<\/head>/<link rel="stylesheet" href="https:\/\/www.qin-juan-ge-zhu.top\/common\/CSS\/pandoc.css">\n<script type="text\/javascript" src="https:\/\/www.qin-juan-ge-zhu.top\/common\/script4code.js"><\/script><\/head>/' $dst | ||