linkify-it icon indicating copy to clipboard operation
linkify-it copied to clipboard

Better handle nested parens

Open puzrin opened this issue 8 years ago • 4 comments

As discussed in #22.

Examples:

  • http://example.com/render?target=summarize(deriviative(app.numUsers),%221min%22)&title=New_Users_Per_Minute, from Graphite
  • http://sv-t-vnl-forge-metrics:5601/?#/dashboard/Logs-Marmotte?_a=(filters:!(),panels:!((col:1,columns:!(message,host,tags),id:Marmotte-logs,row:1,size_x:12,size_y:8,sort:!('@timestamp',asc),type:search)),query:(query_string:(analyze_wildcard:!t,query:'*')),title:'Logs%20Marmotte')&_g=(refreshInterval:(display:'10%20seconds',pause:!f,section:1,value:10000),time:(from:now-15m,mode:quick,to:now)), generated by the "share" link of Kibana 4.

Considerations:

  1. first implementation of #22 was rejected due ignoring rules between scoped pairs: (foo)ignored---content(bar)
  2. Need to limit max nesting level (2-3 max).

Note. This issue is not critical for markdown-it. Improvment left to volunteers help.

puzrin avatar Sep 08 '15 13:09 puzrin

@puzrin I believe that this issue is important for markdown-it . In fact, not knowing that this is the underlying library - I had opened an issue there . ( sorry.. ?? ) Similar problem ( and potentially more serious because of validity of character ) also occurs with the closing parenthesis character ")" . Should I open another issue in this repository ?

x9t9 avatar May 10 '17 00:05 x9t9

Your case is not related to this issue anyhow. Unpaired closing scope can not be guessed as been or not been part of URL with 100% guarantee. In most of cases - it will not.

puzrin avatar May 10 '17 01:05 puzrin

https://github.com/markdown-it/linkify-it/issues/79

More samples with nested scopes.

puzrin avatar May 18 '20 13:05 puzrin

Hi, we are having this issue as well. Given this URL https://example.com/teams/{{teamid}}/info after reading your source code I figured out that in the validate method passed -> //example.com/teams/{{teamid}}/info matched -> //example.com/teams/{{teamid}

and the issue might be in the regex matching at: https://github.com/markdown-it/linkify-it/blob/master/lib/re.js#L57

changing this line from

'\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}|' +

to

'\\{(?:(?!' + re.src_ZCc + '|[}]).)*\\}}|' +

fixes the issue for us but breaks matching of single curly braces.

image

thisisamir98 avatar Feb 13 '23 13:02 thisisamir98