Fix tests under 1.8 by coercing Kramdown's OrderedHash into a real Hash.

This commit is contained in:
Ben Hollis 2013-10-19 19:02:34 -07:00
parent ae2b6b34f1
commit e773e8c1a9
2 changed files with 7 additions and 2 deletions

View file

@ -1,6 +1,7 @@
Feature: Markdown (Kramdown) support Feature: Markdown (Kramdown) support
In order to test included Kramdown support In order to test included Kramdown support
@no18
Scenario: Kramdown smartypants extension Scenario: Kramdown smartypants extension
Given a fixture app "markdown-app" Given a fixture app "markdown-app"
And a file named "config.rb" with: And a file named "config.rb" with:

View file

@ -19,14 +19,17 @@ module Middleman
cattr_accessor :middleman_app cattr_accessor :middleman_app
def convert_img(el, indent) def convert_img(el, indent)
attrs = el.attr.dup # Constructing a new hash is required because Kramdown uses a crazy non-hash in 1.8
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)
end end
def convert_a(el, indent) def convert_a(el, indent)
content = inner(el, indent) content = inner(el, indent)
attr = el.attr.dup # 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:/ if attr['href'] =~ /\Amailto:/
mail_addr = attr['href'].sub(/\Amailto:/, '') mail_addr = attr['href'].sub(/\Amailto:/, '')
attr['href'] = obfuscate('mailto') << ":" << obfuscate(mail_addr) attr['href'] = obfuscate('mailto') << ":" << obfuscate(mail_addr)
@ -34,6 +37,7 @@ module Middleman
end end
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