-
Notifications
You must be signed in to change notification settings - Fork 0
/
demo.sh
executable file
·76 lines (69 loc) · 1.33 KB
/
demo.sh
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
70
71
72
73
74
75
76
#!/bin/bash
infile='README.md'
outfile='index.html'
# github markdown css from:
# https://github.com/sindresorhus/github-markdown-css/blob/main/github-markdown.css
fix_cols() {
sed -E '
\_<colgroup>_,\_</colgroup>_ {
\_</?colgroup>_p
\_<colgroup>_a \
<col style="width: 20%" />\
<col style="width: 30%" />\
<col style="width: 50%" />
d
}
'
}
import_licence() {
sed -E '
/^ *## License/ {
a
r LICENSE
q
}
'
}
html() {
cat <<HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Scrolltopable</title>
<script type="module" src="index.min.js"></script>
<link rel="stylesheet" type="text/css" href="basic.css"/>
<link rel="stylesheet" href="github-markdown.css"/>
<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;
}
}
</style>
<script type="module">
import { Scrolltopable } from './index.min.js'
Scrolltopable.init({})
</script>
</head>
<body class="markdown-body">
HTML
cat -
cat <<HTML
</body>
</html>
HTML
}
import_licence < "${infile}" \
| pandoc -t html -f markdown \
| html \
| fix_cols \
> "${outfile}"