-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdown.py
81 lines (60 loc) · 1.37 KB
/
mdown.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/env python
# encoding: utf-8
"""
markdowngen.py
Created by Emil Erlandsson on 2011-02-10.
Copyright (c) 2011 Emil Erlandsson. All rights reserved.
"""
import sys
import os
def e(str):
"""emphasis"""
return "_%s_"
def se(str):
"""strong emphasis"""
return self.emphasis(self.emphasis(str))
def c(str):
"""code"""
return "`%s`" % str
def h1(str):
return "%s\n%s\n" % (str, "=" * len(str))
def h2(str):
return "%s\n%s\n" % (str, "-" * len(str))
def h3(str):
return "### %s ###" % str
def h3(str):
return "### %s ###" % str
def h4(str):
return "#### %s ####" % str
def h5(str):
return "##### %s #####" % str
def h6(str):
return "###### %s ######" % str
def bq(str):
lines = str.split("\n")
output = ""
for line in lines:
output = output + "> %s\n" % line
return output
def a(text, url, title = ""):
return '[%s](%s "%s")' % (text, url, title)
def li(items):
output = ""
for item in items:
output = output + "* %s\n" % item
return output
class MarkdownDocument(object):
"""docstring for MarkdownDocument"""
def __init__(self):
super(MarkdownDocument, self).__init__()
self.document = []
def __str__(self):
"""docstring for __str__"""
return "..."
def main():
print h1("Emil Erlandsson")
print li(["apa", "bepa", "cepa"])
print a("text", "http://localhost")
print h2("a second level heading")
if __name__ == '__main__':
main()