Skip to content
Permalink
Browse files
905: Github UI code markdown can fail to get copied correctly into email
Reviewed-by: erikj
  • Loading branch information
rwestberg committed Apr 12, 2021
1 parent d9b551d commit 1137b55a4944a965ea6a0bd0a22bebe3fee426c9
@@ -27,7 +27,7 @@
public class MarkdownToText {
private static final Pattern emojiPattern = Pattern.compile("(:([0-9a-z_+-]+):)");
private static final Pattern suggestionPattern = Pattern.compile("^```suggestion$", Pattern.MULTILINE);
private static final Pattern codePattern = Pattern.compile("^```(?:\\w+)?\\R?", Pattern.MULTILINE);
private static final Pattern codePattern = Pattern.compile("^```+(?:\\w+)?$", Pattern.MULTILINE);
private static final Pattern escapesPattern = Pattern.compile("\\\\([!\"#$%&'()*+,\\-./:;<=?@\\[\\]^_`{|}~])", Pattern.MULTILINE);
private static final Pattern entitiesPattern = Pattern.compile("&#32;", Pattern.MULTILINE);

@@ -24,7 +24,8 @@

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

class MarkdownToTextTests {
@Test
@@ -49,6 +50,8 @@ void code() {
assertEquals("Just some text", MarkdownToText.removeFormatting("```\nJust some text\n```"));
assertEquals("Multi\nline", MarkdownToText.removeFormatting("```\nMulti\nline\n```"));
assertEquals("Script", MarkdownToText.removeFormatting("```bash\nScript\n```"));
assertEquals("Longer", MarkdownToText.removeFormatting("`````bash\nLonger\n`````"));
assertEquals("``bash\nShorter\n``", MarkdownToText.removeFormatting("``bash\nShorter\n``"));
}

@Test
@@ -65,4 +68,9 @@ void escapes() {
void entities() {
assertEquals("space is here", MarkdownToText.removeFormatting("space&#32;is here"));
}

@Test
void singleLineCode() {
assertEquals("```assert_locked_or_safepoint(Threads_lock);```", MarkdownToText.removeFormatting("```assert_locked_or_safepoint(Threads_lock);```"));
}
}

1 comment on commit 1137b55

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 1137b55 Apr 12, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.