diff options
Diffstat (limited to 'justfile')
| -rw-r--r-- | justfile | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -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}} |