linux_introduction/generate_md.py

34 lines
1.0 KiB
Python
Raw Normal View History

2022-07-14 11:46:16 +02:00
#!/usr/bin/python3
import re
INPUT = "readme.md"
OUTPUT = "todo_over_the_break.md"
URL = "https://gitea.86thumbs.net/waldek/linux_introduction/src/branch/master/"
if __name__ == "__main__":
with open(INPUT, "r") as fp:
data = []
for line in fp.readlines():
stripped = line.strip()
stripped = stripped.replace("*", "")
stripped = stripped.strip()
if "(./" in stripped:
topic = stripped[stripped.find("[")+1:stripped.find("]")]
url = stripped.replace("(./", "({}".format(URL))
url = re.sub("\[.*\]", "[Link]", url)
url = " * {} to course documentation".format(url)
header = "# {}".format(topic)
notes = "## Student notes:"
data.append(header)
data.append(url)
data.append(notes)
data.append("TODO")
with open(OUTPUT, "w") as fp:
for line in data:
fp.write("{}\n\n".format(line))