Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to set a ignore area #572

Closed
AkonXI opened this issue Nov 26, 2024 · 1 comment
Closed

How to set a ignore area #572

AkonXI opened this issue Nov 26, 2024 · 1 comment
Labels

Comments

@AkonXI
Copy link

AkonXI commented Nov 26, 2024

I want to compare the difference between rich text and plain text and get each char's index in rich text. As the pic show ,HTML tags can affect the comparison results. so How could I set a regex such as /<(\S{1,}?)[^>]*>|<\/\1>/gms to ignore these tags but keep their positions in the string or treat HTML tags as a whole ?
image

@ExplodingCabbage
Copy link
Collaborator

Sounds like you'd maybe want to write your own tokenizer (maybe treating each tag, attribute, or text node as a token), tokenize the strings you're comparing to diffArrays? I'm not 100% sure I understand what you want to achieve from the description but I suspect it could be done with a custom tokenizer as described in the second paragraph of Defining custom diffing behaviors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants