OfficeIMO.MarkdownRenderer 0.2.0

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

OfficeIMO.MarkdownRenderer — WebView-Friendly Markdown Rendering for .NET

OfficeIMO.MarkdownRenderer is a host-oriented companion package for OfficeIMO.Markdown. It builds full HTML shells, renders safe HTML fragments, and produces incremental update scripts for WebView2 and browser-based chat/document surfaces.

nuget version nuget downloads

  • Targets: netstandard2.0, net472, net8.0, net10.0
  • License: MIT
  • NuGet: OfficeIMO.MarkdownRenderer
  • Dependencies: OfficeIMO.Markdown, System.Text.Json

AOT / Trimming Notes

  • The renderer itself stays lightweight and mostly composes OfficeIMO.Markdown.
  • Optional runtime features such as Mermaid, charts, and math are exposed through HTML shell assets rather than heavy managed dependencies.
  • For minimal hosts, use the strict minimal presets to disable optional client-side renderers.

Install

dotnet add package OfficeIMO.MarkdownRenderer

Hello, Renderer

using OfficeIMO.MarkdownRenderer;

var options = MarkdownRendererPresets.CreateStrict();

var shellHtml = MarkdownRenderer.BuildShellHtml("Markdown", options);
var bodyHtml = MarkdownRenderer.RenderBodyHtml("""
# Hello

This is rendered through OfficeIMO.MarkdownRenderer.
""", options);

Common Tasks by Example

WebView2 shell + update flow

using OfficeIMO.MarkdownRenderer;

var options = MarkdownRendererPresets.CreateStrict();

webView.NavigateToString(MarkdownRenderer.BuildShellHtml("Markdown", options));
await webView.ExecuteScriptAsync(MarkdownRenderer.RenderUpdateScript(markdownText, options));

Streaming-friendly update path

var options = MarkdownRendererPresets.CreateStrict();

webView.NavigateToString(MarkdownRenderer.BuildShellHtml("Markdown", options));

var bodyHtml = MarkdownRenderer.RenderBodyHtml(markdownText, options);
webView.CoreWebView2.PostWebMessageAsString(bodyHtml);

Optional chat bubble wrappers

var options = MarkdownRendererPresets.CreateChatStrict();
var bubbleHtml = MarkdownRenderer.RenderChatBubbleBodyHtml(markdownText, ChatMessageRole.Assistant, options);

webView.CoreWebView2.PostWebMessageAsString(bubbleHtml);

Generic-first chat composition

var options = MarkdownRendererPresets.CreateStrictMinimal();
MarkdownRendererPresets.ApplyChatPresentation(options, enableCopyButtons: false);
MarkdownRendererIntelligenceXAdapter.Apply(options);

Use this as the preferred composition path for downstream hosts. The CreateChatStrict* helpers remain available as compatibility wrappers.

Strict vs portable presets

var strict = MarkdownRendererPresets.CreateStrict();
var strictPortable = MarkdownRendererPresets.CreateStrictPortable();
var minimal = MarkdownRendererPresets.CreateStrictMinimal();
var minimalPortable = MarkdownRendererPresets.CreateStrictMinimalPortable();
var relaxed = MarkdownRendererPresets.CreateRelaxed();

var chatStrict = MarkdownRendererPresets.CreateChatStrict();
var chatMinimal = MarkdownRendererPresets.CreateChatStrictMinimal();
  • CreateStrict(...): neutral untrusted-content defaults for generic markdown hosting
  • CreateStrictPortable(...): same neutral defaults, but uses the portable markdown reader profile
  • CreateStrictMinimal(...): neutral strict preset with Mermaid, charts, math, Prism, and copy buttons disabled
  • CreateStrictMinimalPortable(...): combines minimal shell behavior with the portable reader profile
  • CreateRelaxed(...): trusted-content preset that allows HTML parsing and sanitizes raw HTML conservatively
  • ApplyChatPresentation(...): composes chat presentation/chrome onto any existing preset without changing its security profile
  • CreateChatStrict(...): compatibility wrapper built on top of the strict preset family
  • CreateChatStrictPortable(...): portable chat wrapper
  • CreateChatStrictMinimal(...): minimal chat wrapper
  • CreateChatStrictMinimalPortable(...): minimal portable chat wrapper
  • CreateChatRelaxed(...): relaxed chat wrapper

Generic presets register neutral fenced block languages such as chart, network, visnetwork, and dataview. Chat presets additionally apply the MarkdownRendererIntelligenceXAdapter, which registers the IntelligenceX-oriented aliases ix-chart, ix-network, and ix-dataview.

IntelligenceX alias adapter

var options = MarkdownRendererPresets.CreateStrict();
MarkdownRendererIntelligenceXAdapter.Apply(options);

Use this when you want the generic strict/relaxed presets but still need the IntelligenceX alias fence contract.

Offline assets

using OfficeIMO.Markdown;
using OfficeIMO.MarkdownRenderer;

var options = MarkdownRendererPresets.CreateStrict();
options.HtmlOptions.AssetMode = AssetMode.Offline;

options.Mermaid.ScriptUrl = @"C:\app\assets\mermaid.min.js";
options.Chart.ScriptUrl = @"C:\app\assets\chart.umd.min.js";
options.Math.CssUrl = @"C:\app\assets\katex.min.css";
options.Math.ScriptUrl = @"C:\app\assets\katex.min.js";
options.Math.AutoRenderScriptUrl = @"C:\app\assets\auto-render.min.js";

