Skip to content

Instantly share code, notes, and snippets.

@tkisason
Created November 6, 2018 00:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkisason/0f41ceadb1a9819fa1dd14352c22fc2b to your computer and use it in GitHub Desktop.
Save tkisason/0f41ceadb1a9819fa1dd14352c22fc2b to your computer and use it in GitHub Desktop.
Convert markdown table to mediawiki table format (owasp.org wiki)
def convert(intext):
intext = intext.split('\n')
text = '{| class="wikitable"' +'\n'
line = intext[0].replace(' | ', ' !! ').replace('| ','! ')
text += line + '\n'
intext.pop(0)
for row in intext:
text += '|-' + '\n'
row = row.replace(' | ',' || ').replace('**','')
text += row[:-1] + '\n'
text += '|}'
return text
a = ""dump content here""
print(convert(a))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment