-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Parse complicated url problem #366
Comments
Marked follows original mardown.pl behavior for this. Libupskirt/sundown also shares the same behavior. If we're supposed to allow parentheses in urls, what happens when parentheses are incorrectly closed? [foo](http://example.com/foo_)bar) What should happen here? The only way to parse What about: [foo](http://example.com/foo_(bar) Should marked keep parsing the text after "bar)" since it hasn't seen a proper closing paren for the link syntax? How about this: [foo](http://example.com/foo_(((((((((bar)) Is marked even supposed to guess what is going on there by interpreting the parens in that url? I feel like this change would only exist to accommodate wikipedia links, which can already either be encoded, or included as link references. If someone can come up with a definite outline of what should happen in all these other cases, I'm all for it. |
I got your point. Since you must have a line break, or a space after an url, or another url, or still you have reached the end of the document, you can simply consider the last parenthesis, like the parenthesis that closes the link.
In the above example, you should have the following link: |
I just saw this while reading the source code from hoedown, https://github.com/hoedown/hoedown/blob/master/src/autolink.c#L102 It's from the autolink feature, but somewhat related, isn't? |
I have just known that the bug was fixed in Hoedown long time ago. Yeah, I suppose you right. |
That would break links at the end of a parenthetical, which is common enough to be concerning. |
Perhaps you could also support using double quotes inside the parenthesis and take everything inside the quotes as the url:
|
@chjj I think it's time to close this and just tell people to manually encode the URLs using |
Actually, you'll need to implement paren matching logic for GFM. It looks like GitHub always requires paired parens inside a URL. |
@scottgonzalez, I've told people that before. It doesn't seem very effective. This is probably the second issue on this. GFM does do it, and I think it's unintelligent, but I'll try it and see how it goes. Maybe it won't hurt performance much and I'll be okay with it despite disagreeing with it philosophically. |
You can't ask people to encode urls, because they simply copy and paste urls from the address bar of a browser. :-( -Filippo On May 15, 2014, at 2:19 PM, Scott González wrote:
|
Encoding URLs is not an option :( |
I'm using Hoedown, a PHP extension to the Hoedown library. |
In github,
[Ajax](http://en.wikipedia.org/wiki/Ajax_(programming))
will be correctly parsed: Ajax, but marked will add unnecessary)
The text was updated successfully, but these errors were encountered: