This repository has been archived by the owner on Mar 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcreate_html
executable file
·36 lines (31 loc) · 1.85 KB
/
create_html
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
#!/bin/bash
set -euo pipefail
IFS=$'\n\t'
cat <<-'EOF' > index.html
<!DOCTYPE html><html><head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Development Bookmarks – vbwx</title>
<style>body{font:0.9em/1 "Helvetica Neue",Helvetica,Arial,sans-serif}p:last-of-type{font-size:0.7rem;margin:2rem}li{line-height:1.5}h2+ul,h3+ul{margin-top:-1.1ex}h2,h2+ul{margin-left:2rem}h3,h3+ul{margin-left:4rem}ul{list-style:none;padding-left:2rem}h1,h2,h3{font-weight:normal;cursor:pointer}h2:first-of-type{color:#666}a{outline:none;text-decoration:none;margin-top:0.8ex;display:inline-block}a:focus{text-decoration:underline}a:link,a:visited{color:#0261E5}a:active,a:focus,a:hover{color:#102EA1}.c+ul,.c+div{display:none}.c::before{content:'▸';position:absolute;margin-left:-1.8ex}.o::before{content:'▾';position:absolute;margin-left:-2ex}.o,.c{padding-left:2ex}hr{display:none}</style>
</head><body>
EOF
pandoc -t html README.md | sed -e 's/<!--\([a-z0-9\/]*\)-->/<\1>/g' -e 's/--/-/' >> index.html
cat <<-'EOF' >> index.html
<script>$=function(n,f){[].forEach.call(document.getElementsByTagName(n),f)};toggle=function(b){['h1','h2','h3'].forEach(function(h){$(h,function(t){t.className=b?'o':'c'})})};['h2','h3'].forEach(function(h){$(h,function(t){t.addEventListener('click',function(){this.className=this.className==='c'?'o':'c'})})});$('h1',function(t){t.addEventListener('click',function(){toggle(this.className==='c')})});$('a',function(t){if(t.getAttribute('href')[0]!=='#')t.target="_blank"});toggle(0)</script>
</body></html>
EOF
if [ "${1-}" = "-c" ]; then
if [ -z "${2-}" ]; then
>&2 echo "create_html: Commit message argument missing"
exit 1
fi
git commit -am "$2"
git pull
git push
git checkout gh-pages
git pull
git checkout --patch master index.html
git commit -am "$2"
git push
git checkout master
fi