summaryrefslogtreecommitdiff
path: root/justfile
diff options
context:
space:
mode:
Diffstat (limited to 'justfile')
-rw-r--r--justfile14
1 files changed, 10 insertions, 4 deletions
diff --git a/justfile b/justfile
index d344180..be83f99 100644
--- a/justfile
+++ b/justfile
@@ -1,7 +1,13 @@
-format $filename:
- #!/bin/sh
- title=`sed -n 's/^# \(.*\)/\1/p' $filename | head -n1`
- printf "$(< template.html)\n" "$title" "$filename" > index.html
+format filename:
+ #!/usr/bin/env python3
+ import re
+ with open("{{filename}}") as f:
+ m = re.search("^# (.*)", f.read())
+ title = "Презентация" if m is None else m.group(1)
+ with open("template.html") as f:
+ template = f.read()
+ with open("index.html", "w") as f:
+ f.write(template % (title, "{{filename}}"))
serve filename port="8000": (format filename)
python3 -m http.server {{port}}