Skip to content

Commit

Permalink
Fix bug with text rendering on trade step info
Browse files Browse the repository at this point in the history
  • Loading branch information
xyzmaker123 authored and ripcurlx committed Feb 21, 2022
1 parent 0f60bfa commit 5e0ebf1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/bisq/core/util/SimpleMarkdownParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public static List<? extends MarkdownNode> parse(String markdown) {
sb = new StringBuilder();
}
state = MarkdownParsingState.LINK_TEXT;
} else if (c == '(') {
} else if (c == '(' && state == MarkdownParsingState.LINK_TEXT) {
state = MarkdownParsingState.LINK_HREF;
} else if (c == ')') {
} else if (c == ')' && state == MarkdownParsingState.LINK_HREF) {
state = MarkdownParsingState.TEXT;
items.add(new HyperlinkNode(sb.toString(), sb2.toString()));
sb = new StringBuilder();
Expand Down
12 changes: 12 additions & 0 deletions core/src/test/java/bisq/core/util/SimpleMarkdownParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,16 @@ public void testParse() {
SimpleMarkdownParser.TextNode item2 = (SimpleMarkdownParser.TextNode) result.get(2);
assertEquals(". \n\nIf you have any problems you can try to contact the trade peer in the trade chat.", item2.getText());
}

@Test
public void testParseWithBrackets() {
String text = "Take a look (here) for more";

List<? extends SimpleMarkdownParser.MarkdownNode> result = SimpleMarkdownParser.parse(text);

assertEquals(1, result.size());

SimpleMarkdownParser.TextNode item0 = (SimpleMarkdownParser.TextNode) result.get(0);
assertEquals("Take a look (here) for more", item0.getText());
}
}

0 comments on commit 5e0ebf1

Please sign in to comment.