dont route kramdown mailto links through link_to. Closes #1058
This commit is contained in:
parent
6db13610ac
commit
e0a4b8f17d
2 changed files with 10 additions and 9 deletions
|
@ -26,7 +26,7 @@ Feature: Markdown (Kramdown) support
|
||||||
|
|
||||||
![image](blank.gif)
|
![image](blank.gif)
|
||||||
|
|
||||||
[Mail me](mailto:ben@benhollis.net)
|
(mailto:mail@mail.com)
|
||||||
"""
|
"""
|
||||||
Given the Server is running at "markdown-app"
|
Given the Server is running at "markdown-app"
|
||||||
When I go to "/link_and_image/"
|
When I go to "/link_and_image/"
|
||||||
|
@ -34,3 +34,5 @@ Feature: Markdown (Kramdown) support
|
||||||
Then I should see 'width="1"'
|
Then I should see 'width="1"'
|
||||||
And I should see 'height="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 'src="/images/blank.gif"'
|
||||||
|
And I should see "mail@mail.com"
|
||||||
|
|
|
@ -19,8 +19,7 @@ module Middleman
|
||||||
cattr_accessor :middleman_app
|
cattr_accessor :middleman_app
|
||||||
|
|
||||||
def convert_img(el, indent)
|
def convert_img(el, indent)
|
||||||
# Constructing a new hash is required because Kramdown uses a crazy non-hash in 1.8
|
attrs = el.attr.dup
|
||||||
attrs = Hash[el.attr.dup.to_a]
|
|
||||||
|
|
||||||
link = attrs.delete('src')
|
link = attrs.delete('src')
|
||||||
middleman_app.image_tag(link, attrs)
|
middleman_app.image_tag(link, attrs)
|
||||||
|
@ -28,16 +27,16 @@ module Middleman
|
||||||
|
|
||||||
def convert_a(el, indent)
|
def convert_a(el, indent)
|
||||||
content = inner(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 el.attr['href'] =~ /\Amailto:/
|
||||||
if attr['href'] =~ /\Amailto:/
|
mail_addr = el.attr['href'].sub(/\Amailto:/, '')
|
||||||
mail_addr = attr['href'].sub(/\Amailto:/, '')
|
href = obfuscate('mailto') << ":" << obfuscate(mail_addr)
|
||||||
attr['href'] = obfuscate('mailto') << ":" << obfuscate(mail_addr)
|
|
||||||
content = obfuscate(content) if content == mail_addr
|
content = obfuscate(content) if content == mail_addr
|
||||||
|
return %Q{<a href="#{href}">#{content}</a>}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
attr = el.attr.dup
|
||||||
link = attr.delete('href')
|
link = attr.delete('href')
|
||||||
|
|
||||||
middleman_app.link_to(content, link, attr)
|
middleman_app.link_to(content, link, attr)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Reference in a new issue