Zymergi.Rendering 11.4.0-alpha

This is a prerelease version of Zymergi.Rendering.
dotnet add package Zymergi.Rendering --version 11.4.0-alpha
                    
NuGet\Install-Package Zymergi.Rendering -Version 11.4.0-alpha
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Zymergi.Rendering" Version="11.4.0-alpha" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Zymergi.Rendering" Version="11.4.0-alpha" />
                    
Directory.Packages.props
<PackageReference Include="Zymergi.Rendering" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Zymergi.Rendering --version 11.4.0-alpha
                    
#r "nuget: Zymergi.Rendering, 11.4.0-alpha"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Zymergi.Rendering@11.4.0-alpha
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Zymergi.Rendering&version=11.4.0-alpha&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Zymergi.Rendering&version=11.4.0-alpha&prerelease
                    
Install as a Cake Tool

Zymergi.Rendering

HTML, Markdown, and XSLT rendering: HtmlPage parses and edits existing HTML, MarkdigRenderer turns Markdown into HTML, XslTransformViewPool transforms XML through compiled XSL stylesheets, and ToRss20 writes a SyndicationFeed as RSS 2.0.

Targets .NET 10. Depends on Zymergi.Core. Namespaces: Zymergi.Rendering, Zymergi.Rendering.Html, Zymergi.Rendering.Markdown, Zymergi.Rendering.XslTransformView, and Zymergi.Core.Utilities for ToRss20. IMarkdownRenderer is in Core.

Install

dotnet add package Zymergi.Rendering

Register in Program.cs

using Zymergi.Core.Interfaces;
using Zymergi.Rendering;
using Zymergi.Rendering.Markdown;

builder.Services.AddXslTransformViewPool(builder.Configuration);   // singleton; folder from PATH_XSL
builder.Services.AddSingleton<IMarkdownRenderer, MarkdigRenderer>();

PATH_XSL is relative to the current directory. A missing key throws when the pool is first resolved. You can pass XsltOptions instead of configuration.

Use it

using Zymergi.Core.Interfaces;
using Zymergi.Rendering.XslTransformView;

public sealed class PageRenderer(IXslTransformViewPool xsl, IMarkdownRenderer markdown)
{
    public string RenderXml(string xml) =>
        xsl.ContainsKey("page") ? xsl["page"].Transform(xml) : throw new InvalidOperationException("page.xsl missing");

    public string RenderComment(string userMarkdown) => markdown.Render(userMarkdown);
}

app.MapGet("/help/{topic}", (string topic, PageRenderer r, HelpStore store) =>
    Results.Content(r.RenderXml(store.Get(topic)), "text/html"))
   .CacheOutput();

Editing HTML:

using Zymergi.Rendering.Html;

var page = new HtmlPage(rawHtml);
string? title = page.Title;
IHtmlPage merged = page.ReplaceFooter(new HtmlPage(siteTemplateHtml));

Best practices

  • Register the pool and MarkdigRenderer as singletons. Both are built once and reused; building a Markdig pipeline or compiling a stylesheet per request is slow.
  • The pool checks stylesheet files for changes at most every 5 s and reloads them, so you can edit XSL without a restart.
  • Use output caching for rendered pages that do not depend on the user.
  • Use IMarkdownRenderer (MarkdigRenderer) for user input. It removes script, iframe, object, embed, form, link, and style elements, on* attributes, and javascript: URLs.
  • Call AddLogging (the default in ASP.NET Core) so XSLT compile and transform failures are logged through ILogger<XslTransformViewPool>.

Testing

  • Test stylesheets by building new XslTransformViewPool(folder, "*.xsl", logger) or new XslTransformView(path, logger) over a test folder and asserting on the output.
  • MarkdigRenderer has no dependencies; construct it directly.

Gotchas

  • "text".ToHtml() (MarkdownStringExtensions) does not remove dangerous HTML. Use it only for trusted content.
  • MarkdigRenderer uses a deny list. For untrusted HTML that must be safe in every browser, add an allow-list HTML sanitizer.
  • An unknown pool key returns an empty view, not an exception. Check ContainsKey first.
  • Zymergi.AspNetCore has a forwarding AddXslTransformViewPool with the same signature. Importing both Zymergi.Rendering and Zymergi.AspNetCore in one file makes the call ambiguous (CS0121). Import one, or call the method by its full name.
  • Rendering does not use the static Loggor. With no logger, nothing is logged.

API reference

HTML

Type Purpose
HtmlPage Parsed HTML page with structured access to head, body, title, and meta
IHtmlPage Contract for parsed HTML with immutable copy operations
ImageFromWeb Downloaded image convertible to a data URI for inline embedding
HtmlExtensionMethods Extensions for HTML find/replace, XPath selection, and text extraction

Markdown

Type Purpose
MarkdigRenderer IMarkdownRenderer implementation using Markdig with dangerous-element stripping
MarkdownStringExtensions String extensions for markdown conversion (ToHtml, ToMarkdown, AddHeaders). Namespace Zymergi.Rendering.Markdown.

XSLT

Type Purpose
XslTransformView Transforms XML input through a compiled XSL stylesheet
XslTransformViewPool Lookup pool of compiled XSL transforms with file-modification tracking
IXslTransformView Contract for XSL transforms with multiple input types and parameterization
IXslTransformViewPool Contract for a pool of IXslTransformView instances with reload detection
XsltExtensionMethods Converts KeyValuePair collections to XsltArgumentList
XsltOptions PATH_XSL key and the full folder path for the pool
ServiceCollectionExtensions Registers IXslTransformViewPool from configuration or from XsltOptions

Version notes

11.4.0-alpha: no API change.

11.3.0-alpha

  • Breaking: MarkdownStringExtensions moved to namespace Zymergi.Rendering.Markdown.
  • XSLT failures go to an injected ILogger. New overloads XslTransformView(path, logger), XslTransformViewPool(folder, searchPattern, logger), and ToXsltArgumentList(namespaceUri, logger).

Source: bitbucket.org/zymergy/zymergi.saas

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Zymergi.Rendering:

Package Downloads
Zymergi.AspNetCore

ASP.NET Core controllers, authentication filters, and startup extensions for Zymergi.

Zymergi.Articles.MariaDb

MariaDB persistence and DI registration for the Zymergi Article domain.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
11.4.0-alpha 95 11/16/2026
11.3.0-alpha 78 11/12/2026
11.2.0-alpha 74 11/2/2026
11.1.1-alpha 104 10/4/2026
11.1.0-alpha 120 10/1/2026
11.0.6-alpha 67 10/1/2026