MarkupString.Html 1.1.0

dotnet add package MarkupString.Html --version 1.1.0
                    
NuGet\Install-Package MarkupString.Html -Version 1.1.0
                    
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="MarkupString.Html" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MarkupString.Html" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="MarkupString.Html" />
                    
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 MarkupString.Html --version 1.1.0
                    
#r "nuget: MarkupString.Html, 1.1.0"
                    
#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 MarkupString.Html@1.1.0
                    
#: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=MarkupString.Html&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=MarkupString.Html&version=1.1.0
                    
Install as a Cake Tool

MarkupString.Html

Raw HTML tag markup for MarkupString: an MXP <send>, an anchor, a <div class="..."> — carried as a layer over a span of text and written as itself in the Html, Pueblo and Mxp formats.

Where a tag has no meaning — a terminal — it does not vanish silently: b, strong, i, em, u, s, strike and del fold into the run's terminal styling through MarkupString.Ansi, and any other tag leaves its body untouched.

dotnet add package MarkupString.Html

Usage

using MarkupString;
using MarkupString.Ansi;
using MarkupString.Html;

MarkupRegistry.Default = MarkupRegistry.Empty.WithAnsi().WithHtml();

var text = MarkupText.Wrap(
  HtmlMarkup.Create("send", "href=\"n\""),
  MarkupText.Wrap(AnsiCodeParser.Parse("hr"), "north"));

text.Render(MarkupFormat.Html);   // <send href="n"><span style="color: #ff5555">north</span></send>
text.Render(MarkupFormat.Ansi);   // \e[1;31mnorth\e[0m
text.Render(MarkupFormat.Plain);  // north

var json = MarkupTextSerializer.Serialize(text);
var back = MarkupTextSerializer.Deserialize(json);

WithAnsi() must be applied as well: the terminal fold for b/i/u/s comes from that package. Neither the tag name nor the attribute string is sanitised — validate what you put in one.

Styling

The HTML emitters write ms-* classes for the text attributes that have a fixed rendering, and inline style for colours, which are open-ended. Every one of those classes comes from MarkupString.Ansi, so the stylesheet does too: include AnsiCss.Fixed once per page, or copy its rules into your own sheet.

Extension points

  • IMarkup + IMarkupEmitter — register an emitter for HtmlMarkup in a format of your own, or replace this package's by adding yours to the registry afterwards.
  • IMarkupCodecHtmlMarkupCodec is the wire shape under kind "html".
  • IAnsiStyleSourceHtmlMarkup implements it; that is how a tag becomes terminal styling.

AOT and trimming

IsAotCompatible; no reflection, no dynamic code. Registration is an explicit WithHtml() call.

Licence

Apache-2.0. Source, guides and issues: SharpMUSH/MarkupString.

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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 44 9/7/2026
1.0.0 40 9/7/2026