blob: 13f267083d8f1142300e5793cf05900be11db3f3 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
已复制! #!/bin/bash
origin=$1
src="."$origin
dst=${origin%.*}".html"
if [ $# -ne 2 ] || [ ${origin##*.} != "md" ]; then
echo "Usage: $0 <markdown file> <html title>"
exit 1
elif [ ! -f $origin ]; then
echo "Error: $1 does not exist"
exit 1
fi
cp $origin $src
pandoc --no-highlight --mathjax=none -s $src -o $dst --metadata title="$2"
rm $src
sed -i -E ':a;N;$!ba;s|<pre[^>]*class="([^"]+)"[^>]*>[[:space:]]*<code[^>]*>|<pre><code class="language-\1">|g' $dst
sed -i '/<style/,/<\/style>/d' $dst
sed -i 's/<body>/<body>\n<div class="pandoc">\n<div class="main">/' $dst
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
sed -i 's/\t/ /g' $dst
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
if grep -Eq "math inline|math display" $dst; then
sed -i 's|</head>|<script type="text/javascript" async\
src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML"></script>\
<script type="text/x-mathjax-config">\
MathJax.Hub.Config({\
tex2jax: {\
inlineMath: [["$","$"], ["\\\\(","\\\\)"]],\
processEscapes: true\
}\
});\
</script>\
</head>|' "$dst"
fi
grep -n "language-mermaid" $dst
if [ $? -eq 0 ]; then
echo "Convertion Warning: mermaid is included, may you need to replace it with a picture???"
fi
|