Skip to content

Commit

Permalink
Completely ignore/don't require closing tags of void elements (#2225)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruzihm authored Feb 21, 2025
1 parent fa88b9d commit 30a332d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions OpenDreamClient/Interface/Html/HtmlParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,13 @@ void PushCurrentText() {
string tagType = attributes[0].ToLowerInvariant();

currentText.Clear();
bool isSelfClosing = IsSelfClosing(tagType, attributes);
if (closingTag) {
if (tags.Count == 0) {
if (isSelfClosing) {
// ignore closing tags of void elements since they don't
// do anything anyway. Should probably warn.
return;
} else if (tags.Count == 0) {
Sawmill.Error("Unexpected closing tag");
return;
} else if (tags.Peek() != tagType) {
Expand All @@ -82,9 +87,9 @@ void PushCurrentText() {
appendTo.Pop();
tags.Pop();
} else {
tags.Push(tagType);

bool isSelfClosing = IsSelfClosing(tagType, attributes);
if (!isSelfClosing) {
tags.Push(tagType);
}
appendTo.PushTag(new MarkupNode(tagType, null, ParseAttributes(attributes)), selfClosing: isSelfClosing);
}

Expand Down

0 comments on commit 30a332d

Please sign in to comment.