feat(garden): generate html files
This commit is contained in:
parent
2d0fb9ed84
commit
89bdaf95b9
|
@ -0,0 +1 @@
|
||||||
|
*.html
|
|
@ -1,10 +1,15 @@
|
||||||
html: feed.py Makefile
|
py = feed.py books.py
|
||||||
|
md = rss.md book-collecting.md gardens.md
|
||||||
|
html = $(md:%.md=%.html)
|
||||||
|
|
||||||
|
site: Makefile $(md) $(py)
|
||||||
mkdir html
|
mkdir html
|
||||||
cp feed.py Makefile html
|
python md2html.py $(md)
|
||||||
cp *.md html
|
cp $(html) $(py) Makefile html
|
||||||
|
|
||||||
clean-html:
|
clean-html:
|
||||||
[[ -d html ]] && rm -r html
|
[[ -d html ]] && rm -r html
|
||||||
|
rm $(pages_html)
|
||||||
|
|
||||||
.PHONY: clean-html
|
.PHONY: clean-html
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import markdown
|
||||||
|
|
||||||
|
def print_usage():
|
||||||
|
print(f"usage: python {sys.argv[0]} PATHS")
|
||||||
|
print("")
|
||||||
|
print("\t\PATHS\tpaths of input markdown files")
|
||||||
|
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print_usage()
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
paths = sys.argv[1:]
|
||||||
|
|
||||||
|
bad_paths = [p for p in paths if not p.endswith(".md")]
|
||||||
|
if len(bad_paths) != 0:
|
||||||
|
for p in bad_paths:
|
||||||
|
print(f"Not a markdown file: {p}")
|
||||||
|
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
def write_html(src : str):
|
||||||
|
with open(src) as md:
|
||||||
|
dest = src.replace(".md", ".html")
|
||||||
|
with open(dest, "w") as html:
|
||||||
|
print(f"{src} -> {dest}")
|
||||||
|
html.write(markdown.markdown(md.read()))
|
||||||
|
|
||||||
|
for p in paths:
|
||||||
|
write_html(p)
|
Loading…
Reference in New Issue