Skip to content
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

Autolink breaks on underscores #427

Closed
jacobat opened this issue Oct 27, 2014 · 1 comment
Closed

Autolink breaks on underscores #427

jacobat opened this issue Oct 27, 2014 · 1 comment
Labels

Comments

@jacobat
Copy link

jacobat commented Oct 27, 2014

When converting markdown with urls containing underscores they need to be escaped, unless using autolinking in which case they must not be escaped:

irb(main):001:0> Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: false).render("http://google.com/foo\\_bar\\_baz")
=> "<p>http://google.com/foo_bar_baz</p>\n"
irb(main):002:0> Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true).render("http://google.com/foo\\_bar\\_baz")
=> "<p><a href=\"http://google.com/foo%5C_bar%5C_baz\">http://google.com/foo\\_bar\\_baz</a></p>\n"

If one avoids escaping underscores in URL's it works with autolinking, but not without:

irb(main):003:0> Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: false).render("http://google.com/foo_bar_baz")
=> "<p>http://google.com/foo<em>bar</em>baz</p>\n"
irb(main):004:0> Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true).render("http://google.com/foo_bar_baz")
=> "<p><a href=\"http://google.com/foo_bar_baz\">http://google.com/foo_bar_baz</a></p>\n"

I believe the right solution is to escape underscores in URL's and change the autolinking to work with this.

@jacobat
Copy link
Author

jacobat commented Oct 27, 2014

This is possibly related to #402

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants