From 8f50cf28de0e8e7e2eceb0adbcba4e415370dc28 Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Nov 2026 09:31:16 +0000 Subject: [PATCH 1/2] Read a fixed-width table row as one line for a screen reader BlockLayout.Relayout wrapped a block that is not fluid at its own width even when read in order, so a 35-cell WHO listing put each player over two lines. A linear reader now wraps every block at its own width. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Rqqt7TtjS4aEBMGrbaAp6T --- CHANGELOG.md | 3 +++ MarkupString.Tests/Layout/BlockLayoutTests.cs | 14 ++++++++++++++ MarkupString/Layout/Blocks/BlockLayout.cs | 7 +++++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 854fdad..1c327c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,9 @@ follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed +- A screen reader hears one row of a fixed-width table as one line. `BlockLayout.Relayout` with + `LayoutContext.Linear` now wraps a block that is not fluid at the reader's width, as it does a fluid one; + before, it wrapped at the width the block's columns took, so a 35-cell WHO listing broke each player's row in two. - Two equal elements side by side stay two. Before, an element closed and an equal one opened straight after it became one run, so a client saw one thing where the server sent two. This happened with two exits of one flagged element (`northsouth` read as one exit, `northsouth`), two ``s, ``s diff --git a/MarkupString.Tests/Layout/BlockLayoutTests.cs b/MarkupString.Tests/Layout/BlockLayoutTests.cs index 2d7cca5..959160e 100644 --- a/MarkupString.Tests/Layout/BlockLayoutTests.cs +++ b/MarkupString.Tests/Layout/BlockLayoutTests.cs @@ -210,6 +210,20 @@ await Assert.That(string.Join("\n", lines.Select(l => l.ToPlainText()))).IsEqual "Origin: Super Robot Wars AG\nOnline: 1h, Idle: 0s\nFactions\nMEDJAI, Court of Stardust\nQuote\nHooooo?"); } + [Test] + public async Task Linear_ReadsAFixedWidthTableRowAsOneLineAtTheReadersWidth() + { + // A WHO listing is laid out at its own width (not fluid); read aloud, its one row is one line. + var table = new Table([new TableColumn(P("Player Name")) { Min = 16 }, new TableColumn(P("On For")) { Min = 10, Alignment = Alignment.Right }, new TableColumn(P("Idle ")) { Min = 7, Alignment = Alignment.Right }], + [[P("Marguerite"), P("7s"), P("0s")]]) + { Gap = 1 }; + var text = BlockLayout.Build(table, 35); + + var read = BlockLayout.Relayout(text, 78, new LayoutContext { Linear = true }); + + await Assert.That(read.ToPlainText()).IsEqualTo("Player Name: Marguerite, On For: 7s, Idle: 0s"); + } + [Test] public async Task Flex_StacksWhenItemsDoNotFit() { diff --git a/MarkupString/Layout/Blocks/BlockLayout.cs b/MarkupString/Layout/Blocks/BlockLayout.cs index 94508b2..a55bf34 100644 --- a/MarkupString/Layout/Blocks/BlockLayout.cs +++ b/MarkupString/Layout/Blocks/BlockLayout.cs @@ -105,7 +105,8 @@ private static void AddText(MarkupText content, int start, int end, Alignment? a /// /// with every intact block laid out again under : - /// a block at , any other at its own width. + /// a block at , and any block read in order + /// () too; any other at its own width. /// A block that was cut, edited or shares a line with other text is left as it is. /// /// The text. @@ -120,7 +121,9 @@ public static MarkupText Relayout(MarkupText text, int width, LayoutContext cont foreach (var region in BlockRegions.Find(text)) { if (region.Markup is not LayoutMarkup layout || !region.Intact || !region.Standalone) continue; - var target = layout.Fluid && width > 0 ? width : layout.Width; + // A screen reader hears a fixed-width block in reading order, so its lines wrap at the reader's + // width, not at the width its columns took: one row of a table stays one line. + var target = (layout.Fluid || context.Linear) && width > 0 ? width : layout.Width; if (target == layout.Width && context == LayoutContext.Default) continue; edits.Add((region.Start, region.End - region.Start, Build(layout.Root, target, layout.Fluid, context))); } From 145218c4655d6938494d55c18ea44fbf24d2cf6d Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 11 Nov 2026 09:39:23 +0000 Subject: [PATCH 2/2] Read a nested fixed-width block at the reader's width too Bounded kept its width for a linear reader, so a fixed-width table nested in a fluid block (ServerLayout.Body) still split a row in two. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Rqqt7TtjS4aEBMGrbaAp6T --- CHANGELOG.md | 2 +- MarkupString.Tests/Layout/BlockLayoutTests.cs | 13 +++++++++++++ MarkupString/Layout/Blocks/Modifiers.cs | 5 +++++ MarkupString/PublicAPI.Unshipped.txt | 1 + 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c327c2..3a4fb8b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,7 @@ follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - A screen reader hears one row of a fixed-width table as one line. `BlockLayout.Relayout` with `LayoutContext.Linear` now wraps a block that is not fluid at the reader's width, as it does a fluid one; - before, it wrapped at the width the block's columns took, so a 35-cell WHO listing broke each player's row in two. + before, it wrapped at the width the block's columns took, so a 35-cell WHO listing broke each player's row in two. The same holds for one nested in another block (`Bounded`). - Two equal elements side by side stay two. Before, an element closed and an equal one opened straight after it became one run, so a client saw one thing where the server sent two. This happened with two exits of one flagged element (`northsouth` read as one exit, `northsouth`), two ``s, ``s diff --git a/MarkupString.Tests/Layout/BlockLayoutTests.cs b/MarkupString.Tests/Layout/BlockLayoutTests.cs index 959160e..76d14bf 100644 --- a/MarkupString.Tests/Layout/BlockLayoutTests.cs +++ b/MarkupString.Tests/Layout/BlockLayoutTests.cs @@ -224,6 +224,19 @@ public async Task Linear_ReadsAFixedWidthTableRowAsOneLineAtTheReadersWidth() await Assert.That(read.ToPlainText()).IsEqualTo("Player Name: Marguerite, On For: 7s, Idle: 0s"); } + [Test] + public async Task Linear_ReadsANestedFixedWidthTableRowAsOneLine() + { + // The same listing nested in a fluid block keeps its own width (Bounded); read aloud, it still reads as one line. + var table = new Table([new TableColumn(P("Player Name")) { Min = 16 }, new TableColumn(P("On For")) { Min = 10, Alignment = Alignment.Right }], + [[P("Marguerite"), P("7s")]]); + var text = BlockLayout.Build(new Bounded(table, 20), 78, fluid: true); + + var read = BlockLayout.Relayout(text, 78, new LayoutContext { Linear = true }); + + await Assert.That(read.ToPlainText()).IsEqualTo("Player Name: Marguerite, On For: 7s"); + } + [Test] public async Task Flex_StacksWhenItemsDoNotFit() { diff --git a/MarkupString/Layout/Blocks/Modifiers.cs b/MarkupString/Layout/Blocks/Modifiers.cs index e20375f..c57b169 100644 --- a/MarkupString/Layout/Blocks/Modifiers.cs +++ b/MarkupString/Layout/Blocks/Modifiers.cs @@ -119,6 +119,11 @@ public override Block MapText(Func map) => public override void Draw(LayoutContext context, int width, IList lines) => context.Draw(Content, Math.Min(width, Math.Max(1, Width)), lines); + /// + /// Read in order, its content wraps at the reader's width: the bound keeps columns, which a reader does not hear. + public override void DrawLinear(LayoutContext context, int width, IList lines) => + context.Draw(Content, width, lines); + /// public override BlockMeasure Measure(LayoutContext context, int width) { diff --git a/MarkupString/PublicAPI.Unshipped.txt b/MarkupString/PublicAPI.Unshipped.txt index 4c6629a..54795e9 100644 --- a/MarkupString/PublicAPI.Unshipped.txt +++ b/MarkupString/PublicAPI.Unshipped.txt @@ -877,3 +877,4 @@ override MarkupString.ElementMarkup.GetHashCode() -> int override MarkupString.ElementMarkup.ToString() -> string! static MarkupString.ElementMarkup.operator !=(MarkupString.ElementMarkup? left, MarkupString.ElementMarkup? right) -> bool static MarkupString.ElementMarkup.operator ==(MarkupString.ElementMarkup? left, MarkupString.ElementMarkup? right) -> bool +override MarkupString.Layout.Bounded.DrawLinear(MarkupString.Layout.LayoutContext! context, int width, System.Collections.Generic.IList! lines) -> void