thestinger / termite

Termite is obsoleted by Alacritty. Termite was a keyboard-centric VTE-based terminal, aimed at use within a window manager with tiling and/or tabbing support.
https://github.com/alacritty/alacritty
2.73k stars 240 forks source link

Use recursive subpattern to match balanced parentheses. #596

Closed MaskRay closed 6 years ago

MaskRay commented 6 years ago

This skips the trailing ) in [](http://example) while matches https://en.wikipedia.org/wiki/Haskell_(programming_language)

Fix #594

thestinger commented 6 years ago

This doesn't look what I've requested in the past.

I think it makes sense to ignore the trailing URL in the following case, bu treating it as part of a wrapper around the URL:

(https://foobar.com/baz)

However, I don't want it to be ignored in the following

https://foobar.com/baz)

In a case like this, I don't want to make an attempt to treat the trailing parentheses as not part of the URL:

(a statement in parentheses with a URL is not something I want to try to handle: https://foobar.com/baz)

This regular expression also needs to be treated as somewhat performance sensitive.

thestinger commented 6 years ago

I'd also be fine with approaching cases like a URL wrapped in single quotes in the same way.

MaskRay commented 6 years ago

the argument here is that unbalanced right parentheses are unlikely to be part of the URL. We are using heuristics anyway as proper URL detection is extremely hard and we have to consider the context. Your second case is indeed rejected but I think this is what ppl usually want (foo http://example.com/bar)

On Wed, May 9, 2018, 02:41 Daniel Micay notifications@github.com wrote:

I'd also be fine with approaching cases like a URL wrapped in single quotes in the same way.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/thestinger/termite/pull/596#issuecomment-387683421, or mute the thread https://github.com/notifications/unsubscribe-auth/AAZaQvMYoS2fE-bO50kGsYYg4qet8_c3ks5twrmxgaJpZM4T2Abr .

MaskRay commented 6 years ago

atomic subgroup ?> is used for performance

MaskRay commented 6 years ago

Has this PR been rejected? If so I can close it and use my local patch.

jelly commented 6 years ago

Are the cases brought up by @thestinger resolved in the pull request?

MaskRay commented 6 years ago

I don't understand the rationale of the cases brought up. With the PR,

(https://foobar.com/baz)

However, I don't want it to be ignored in the following

https://foobar.com/baz)

In a case like this, I don't want to make an attempt to treat the trailing parentheses as not part of the URL:

(a statement in parentheses with a URL is not something I want to try to handle: https://foobar.com/baz)

This is IMHO more intuitive and better than his proposed () being part of the URL):

unmatched ) will not be a part of the URL. If you think this is unintended, I can close the PR immediately.

thestinger commented 6 years ago

It's valid to have ( and ) characters in a URL and they don't need to be balanced. That's the rationale.

I'll wait for someone to submit a pull request implementing ignoring ) when ( is directly in front of the URL because that's a clear form of syntax.

MaskRay commented 3 years ago

I've carried this local patch for 2 years now as it is needed to mitigate #594 and #556 and many Wikipedia links.

thestinger commented 3 years ago

It wasn't the approach that I wanted and there isn't currently a maintainer/developer for the project.