Correzione display XML files
This commit is contained in:
@@ -31,12 +31,12 @@
|
||||
<div class="row" style=" height: @(pHeight)em; overflow-y: scroll;">
|
||||
<div class="col-6 table-primary">
|
||||
<div class="border border-primary p-2 bg-light">
|
||||
<p style="max-width: 70em;">@((MarkupString)StrFix(oldResult))</p>
|
||||
<p style="max-width: 70em;">@StrFix(oldResult)</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-6 table-warning">
|
||||
<div class="border border-warning p-2 bg-light">
|
||||
<p style="max-width: 70em;">@((MarkupString)StrFix(newResult))</p>
|
||||
<p style="max-width: 70em;">@StrFix(newResult)</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -4,6 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
|
||||
namespace MP.Prog.Components
|
||||
{
|
||||
@@ -77,21 +78,26 @@ namespace MP.Prog.Components
|
||||
StringBuilder sbOld = new StringBuilder();
|
||||
foreach (var item in diff)
|
||||
{
|
||||
// se fosse testo vuoto --> metto spazio!
|
||||
if (string.IsNullOrEmpty(item.text))
|
||||
{
|
||||
item.text = " ";
|
||||
}
|
||||
switch (item.operation)
|
||||
{
|
||||
case Operation.DELETE:
|
||||
sbOld.Append($"<span class=\"border border-success table-success\">{item.text}</span>");
|
||||
sbOld.Append($"<span class=\"border border-success table-success\">{HttpUtility.HtmlEncode(item.text)}</span>");
|
||||
numChanges++;
|
||||
break;
|
||||
|
||||
case Operation.INSERT:
|
||||
sbNew.Append($"<span class=\"border border-danger table-danger\">{item.text}</span>");
|
||||
sbNew.Append($"<span class=\"border border-danger table-danger\">{HttpUtility.HtmlEncode(item.text)}</span>");
|
||||
numChanges++;
|
||||
break;
|
||||
|
||||
case Operation.EQUAL:
|
||||
sbNew.Append($"<span class=\"text-dark\">{item.text}</span>");
|
||||
sbOld.Append($"<span class=\"text-dark\">{item.text}</span>");
|
||||
sbNew.Append($"<span class=\"text-dark\">{HttpUtility.HtmlEncode(item.text)}</span>");
|
||||
sbOld.Append($"<span class=\"text-dark\">{HttpUtility.HtmlEncode(item.text)}</span>");
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -99,8 +105,8 @@ namespace MP.Prog.Components
|
||||
}
|
||||
}
|
||||
|
||||
newResult = sbNew.ToString().Trim();
|
||||
oldResult = sbOld.ToString().Trim();
|
||||
newResult = sbNew.ToString();
|
||||
oldResult = sbOld.ToString();
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await diffDone.InvokeAsync(numChanges);
|
||||
@@ -118,9 +124,14 @@ namespace MP.Prog.Components
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string StrFix(string origVal)
|
||||
private MarkupString StrFix(string origVal)
|
||||
{
|
||||
return origVal.Replace(" ", " ").Replace(Environment.NewLine, sepDest).Replace("\n", sepDest).Replace("\r", sepDest);
|
||||
string fixVal = origVal.Trim()
|
||||
.Replace(" ", " ")
|
||||
.Replace(Environment.NewLine, sepDest);
|
||||
//.Replace("\r", sepDest)
|
||||
//.Replace("\n", sepDest);
|
||||
return new MarkupString(fixVal);
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
Reference in New Issue
Block a user