-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathcomment.py
More file actions
32 lines (22 loc) · 785 Bytes
/
comment.py
File metadata and controls
32 lines (22 loc) · 785 Bytes
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
import config
class Comment:
def __init__(self, title, body, byline="", attribution=""):
self.title = title
self.body = body
self.byline = byline
self.attribution = attribution
def generate_title_markdown(title):
return "> # " + title
def generate_body_markdown(body):
body = "> " + body # Insert first blockquote (>) Markdown symbol
body = body.replace("\n\n", "\n\n> ")
return body
COMMENT_FOOTER = "---\n{} | [Source code]({}) | [Contribute]({})".format(
config.BOT["VERSION"],
config.BOT["REPO_LINK"],
config.BOT["CONTRIBUTE_LINK"]
)
def format_comment(comment):
return generate_title_markdown(comment.title) + \
"\n\n" + generate_body_markdown(comment.body) + \
"\n\n" + COMMENT_FOOTER