Skip to content

Commit ecb85fc

Browse files
authored
Merge pull request #3 from DavidKarlas/fixXmlAndWhitespace
Fix xml and whitespace
2 parents a996293 + 44e0c27 commit ecb85fc

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

samples/BlazorTextDiff.Web/Pages/Index.razor

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,22 @@
2020

2121

2222
@code {
23-
string left = @"Mr. and Mrs. Fursley, of number six, Sunset Drive, were proud to say that they were almost perfectly normal. They were the last people you'd expect to be involved in anything weird or mysterious, because they just didn't hold with such nonsense.
23+
string left = @"Mr. and Mrs. Fursley, of number six, Sunset Drive, were proud to say that they were almost perfectly normal. They were the last people you'd expect to be involved in anything weird or mysterious, because they just didn't hold with such nonsense.
2424
Mr. Fursley was the director of a firm called Brunings, which made hatchets. He was a big, well fed man with no neck, although he did have a very large mustache. Mrs. Fursley was petite and blonde and had nearly twice the usual amount of neck, which came in very useful as she spent so much of her time bending over garden fences, spying on the neighbors. The Fursley's had a small son called Fudley and in their opinion there was no finer boy anywhere.
25-
The Dursleys had everything they wanted...";
26-
string right = @"Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much. They were the last people you'd expect to be involved in anything strange or mysterious, because they just didn't hold with such nonsense.
25+
The Dursleys had everything they wanted...
26+
27+
<some>
28+
<xml1>
29+
</xml1>
30+
</some>
31+
";
32+
string right = @"Mr. and Mrs. Dursley, of number four, Privet Drive, were proud to say that they were perfectly normal, thank you very much. They were the last people you'd expect to be involved in anything strange or mysterious, because they just didn't hold with such nonsense.
2733
Mr. Dursley was the director of a firm called Grunnings, which made drills. He was a big, beefy man with hardly any neck, although he did have a very large mustache. Mrs. Dursley was thin and blonde and had nearly twice the usual amount of neck, which came in very useful as she spent so much of her time craning over garden fences, spying on the neighbors. The Dursleys had a small son called Dudley and in their opinion there was no finer boy anywhere.
28-
The Dursleys had everything they wanted...";
34+
The Dursleys had everything they wanted...
35+
36+
<some>
37+
<xml2>
38+
</xml2>
39+
</some>";
2940
bool collapsible = true;
3041
}

src/TextDiffLine.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
{
1111
if (ShowWhiteSpace)
1212
{
13-
@((MarkupString)Model.Text.Replace(" ", spaceValue).Replace("\t", tabValue).Trim())
13+
@(Model.Text.Replace(" ", spaceValue).Replace("\t", tabValue))
1414
}
1515
else
1616
{
17-
@((MarkupString)Model.Text.Trim())
17+
@(Model.Text)
1818
}
1919
}
2020
else if (Model.Type == ChangeType.Modified)
@@ -23,7 +23,7 @@
2323
{
2424
if (character.Type == ChangeType.Imaginary) { continue; }
2525

26-
<span class="@character.Type.ToString().ToLower()-character"> @(ShowWhiteSpace ? character.Text.Replace(" ", spaceValue.ToString()).Trim() : character.Text.Trim())</span>
26+
<span style="white-space: pre-wrap;" class="@character.Type.ToString().ToLower()-character">@(ShowWhiteSpace ? character.Text.Replace(" ", spaceValue.ToString()) : character.Text)</span>
2727
}
2828
}
2929

src/TextDiffPane.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
@((MarkupString)(diffLine.Position.HasValue ? diffLine.Position.ToString() : "&nbsp;"))
1010
</td>
1111
<td class="line @diffLine.Type.ToString().ToLower()-line">
12-
<span class="line-text">
12+
<span class="line-text" style="white-space: pre-wrap;">
1313
<TextDiffLine Model="diffLine"></TextDiffLine>
1414
</span>
1515
</td>

0 commit comments

Comments
 (0)