MarkupString.Html
1.1.0
dotnet add package MarkupString.Html --version 1.1.0
NuGet\Install-Package MarkupString.Html -Version 1.1.0
<PackageReference Include="MarkupString.Html" Version="1.1.0" />
<PackageVersion Include="MarkupString.Html" Version="1.1.0" />
<PackageReference Include="MarkupString.Html" />
paket add MarkupString.Html --version 1.1.0
#r "nuget: MarkupString.Html, 1.1.0"
#:package MarkupString.Html@1.1.0
#addin nuget:?package=MarkupString.Html&version=1.1.0
#tool nuget:?package=MarkupString.Html&version=1.1.0
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 forHtmlMarkupin a format of your own, or replace this package's by adding yours to the registry afterwards.IMarkupCodec—HtmlMarkupCodecis the wire shape under kind"html".IAnsiStyleSource—HtmlMarkupimplements 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 | Versions 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. |
-
net10.0
- MarkupString (>= 1.1.0)
- MarkupString.Ansi (>= 1.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.