mirror of
https://github.com/TeamOctolings/Octobot.git
synced 2025-04-29 02:29:55 +03:00
Improve diff display for edited messages
Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
parent
63484ac353
commit
4595638cdb
2 changed files with 10 additions and 6 deletions
|
@ -122,11 +122,16 @@ public static class Extensions {
|
|||
return WebUtility.UrlEncode(s).Replace('+', ' ');
|
||||
}
|
||||
|
||||
public static string AsMarkdown(this SideBySideDiffModel model) {
|
||||
public static string AsMarkdown(this DiffPaneModel model) {
|
||||
var builder = new StringBuilder();
|
||||
foreach (var line in model.OldText.Lines.Where(piece => !string.IsNullOrWhiteSpace(piece.Text)))
|
||||
builder.Append("-- ").AppendLine(line.Text);
|
||||
foreach (var line in model.NewText.Lines) builder.Append("++ ").AppendLine(line.Text);
|
||||
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);
|
||||
}
|
||||
|
||||
return Markdown.BlockCode(builder.ToString().SanitizeForBlockCode(), "diff");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue