Quickly dump a nicely formatted diff output to System.Console or to HTML
This is the full code to create above samples:
usingSystem;usingSystem.Diagnostics;usingSystem.IO;staticclassSampleMain{publicstaticvoidMain(){conststringtext1="This is a demo\nThis is a test of the diff implementation, with some text that is deleted.\n\n\t- a 1st bullet point\n\t- a 2nd bullet point\n\n\0End of diff demo.";conststringtext2="This is a demo\nThis is another test of the same implementation, with some more text.\n\n\t- a 1st bullet point\n\t- a 2nd bullet point\n\nEnd of diff demo.";Console.WriteLine("==== Diff2Console ====");CompuMaster.Text.Diffs.DumpDiffToConsole(text1,text2);Console.WriteLine();Console.WriteLine("==== Diff2Console+HumanFriendlyControlChars ====");CompuMaster.Text.Diffs.DumpDiffToConsole(text1,text2,true);Console.WriteLine();Console.WriteLine("==== Diff2ConsoleShort+HumanFriendlyControlChars ====");CompuMaster.Text.Diffs.DumpDiffToConsoleShort(text1,text2,true);Console.WriteLine();Console.WriteLine("==== Diff2Html (Input as Text) ====");stringText2HtmlOut=CompuMaster.Text.Diffs.DumpDiffAsHtml(text1,text2,CompuMaster.Text.Diffs.EncodingRequirement.TextInputToBeEncodedIntoHtmlBeforeOutput);Console.WriteLine(Text2HtmlOut);Console.WriteLine();Console.WriteLine("==== Diff2Html (Input as Html) ====");stringHtml2HtmlOut=CompuMaster.Text.Diffs.DumpDiffAsHtml(text1,text2,CompuMaster.Text.Diffs.EncodingRequirement.HtmlInputWithoutRequirementOfEncodingBeforeOutput);Console.WriteLine(Html2HtmlOut);Console.WriteLine();Console.WriteLine("==== Diff2Html+HumanFriendlyControlChars (Input as Text) ====");stringText2HtmlOutHumanFriendly=CompuMaster.Text.Diffs.DumpDiffAsHtml(text1,text2,CompuMaster.Text.Diffs.EncodingRequirement.TextInputToBeEncodedIntoHtmlBeforeOutput,true);Console.WriteLine(Text2HtmlOutHumanFriendly);Console.WriteLine();Console.WriteLine("==== Diff2Html+HumanFriendlyControlChars (Input as Html) ====");stringHtml2HtmlOutHumanFriendly=CompuMaster.Text.Diffs.DumpDiffAsHtml(text1,text2,CompuMaster.Text.Diffs.EncodingRequirement.HtmlInputWithoutRequirementOfEncodingBeforeOutput,true);Console.WriteLine(Html2HtmlOutHumanFriendly);Console.WriteLine();stringTempHtmlFile=Path.GetTempFileName()+".html";File.WriteAllText(TempHtmlFile,"<h1>Diff2Html (Input as Text)</h1>"+Text2HtmlOut+"<h1>Diff2Html (Input as Html)</h1>"+Html2HtmlOut+"<h1>Diff2Html+HumanFriendlyControlChars (Input as Text)</h1>"+Text2HtmlOutHumanFriendly+"<h1>Diff2Html+HumanFriendlyControlChars (Input as Html)</h1>"+Html2HtmlOutHumanFriendly);System.Diagnostics.Process.Start(newSystem.Diagnostics.ProcessStartInfo(TempHtmlFile){UseShellExecute=true});}}ModuleSampleMainSubMain()Consttext1AsString="This is a demo"&vbNewLine&"This is a test of the diff implementation, with some text that is deleted."&vbNewLine&vbNewLine&vbTab&"- a 1st bullet point"&vbNewLine&vbTab&"- a 2nd bullet point"&vbNewLine&vbNewLine&vbTab&ControlChars.NullChar&"End of diff demo."Consttext2AsString="This is a demo"&vbNewLine&"This is another test of the same implementation, with some more text."&vbNewLine&vbNewLine&vbTab&"- a 1st bullet point"&vbNewLine&vbTab&"- a 2nd bullet point"&vbNewLine&vbNewLine&"End of diff demo."Console.WriteLine("==== Diff2Console ====")CompuMaster.Text.Diffs.DumpDiffToConsole(text1,text2)Console.WriteLine()Console.WriteLine("==== Diff2Console+HumanFriendlyControlChars ====")CompuMaster.Text.Diffs.DumpDiffToConsole(text1,text2,True)Console.WriteLine()Console.WriteLine("==== Diff2ConsoleShort+HumanFriendlyControlChars ====")CompuMaster.Text.Diffs.DumpDiffToConsoleShort(text1,text2,True)Console.WriteLine()Console.WriteLine("==== Diff2Html (Input as Text) ====")DimText2HtmlOutAsString=CompuMaster.Text.Diffs.DumpDiffAsHtml(text1,text2,CompuMaster.Text.Diffs.EncodingRequirement.TextInputToBeEncodedIntoHtmlBeforeOutput)Console.WriteLine(Text2HtmlOut)Console.WriteLine()Console.WriteLine("==== Diff2Html (Input as Html) ====")DimHtml2HtmlOutAsString=CompuMaster.Text.Diffs.DumpDiffAsHtml(text1,text2,CompuMaster.Text.Diffs.EncodingRequirement.HtmlInputWithoutRequirementOfEncodingBeforeOutput)Console.WriteLine(Html2HtmlOut)Console.WriteLine()Console.WriteLine("==== Diff2Html+HumanFriendlyControlChars (Input as Text) ====")DimText2HtmlOutHumanFriendlyAsString=CompuMaster.Text.Diffs.DumpDiffAsHtml(text1,text2,CompuMaster.Text.Diffs.EncodingRequirement.TextInputToBeEncodedIntoHtmlBeforeOutput,True)Console.WriteLine(Text2HtmlOutHumanFriendly)Console.WriteLine()Console.WriteLine("==== Diff2Html+HumanFriendlyControlChars (Input as Html) ====")DimHtml2HtmlOutHumanFriendlyAsString=CompuMaster.Text.Diffs.DumpDiffAsHtml(text1,text2,CompuMaster.Text.Diffs.EncodingRequirement.HtmlInputWithoutRequirementOfEncodingBeforeOutput,True)Console.WriteLine(Html2HtmlOutHumanFriendly)Console.WriteLine()DimTempHtmlFileAsString=System.IO.Path.GetTempFileName&".html"System.IO.File.WriteAllText(TempHtmlFile,"<h1>Diff2Html (Input as Text)</h1>"&Text2HtmlOut&"<h1>Diff2Html (Input as Html)</h1>"&Html2HtmlOut&"<h1>Diff2Html+HumanFriendlyControlChars (Input as Text)</h1>"&Text2HtmlOutHumanFriendly&"<h1>Diff2Html+HumanFriendlyControlChars (Input as Html)</h1>"&Html2HtmlOutHumanFriendly)System.Diagnostics.Process.Start(NewSystem.Diagnostics.ProcessStartInfo(TempHtmlFile)With{.UseShellExecute=True})EndSubEndModule
