flutter_parsed_text icon indicating copy to clipboard operation
flutter_parsed_text copied to clipboard

Nested or Overlapped MatchText

Open Addictorator opened this issue 4 years ago • 5 comments

As it is now, it seems I'm unable to nest multiple matchtext without specifically writing a regex pattern to match for the amalgamation of the two. Let's say I have italics and I check for it with "(i) Test (i)" (test), and bold with "(b) Test (b)" (test) . A combination of the two simply seems to match the outer set and ignore anything within. A bold and italicized text writted as "(b) (i) Test (i) (b) " simply parses as "(i) Test (i)" in bold.

That's straightforward nesting, disregarding partial overlapping such as "(i) This is (b) a test (i) to check (b)" But this is likely far more complicated to do.

I understand allowing for applying multiple text matching to a single portion of text might conflict with multiple text styles, but why not have a list of parsed with the order of parsing, overwriting the previous one matched, in case of any conflicting parameters, the same for the onTap() function. Is this a feasible request? Thanks!

Addictorator avatar Oct 19 '19 08:10 Addictorator

The behavior you are observing is intentional, Initial this package used to override the previously parsed text, lets say you have this https://apps.apple.com/id/app/facebook/id284882215 If you passed Email & Phone as MatchText this would get parsed as https://apps.apple.com/id/app/facebook/id and this end part 284882215 would be parsed as Phone so I changed how the package works.

So now whenever a match is found it is padded with %%%% so in your case (b) (i) Test (i) (b) this would become %%%%(b) (i) Test (i) (b)%%%% so next time when its run through next MatchText it won't be matched with the regex pattern.

Hope this helps.

fayeed avatar Oct 19 '19 18:10 fayeed

Hi, is this in commit 0fad3e7 (v.1.1.2 -> v1.2.0)? Thinking of forking, adding Boolean and sending a merge request. By the way, this package has been really useful in multiple ways, I like how customizable it is. Thanks :)

Addictorator avatar Oct 20 '19 04:10 Addictorator

Yes, that's the commit. Feel free to make a PR too.

fayeed avatar Oct 20 '19 08:10 fayeed

Is there any update on this? I love how easy this package is to use, but I'm trying to parse a custom markdown language and not having nested matching makes things ... hard.

I was thinking maybe we could add a boolean to MatchText that indicates wether or not to match the text multiple times.

clragon avatar Apr 15 '20 23:04 clragon

is it possible to support nested matching?

mccol avatar May 31 '20 08:05 mccol