public Object Convert(Object inforValue, Type targetType, object parameter, CultureInfo culture)
        {
            var emptyLineOffsets = new List <int>();
            var value            = ((IHighlightRawInfo)inforValue).Text;
            var span             = new Span();
            var originalSpan     = new Span();

            try
            {
                originalSpan = new Span(new Run(value.Replace("|~E~|", String.Empty).Replace("|~S~|", String.Empty)));
            }
            catch (NullReferenceException npe)
            {
                //ignore for now, return empty summary
                //if we see too many of these in the log we'll start fixing it
                LogEvents.HighlightingNpe(this);
            }

            try
            {
                // return null;
                if (value == null)
                {
                    return(null);
                }

                var      input = value as string;
                string[] lines = input.SplitToLines().Select(RemoveHeadAndTailNewLine).ToArray();
                lines = RemoveHeadTailEmptyStrings(lines);
                var keyTemp = new List <string>();
                var offset  = 0;

                foreach (string line in lines)
                {
                    if (String.IsNullOrWhiteSpace(line))
                    {
                        emptyLineOffsets.Add(offset);
                    }
                    offset++;

                    if (line.Contains("|~S~|"))
                    {
                        string findKey = string.Copy(line);

                        while (findKey.IndexOf("|~S~|") >= 0)
                        {
                            int first = findKey.IndexOf("|~S~|") + "|~S~|".Length;
                            int last  = findKey.IndexOf("|~E~|");

                            string key_candidate = findKey.Substring(first, last - first);

                            bool removed = false;
                            if (key_candidate.StartsWith("|~S~|"))
                            {
                                removed       = true;
                                key_candidate = key_candidate.Remove("|~S~|".Length);
                            }


                            if (!keyTemp.Contains(key_candidate))
                            {
                                keyTemp.Add(key_candidate);
                            }

                            //Remove the searched string
                            int lengthRemove = last - first + 2 * "|~S~|".Length;
                            findKey = findKey.Remove(first - "|~S~|".Length, lengthRemove);
                            if (removed)
                            {
                                findKey = findKey.Insert(first - "|~S~|".Length, "|~S~|");
                            }
                        }

                        string[] key  = keyTemp.ToArray();
                        string[] temp = line.Split(new[] { "|~S~|", "|~E~|" }, StringSplitOptions.RemoveEmptyEntries);

                        foreach (string item in temp)
                        {
                            span.Inlines.Add(IsSearchKey(item, key)
                                ? CreateRun(item, highlightedWeight, SearchViewControl.GetHistoryTextColor())
                                    : CreateRun(item, regularWeight));
                        }
                    }
                    else
                    {
                        span.Inlines.Add(CreateRun(line, regularWeight));
                    }
                    span.Inlines.Add(CreateRun(Environment.NewLine, regularWeight));
                }
                return(ClearSpan((IHighlightRawInfo)inforValue, span, emptyLineOffsets));
            }
            catch (Exception e)
            {
                return(originalSpan);
            }
        }