예제 #1
0
        public WikEdDiffText(string text, WikEdDiff parent)
        {
            Text   = text.Replace("\r", string.Empty);
            Parent = parent;

            WordParse(WikEdDiffConfiguration.RegularExpressions.CountWords);
            WordParse(WikEdDiffConfiguration.RegularExpressions.CountChunks);
        }
예제 #2
0
        static void Main(string[] args)
        {
            var originalText = @"Salt is found in greater or less quantities in almost every substance on earth, but [the waters of the sea appear to have been its first great magazine]. It is found there dissolved in certain proportions, and two purposes are thus served, namely, the preservation of that vast body of waters, which otherwise, from the innumerable objects of animal and vegetable life within it, would become an insupportable mass of corruption, and the supplying of a large proportion of the salt we require in our food, and for other purposes. The quantity of salt contained in the sea (according to the best authorities) amounts to four hundred thousand billion cubic feet, which, if piled up, would form a mass one hundred and forty miles long, as many broad, and as many high, or, otherwise disposed, would cover the whole of Europe, islands, seas, and all, to the height of the summit of Mont Blanc, which is about sixteen thousand feet in height.";
            var modifiedText = @"This is great. It is found there dissolved in certain proportions, and two purposes are thus served, namely, the preservation of that vast body of waters, which otherwise, from the innumerable objects of animal and vegetable life within it, would become an insupportable mass of corruption, and the supplying of a large proportion of the salt we require in our food, and for other purposes. Salt is found in greater or less quantities in almost every substance on earth, but [the waters of the sea seem to have been its first great]. This sentence should not impact anything. The quantity of salt contained in the sea (according to the best authorities) amounts to four hundred thousand billion cubic feet, which, if piled up, would form a mass one hundred and forty miles long, as many broad, and as many high, or, otherwise disposed, would cover the whole of Europe, islands, seas, and all, to the height of the summit of Mont Blanc, which is about sixteen thousand feet in height.";

            var wikEdDiff = new WikEdDiff
            {
                Configuration = new WikEdDiffConfiguration
                {
                    // Override configuration here
                }
            };

            var html = wikEdDiff.Diff(originalText, modifiedText);

            // Save html file and open it
            var file  = Path.GetTempFileName() + ".html";
            var style = "<style id=\"wikEdDiffStyles\" type=\"text/css\">.wikEdDiffInsert {font-weight: bold; background-color: #bbddff; color: #222; border-radius: 0.25em; padding: 0.2em 1px; } .wikEdDiffInsertBlank { background-color: #66bbff; } .wikEdDiffFragment:hover .wikEdDiffInsertBlank { background-color: #bbddff; } .wikEdDiffDelete {font-weight: bold; background-color: #ffe49c; color: #222; border-radius: 0.25em; padding: 0.2em 1px; } .wikEdDiffDeleteBlank { background-color: #ffd064; } .wikEdDiffFragment:hover .wikEdDiffDeleteBlank { background-color: #ffe49c; } .wikEdDiffBlock {font-weight: bold; background-color: #e8e8e8; border-radius: 0.25em; padding: 0.2em 1px; margin: 0 1px; } .wikEdDiffBlock { } .wikEdDiffBlock0 { background-color: #ffff80; } .wikEdDiffBlock1 { background-color: #d0ff80; } .wikEdDiffBlock2 { background-color: #ffd8f0; } .wikEdDiffBlock3 { background-color: #c0ffff; } .wikEdDiffBlock4 { background-color: #fff888; } .wikEdDiffBlock5 { background-color: #bbccff; } .wikEdDiffBlock6 { background-color: #e8c8ff; } .wikEdDiffBlock7 { background-color: #ffbbbb; } .wikEdDiffBlock8 { background-color: #a0e8a0; } .wikEdDiffBlockHighlight {background-color: #777; color: #fff; border: solid #777; border-width: 1px 0; } .wikEdDiffMarkLeft, .wikEdDiffMarkRight {font-weight: bold; background-color: #ffe49c; color: #666; border-radius: 0.25em; padding: 0.2em; margin: 0 1px; } .wikEdDiffMarkLeft:before { content: \"◀\"; } .wikEdDiffMarkRight:before { content: \"▶\"; } .wikEdDiffMarkLeft.wikEdDiffNoUnicode:before { content: \" < \"; } .wikEdDiffMarkRight.wikEdDiffNoUnicode:before { content: \" > \"; } .wikEdDiffMark { background-color: #e8e8e8; color: #666; } .wikEdDiffMark0 { background-color: #ffff60; } .wikEdDiffMark1 { background-color: #c8f880; } .wikEdDiffMark2 { background-color: #ffd0f0; } .wikEdDiffMark3 { background-color: #a0ffff; } .wikEdDiffMark4 { background-color: #fff860; } .wikEdDiffMark5 { background-color: #b0c0ff; } .wikEdDiffMark6 { background-color: #e0c0ff; } .wikEdDiffMark7 { background-color: #ffa8a8; } .wikEdDiffMark8 { background-color: #98e898; } .wikEdDiffMarkHighlight { background-color: #777; color: #fff; } .wikEdDiffContainer { } .wikEdDiffFragment {white-space: pre-wrap; background: #fff; border: #bbb solid; border-width: 1px 1px 1px 0.5em; border-radius: 0.5em; font-family: sans-serif; font-size: 88%; line-height: 1.6; box-shadow: 2px 2px 2px #ddd; padding: 1em; margin: 0; } .wikEdDiffNoChange { background: #f0f0f0; border: 1px #bbb solid; border-radius: 0.5em; line-height: 1.6; box-shadow: 2px 2px 2px #ddd; padding: 0.5em; margin: 1em 0; text-align: center; } .wikEdDiffSeparator { margin-bottom: 1em; } .wikEdDiffOmittedChars { } .wikEdDiffNewline:before { content: \"¶\"; color: transparent; } .wikEdDiffBlock:hover .wikEdDiffNewline:before { color: #aaa; } .wikEdDiffBlockHighlight .wikEdDiffNewline:before { color: transparent; } .wikEdDiffBlockHighlight:hover .wikEdDiffNewline:before { color: #ccc; } .wikEdDiffBlockHighlight:hover .wikEdDiffInsert .wikEdDiffNewline:before, .wikEdDiffInsert:hover .wikEdDiffNewline:before{ color: #999; } .wikEdDiffBlockHighlight:hover .wikEdDiffDelete .wikEdDiffNewline:before, .wikEdDiffDelete:hover .wikEdDiffNewline:before{ color: #aaa; } .wikEdDiffTab { position: relative; } .wikEdDiffTabSymbol { position: absolute; top: -0.2em; } .wikEdDiffTabSymbol:before { content: \"→\"; font-size: smaller; color: #ccc; } .wikEdDiffBlock .wikEdDiffTabSymbol:before { color: #aaa; } .wikEdDiffBlockHighlight .wikEdDiffTabSymbol:before { color: #aaa; } .wikEdDiffInsert .wikEdDiffTabSymbol:before { color: #aaa; } .wikEdDiffDelete .wikEdDiffTabSymbol:before { color: #bbb; } .wikEdDiffSpace { position: relative; } .wikEdDiffSpaceSymbol { position: absolute; top: -0.2em; left: -0.05em; } .wikEdDiffSpaceSymbol:before { content: \"·\"; color: transparent; } .wikEdDiffBlock:hover .wikEdDiffSpaceSymbol:before { color: #999; } .wikEdDiffBlockHighlight .wikEdDiffSpaceSymbol:before { color: transparent; } .wikEdDiffBlockHighlight:hover .wikEdDiffSpaceSymbol:before { color: #ddd; } .wikEdDiffBlockHighlight:hover .wikEdDiffInsert .wikEdDiffSpaceSymbol:before,.wikEdDiffInsert:hover .wikEdDiffSpaceSymbol:before { color: #888; } .wikEdDiffBlockHighlight:hover .wikEdDiffDelete .wikEdDiffSpaceSymbol:before,.wikEdDiffDelete:hover .wikEdDiffSpaceSymbol:before { color: #999; } .wikEdDiffError .wikEdDiffFragment,.wikEdDiffError .wikEdDiffNoChange{ background: #faa; }</style>";

            File.WriteAllText(file, style + html);
            Process.Start("cmd.exe", "/c " + file);
        }