Nucleus .Net Core CMS

ContentExtensions Class

Namespace: Nucleus.Extensions
Assembly: Nucleus.Extensions.dll
Content extensions.
BuildModerateHtmlSanitizer ()
Build a HtmlSanitizer which removes unsafe markup and allows a subset of supported markup, suitable for multi-line content which was generated by an end user.
BuildStandardHtmlSanitizer ()
Build a HtmlSanitizer which removes unsafe markup but allows as much as possible.
BuildStrictHtmlSanitizer ()
Build a HtmlSanitizer which removes unsafe markup and allows a subset of supported markup, suitable for simple multi-line content.
Remarks
Allows p, span, div, h1-h6, br, hr, ul, ol, li, table, code, blockquote, as well as the simple formatting elements allowed by the VeryStrict sanitizer, b, strong, u, del, s, i, em, sub, sup, small.
BuildSvgSanitizer ()
Build a HtmlSanitizer which removes unsafe markup from SVG content.
BuildVeryStrictHtmlSanitizer ()
Build an HtmlSanitizer which supports a very limited set of elements, suitable for single lines content like module titles, headings and similar.
Remarks
Allows b, strong, u, del, s, i, em, sub, sup, small.
ConvertTo (Content content, String targetContentType)
Convert a Models.Content object's Value to the format specified by targetContentType. This function changes the values of the Value and ContentType properties in the specified Models.Content object.
Parameters
Name Type
content Nucleus.Abstractions.Models.Content
targetContentType String
Remarks
This function supports convertion to and from text/html, text/markdown and text/plain.
SanitizeHtml (Content content)
Sanitize the Html in content.Value.
Parameters
Name Type
content Nucleus.Abstractions.Models.Content
Remarks
If the ContentType of the Content object is not "text/html", this function does nothing and returns the passed-in content object, unchanged.
SanitizeHtml (String content)
Sanitize the specified Html string.
Parameters
Name Type
content String
SanitizeHtml (String content, HtmlSanitizeStrictness strictness)
Sanitize the specified Html string.
SanitizeSvg (Stream content)
Sanitize the specified Html string.
Parameters
Name Type
content System.IO.Stream
ToHtml (Content content)
Convert the specified content to Html.
Parameters
Name Type
content Nucleus.Abstractions.Models.Content
ToHtml (String content, String fromContentType)
Return a string containing the conversion of the specified Models.Content object's Value to Html.
Parameters
Name Type
content String
fromContentType String

MIME type of the original content.

Returns
The converted content string.
Remarks
The contentType can be text/markdown or text/plain. All other content type values are treated as text/html and are not converted.
ToMarkdown (Content content)
Return a string containing the conversion of the specified Models.Content object's Value to Markdown.
Parameters
Name Type
content Nucleus.Abstractions.Models.Content
ToMarkdown (String content, String fromContentType)
Converts the specified string content to Markdown.
Parameters
Name Type
content String
fromContentType String

MIME type of the original content.

Returns
The converted content string.
Remarks
The contentType can be text/html or text/plain. All other content type values are treated as text/markdown and are not converted.
ToText (Content content)
Return a string containing the conversion of the specified Models.Content object's Value to plain text.
Parameters
Name Type
content Nucleus.Abstractions.Models.Content
ToText (String content, String fromContentType)
Convert the specified string content to plain text.
Parameters
Name Type
content String
fromContentType String

MIME type of the original content.

Returns
The converted content string.
Remarks
The contentType can be text/markdown or text/html. All other content type values are treated as text/plain and are not converted.