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.
When converting markdown with urls containing underscores they need to be escaped, unless using autolinking in which case they must not be escaped:
If one avoids escaping underscores in URL's it works with autolinking, but not without:
I believe the right solution is to escape underscores in URL's and change the autolinking to work with this.