INNER CODE UNIT · Python
index_to_markdown
mitre-attack/attack-stix-data · util/index-to-md.py:6
def index_to_markdown(index):
"""
convert the index (dict) to a markdown string and return the markdown string
"""
lines = ["<!-- begin index generated by util/index-to-md.py -->"]
lines.append(f"## {index['name']}")
lines.append(f"\n{index['description']}\n")
lines.append(f"### {index['name']} Collections\n")
for collection in index['collections']:
lines.append(f"#### {collection['name']}")
lines.append(f"\n{collection['description']}\n")
format_versions = list(map(lambda v: [
f"[{collection['name']} v{v['version']}]({v['url']})",
isoparse(v['modified']).strftime("%d %B %Y")
], collection["versions"]))
lines.append(tabulate(format_versions, headers=['version', 'released'], tablefmt="github"))