Merge pull request #6064 from xyzmaker123/fix-parser

Fix bug with text rendering on trade step info
This commit is contained in:
Christoph Atteneder 2022-02-21 14:49:46 +01:00 committed by GitHub
commit 737faa6443
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -46,9 +46,9 @@ public class SimpleMarkdownParser {
sb = new StringBuilder(); sb = new StringBuilder();
} }
state = MarkdownParsingState.LINK_TEXT; state = MarkdownParsingState.LINK_TEXT;
} else if (c == '(') { } else if (c == '(' && state == MarkdownParsingState.LINK_TEXT) {
state = MarkdownParsingState.LINK_HREF; state = MarkdownParsingState.LINK_HREF;
} else if (c == ')') { } else if (c == ')' && state == MarkdownParsingState.LINK_HREF) {
state = MarkdownParsingState.TEXT; state = MarkdownParsingState.TEXT;
items.add(new HyperlinkNode(sb.toString(), sb2.toString())); items.add(new HyperlinkNode(sb.toString(), sb2.toString()));
sb = new StringBuilder(); sb = new StringBuilder();

View File

@ -28,4 +28,16 @@ public class SimpleMarkdownParserTest {
SimpleMarkdownParser.TextNode item2 = (SimpleMarkdownParser.TextNode) result.get(2); 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()); 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());
}
} }