-
Notifications
You must be signed in to change notification settings - Fork 863
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
parentheses in links cannot be parsed by regex #248
Comments
I am not sure whether I am not just getting your point but can't we find a regex to match them all? Instead of just catching alphanumeric symbols we could decide to match all symbols expect spaces. You can just play here: https://regex101.com/#javascript and I found this one (http[\S]*) as a short and simple solution. |
the problem is catching the parenthesis. For instance:
This should match Writing a pattern so that any pairs It's definitely worth adding that simple pattern match, but the README.md would definitely need a booknote on how link parsing is guaranteed to fail for certain links, and how to mitigate that (using |
Ok, this explains it, you can't count with regex ;-) |
yeah, thinking about that. |
I was looking for a new markdown library, since
chjj/marked
is built entirely using regex, which means it completely fails at parsing URLs with parentheses in it (wikipedia's full of those, for instance), but looking at https://github.com/evilstreak/markdown-js/blob/master/src/parser.js#L179-202 it seems like this code is also using regex for inline pattern extraction.If that is the case, then this parser also can't deal with URLs like https://en.wikipedia.org/wiki/Set_(mathematics) (github's parser gets URIs like these right), unless people manually replace the parentheses with
%..
values (which is not a realistic solution). And as long as regex are used, there is no solution to that problem, so this might be something that needs to be put in the README.md as a "warning: there are limitations to this parser. [...]" so that people don't suddenly run into this problem but can plan around it.The text was updated successfully, but these errors were encountered: