dont route kramdown mailto links through link_to. Closes #1058

This commit is contained in:
Thomas Reynolds 2013-10-30 09:18:25 -07:00
parent 6db13610ac
commit e0a4b8f17d
2 changed files with 10 additions and 9 deletions

View file

@ -26,7 +26,7 @@ Feature: Markdown (Kramdown) support
![image](blank.gif)
[Mail me](mailto:ben@benhollis.net)
(mailto:mail@mail.com)
"""
Given the Server is running at "markdown-app"
When I go to "/link_and_image/"
@ -34,3 +34,5 @@ Feature: Markdown (Kramdown) support
Then I should see 'width="1"'
And I should see 'height="1"'
And I should see 'src="/images/blank.gif"'
And I should see 'src="/images/blank.gif"'
And I should see "mail@mail.com"

View file

@ -19,8 +19,7 @@ module Middleman
cattr_accessor :middleman_app
def convert_img(el, indent)
# Constructing a new hash is required because Kramdown uses a crazy non-hash in 1.8
attrs = Hash[el.attr.dup.to_a]
attrs = el.attr.dup
link = attrs.delete('src')
middleman_app.image_tag(link, attrs)
@ -28,16 +27,16 @@ module Middleman
def convert_a(el, indent)
content = inner(el, indent)
# Constructing a new hash is required because Kramdown uses a crazy non-hash in 1.8
attr = Hash[el.attr.dup.to_a]
if attr['href'] =~ /\Amailto:/
mail_addr = attr['href'].sub(/\Amailto:/, '')
attr['href'] = obfuscate('mailto') << ":" << obfuscate(mail_addr)
if el.attr['href'] =~ /\Amailto:/
mail_addr = el.attr['href'].sub(/\Amailto:/, '')
href = obfuscate('mailto') << ":" << obfuscate(mail_addr)
content = obfuscate(content) if content == mail_addr
return %Q{<a href="#{href}">#{content}</a>}
end
attr = el.attr.dup
link = attr.delete('href')
middleman_app.link_to(content, link, attr)
end
end