Read text format using diff patch match

535 views Asked by At

I am using diff match patch https://github.com/google/diff-match-patch to compare text of a html file and its working as expected. But the user want's to add a functionality to compare the format (bold, italic, underline)

But the diff match patch accept only string.

I created a class that holds the text and its font property of the html files

class TextProperty
{
    public string Text { get; set; }
    public bool isBold { get; set; }
    public bool isItalic { get; set; }
    public bool isUnderline { get; set; }
}

But the problem now i have is when i read the html content. i read it by text. and i append the text that has the same format

example i have this sample text

enter image description here

So my output is

This is a normal text with : isBold = false : isItalic = false : isUnderline = false
bold : isBold = true: isItalic = false : isUnderline = false
and : isBold = false : isItalic = false : isUnderline = false
italic : isBold = false : isItalic = true : isUnderline = false
and : isBold = false : isItalic = false : isUnderline = false
underline : isBold = false : isItalic = false : isUnderline = true
text : isBold = false : isItalic = false : isUnderline = false

But with this output How can i pass this in my diff match pass.

If i modify the diff match patch. That it will accept List of TextProperty

is it a good way to do this way? or any better option?

But upon reading the code of diff-match-patch i need to modify a lot of codes

0

There are 0 answers