diff --git a/CHANGELOG.md b/CHANGELOG.md
index 63ac754..6c17f88 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -17,6 +17,9 @@ follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
- In HTML, an item of a `Flex` row with a set width keeps that width beside an item with none, as a
terminal draws it: the spare width goes to the item with none. A two-cell marker beside a reply took
half the row and pushed the reply to the right.
+- Half-block pictures write a cell whose two halves are the same colour (at the client's colour depth) as
+ `█` in that colour alone, not `▀` with equal foreground and background. Clients such as BeipMU flag a
+ cell whose foreground matches its background as hidden text, and the cell needed one colour code, not two.
## 2.31.0 — 2026-11-12
diff --git a/MarkupString.Ansi/Emitters/TerminalPictureWriter.cs b/MarkupString.Ansi/Emitters/TerminalPictureWriter.cs
index 959f1d0..997f7b4 100644
--- a/MarkupString.Ansi/Emitters/TerminalPictureWriter.cs
+++ b/MarkupString.Ansi/Emitters/TerminalPictureWriter.cs
@@ -344,6 +344,7 @@ private static string[] EncodeBlockArt(TerminalPicture picture, BlockKey key)
var width = key.Columns;
var pixels = PictureScaler.Letterbox(picture, width, key.Rows * 2);
var plain = key.Effective with { Foreground = null };
+ var plainShown = plain.AtDepth(key.Depth);
var rows = new string[key.Rows];
using var line = new PooledCharWriter(width * 40);
@@ -365,6 +366,14 @@ private static string[] EncodeBlockArt(TerminalPicture picture, BlockKey key)
_ => (plain, ' '),
};
style = style.AtDepth(key.Depth);
+ // Both halves the same colour at this depth: a full block in the foreground alone, so no cell is
+ // written with its foreground equal to its background (some clients flag that as hidden text).
+ if (glyph != ' ' && style.Background is { } shown && Equals(style.Foreground, shown))
+ {
+ style = style with { Background = plainShown.Background };
+ glyph = '█';
+ }
+
SgrWriter.Transition(current, style, line);
current = style;
line.GetSpan(1)[0] = glyph;
diff --git a/MarkupString.Tests/Ansi/TerminalFeatureTests.cs b/MarkupString.Tests/Ansi/TerminalFeatureTests.cs
index cf05be3..ffac40d 100644
--- a/MarkupString.Tests/Ansi/TerminalFeatureTests.cs
+++ b/MarkupString.Tests/Ansi/TerminalFeatureTests.cs
@@ -43,6 +43,10 @@ private static TerminalPicture RedBlue(int width = 4, int height = 4)
return new TerminalPicture("red-blue", width, height, rgba);
}
+ /// A picture one pixel wide, its upper half one colour and its lower half another, opaque.
+ private static TerminalPicture TopBottom(byte r1, byte g1, byte b1, byte r2, byte g2, byte b2) =>
+ new("top-bottom", 1, 2, new byte[] { r1, g1, b1, 255, r2, g2, b2, 255 });
+
private static readonly ImageMarkup Cat = new("cat.png", "A cat");
private static MarkupText Render(MarkupText text, AnsiOutputOptions options) =>
@@ -783,7 +787,34 @@ public async Task BlockArtDrawsTwoPixelsACell()
var output = RenderString(Laid(new Figure(Cat, MarkupText.Empty), 10, new PictureCells(2, 1)), options);
- await Assert.That(output).IsEqualTo($"{Esc}[38;2;255;0;0;48;2;255;0;0m▀{Esc}[38;2;0;0;255;48;2;0;0;255m▀{Esc}[0m" + new string(' ', 8));
+ await Assert.That(output).IsEqualTo($"{Esc}[38;2;255;0;0m█{Esc}[38;2;0;0;255m█{Esc}[0m" + new string(' ', 8));
+ }
+
+ /// A cell whose halves differ keeps the half block, the upper pixel its foreground and the lower its background.
+ [Test]
+ public async Task BlockArtKeepsTheHalfBlockWhenTheHalvesDiffer()
+ {
+ var options = new AnsiOutputOptions(Features: TerminalFeatures.BlockArt) { Pictures = new Source(TopBottom(255, 0, 0, 0, 0, 255)) };
+
+ var output = RenderString(Laid(new Figure(Cat, MarkupText.Empty), 1, new PictureCells(1, 1)), options);
+
+ await Assert.That(output).IsEqualTo($"{Esc}[38;2;255;0;0;48;2;0;0;255m▀{Esc}[0m");
+ }
+
+ ///
+ /// Halves that differ in true colour but come out the same at the client's depth are one colour on its
+ /// screen, so they are a full block too, with no background equal to the foreground.
+ ///
+ [Test]
+ public async Task BlockArtMergesHalvesTheDepthMakesEqual()
+ {
+ var options = new AnsiOutputOptions(AnsiColorDepth.Xterm256, TerminalFeatures.BlockArt) { Pictures = new Source(TopBottom(0, 245, 183, 0, 244, 182)) };
+
+ var output = RenderString(Laid(new Figure(Cat, MarkupText.Empty), 1, new PictureCells(1, 1)), options);
+
+ await Assert.That(output).Contains("█");
+ await Assert.That(output).DoesNotContain("▀");
+ await Assert.That(output).DoesNotContain("48;");
}
[Test]
@@ -794,7 +825,7 @@ public async Task BlockArtFollowsTheColourDepth()
var output = RenderString(Laid(new Figure(Cat, MarkupText.Empty), 2, new PictureCells(2, 1)), options);
await Assert.That(output).DoesNotContain("38;2");
- await Assert.That(output.Count(c => c == '▀')).IsEqualTo(2);
+ await Assert.That(output.Count(c => c == '█')).IsEqualTo(2);
}
[Test]