@Test public void createInline() { assertInline(SoftLineBreak.class, 1, 1, createCursor("a\nb", 1)); assertInline(SoftLineBreak.class, 1, 2, createCursor("a \nb", 1)); assertInline(SoftLineBreak.class, 1, 2, createCursor("a \nb\nc", 1)); assertInline(HardLineBreak.class, 1, 4, createCursor("a \nb", 1)); assertInline(HardLineBreak.class, 1, 3, createCursor("a \\\nb", 1)); assertNoInline(createCursor("one")); }
@Override public Optional<? extends Inline> createInline(Cursor cursor) { char c = cursor.getChar(); if (c == '\n' || c == ' ') { Matcher matcher = cursor.matcher(pattern); if (matcher.matches()) { int length = matcher.group(1).length(); if (length > 2 || matcher.group(2) != null) { return Optional.of(new HardLineBreak(cursor.getLineAtOffset(), cursor.getOffset(), length)); } return Optional.of(new SoftLineBreak(cursor.getLineAtOffset(), cursor.getOffset(), length)); } } return Optional.empty(); }
LineBreakSpan extends SourceSpan { @Override public Optional<? extends Inline> createInline(Cursor cursor) { char c = cursor.getChar(); if (c == '\n' || c == ' ') { Matcher matcher = cursor.matcher(pattern); if (matcher.matches()) { int length = matcher.group(1).length(); if (length > 2 || matcher.group(2) != null) { return Optional.of(new HardLineBreak(cursor.getLineAtOffset(), cursor.getOffset(), length)); } return Optional.of(new SoftLineBreak(cursor.getLineAtOffset(), cursor.getOffset(), length)); } } return Optional.empty(); } }
LineBreakSpan extends SourceSpan { @Override public Optional<? extends Inline> createInline(Cursor cursor) { char c = cursor.getChar(); if (c == '\n' || c == ' ') { Matcher matcher = cursor.matcher(pattern); if (matcher.matches()) { int length = matcher.group(1).length(); if (length > 2 || matcher.group(2) != null) { return Optional.of(new HardLineBreak(cursor.getLineAtOffset(), cursor.getOffset(), length)); } return Optional.of(new SoftLineBreak(cursor.getLineAtOffset(), cursor.getOffset(), length)); } } return Optional.empty(); }  }
LineBreakSpan extends SourceSpan { @Override public Optional<? extends Inline> createInline(Cursor cursor) { char c = cursor.getChar(); if (c == '\n' || c == ' ') { Matcher matcher = cursor.matcher(pattern); if (matcher.matches()) { int length = matcher.group(1).length(); if (length > 2 || matcher.group(2) != null) { return Optional.of(new HardLineBreak(cursor.getLineAtOffset(), cursor.getOffset(), length)); } return Optional.of(new SoftLineBreak(cursor.getLineAtOffset(), cursor.getOffset(), length)); } } return Optional.empty(); }  @Override Optional<? extends Inline> createInline(Cursor cursor); }
LineBreakSpan extends SourceSpan { @Override public Optional<? extends Inline> createInline(Cursor cursor) { char c = cursor.getChar(); if (c == '\n' || c == ' ') { Matcher matcher = cursor.matcher(pattern); if (matcher.matches()) { int length = matcher.group(1).length(); if (length > 2 || matcher.group(2) != null) { return Optional.of(new HardLineBreak(cursor.getLineAtOffset(), cursor.getOffset(), length)); } return Optional.of(new SoftLineBreak(cursor.getLineAtOffset(), cursor.getOffset(), length)); } } return Optional.empty(); }  @Override Optional<? extends Inline> createInline(Cursor cursor);  }