vmg / rinku

Autolinking. Ruby. Yes, that's pretty much it.
ISC License
597 stars 67 forks source link

Handle entities+parens, or multiple entities in URLs #61

Closed grosser closed 7 years ago

grosser commented 7 years ago

Calling autolink_delim multiple times instead of just once, until we find no more delimiters.

/cc @jcheatham @shajith

the last test is failing with this but I'm not sure why:

--- expected
+++ actual
@@ -1 +1 @@
-"&lt;<a href=\"http://www.google.com&gt;\">http://www.google.com&gt;</a>)&lt;)&lt;)&lt;)&lt;)&lt;)&lt;)"
+"&lt;<a href=\"http://www.google.com\">http://www.google.com</a>&gt;&lt;&lt;&lt;&lt;&lt;&lt;"

original commit had the iter patch in only www ... but we had to add it into url to make it work at all ...

jcheatham commented 7 years ago

yeah, that's pretty weird, the actual is substantially different... dunno, maybe part of the whole revamp? Looks like the autolink_delim reference in autolink__email was missed here.

kivikakk commented 7 years ago

The fixed assert might look like this:

    assert_linked "&lt;<a href=\"http://www.google.com&gt;\">http://www.google.com&gt;</a>)&lt;)&lt;)&lt;)&lt;)&lt;)&lt;)&lt;)", "&lt;http://www.google.com&gt;)&lt;)&lt;)&lt;)&lt;)&lt;)&lt;)&lt;)"

(Or remove the initial call to autolink_delim before the while loop.)

kivikakk commented 7 years ago

The way emails are parsed is different (we parse forward from the @ and halt when we stop finding email-like characters), so it doesn't need the same treatment. I'll fix the test, add some more and merge this.

Thanks! :bow:

kivikakk commented 7 years ago

Merged in 42811262c83eab636de6832b0abc0d1509713933.