Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<pre>`
elements, one per run, so a client drew three blocks on three lines. A tag still closes before an outer layer
Expand Down
2 changes: 2 additions & 0 deletions MarkupString.Html/LayoutCss.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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" +
Expand Down
6 changes: 6 additions & 0 deletions MarkupString.Tests/Web/MarkupWebTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using MarkupString.Ansi.Decoding;
using MarkupString.Decoding;
using MarkupString.Html;
using MarkupString.Layout;
using MarkupString.Mxp.Decoding;
using MarkupString.Web;

Expand Down Expand Up @@ -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";

Expand Down
1 change: 1 addition & 0 deletions MarkupString.Web/tests/fragments.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"pane": "<span class=\"ms-pane\" data-pane=\"chat\" data-title=\"Chat\">chat line</span>",
"prompt": "<span class=\"ms-menu ms-prompt\" role=\"button\" tabindex=\"0\" data-commands=\"[{&quot;label&quot;:&quot;Say&quot;,&quot;command&quot;:&quot;say &quot;}]\">talk</span>",
"relocate": "<span class=\"ms-relocate\" data-host=\"h\" data-port=\"23\"></span>",
"rules": "<div class=\"ms-layout\" style=\"max-width:40ch\"><div class=\"ms-stack\"><div class=\"ms-rule ms-border-single\" role=\"separator\"><span class=\"ms-rule-title\">Single</span></div><div class=\"ms-rule ms-border-heavy\" role=\"separator\"><span class=\"ms-rule-title\">Heavy</span></div><div class=\"ms-rule ms-border-double\" role=\"separator\"><span class=\"ms-rule-title\">Double</span></div><div class=\"ms-rule ms-titles ms-border-heavy\" role=\"separator\"><span class=\"ms-line\"></span><span class=\"ms-rule-title\">Left</span><span class=\"ms-line\"></span><span class=\"ms-rule-title\">Right</span><span class=\"ms-line ms-end\"></span></div></div></div>",
"sound": "door<audio class=\"ms-sound\" data-channel=\"effects\" src=\"door.wav\" preload=\"none\"></audio>",
"stop": "<span class=\"ms-sound-stop\"></span>",
"vars": "<span class=\"ms-variable\" data-name=\"maxhp\">50</span><span class=\"ms-variable\" data-name=\"hp\">25</span>"
Expand Down
5 changes: 5 additions & 0 deletions MarkupString.Web/tests/runtime.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions MarkupString.Web/wwwroot/markupstring.css
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Loading