|
33 | 33 | GITHUB_ISSUE_URL = "https://github.com/{}/issues/{}"
|
34 | 34 | LIB_ISSUE_REGEX = re.compile(r"(?P<lib>[a-z]+)?##(?P<number>[0-9]+)", flags=re.IGNORECASE)
|
35 | 35 | GITHUB_CODE_REGION_REGEX = re.compile(
|
36 |
| - r"https?://github\.com/(?P<user>.*)/(?P<repo>.*)/blob/(?P<hash>[a-zA-Z0-9]+)/(?P<path>.*)(?:\#L)(?P<linestart>[0-9]+)(?:-L)?(?P<lineend>[0-9]+)?" |
| 36 | + r"https?://github\.com/(?P<user>.*)/(?P<repo>.*)/blob/(?P<hash>[a-zA-Z0-9]+)/(?P<path>.*)/(?P<file>.*)(?:\#L)(?P<linestart>[0-9]+)(?:-L)?(?P<lineend>[0-9]+)?" |
37 | 37 | )
|
38 | 38 |
|
39 | 39 | GITHUB_BASE_URL = "https://github.com/"
|
@@ -98,21 +98,29 @@ async def format_highlight_block(self, url: str, line_adjustment: int = 10) -> d
|
98 | 98 | _min_boundary = highlighted_line - 1 - bound_adj
|
99 | 99 | _max_boundary = highlighted_line - 1 + bound_adj
|
100 | 100 |
|
101 |
| - # loop through all the lines, and adjust the formatting |
102 |
| - msg = "```ansi\n" |
| 101 | + # get the file extension to format nicely |
| 102 | + file = match["file"] |
| 103 | + extension = file.split(".")[1] |
| 104 | + |
| 105 | + msg = f"```{extension}\n" |
103 | 106 | key = _min_boundary
|
104 | 107 |
|
| 108 | + max_digit = len(str(_max_boundary)) |
| 109 | + |
| 110 | + # loop through all our lines |
105 | 111 | while key <= _max_boundary:
|
106 | 112 | curr_line_no: str = str(key + 1)
|
| 113 | + spaced_line_no = f"%{max_digit}d" % int(curr_line_no) |
107 | 114 |
|
108 | 115 | # insert a space if there is no following char before the first character...
|
109 | 116 | if key + 1 == highlighted_line:
|
110 |
| - highlighted_msg_format = f"\u001b[0;37m\u001b[4;31m{curr_line_no} {line_list[key]}\u001b[0;0m\n" |
| 117 | + highlighted_msg_format = f">{spaced_line_no} {line_list[key]}\n" |
111 | 118 | msg += highlighted_msg_format
|
112 | 119 |
|
113 | 120 | else:
|
114 | 121 | # if we hit the end of the file, just write an empty string
|
115 |
| - display_str = "{} {}\n" if line_list.get(key) is not None else "" |
| 122 | + display_str = " {} {}\n" if line_list.get(key) is not None else "" |
| 123 | + curr_line_no = spaced_line_no |
116 | 124 | msg += display_str.format(curr_line_no, line_list.get(key))
|
117 | 125 |
|
118 | 126 | key += 1
|
|
0 commit comments