Repository navigation
Description
Problem and administrator outcome
SharpMUSH builders need consistent Unicode counting, splitting and display-width behavior. Generic primitives must be implemented in MarkupString first, before the softcode wrappers.
Approved workstream: R9-library. Program: SharpMUSH/SharpMUSH#922
Scope
- Review and extend existing Graphemes, DisplayWidth and MarkupText operations; do not duplicate primitives that already exist.
- Expose explicit grapheme count/enumeration and markup-preserving cluster extraction; document UTF-16 index, Unicode scalar, grapheme and display-column units.
- Preserve mixed ANSI/HTML/custom markup when slicing or enumerating, without forcing a rendering format; keep generic Unicode logic in the core package.
- Validate long combining/ZWJ clusters and existing snap-boundary optimizations rather than assuming a fixed lookback is correct for every cluster.
- Document normalization and malformed-input policy; preserve existing public behavior unless a versioned migration is explicitly required.
- Keep trimming/AOT support and bounded allocation behavior. Publish/version the tested library packages for downstream consumption.
Dependencies
None; foundation work can start independently.
Implementation sequence
- Read the listed integration points at current main and capture existing behavior with a focused regression or contract test.
- Specify public inputs, outputs, authority, state transitions and error results for the approved scope before adding endpoints or commands.
- Implement the core behavior through the existing library/service/store architecture and verify the acceptance cases below.
- Wire the authorized game/web surfaces where in scope; add help, metadata and localization alongside the behavior.
- Run focused validation, then relevant provider/integration checks; review the diff and link the completing pull request here.
Existing integration points
MarkupString/Graphemes.csMarkupString/DisplayWidth.csMarkupString/MarkupText.Operations.csMarkupString.TestsMarkupString.AotSmokeREADME.md
These paths are entry points, not a requirement to grow existing large files. Put new cohesive services, models and tests in focused adjacent files. Avoid creating duplicate registries or alternate state-write paths.
Acceptance criteria
- CJK, combining accents, supplementary characters, emoji modifiers, ZWJ sequences, flags, empty text and long clusters have reference/property tests.
- Concatenated extracted clusters reconstruct original text and equivalent markup coverage.
- Count and display width differ correctly for wide characters; slicing never loses the tail or strands a surrogate/combining sequence.
- Core, ANSI, HTML and AOT smoke validation pass; generic APIs acquire no SharpMUSH dependency.
- Release version and documented API are recorded for the dependent SharpMUSH issue.
Validation
Run dotnet run --project MarkupString.Tests and the repository AOT smoke workflow; include core, ANSI and HTML cases.
Constraints and references
Original implementation and original documentation only. Preserve Penn compatibility, existing markup, durable storage and shared permissions. Generic markup/Unicode work belongs in MarkupString. Help/source links establish reference functionality, not permission to copy code or a requirement to reproduce a foreign dialect wholesale.
Activity
HarryCordewener commentedon Sep 8, 2026
Implemented and reviewed in #9, merged at 6249f52, and released as 2.1.0. All six PR checks passed; both review findings were fixed and answered directly. Public NuGet indexes and a fresh SharpMUSH restore confirm version 2.1.0 of MarkupString, MarkupString.Ansi, and MarkupString.Html. Dependent work is in SharpMUSH/SharpMUSH#942; package-validation baseline maintenance is tracked separately in #10.