Skip to content

Instantly share code, notes, and snippets.

@cameroncros
Created July 9, 2018 14:10
Show Gist options
  • Save cameroncros/46b75b0a05e320d25af6081256f01995 to your computer and use it in GitHub Desktop.
Save cameroncros/46b75b0a05e320d25af6081256f01995 to your computer and use it in GitHub Desktop.
Markdown creator for Python
class Markdown:
string = ''
def __init__(self):
self.string = ''
def add_line(self, lines):
self.string += '%s\n' % lines
def heading(string, level=1):
output = ''
for i in range(level):
output += '#'
output += ' %s' % string
return output
def blank():
return '----'
def quote(string):
output = ''
for line in string.split('\n'):
output += '> %s\n' % line
return output
def code(string):
output = '\n'
for line in string.split('\n'):
output += ' %s\n' % line
return output
def bullet(string):
return '* %s' % string
def number(string):
return '1. %s' % string
def link(url, text=None):
return '[%s](%s)' % (text or url, url)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment