private static void OnHighlightContextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (!(d is FlowDocumentScrollViewer docScrollViewer))
            {
                return;
            }

            if (!(e.NewValue is TextFragments context))
            {
                docScrollViewer.Document = null;
                return;
            }


            var         para           = new Paragraph();
            RunFragment firstHighlight = default(RunFragment);

            foreach (var fragment in context.Fragments)
            {
                var run = RunFragment.Create(fragment);
                if (firstHighlight == null && run.TextFragmentType == TextFragmentType.Highlight)
                {
                    firstHighlight = run;
                }

                para.Inlines.Add(run);
            }

            docScrollViewer.Document = new FlowDocument(para);
            HandleScrollPosition(docScrollViewer, firstHighlight);
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var highlight = value as TextFragments;
            var tb        = new TextBlock();

            foreach (var fragment in highlight.Fragments)
            {
                var run = RunFragment.Create(fragment);
                tb.Inlines.Add(run);
            }
            return(tb);
        }