private void InterlineDiff(LineDiffInfo baseLineInfo, LineDiffInfo diffLineInfo, bool ignoreWhiteSpaces = false)
        {
            string result;
            using (var diff = new Process())
            {
                var diffArgs = "";
                if (!string.IsNullOrEmpty(_diffArgsBase))
                    diffArgs = _diffArgsBase + " " + diffArgs;
                if (ignoreWhiteSpaces && !string.IsNullOrEmpty(_diffArgsIgnoreWhiteSpace))
                    diffArgs +=  " " + _diffArgsIgnoreWhiteSpace;
                diffArgs += " " + baseLineInfo.TempFileName + " " + diffLineInfo.TempFileName;

                diff.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
                diff.StartInfo.UseShellExecute = false;
                diff.StartInfo.RedirectStandardError = true;
                diff.StartInfo.RedirectStandardOutput = true;
                diff.StartInfo.CreateNoWindow = true;
                diff.StartInfo.FileName = _diffExe;
                diff.StartInfo.Arguments = diffArgs;
                diff.Start();

                string stderr;
                result = CommonUtils.ReadProcessOutput(diff, false, out stderr);
            }

            var lines = result.Replace("\r", "").Replace("> ", "").Replace("< ", "").Split(new char[] { '\n' });

            var diffInfos = DiffInfo.Parse(lines);
            foreach (var diffInfo in diffInfos)
            {
                // reset diffType to before change
                baseLineInfo.Add(DiffType.None);
                diffLineInfo.Add(DiffType.None);

                // Add lines before diffInfo starts

                while (!baseLineInfo.Done &&
                    (diffInfo == null || baseLineInfo.Position < diffInfo.baseLine - 1))
                {
                    baseLineInfo.Next();
                }

                while (!diffLineInfo.Done &&
                    (diffInfo == null || diffLineInfo.Position < diffInfo.diffLine - 1))
                {
                    diffLineInfo.Next();
                }

                // start diffType
                switch (diffInfo.diffType)
                {
                    case DiffType.Deleted: // left line
                        baseLineInfo.Add(diffInfo.diffType);
                        break;

                    case DiffType.Added: // right line
                        diffLineInfo.Add(diffInfo.diffType);
                        break;

                    case DiffType.Changed: // left line
                        baseLineInfo.Add(diffInfo.diffType);
                        diffLineInfo.Add(diffInfo.diffType);
                        break;

                    default:
                        throw new Exception(string.Format("Unknown diff prefix: {0}", diffInfo.baseLine));
                }

                // Add lines in diffInfo range

                while (!baseLineInfo.Done &&
                    (diffInfo == null || baseLineInfo.Position < diffInfo.baseLineEnd))
                {
                    baseLineInfo.Next();
                }

                while (!diffLineInfo.Done &&
                    (diffInfo == null || diffLineInfo.Position < diffInfo.diffLineEnd))
                {
                    diffLineInfo.Next();
                }
            }

            baseLineInfo.AddLast();
            diffLineInfo.AddLast();
        }
        private void InterlineDiff(HtmlTableRowGroup rowGroup, bool ignoreWhiteSpaces)
        {
            var baseLineInfo = new LineDiffInfo(rowGroup);
            var diffLineInfo = new LineDiffInfo(rowGroup, baseLineInfo);
            InterlineDiff(baseLineInfo, diffLineInfo, ignoreWhiteSpaces);

            UnPackDiffedLine(rowGroup, baseLineInfo.Lines, diffLineInfo.Lines);

            baseLineInfo.Dispose();
            diffLineInfo.Dispose();
        }
            public LineDiffInfo(HtmlTableRowGroup rowGroup, LineDiffInfo baseInfo = null)
            {
                BaseInfo = baseInfo ?? this;
                BaseMode = baseInfo == null;

                var charsList = new List<string>();
                foreach (var item in rowGroup.Lines)
                {
                    var line = BaseMode ? item.Left.Code : item.Right.Code;
                    line = line ?? "";
                    var lineEscapes = UnEncodeLine(ref line);
                    Escapes.Add(lineEscapes);
                    Chars += line;

                    var chars = line.ToCharArray();
                    charsList.AddRange(chars.Select(ch => ch.ToString(CultureInfo.InvariantCulture)));

                    LinePositions.Add(line.Length);
                }
                Length = Chars.Length;

                File.WriteAllLines(TempFileName, charsList);
            }