-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmarkup_formatter.py
More file actions
61 lines (54 loc) · 1.05 KB
/
Copy pathmarkup_formatter.py
File metadata and controls
61 lines (54 loc) · 1.05 KB
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
'''
Header text
'''
def hx(size, text):
return (('#' * size) + ' {}'.format(text))
'''
Bold text
'''
def bold(text):
return '**{}**'.format(text)
'''
Italic text
'''
def italic(text):
return '*{}*'.format(text)
'''
Image link (inline)
'''
def image(link, alt_text=None):
if alt_text:
return ''.format(link, alt_text)
else:
return ''.format(link)
'''
Quote text
'''
def quote(text, cite=None):
if cite:
return '> {}\n> <cite>{}</cite>'.format(text, cite)
else:
return '> {}'.format(text)
'''
Syntax highlighting
'''
def code(lang, text):
return '```{}\n{}\n```'.format(lang, text)
'''
Web link
'''
def link(text, link):
return '[{}]({})'.format(text, link)
'''
Create list from array
'''
def clist(list, numbered=False, join=False):
for i in range(len(list)):
if numbered:
list[i] = '{}. {}'.format(i+1, list[i])
else:
list[i] = '* {}'.format(list[i])
if join:
return ''.join(list)
else:
return list