Created
July 9, 2018 14:10
-
-
Save cameroncros/46b75b0a05e320d25af6081256f01995 to your computer and use it in GitHub Desktop.
Markdown creator for Python
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
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