Skip to content
This repository has been archived by the owner on Aug 5, 2024. It is now read-only.

Allow change default colors on C# method diff_prettyHtm #163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions csharp/DiffMatchPatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1334,18 +1334,18 @@ public int diff_xIndex(List<Diff> diffs, int loc) {
* @param diffs List of Diff objects.
* @return HTML representation.
*/
public string diff_prettyHtml(List<Diff> diffs) {
public string diff_prettyHtml(List<Diff> diffs, string insertColor="e6ffe6", string deleteColor="ffe6e6") {
StringBuilder html = new StringBuilder();
foreach (Diff aDiff in diffs) {
string text = aDiff.text.Replace("&", "&amp;").Replace("<", "&lt;")
.Replace(">", "&gt;").Replace("\n", "&para;<br>");
switch (aDiff.operation) {
case Operation.INSERT:
html.Append("<ins style=\"background:#e6ffe6;\">").Append(text)
html.Append($"<ins style=\"background:#{insertColor};\">").Append(text)
.Append("</ins>");
break;
case Operation.DELETE:
html.Append("<del style=\"background:#ffe6e6;\">").Append(text)
html.Append($"<del style=\"background:#{deleteColor};\">").Append(text)
.Append("</del>");
break;
case Operation.EQUAL:
Expand Down