UtilHtmlLinkify(String, LinkifyInterfaceType, LinkifyPlugins, LinkifyFormatOptions) Method
Highlights links within strings that contain HTML markup,
or replace links in plain-text strings with anchor (<a>) tags.
The behavior depends on the
interfaceType parameter.
This function internally uses linkify JavaScript library (
https://linkify.js.org/).
Namespace: DevCase.Core.DataProcessing.HtmlAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
No code example is currently available or this language may not be supported.
- str String
-
The source html or plain-text string.
- interfaceType LinkifyInterfaceType
-
A interface type that defines how to parse the value specified in str parameter.
If this value is Html,
this function will highlight links within strings that contain HTML markup.
If this value is Html,
this function will replace links in plain-text strings with anchor (<a>) tags.
- plugins LinkifyPlugins (Optional)
-
Optional LinkifyPlugins flags that adds additional linkify capabilities.
By default this function only linkifies domain urls and email addresses.
Default value: None
- formatOptions LinkifyFormatOptions (Optional)
-
Optional LinkifyFormatOptions object that adds additional formatting capabilities to links.
String
The resulting linkified text.
This is a code example.
No code example is currently available or this language may not be supported.
Dim htmlString As String = "
<!DOCTYPE html>
<html>
<body>
<p>Linkify Test.</p>
<p>Domain: example.domain.com</p>
<p>E-mail Address: For help with GitHub, please email support@github.com</p>
<p>IP Address: No place like 127.0.0.1</p>
<p>#Hashtag: Works with hashtags #PhotoOfTheDay or #일상</p>
<p>@Mention: Check out @Hypercontext and @nfrasser</p>
<p>#-Ticket: This is related to #42.</p>
</body>
</html>"
Dim interfaceType As LinkifyInterfaceType = LinkifyInterfaceType.Html
Dim plugins As LinkifyPlugins = LinkifyPlugins.All
Dim options As New LinkifyFormatOptions
options.UrlProtocol = Uri.UriSchemeHttps
options.TruncateLength = 50
options.TargetAttribute =
Function(linkType As LinkifyLinkType, href As String) As String
Return "_blank"
End Function
options.FormatHref =
Function(linkType As LinkifyLinkType, href As String) As String
Select Case linkType
Case LinkifyLinkType.Hashtag
Return "https://twitter.com/hashtag/" & href.Substring(1)
Case LinkifyLinkType.Mention
Return "https://github.com" & href
Case LinkifyLinkType.Ticket
Return "https://github.com/Hypercontext/linkifyjs/issues/" & href.Substring(1)
Case Else
Return href ' no formatting
End Select
End Function
Dim linkifiedHtml As String = Linkify(htmlString, interfaceType, plugins, options)
Console.WriteLine(linkifiedHtml)
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.