Skip to content

Commit a7cb1e6

Browse files
committed
HMR-157 Fix parsing Jira ticket numbers
Add more test cases
1 parent b738154 commit a7cb1e6

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

flexmark-ext-jira-ticket-links/src/main/java/com/vladsch/flexmark/ext/jira/tickets/internal/JiraTicketNumberInLineParserExtension.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@ public void finalizeBlock(@NotNull InlineParser inlineParser) {
3939

4040
@Override
4141
public boolean parse(@NotNull LightInlineParser inlineParser) {
42+
// abort if the preceding character is a word character
43+
if (inlineParser.getIndex() > 0) {
44+
char precedingChar = inlineParser.getInput().charAt(inlineParser.getIndex() - 1);
45+
if (Character.isLetterOrDigit(precedingChar) || precedingChar == '_') {
46+
return false;
47+
}
48+
}
49+
4250
BasedSequence match = inlineParser.match(REGEX_JIRA_TICKET_NUMBER);
4351
if (match == null) {
4452
return false;

flexmark-ext-jira-ticket-links/src/test/resources/ext_jira_ast_spec.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,28 @@ Document[0, 40]
4646
Text[17, 40] chars:[17, 40, " foll … text."]
4747
````````````````````````````````
4848

49+
---
50+
51+
## Non-tickets
52+
53+
Ticket numbers have to begin and end at a word boundary
54+
55+
```````````````````````````````` example Non-tickets: 1
56+
textHMR-157
57+
.
58+
<p>textHMR-157</p>
59+
.
60+
Document[0, 11]
61+
Paragraph[0, 11]
62+
Text[0, 11] chars:[0, 11, "textH … R-157"]
63+
````````````````````````````````
4964

65+
```````````````````````````````` example Non-tickets: 2
66+
HMR-157text
67+
.
68+
<p>HMR-157text</p>
69+
.
70+
Document[0, 11]
71+
Paragraph[0, 11]
72+
Text[0, 11] chars:[0, 11, "HMR-1 … 7text"]
73+
````````````````````````````````

0 commit comments

Comments
 (0)