|
25 | 25 | import re |
26 | 26 | import cfdoc_qa as qa |
27 | 27 |
|
| 28 | +# Jira base URL for ticket links |
| 29 | +JIRA_BASE_URL = "https://northerntech.atlassian.net/browse/" |
| 30 | +# Pattern to match Jira ticket references (ENT-1234, CFE-4567, etc.) |
| 31 | +JIRA_TICKET_PATTERN = re.compile(r'\b(ENT|CFE)-(\d+)\b') |
| 32 | + |
28 | 33 |
|
29 | 34 | def run(config): |
30 | 35 | markdown_files = config["markdown_files"] |
@@ -115,6 +120,13 @@ def headerToAnchor(header): |
115 | 120 | return anchor |
116 | 121 |
|
117 | 122 |
|
| 123 | +def convertJiraTicketsToLinks(line): |
| 124 | + """Convert Jira ticket references (ENT-1234, CFE-4567) to markdown links.""" |
| 125 | + return JIRA_TICKET_PATTERN.sub( |
| 126 | + lambda m: "[%s](%s%s)" % (m[0], JIRA_BASE_URL, m[0]), line |
| 127 | + ) |
| 128 | + |
| 129 | + |
118 | 130 | def parseMarkdownForAnchors(file_name, config): |
119 | 131 | in_file = open(file_name, "r") |
120 | 132 | lines = in_file.readlines() |
@@ -305,6 +317,14 @@ def applyLinkMap(file_name, config): |
305 | 317 | else: |
306 | 318 | break |
307 | 319 | new_line += markdown_line |
| 320 | + |
| 321 | + # Convert Jira ticket references to links (only outside code blocks) |
| 322 | + if not in_pre: |
| 323 | + original_line = new_line |
| 324 | + new_line = convertJiraTicketsToLinks(new_line) |
| 325 | + if new_line != original_line: |
| 326 | + write_changes = True |
| 327 | + |
308 | 328 | new_lines.append(new_line) |
309 | 329 | previous_empty = markdown_line.lstrip() == "" |
310 | 330 |
|
|
0 commit comments