WordbreakMiddleware 0.0.0-alpha.0.7
dotnet add package WordbreakMiddleware --version 0.0.0-alpha.0.7
NuGet\Install-Package WordbreakMiddleware -Version 0.0.0-alpha.0.7
<PackageReference Include="WordbreakMiddleware" Version="0.0.0-alpha.0.7" />
<PackageVersion Include="WordbreakMiddleware" Version="0.0.0-alpha.0.7" />
<PackageReference Include="WordbreakMiddleware" />
paket add WordbreakMiddleware --version 0.0.0-alpha.0.7
#r "nuget: WordbreakMiddleware, 0.0.0-alpha.0.7"
#:package WordbreakMiddleware@0.0.0-alpha.0.7
#addin nuget:?package=WordbreakMiddleware&version=0.0.0-alpha.0.7&prerelease
#tool nuget:?package=WordbreakMiddleware&version=0.0.0-alpha.0.7&prerelease
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 in two ways:
- After dots in long identifiers: Breaks at natural namespace/type boundaries
- Before uppercase letters in long words: Breaks PascalCase identifiers for better wrapping
Examples:
System.Collections.Generic.DictionarybecomesSystem.<wbr>Collections.<wbr>Generic.<wbr>DictionaryICustomerOrderRepositorybecomesICustomer<wbr>Order<wbr>RepositoryGetCustomerByIdAsyncbecomesGet<wbr>Customer<wbr>By<wbr>Id<wbr>AsyncMicrosoft.AspNetCore.Mvc.ControllerBasebecomesMicrosoft.<wbr>AspNetCore.<wbr>Mvc.<wbr>Controller<wbr>Base
By default, the middleware targets:
- Words with 20+ characters
- In heading elements (
h1,h2,h3,h4,h5,h6) and elements with classtext-break
.NET Identifier Examples
Here are common scenarios where long .NET identifiers benefit from word breaking:
Interface Names
<h2>ICustomerOrderManagementService</h2>
Long Method Names
<h3>ValidateCustomerCreditScoreAsync</h3>
Entity Framework DbContext
<h2>ApplicationDbContextModelSnapshot</h2>
Combined Namespace and Type Breaking
<h3>System.ComponentModel.DataAnnotations.ValidationAttribute</h3>
Generic Type Constraints
<h4>IRepository<TEntity> where TEntity : BaseEntityWithTimestamps</h4>
ASP.NET Core Middleware Names
<h2>UseAuthenticationMiddleware</h2>
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 | Versions 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. |
-
net9.0
- AngleSharp (>= 1.3.1-beta.491)
- Microsoft.AspNetCore.Http.Abstractions (>= 2.3.0)
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.7 | 218 | 11/16/2025 |
| 0.0.0-alpha.0.4 | 257 | 8/5/2025 |
| 0.0.0-alpha.0.3 | 162 | 8/4/2025 |
| 0.0.0-alpha.0.2 | 164 | 8/4/2025 |
| 0.0.0-alpha.0.1 | 89 | 8/1/2025 |
| 0.0.0-alpha.0 | 304 | 7/26/2025 |