Skip to content

Commit 0a2e0e2

Browse files
authored
Add "What this is not" section
See e.g. #31
1 parent 9b01c26 commit 0a2e0e2

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ for (Span span : spans) {
8686
sb.toString(); // "wow <a href=\"http://test.com\">http://test.com</a> such linked"
8787
```
8888

89+
Note that this assumes that the input is plain text, not HTML.
90+
Also see the "What this is not" section below.
91+
8992
Features
9093
--------
9194

@@ -161,6 +164,23 @@ matched), unless the `emailDomainMustHaveDot` option is disabled.
161164
Use `LinkType.EMAIL` for this, and see [test cases
162165
here](src/test/java/org/nibor/autolink/AutolinkEmailTest.java).
163166

167+
What this is not
168+
----------------
169+
170+
This library is intentionally *not* aware of HTML. If it was, it would need to depend on an HTML parser and renderer.
171+
Consider this input:
172+
173+
```
174+
HTML that contains <a href="https://one.example">links</a> but also plain URLs like https://two.example.
175+
```
176+
177+
If you want to turn the plain links into `a` elements but leave the already linked ones intact, I recommend:
178+
179+
1. Parse the HTML using an HTML parser library
180+
2. Walk through the resulting DOM and use autolink-java to find links within *text* nodes only
181+
3. Turn those into `a` elements
182+
4. Render the DOM back to HTML
183+
164184
Contributing
165185
------------
166186

0 commit comments

Comments
 (0)