Readme / Examples
Generic examples of Url highlight capabilities.
🔍 Feel free to inspect UrlHighlightTest and MatcherTest for more details.
Input:
The main purpose of this library is to linkify urls in string input. The easiest case would be url with scheme like http://example.com.
Without scheme example.com - also works fine, but not for example.txt. You want to know what about punctuation.
If this highlighted properly: http://example.com? It is! Also, it takes care about brackets. So enclosed urls looks fine
(http://example.com/path_with_(brackets)). Of course, it supports emails user@example.com. In real life
there is urls like this one: http://elk.example.com:81/app/kibana#/discover?_g=()&_a=(columns:!(_source),index:'deve-',interval:auto,query:(query_string:(analyze_wildcard:!t,query:'')),sort:!('@timestamp',desc))
from ELK. As you see, it also works fine. Yes, it supports HTML and HTML encoded input.
For example links <a href="http://example.com">example.com</a> won't be "double highlighted".
See more details and examples bellow.
Result:
The main purpose of this library is to linkify urls in string input. The easiest case would be url with scheme like http://example.com.
Without scheme example.com - also works fine, but not for example.txt. You want to know what about punctuation.
If this highlighted properly: http://example.com? It is! Also, it takes care about brackets. So enclosed urls looks fine
(http://example.com/path_with_(brackets)). Of course, it supports emails [email protected]. In real life
there is urls like this one: http://elk.example.com:81/app/kibana#/discover?_g=()&_a=(columns:!(_source),index:'deve-*',interval:auto,query:(query_string:(analyze_wildcard:!t,query:'*')),sort:!('@timestamp',desc))
from ELK. As you see, it also works fine. Yes, it supports HTML and HTML encoded input.
For example links example.com won't be "double highlighted".
See more details and examples bellow.
|
Value |
Input: |
Text before http://example.com and after. |
Output: |
Text before <a href="http://example.com">http://example.com</a> and after. |
Rendered: |
Text before http://example.com and after. |
|
Value |
Input: |
Text before example.com and after, but not example.txt. |
Output: |
Text before <a href="http://example.com">example.com</a> and after, but not example.txt. |
Rendered: |
Text before example.com and after, but not example.txt. |
|
Value |
Input: |
Did you visit http://example.com? |
Output: |
Did you visit <a href="http://example.com">http://example.com</a>? |
Rendered: |
Did you visit http://example.com? |
|
Value |
Input: |
Text before (http://example.com/path_with_(brackets)) and after. |
Output: |
Text before (<a href="http://example.com/path_with_(brackets)">http://example.com/path_with_(brackets)</a>) and after. |
Rendered: |
Text before (http://example.com/path_with_(brackets)) and after. |
|
Value |
Input: |
Text before http://привіт.укр/★ and after. |
Output: |
Text before <a href="http://привіт.укр/★">http://привіт.укр/★</a> and after. |
Rendered: |
Text before http://привіт.укр/★ and after. |
|
Value |
Input: |
<p>Text before http://example.com and after.</p> |
Output: |
<p>Text before <a href="http://example.com">http://example.com</a> and after.</p> |
Rendered: |
Text before http://example.com and after. |
|
Value |
Input: |
Text before <a href="http://example.com">http://example.com</a> and after. |
Output: |
Text before <a href="http://example.com">http://example.com</a> and after. |
Rendered: |
Text before http://example.com and after. |
|
Value |
Input: |
Text before <img src="https://github.githubassets.com/images/icons/emoji/unicode/1f369.png" height="14"> http://example.com and after. |
Output: |
Text before <img src="https://github.githubassets.com/images/icons/emoji/unicode/1f369.png" height="14"> <a href="http://example.com">http://example.com</a> and after. |
Rendered: |
Text before http://example.com and after. |
|
Value |
Input: |
Text before <a href="http://example.com">example.com</a> and after. |
Output: |
Text before <a href="<a href="http://example.com">http://example.com</a>"><a href="http://example.com">example.com</a></a> and after. |
Rendered: |
Text before <a href="http://example.com">example.com</a> and after. |
💡 Tip: HtmlSpecialcharsEncoder used here.
See Encoder for more details.
|
Value |
Input: |
Text before http://example.com and after. |
Output: |
Text before <a href="http://example.com">http://example.com</a> and after. |
Rendered: |
Text before http://example.com and after. |
💡 Tip: HtmlEntitiesEncoder used here.
See Encoder for more details.