Shell CSS overrides

var options = MarkdownRendererPresets.CreateChatStrict();
options.ShellCss = """
.omd-chat-bubble { border-radius: 18px; }
.omd-chat-row.omd-role-user .omd-chat-bubble { background: rgba(0, 120, 212, .18); }
""";

Feature Highlights

  • Full shell HTML builder for WebView/browser hosts
  • Body fragment renderer for incremental updates
  • Neutral and chat-specific strict, portable, minimal, and relaxed presets
  • Optional Mermaid, Chart.js, vis-network, and math shell integration
  • Chat bubble helpers and copy-button UX
  • Host-friendly message contract and data attributes for native integration
  • Shared markdown normalization story through OfficeIMO.Markdown

Host Contract Highlights

Primary APIs

  • BuildShellHtml(...)
  • RenderBodyHtml(...)
  • BuildUpdateScript(...)
  • RenderUpdateScript(...)
  • RenderChatBubbleBodyHtml(...)

WebView2 message contract

Host to web:

  • PostWebMessageAsString(bodyHtml)
  • PostWebMessageAsJson({ type: "omd.update", bodyHtml: "..." })

Web to host:

  • { type: "omd.copy", text: "..." }

Shared visual metadata contract

Built-in visual renderers emit shared data-omd-* attributes:

  • data-omd-visual-kind
  • data-omd-fence-language
  • data-omd-visual-hash
  • data-omd-visual-contract
  • data-omd-config-format
  • data-omd-config-encoding
  • data-omd-config-b64

That keeps host integrations stable even when new visual types are added later. Chart, network, and dataview built-ins now all flow through the same shared metadata builder, so future visual types can reuse the same contract instead of hand-assembling attributes per renderer.

You can also emit the same metadata contract directly from host code through MarkdownVisualContract.CreatePayload(...) and MarkdownVisualContract.BuildElementHtml(...) when you need custom visual blocks outside the built-in renderer list.

Security Defaults

The strict presets are biased toward untrusted chat-style content:

  • raw HTML parsing disabled
  • raw HTML blocks stripped at render time
  • restricted URL schemes
  • file: URLs blocked
  • data: URLs blocked by default
  • external HTTP images blocked unless explicitly allowed
  • external links hardened with noopener noreferrer nofollow ugc

Use the relaxed preset only for trusted or controlled content.

Built-In Styling and Hooks

  • Shell root: #omdRoot
  • Default content wrapper: article.markdown-body
  • Bubble wrappers: .omd-chat-row, .omd-chat-bubble
  • Bubble roles: .omd-role-user, .omd-role-assistant, .omd-role-system
  • Helper classes: .omd-image-blocked, .omd-chart, .omd-math

Themes come from OfficeIMO.Markdown HTML styles, and the chat presets default to HtmlStyle.ChatAuto.

Normalization and Reader Behavior

The renderer uses OfficeIMO.Markdown reader options and normalization behavior underneath.

  • strict presets enable the chat-output normalization helpers
  • portable presets switch the underlying reader to MarkdownReaderOptions.CreatePortableProfile()
  • if you need the same parsing behavior outside the renderer, use MarkdownReaderOptions and MarkdownInputNormalizationPresets directly in OfficeIMO.Markdown

Built-In Visuals

Fenced code blocks can be converted into shell-native visuals:

  • Mermaid
  • Chart.js
  • vis-network
  • dataview tables
  • math rendering

Generic dataview fences accept both array-row and object-row payloads. The built-in parser recognizes neutral aliases such as headers/items, caption/description, and callId, while ix-dataview continues to mirror the legacy data-ix-* attributes for IntelligenceX hosts.

These features are optional and can be disabled entirely in the minimal presets.

Dependencies & Versions

  • OfficeIMO.Markdown
  • System.Text.Json 8.x
  • Targets: netstandard2.0, net472, net8.0, net10.0
  • License: MIT

Package Family

  • OfficeIMO.Markdown: markdown builder, typed reader/AST, and HTML rendering
  • OfficeIMO.MarkdownRenderer: host/WebView rendering shell and incremental update helpers
  • OfficeIMO.Word.Markdown: Word conversion layer that can sit above the markdown family

Notes on Versioning

  • Minor releases may add presets, host hooks, and optional visual integrations.
  • Patch releases focus on host compatibility, rendering correctness, and shell behavior hardening.

Notes

  • Designed for chat surfaces, docs viewers, and embedded reporting experiences
  • WebView2 is a first-class scenario, but the generated HTML works in standard browser hosts too
  • Keep the renderer preset and the host trust model aligned; use strict defaults unless you intentionally need relaxed HTML handling
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  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. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
0.2.0 0 3/13/2026
0.1.9 142 2/21/2026
0.1.8 90 2/19/2026
0.1.7 86 2/18/2026
0.1.6 94 2/18/2026
0.1.5 86 2/17/2026
0.1.4 94 2/16/2026
0.1.3 89 2/15/2026
0.1.2 91 2/15/2026
0.1.1 93 2/15/2026
0.1.0 92 2/11/2026

0.2.0: introduces generic-first preset composition, AST-based semantic fenced-block rendering, IntelligenceX alias adapters, shared visual metadata contracts, and broader dataview payload support for host integrations.