@Test public void createInline() { assertNoInline(createCursor("<http: assertNoInline(createCursor("<http:/ >")); assertNoInline(createCursor("<http: assertNoInline(createCursor("http: assertLink(30, "http: createCursor("<http: assertLink(37, "ftp:/example.com/a/b/c?one=&two=%20", "ftp:/example.com/a/b/c?one=&two=%20", createCursor("<ftp:/example.com/a/b/c?one=&two=%20> one")); assertLink(24, "ssh: assertLink(23, "mailto:user@test.example.com", "user@test.example.com", createCursor("<user@test.example.com>")); assertLink(25, "http: createCursor("<http: }
@Override public Optional<? extends Inline> createInline(Cursor cursor) { char c = cursor.getChar(); if (c == '<') { Matcher matcher = cursor.matcher(linkPattern); if (matcher.matches()) { String href = matcher.group(1); String link = href; String email = matcher.group(2); if (email != null) { link = "mailto:" + email; } int endOffset = cursor.getOffset(matcher.end(3)); int linkLength = endOffset - cursor.getOffset(); return Optional.of(new Link(cursor.getLineAtOffset(), cursor.getOffset(), linkLength, escapeUri(link), null, ImmutableList.<Inline> of(new Characters(cursor.getLineAtOffset(), cursor.getOffset() + 1, linkLength - 2, href)))); } } return Optional.empty(); }
AutoLinkSpan extends SourceSpan { @Override public Optional<? extends Inline> createInline(Cursor cursor) { char c = cursor.getChar(); if (c == '<') { Matcher matcher = cursor.matcher(linkPattern); if (matcher.matches()) { String href = matcher.group(1); String link = href; String email = matcher.group(2); if (email != null) { link = "mailto:" + email; } int endOffset = cursor.getOffset(matcher.end(3)); int linkLength = endOffset - cursor.getOffset(); return Optional.of(new Link(cursor.getLineAtOffset(), cursor.getOffset(), linkLength, escapeUri(link), null, ImmutableList.<Inline> of(new Characters(cursor.getLineAtOffset(), cursor.getOffset() + 1, linkLength - 2, href)))); } } return Optional.empty(); } }
AutoLinkSpan extends SourceSpan { @Override public Optional<? extends Inline> createInline(Cursor cursor) { char c = cursor.getChar(); if (c == '<') { Matcher matcher = cursor.matcher(linkPattern); if (matcher.matches()) { String href = matcher.group(1); String link = href; String email = matcher.group(2); if (email != null) { link = "mailto:" + email; } int endOffset = cursor.getOffset(matcher.end(3)); int linkLength = endOffset - cursor.getOffset(); return Optional.of(new Link(cursor.getLineAtOffset(), cursor.getOffset(), linkLength, escapeUri(link), null, ImmutableList.<Inline> of(new Characters(cursor.getLineAtOffset(), cursor.getOffset() + 1, linkLength - 2, href)))); } } return Optional.empty(); }  }
AutoLinkSpan extends SourceSpan { @Override public Optional<? extends Inline> createInline(Cursor cursor) { char c = cursor.getChar(); if (c == '<') { Matcher matcher = cursor.matcher(linkPattern); if (matcher.matches()) { String href = matcher.group(1); String link = href; String email = matcher.group(2); if (email != null) { link = "mailto:" + email; } int endOffset = cursor.getOffset(matcher.end(3)); int linkLength = endOffset - cursor.getOffset(); return Optional.of(new Link(cursor.getLineAtOffset(), cursor.getOffset(), linkLength, escapeUri(link), null, ImmutableList.<Inline> of(new Characters(cursor.getLineAtOffset(), cursor.getOffset() + 1, linkLength - 2, href)))); } } return Optional.empty(); }  @Override Optional<? extends Inline> createInline(Cursor cursor); }
AutoLinkSpan extends SourceSpan { @Override public Optional<? extends Inline> createInline(Cursor cursor) { char c = cursor.getChar(); if (c == '<') { Matcher matcher = cursor.matcher(linkPattern); if (matcher.matches()) { String href = matcher.group(1); String link = href; String email = matcher.group(2); if (email != null) { link = "mailto:" + email; } int endOffset = cursor.getOffset(matcher.end(3)); int linkLength = endOffset - cursor.getOffset(); return Optional.of(new Link(cursor.getLineAtOffset(), cursor.getOffset(), linkLength, escapeUri(link), null, ImmutableList.<Inline> of(new Characters(cursor.getLineAtOffset(), cursor.getOffset() + 1, linkLength - 2, href)))); } } return Optional.empty(); }  @Override Optional<? extends Inline> createInline(Cursor cursor);  }