From fe2f9939fc9b088963f316aa56cb137a4f927ccd Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 26 Nov 2026 09:07:24 +0000 Subject: [PATCH] Draw a heavy rule 2px thick in HTML A heavy box already had a 2px border, but a heavy rule, and the line between titles on a heavy edge, kept the 1px line of a single one, so the portal drew rule(...,{"border":"heavy"}) the same as single. The browser test checks the computed line width of single, heavy and double rules. Fixes SharpMUSH/SharpMUSH#2912 Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01Rqqt7W3gzmP3nZJkUZeSwE --- CHANGELOG.md | 3 +++ MarkupString.Html/LayoutCss.cs | 2 ++ MarkupString.Tests/Web/MarkupWebTests.cs | 6 ++++++ MarkupString.Web/tests/fragments.json | 1 + MarkupString.Web/tests/runtime.test.cjs | 5 +++++ MarkupString.Web/wwwroot/markupstring.css | 2 ++ 6 files changed, 19 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a9aabdf..06a15a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,9 @@ follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ### Fixed +- A heavy rule, and the line between several titles on a heavy rule or box edge, is drawn 2px thick in HTML, as a + heavy box's border is. It was drawn 1px, the same as a single rule (SharpMUSH#2912). + - An `HtmlMarkup` tag over text that an inner layer splits into runs is written as one element in HTML, Pueblo and MXP. `tagwrap(pre,[cmdlink(aaa,look)][space(5)][cmdlink(bbb,look)])` was written as three `
`
   elements, one per run, so a client drew three blocks on three lines. A tag still closes before an outer layer
diff --git a/MarkupString.Html/LayoutCss.cs b/MarkupString.Html/LayoutCss.cs
index f1eadf1..a29cf4f 100644
--- a/MarkupString.Html/LayoutCss.cs
+++ b/MarkupString.Html/LayoutCss.cs
@@ -40,12 +40,14 @@ public static class LayoutCss
 		".ms-line { flex: 1 1 0; min-width: 1ch; border-top: 1px solid var(--ms-border, var(--ms-border-default, currentColor)); }\n" +
 		".ms-line.ms-end { flex: 0 0 1ch; }\n" +
 		".ms-border-double.ms-titles > .ms-line { border-top: 3px double var(--ms-border, var(--ms-border-default, currentColor)); }\n" +
+		".ms-border-heavy.ms-titles > .ms-line { border-top-width: 2px; }\n" +
 		".ms-border-none.ms-titles > .ms-line { border-top: none; }\n" +
 		".ms-box-title.ms-titles { display: flex; align-items: center; gap: 1ch; flex-wrap: wrap; padding: 0; margin-inline: calc(-1 * var(--ms-pad)); width: calc(100% + 2 * var(--ms-pad)); box-sizing: border-box; }\n" +
 		".ms-box:has(> .ms-box-bottom) { border-bottom: none; }\n" +
 		".ms-box-bottom { display: flex; align-items: center; gap: 1ch; flex-wrap: wrap; margin: 0 calc(-1 * var(--ms-pad, 1ch)); }\n" +
 		".ms-box.ms-border-none > .ms-divider { margin: 0; }\n" +
 		".ms-border-double.ms-rule::before, .ms-border-double.ms-rule::after { border-top: 3px double var(--ms-border, var(--ms-border-default, currentColor)); }\n" +
+		".ms-border-heavy.ms-rule::before, .ms-border-heavy.ms-rule::after { border-top-width: 2px; }\n" +
 		".ms-border-none.ms-rule::before, .ms-border-none.ms-rule::after { border-top: none; }\n" +
 		".ms-flex { display: flex; flex-wrap: wrap; }\n" +
 		".ms-flex.ms-vertical { flex-direction: column; }\n" +
diff --git a/MarkupString.Tests/Web/MarkupWebTests.cs b/MarkupString.Tests/Web/MarkupWebTests.cs
index b245a68..2bdc4c1 100644
--- a/MarkupString.Tests/Web/MarkupWebTests.cs
+++ b/MarkupString.Tests/Web/MarkupWebTests.cs
@@ -2,6 +2,7 @@
 using MarkupString.Ansi.Decoding;
 using MarkupString.Decoding;
 using MarkupString.Html;
+using MarkupString.Layout;
 using MarkupString.Mxp.Decoding;
 using MarkupString.Web;
 
@@ -77,6 +78,11 @@ public async Task BrowserTestFragments_AreWhatTheHtmlWriterWrites()
 			["vars"] = Html(MarkupText.Concat([MarkupText.Variable(MarkupText.Plain("50"), "maxhp"), MarkupText.Variable(MarkupText.Plain("25"), "hp")])),
 			["pane"] = Html(MarkupText.Pane(MarkupText.Plain("chat line"), "chat", "Chat")),
 			["relocate"] = Html(Point(new RelocateMarkup("h", 23))),
+			["rules"] = Html(BlockLayout.Build(new Stack([
+				new Rule(MarkupText.Plain("Single")) { Border = BorderStyle.Single },
+				new Rule(MarkupText.Plain("Heavy")) { Border = BorderStyle.Heavy },
+				new Rule(MarkupText.Plain("Double")) { Border = BorderStyle.Double },
+				new Rule(MarkupText.Plain("Left")) { Border = BorderStyle.Heavy, Titles = [new EdgeTitle(MarkupText.Plain("Right"), Alignment.Right)] }]), 40)),
 		};
 		var json = System.Text.Json.JsonSerializer.Serialize(fragments, new System.Text.Json.JsonSerializerOptions { WriteIndented = true, NewLine = "\n", Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping }) + "\n";
 
diff --git a/MarkupString.Web/tests/fragments.json b/MarkupString.Web/tests/fragments.json
index b743d18..fbba183 100644
--- a/MarkupString.Web/tests/fragments.json
+++ b/MarkupString.Web/tests/fragments.json
@@ -10,6 +10,7 @@
   "pane": "chat line",
   "prompt": "talk",
   "relocate": "",
+  "rules": "
Single
Heavy
Double
LeftRight
", "sound": "door", "stop": "", "vars": "5025" diff --git a/MarkupString.Web/tests/runtime.test.cjs b/MarkupString.Web/tests/runtime.test.cjs index c65a931..6d9e2b7 100644 --- a/MarkupString.Web/tests/runtime.test.cjs +++ b/MarkupString.Web/tests/runtime.test.cjs @@ -118,6 +118,11 @@ const check = (ok, name, extra = '') => { console.log((ok ? 'PASS ' : 'FAIL ') + const n = await ev(() => sent.length); await page.click('#out a[xch_cmd="look"]'); check((await ev(() => sent.length)) === n, 'detach stops handling'); + await add('rules'); + const ruleWidths = await ev(() => [...document.querySelectorAll('#out .ms-rule')].map(rule => rule.classList.contains('ms-titles') + ? getComputedStyle(rule.querySelector('.ms-line')).borderTopWidth + : getComputedStyle(rule, '::before').borderTopWidth + ' ' + getComputedStyle(rule, '::after').borderTopWidth)); + check(JSON.stringify(ruleWidths) === '["1px 1px","2px 2px","3px 3px","2px"]', 'heavy rule draws a thicker line than single', JSON.stringify(ruleWidths)); await browser.close(); console.log(fails ? `${fails} FAILED` : 'ALL PASSED'); process.exit(fails ? 1 : 0); diff --git a/MarkupString.Web/wwwroot/markupstring.css b/MarkupString.Web/wwwroot/markupstring.css index 6e488a0..6ff9b56 100644 --- a/MarkupString.Web/wwwroot/markupstring.css +++ b/MarkupString.Web/wwwroot/markupstring.css @@ -29,12 +29,14 @@ .ms-line { flex: 1 1 0; min-width: 1ch; border-top: 1px solid var(--ms-border, var(--ms-border-default, currentColor)); } .ms-line.ms-end { flex: 0 0 1ch; } .ms-border-double.ms-titles > .ms-line { border-top: 3px double var(--ms-border, var(--ms-border-default, currentColor)); } +.ms-border-heavy.ms-titles > .ms-line { border-top-width: 2px; } .ms-border-none.ms-titles > .ms-line { border-top: none; } .ms-box-title.ms-titles { display: flex; align-items: center; gap: 1ch; flex-wrap: wrap; padding: 0; margin-inline: calc(-1 * var(--ms-pad)); width: calc(100% + 2 * var(--ms-pad)); box-sizing: border-box; } .ms-box:has(> .ms-box-bottom) { border-bottom: none; } .ms-box-bottom { display: flex; align-items: center; gap: 1ch; flex-wrap: wrap; margin: 0 calc(-1 * var(--ms-pad, 1ch)); } .ms-box.ms-border-none > .ms-divider { margin: 0; } .ms-border-double.ms-rule::before, .ms-border-double.ms-rule::after { border-top: 3px double var(--ms-border, var(--ms-border-default, currentColor)); } +.ms-border-heavy.ms-rule::before, .ms-border-heavy.ms-rule::after { border-top-width: 2px; } .ms-border-none.ms-rule::before, .ms-border-none.ms-rule::after { border-top: none; } .ms-flex { display: flex; flex-wrap: wrap; } .ms-flex.ms-vertical { flex-direction: column; }