Fix bug with text rendering on trade step info

This commit is contained in:
xyzmaker123 2022-02-20 10:13:56 +01:00
parent aaac08202e
commit 3b966d8740
No known key found for this signature in database
GPG Key ID: 47689699B7B0AAFC
2 changed files with 14 additions and 2 deletions

View File

@ -46,9 +46,9 @@ public class SimpleMarkdownParser {
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();

View File

@ -28,4 +28,16 @@ public class SimpleMarkdownParserTest {
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());
}
}