aboutsummaryrefslogtreecommitdiffstats
path: root/mypath/md2html.sh
diff options
context:
space:
mode:
Diffstat (limited to 'mypath/md2html.sh')
-rwxr-xr-xmypath/md2html.sh29
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
14origin=$1
15src="."$origin
16dst=${origin%.*}".html"
17title="$2"
18
19cp $origin $src
20# src中所有的“```...”替换成“```”,其中...指换行前的所有内容
21sed -i 's/```.*$/```/g' $src
22pandoc -s $src -o $dst --metadata title="$title"
23rm $src
24
25sed -i '/<style/,/<\/style>/d' $dst
26sed -i 's/<body>/<body>\n<div class="pandoc">\n<div class="main">/' $dst
27sed -i 's/<\/body>/<script src="https:\/\/www.qin-juan-ge-zhu.top\/common\/js\/comment.js"><\/script>\n<\/div>\n<\/div>\n<\/body>/' $dst
28sed -i 's/\t/ /g' $dst
29sed -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