Skip to content

Commit

Permalink
Fix Markup Tags in Station News (#30169) (#1116)
Browse files Browse the repository at this point in the history
* Fix (hopefully)

* Fixed Spelling Mistake and minor Code Cleanup

* Revert "Fixed Spelling Mistake and minor Code Cleanup" due to Pull
Request Guidelines

This reverts commit cee3e0226b349187bd8fd8b639e161fb877e8bdb.

# Description

Fixes SS14-Classic/deep-station-14#87

---------

Co-authored-by: DakotaGay <dakotagay@disroot.org>
Co-authored-by: Julian Giebel <juliangiebel@live.de>
  • Loading branch information
3 people authored Oct 25, 2024
1 parent 518812b commit 4f4f82f
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void UpdateState(NewsArticle article, int targetNum, int totalNum, bool n
Author.Visible = true;

PageName.Text = article.Title;
PageText.SetMarkup(article.Content);
PageText.SetMarkupPermissive(article.Content);

PageNum.Text = $"{targetNum}/{totalNum}";

Expand Down
2 changes: 1 addition & 1 deletion Content.Client/MassMedia/Ui/ArticleEditorPanel.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void OnPreview(BaseButton.ButtonEventArgs eventArgs)

TextEditPanel.Visible = !_preview;
PreviewPanel.Visible = _preview;
PreviewLabel.SetMarkup(Rope.Collapse(ContentField.TextRope));
PreviewLabel.SetMarkupPermissive(Rope.Collapse(ContentField.TextRope));
}

private void OnCancel(BaseButton.ButtonEventArgs eventArgs)
Expand Down
18 changes: 18 additions & 0 deletions Content.Client/Message/RichTextLabelExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,27 @@ namespace Content.Client.Message;

public static class RichTextLabelExt
{


/// <summary>
/// Sets the labels markup.
/// </summary>
/// <remarks>
/// Invalid markup will cause exceptions to be thrown. Don't use this for user input!
/// </remarks>
public static RichTextLabel SetMarkup(this RichTextLabel label, string markup)
{
label.SetMessage(FormattedMessage.FromMarkup(markup));
return label;
}

/// <summary>
/// Sets the labels markup.<br/>
/// Uses <c>FormatedMessage.FromMarkupPermissive</c> which treats invalid markup as text.
/// </summary>
public static RichTextLabel SetMarkupPermissive(this RichTextLabel label, string markup)
{
label.SetMessage(FormattedMessage.FromMarkupPermissive(markup));
return label;
}
}
2 changes: 1 addition & 1 deletion Content.Client/Tips/TippyUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void NextState(TippyUI tippy)
sprite.LayerSetVisible("hiding", false);
}
sprite.Rotation = 0;
tippy.Label.SetMarkup(_currentMessage.Msg);
tippy.Label.SetMarkupPermissive(_currentMessage.Msg);
tippy.Label.Visible = false;
tippy.LabelPanel.Visible = false;
tippy.Visible = true;
Expand Down

0 comments on commit 4f4f82f

Please sign in to comment.