@Test public void testUnescapeMarkdownStr() { assertEquals("Hello\nWorld", ModelUtils.unescapeMarkdownStr("Hello<br>World")); assertEquals("<>\n", ModelUtils.unescapeMarkdownStr("\\<\\><br>")); assertEquals("\\`*_{}[]()#<>+-.!\n", ModelUtils.unescapeMarkdownStr("\\\\\\`\\*\\_\\{\\}\\[\\]\\(\\)\\#\\<\\>\\+\\-\\.\\!<br/>")); assertEquals("Hello `<\nWorld>`", ModelUtils.unescapeMarkdownStr("Hello \\`<<br/>World\\>\\`")); assertEquals("", ModelUtils.unescapeMarkdownStr("")); }
@Nonnull public static String unescapeMarkdownStr(@Nonnull final String text) { String unescaped = UNESCAPE_BR.matcher(text).replaceAll("\n"); final StringBuffer result = new StringBuffer(text.length()); final Matcher escaped = MD_ESCAPED_PATTERN.matcher(unescaped); while (escaped.find()) { final String group = escaped.group(1); escaped.appendReplacement(result, Matcher.quoteReplacement(group.substring(1))); } escaped.appendTail(result); return result.toString(); }
ModelUtils { @Nonnull public static String unescapeMarkdownStr(@Nonnull final String text) { String unescaped = UNESCAPE_BR.matcher(text).replaceAll("\n"); final StringBuffer result = new StringBuffer(text.length()); final Matcher escaped = MD_ESCAPED_PATTERN.matcher(unescaped); while (escaped.find()) { final String group = escaped.group(1); escaped.appendReplacement(result, Matcher.quoteReplacement(group.substring(1))); } escaped.appendTail(result); return result.toString(); } }
ModelUtils { @Nonnull public static String unescapeMarkdownStr(@Nonnull final String text) { String unescaped = UNESCAPE_BR.matcher(text).replaceAll("\n"); final StringBuffer result = new StringBuffer(text.length()); final Matcher escaped = MD_ESCAPED_PATTERN.matcher(unescaped); while (escaped.find()) { final String group = escaped.group(1); escaped.appendReplacement(result, Matcher.quoteReplacement(group.substring(1))); } escaped.appendTail(result); return result.toString(); } private  ModelUtils(); }
ModelUtils { @Nonnull public static String unescapeMarkdownStr(@Nonnull final String text) { String unescaped = UNESCAPE_BR.matcher(text).replaceAll("\n"); final StringBuffer result = new StringBuffer(text.length()); final Matcher escaped = MD_ESCAPED_PATTERN.matcher(unescaped); while (escaped.find()) { final String group = escaped.group(1); escaped.appendReplacement(result, Matcher.quoteReplacement(group.substring(1))); } escaped.appendTail(result); return result.toString(); } private  ModelUtils(); static int calcCharsOnStart(final char chr, @Nonnull final String text); static boolean onlyFromChar(@Nonnull final String line, final char chr); @Nonnull @MustNotContainNull static Object[] joinArrays(@Nonnull @MustNotContainNull final Object[]... arrs); @Nonnull static String makePreBlock(@Nonnull final String text); @Nonnull static String escapeTextForPreBlock(@Nonnull final String text); @Nonnull static String makeMDCodeBlock(@Nonnull final String text); @Nonnull static String escapeMarkdownStr(@Nonnull final String text); static int calcMaxLengthOfBacktickQuotesSubstr(@Nullable final String text); static void writeChar(@Nonnull final Appendable out, final char chr, final int times); @Nonnull static String unescapeMarkdownStr(@Nonnull final String text); @Nonnull static String makeShortTextVersion(@Nonnull String text, final int maxLength); static int countLines(@Nonnull final String text); @Nonnull @MustNotContainNull static String[] breakToLines(@Nonnull final String text); @Nonnull static String makeQueryStringForURI(@Nullable final Properties properties); @Nonnull static Properties extractQueryPropertiesFromURI(@Nonnull final URI uri); @Nonnull static String encodeForURI(@Nonnull final String s); @Nullable static File makeFileForPath(@Nullable final String path); @Nonnull static String escapeURIPath(@Nonnull final String text); @Nonnull static String removeISOControls(@Nonnull final String text); @Nullable static URI toURI(@Nullable final Path path); @Nonnull static File toFile(@Nonnull final URI uri); }
ModelUtils { @Nonnull public static String unescapeMarkdownStr(@Nonnull final String text) { String unescaped = UNESCAPE_BR.matcher(text).replaceAll("\n"); final StringBuffer result = new StringBuffer(text.length()); final Matcher escaped = MD_ESCAPED_PATTERN.matcher(unescaped); while (escaped.find()) { final String group = escaped.group(1); escaped.appendReplacement(result, Matcher.quoteReplacement(group.substring(1))); } escaped.appendTail(result); return result.toString(); } private  ModelUtils(); static int calcCharsOnStart(final char chr, @Nonnull final String text); static boolean onlyFromChar(@Nonnull final String line, final char chr); @Nonnull @MustNotContainNull static Object[] joinArrays(@Nonnull @MustNotContainNull final Object[]... arrs); @Nonnull static String makePreBlock(@Nonnull final String text); @Nonnull static String escapeTextForPreBlock(@Nonnull final String text); @Nonnull static String makeMDCodeBlock(@Nonnull final String text); @Nonnull static String escapeMarkdownStr(@Nonnull final String text); static int calcMaxLengthOfBacktickQuotesSubstr(@Nullable final String text); static void writeChar(@Nonnull final Appendable out, final char chr, final int times); @Nonnull static String unescapeMarkdownStr(@Nonnull final String text); @Nonnull static String makeShortTextVersion(@Nonnull String text, final int maxLength); static int countLines(@Nonnull final String text); @Nonnull @MustNotContainNull static String[] breakToLines(@Nonnull final String text); @Nonnull static String makeQueryStringForURI(@Nullable final Properties properties); @Nonnull static Properties extractQueryPropertiesFromURI(@Nonnull final URI uri); @Nonnull static String encodeForURI(@Nonnull final String s); @Nullable static File makeFileForPath(@Nullable final String path); @Nonnull static String escapeURIPath(@Nonnull final String text); @Nonnull static String removeISOControls(@Nonnull final String text); @Nullable static URI toURI(@Nullable final Path path); @Nonnull static File toFile(@Nonnull final URI uri); static final Comparator<String> STRING_COMPARATOR; }