2022-12-09 20:45:50 +00:00
|
|
|
|
|
|
|
def generate_markdown_link(text, url):
|
|
|
|
return "[{}]({})".format(text, url)
|
|
|
|
|
|
|
|
|
|
|
|
class MarkdownTable:
|
|
|
|
|
|
|
|
headers = []
|
|
|
|
rows = []
|
|
|
|
|
|
|
|
def __init__(self, headers):
|
|
|
|
self.headers = headers
|
|
|
|
|
|
|
|
def add_row(self, row_data):
|
|
|
|
if len(row_data) != len(self.headers):
|
|
|
|
raise Exception("Wrong number of row entries.")
|
|
|
|
else:
|
|
|
|
self.rows.append(row_data)
|
|
|
|
|
|
|
|
def __str__(self):
|
2022-12-10 16:40:25 +00:00
|
|
|
table = "|"
|
2022-12-09 20:45:50 +00:00
|
|
|
|
|
|
|
for header in self.headers:
|
2022-12-10 16:40:25 +00:00
|
|
|
table += " {} |".format(header)
|
2022-12-09 20:45:50 +00:00
|
|
|
|
|
|
|
table += "\n"
|
|
|
|
|
|
|
|
table += "|"
|
|
|
|
table += " - |" * len(self.headers)
|
|
|
|
|
|
|
|
for row in self.rows:
|
|
|
|
table += "\n"
|
2022-12-10 16:40:25 +00:00
|
|
|
table += " | ".join(map(str, row))
|
2022-12-09 20:45:50 +00:00
|
|
|
|
|
|
|
return table
|