-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconvertMarkdownToHtml.sh
More file actions
69 lines (63 loc) · 1.78 KB
/
Copy pathconvertMarkdownToHtml.sh
File metadata and controls
69 lines (63 loc) · 1.78 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
#!/usr/bin/env sh
# Dependencies: marked
repoDir="."
journalsDir="$repoDir/journals"
temporaryFile="$repoDir/yaoniplan.md"
indexFile="$repoDir/index.html"
convertMarkdownToHtml() {
# Generate Article
cat $(ls -r "$journalsDir"/*.md) > "$temporaryFile"
marked -i "$temporaryFile" -o "$indexFile" && rm "$temporaryFile"
# Insert into the first line
sed -i '1i\
<!DOCTYPE html>\
<html>\
<head>\
<meta charset="UTF-8">\
<meta name="viewport" content="width=device-width, initial-scale=1">\
<title>yaoniplan</title>\
<link rel="icon" type="image/svg+xml" href="./assets/favicon.svg">\
<link rel="stylesheet" href="./assets/github-markdown.css">\
<link rel="stylesheet" href="./assets/katex.min.css">\
<script defer src="./assets/katex.min.js"></script>\
<script defer src="./assets/auto-render.min.js" onload="renderMathInElement(document.body);"></script>\
<script>\
// Render all KaTeX expressions on the page\
document.addEventListener("DOMContentLoaded", function() {\
renderMathInElement(document.body, {\
delimiters: [\
{ left: "$$", right: "$$", display: true },\
{ left: "$", right: "$", display: false }\
]\
});\
});\
</script>\
<style>\
.markdown-body {\
box-sizing: border-box;\
min-width: 200px;\
max-width: 980px;\
margin: 0 auto;\
padding: 45px;\
}\
@media (max-width: 767px) {\
.markdown-body {\
padding: 15px;\
}\
}\
@media (prefers-color-scheme: dark) {\
body {\
background-color: #0d1117;\
}\
}\
</style>\
</head>\
<body>\
<article class="markdown-body">' "$indexFile"
# Append to the last line
echo ' </article>
</body>
</html>' >> "$indexFile"
}
# Generate index.html file
convertMarkdownToHtml