Class HtmlLocalLinkParser
Utility class used to parse internal links.
Inheritance
Namespace: Umbraco.Cms.Core.Templates
Assembly: Umbraco.Core.dll
Syntax
public sealed class HtmlLocalLinkParser
Remarks
Needs to support media and document links, order of attributes should not matter nor should other attributes mess with things:
<a type = "media" href="/{localLink:7e21a725-b905-4c5f-86dc-8c41ec116e39}" title="media">media</a> <a type="document" href="/{localLink:eed5fc6b-96fd-45a5-a0f1-b1adfb483c2f}" title="other page">other page</a>
Constructors
View SourceHtmlLocalLinkParser(IPublishedUrlProvider)
Initializes a new instance of the HtmlLocalLinkParser class.
Declaration
public HtmlLocalLinkParser(IPublishedUrlProvider publishedUrlProvider)
Parameters
| Type | Name | Description |
|---|---|---|
| IPublishedUrlProvider | publishedUrlProvider | The published URL provider for resolving content and media URLs. |
Methods
View SourceEnsureInternalLinks(string)
Parses the string looking for the {localLink} syntax and updates them to their correct links.
Declaration
public string EnsureInternalLinks(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text |
Returns
| Type | Description |
|---|---|
| string |
EnsureInternalLinks(string, bool)
Parses the string looking for the {localLink} syntax and updates them to their correct links.
Declaration
[Obsolete("This method overload is no longer used in Umbraco and delegates to the overload without the preview parameter. Scheduled for removal in Umbraco 18.")]
public string EnsureInternalLinks(string text, bool preview)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | |
| bool | preview |
Returns
| Type | Description |
|---|---|
| string |
EnsureInternalLinks(string, UrlMode)
Parses the string looking for the {localLink} syntax and updates them to their correct links.
Declaration
public string EnsureInternalLinks(string text, UrlMode urlMode)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | |
| UrlMode | urlMode |
Returns
| Type | Description |
|---|---|
| string |
FindLegacyLocalLinkIds(string)
Finds legacy local link identifiers in the specified text.
Declaration
[Obsolete("This is a temporary method to support legacy formats until we are sure all data has been migrated. Scheduled for removal in Umbraco 18.")]
public IEnumerable<HtmlLocalLinkParser.LocalLinkTag> FindLegacyLocalLinkIds(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to search for legacy local links. |
Returns
| Type | Description |
|---|---|
| IEnumerable<HtmlLocalLinkParser.LocalLinkTag> | An enumerable of HtmlLocalLinkParser.LocalLinkTag objects representing legacy links. |
FindUdisFromLocalLinks(string)
Finds all UDIs from local link references in the specified text.
Declaration
public IEnumerable<Udi?> FindUdisFromLocalLinks(string text)
Parameters
| Type | Name | Description |
|---|---|---|
| string | text | The text to search for local links. |
Returns
| Type | Description |
|---|---|
| IEnumerable<Udi> | An enumerable of Udi objects found in the text. |