@Test public void unescapeBackslashEscapeBrackets() { PotentialBracketEndDelimiter delimiter = new PotentialBracketEndDelimiter(line, 0); assertEquals("a[b", delimiter.toReferenceName("a\\[b")); assertEquals("a]b", delimiter.toReferenceName("a\\]b")); assertEquals("a\\!b", delimiter.toReferenceName("a\\!b")); assertEquals("a\\![b c", delimiter.toReferenceName("a\\![b\n c")); }
String toReferenceName(String stringWithBackslashEscapes) { String referenceName = stringWithBackslashEscapes.replaceAll("(?s)\\\\(\\[|\\])", "$1").replaceAll("\\s+", " "); if (CharMatcher.whitespace().matchesAllOf(referenceName)) { return null; } return referenceName; }
PotentialBracketEndDelimiter extends InlineWithText { String toReferenceName(String stringWithBackslashEscapes) { String referenceName = stringWithBackslashEscapes.replaceAll("(?s)\\\\(\\[|\\])", "$1").replaceAll("\\s+", " "); if (CharMatcher.whitespace().matchesAllOf(referenceName)) { return null; } return referenceName; } }
PotentialBracketEndDelimiter extends InlineWithText { String toReferenceName(String stringWithBackslashEscapes) { String referenceName = stringWithBackslashEscapes.replaceAll("(?s)\\\\(\\[|\\])", "$1").replaceAll("\\s+", " "); if (CharMatcher.whitespace().matchesAllOf(referenceName)) { return null; } return referenceName; } PotentialBracketEndDelimiter(Line line, int offset); }
PotentialBracketEndDelimiter extends InlineWithText { String toReferenceName(String stringWithBackslashEscapes) { String referenceName = stringWithBackslashEscapes.replaceAll("(?s)\\\\(\\[|\\])", "$1").replaceAll("\\s+", " "); if (CharMatcher.whitespace().matchesAllOf(referenceName)) { return null; } return referenceName; } PotentialBracketEndDelimiter(Line line, int offset); @Override void emit(DocumentBuilder builder); @Override void apply(ProcessingContext context, List<Inline> inlines, Cursor cursor); void truncate(List<Inline> inlines, int indexOfOpeningDelimiter); }
PotentialBracketEndDelimiter extends InlineWithText { String toReferenceName(String stringWithBackslashEscapes) { String referenceName = stringWithBackslashEscapes.replaceAll("(?s)\\\\(\\[|\\])", "$1").replaceAll("\\s+", " "); if (CharMatcher.whitespace().matchesAllOf(referenceName)) { return null; } return referenceName; } PotentialBracketEndDelimiter(Line line, int offset); @Override void emit(DocumentBuilder builder); @Override void apply(ProcessingContext context, List<Inline> inlines, Cursor cursor); void truncate(List<Inline> inlines, int indexOfOpeningDelimiter);  }