@@ -37,7 +37,9 @@ Extract links:
3737import org.nibor.autolink.* ;
3838
3939String input = " wow, so example: http://test.com" ;
40- LinkExtractor linkExtractor = LinkExtractor . builder(). build();
40+ LinkExtractor linkExtractor = LinkExtractor . builder()
41+ .linkTypes(EnumSet . of(LinkType . URL , LinkType . WWW , LinkType . EMAIL ))
42+ .build();
4143Iterable<LinkSpan > links = linkExtractor. extractLinks(input);
4244LinkSpan link = links. iterator(). next();
4345link. getType(); // LinkType.URL
@@ -46,7 +48,13 @@ link.getEndIndex(); // 32
4648input. substring(link. getBeginIndex(), link. getEndIndex()); // "http://test.com"
4749```
4850
49- Wrapping URLs in an <a > tag (doesn't handle escaping, uses Java 8):
51+ Note that by default all supported types of links are extracted. If
52+ you're only interested in specific types, narrow it down using the
53+ ` linkTypes ` method.
54+
55+ There's also a static method to replace links found in the text. Here's
56+ an example of using that for wrapping URLs in an ` <a> ` tag. Note that it
57+ doesn't handle escaping at all:
5058
5159``` java
5260import org.nibor.autolink.* ;
@@ -91,7 +99,8 @@ Example input and linked result:
9199 [ https://en.wikipedia.org/wiki/Link_(The_Legend_of_Zelda) ] ( )
92100* ` http://üñîçøðé.com/ ` → [ http://üñîçøðé.com/ ] ( )
93101
94- Also see [ test cases] ( src/test/java/org/nibor/autolink/AutolinkUrlTest.java ) .
102+ Use ` LinkType.URL ` for this, and see [ test
103+ cases here] ( src/test/java/org/nibor/autolink/AutolinkUrlTest.java ) .
95104
96105### WWW link extraction
97106
@@ -112,7 +121,8 @@ Not supported:
112121
113122The domain must have at least 3 parts, so ` www.com ` is not valid, but ` www.something.co.uk ` is.
114123
115- Also see [ test cases] ( src/test/java/org/nibor/autolink/AutolinkWwwTest.java ) .
124+ Use ` LinkType.WWW ` for this, and see [ test
125+ cases here] ( src/test/java/org/nibor/autolink/AutolinkWwwTest.java ) .
116126
117127### Email address extraction
118128
@@ -134,7 +144,8 @@ Not supported:
134144Note that the domain must have at least one dot (e.g. ` foo@com ` isn't
135145matched), unless the ` emailDomainMustHaveDot ` option is disabled.
136146
137- Also see [ test cases] ( src/test/java/org/nibor/autolink/AutolinkEmailTest.java ) .
147+ Use ` LinkType.EMAIL ` for this, and see [ test cases
148+ here] ( src/test/java/org/nibor/autolink/AutolinkEmailTest.java ) .
138149
139150Contributing
140151------------
0 commit comments