forked from TeamInklings/Octobot
Octol1ttle
67d44ff835
This PR fixes an issue that caused syntax highlighting to be applied to incorrect lines in the message edit log. The fix is to prepend a zero-width space before every line of input text. This prevents Discord from highlighting the line when it wasn't edited
31 lines
759 B
C#
31 lines
759 B
C#
using System.Text;
|
|
using DiffPlex.DiffBuilder.Model;
|
|
|
|
namespace Octobot.Extensions;
|
|
|
|
public static class DiffPaneModelExtensions
|
|
{
|
|
public static string AsMarkdown(this DiffPaneModel model)
|
|
{
|
|
var builder = new StringBuilder();
|
|
foreach (var line in model.Lines)
|
|
{
|
|
if (line.Type is ChangeType.Deleted)
|
|
{
|
|
builder.Append("-- ");
|
|
}
|
|
|
|
if (line.Type is ChangeType.Inserted)
|
|
{
|
|
builder.Append("++ ");
|
|
}
|
|
|
|
if (line.Type is not ChangeType.Imaginary)
|
|
{
|
|
builder.AppendLine(line.Text.SanitizeForDiffBlock());
|
|
}
|
|
}
|
|
|
|
return builder.ToString().InBlockCode("diff");
|
|
}
|
|
}
|