mirror of
https://github.com/farcasclaudiu/MartianRobots.git
synced 2026-06-22 05:01:14 +03:00
19 lines
563 B
C#
19 lines
563 B
C#
using Microsoft.AspNetCore.Components;
|
|
using System.Web;
|
|
|
|
namespace MartianRobots.Web.Client.Shared
|
|
{
|
|
public class HtmlHelper
|
|
{
|
|
public static MarkupString RenderMultiline(string textWithLineBreaks)
|
|
{
|
|
var encodedLines = (textWithLineBreaks ?? string.Empty)
|
|
.Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries)
|
|
.Select(line => HttpUtility.HtmlEncode(line))
|
|
.ToArray();
|
|
|
|
return (MarkupString)string.Join("<br />", encodedLines);
|
|
}
|
|
}
|
|
}
|