@Test public void precededByBackslashEscape() { PotentialBracketEndDelimiter delimiter = new PotentialBracketEndDelimiter(line, 0); assertFalse(delimiter.precededByBackslashEscape(Cursors.createCursor("["), 0)); assertFalse(delimiter.precededByBackslashEscape(Cursors.createCursor("\\\\["), 2)); assertFalse(delimiter.precededByBackslashEscape(Cursors.createCursor("\\\\\\\\["), 4)); assertTrue(delimiter.precededByBackslashEscape(Cursors.createCursor("\\["), 1)); assertTrue(delimiter.precededByBackslashEscape(Cursors.createCursor("a\\["), 2)); assertTrue(delimiter.precededByBackslashEscape(Cursors.createCursor("\\\\\\["), 3)); }
boolean precededByBackslashEscape(Cursor cursor, int originalOffset) { int count = 0; for (int index = originalOffset - 1; index >= 0; --index) { char c = cursor.getChar(index); if (c == '\\') { ++count; } else { break; } } return count % 2 == 1; }
PotentialBracketEndDelimiter extends InlineWithText { boolean precededByBackslashEscape(Cursor cursor, int originalOffset) { int count = 0; for (int index = originalOffset - 1; index >= 0; --index) { char c = cursor.getChar(index); if (c == '\\') { ++count; } else { break; } } return count % 2 == 1; } }
PotentialBracketEndDelimiter extends InlineWithText { boolean precededByBackslashEscape(Cursor cursor, int originalOffset) { int count = 0; for (int index = originalOffset - 1; index >= 0; --index) { char c = cursor.getChar(index); if (c == '\\') { ++count; } else { break; } } return count % 2 == 1; } PotentialBracketEndDelimiter(Line line, int offset); }
PotentialBracketEndDelimiter extends InlineWithText { boolean precededByBackslashEscape(Cursor cursor, int originalOffset) { int count = 0; for (int index = originalOffset - 1; index >= 0; --index) { char c = cursor.getChar(index); if (c == '\\') { ++count; } else { break; } } return count % 2 == 1; } 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 { boolean precededByBackslashEscape(Cursor cursor, int originalOffset) { int count = 0; for (int index = originalOffset - 1; index >= 0; --index) { char c = cursor.getChar(index); if (c == '\\') { ++count; } else { break; } } return count % 2 == 1; } 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);  }