Last active
August 22, 2024 16:25
-
-
Save bsweger/177aa1b3214636862350 to your computer and use it in GitHub Desktop.
Convert markdown table rows to html (we converted some markdown tables to html so we could use the "scope" attribute in the header rows for accessibility).
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#tabedata.txt is a file that contains the piped markdown table rows | |
with open ('markdownrows.txt') as f: | |
content = f.readlines() | |
rows = [] | |
for c in content: | |
cells = c.split('|') | |
cells = ['<td>{}</td>'.format(cell.strip()) for cell in cells] | |
rows.append(cells) | |
#htmltable.txt contains the html table rows | |
file = open('htmlrows.txt', 'w+') | |
for r in rows: | |
file.write('<tr>\n') | |
for c in r: | |
file.write(' {}\n'.format(c)) | |
file.write('</tr>\n') | |
file.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment