-
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
Links with underscores are parsed as emphasized text #198
Comments
I have the same problem, within a single link. |
Sorry if I'm out of line, but is there a 👍 mechanism for bugs like this? Just ran into it. I'll take a run at fixing it myself, but in case I fail, wanted to make sure it got bumped. In any event, a |
Alright, I have no idea how to fix this proper. If I were to be hacky about it, I'd start around here: markdown-js/src/dialects/gruber.js Line 541 in 9b8aa65
and have a regex test where Essentially, it seems like you need a rule similar the the escaping rule, but taking into account any leading character that's non-whitespace. IOW, these should not get formatted: this_example_ , _this_example, or_this_example. In all cases, there's an underscore that's immediately preceded by an alphanum. This is solved in other implementations, like GitHub flavored markdown (as you can see above). |
@todb-r7 I think 👍 is the only mechanism for voting on GitHub issues, unfortunately. Anyway, yes I noticed the same issue recently. Finally started debugging it today and that led me here. This is one of the most insane code bases I've ever looked at, but I surmise that changing the behavior of underscores inside words is going to be very difficult, since the current implementation doesn't distinguish "start underscore" from "end underscore" in the same way that it distinguishes However, I did manage to fix the issue of parsing a link with underscores. Change the following line in
to
The principle here is that the link parser will see a link like The fix is to not let |
I have noticed that the Markdown parser gives incorrect results with underscores in both link titles and URLs. Example:
On most Markdown parsers (including Github's), you get:
http://example.com/a_link.html
Instead, evilstreak/markdown-js produces a parse tree roughly (Ignore the auto linking) equivalent to:
[http://example.com/a link.html](http://example.com/a link.html)
i.e. the range between the underscores is parsed as an em first, before the parser looks for links. The result being that the link doesn't actually become a link. I've told the client to escape the underscores as a workaround but I believe this is a parsing issue.
For the record I am using the latest version of the master branch compiled today, and I verified the issue by directly invoking the parser in a JS console. (e.g. without any of the filtering our front-end code does) Is anyone else able to reproduce this?
The text was updated successfully, but these errors were encountered: