Hello world!
go here or have a
- foobar
- well hello there
- yo momma
def header(content, depth=1, underline=False): | |
if underline: | |
char = ('=', '-', '*')[(depth if depth < 4 else 3)] | |
return "{0}\n{1}".format(content, (char * len(content))) | |
return "{0} {1}".format(('#' * depth), content) | |
def quote(content, prefix='> '): | |
return "\n".join("> {0}".format(c) for c in content.split("\n")) | |
def paragraph(content): | |
return "{0}\n\n".format(content) | |
def emphasis(content, strength=1, char='*'): | |
return "{0}{1}{0}".format((char * strength), content) | |
def ulist(content, marker='*'): | |
return "\n".join("* {0}".format(c) for c in content) | |
def olist(content): | |
return "\n".join("{0}. {1}".format((i + 1), c) for i, c in enumerate(content)) | |
def link(content, address, title=None): | |
title = ' "{0}"'.format(title) if title is not None else '' | |
return "[{0}]({1}{2})".format(content, address, title) | |
def image(content, address, title=None): | |
return "!{0}".format(link(content, address, title)) | |
def pre(content, inline=False): | |
if inline: | |
return "`{0}`".format(content) | |
return quote(content, ' ') | |
if __name__ == '__main__': | |
content = '' | |
content += paragraph('Hello world!') | |
content += paragraph(link('go here', 'http://example.com/') + ' or have a ' + image('kitten', 'http://www.catster.com/files/post_images/35653cc7aab32e647da2cd81e37ed1c9.gif')) | |
content += ulist(['foobar', 'well hello there', emphasis('yo momma')]) | |
print content |