WordbreakMiddleware 0.0.0-alpha.0.4

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

WordbreakMiddleware

ASP.NET Core middleware that automatically adds word-break opportunities to long words containing dots in HTML content. This helps prevent layout issues with long domain names, file paths, and similar text that would otherwise overflow their containers.

Installation

dotnet add package WordbreakMiddleware

Quick Start

Add the middleware to your ASP.NET Core pipeline:

var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();

// Add WordbreakMiddleware to the pipeline
app.UseWordBreakMiddleware();

app.Run();

How It Works

The middleware intercepts HTML responses and inserts <wbr> (word break opportunity) tags after dots in long words. For example:

  • verylongdomainname.example.com becomes verylongdomainname.<wbr>example.<wbr>com
  • some.really.long.file.path.txt becomes some.<wbr>really.<wbr>long.<wbr>file.<wbr>path.<wbr>txt

By default, only words with 20+ characters in heading elements (h1-h6) are processed.

Configuration

Customize the middleware behavior:

app.UseWordBreakMiddleware(options =>
{
    // Minimum word length to process (default: 20)
    options.MinimumCharacters = 15;
    
    // Characters to insert at break points (default: "<wbr>")
    options.WordBreakCharacters = "<wbr>";
    
    // Process only HTML content (default: true)
    options.ProcessHtmlOnly = true;
    
    // CSS selector for elements to process (default: "h1, h2, h3, h4, h5, h6")
    options.CssSelector = "h1, h2, h3, h4, h5, h6, .text-break";
});

License

MIT

Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  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 was computed.  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
0.0.0-alpha.0.4 188 8/5/2025
0.0.0-alpha.0.3 116 8/4/2025
0.0.0-alpha.0.2 120 8/4/2025
0.0.0-alpha.0.1 43 8/1/2025
0.0.0-alpha.0 233 7/26/2025