From bc20ba9be961ece9d5e49283366956d23c71bdd1 Mon Sep 17 00:00:00 2001 From: Stephen McDonald Date: Fri, 25 Nov 2011 06:10:47 +1100 Subject: [PATCH] Preserve HTML tables as per markdown's support for tables. --- lib/jekyll/migrators/tumblr.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/jekyll/migrators/tumblr.rb b/lib/jekyll/migrators/tumblr.rb index 3fd15642..10f41601 100644 --- a/lib/jekyll/migrators/tumblr.rb +++ b/lib/jekyll/migrators/tumblr.rb @@ -60,7 +60,12 @@ module Jekyll name = "#{Date.parse(post['date']).to_s}-#{title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.#{format}" File.open("_posts/tumblr/#{name}", "w") do |f| - content = %x[echo '#{content.gsub("'", "''")}' | html2text] if format == "md" + if format == "md" + preserve = ["table", "tr", "th", "td"] + preserve.each { |tag| content = content.gsub(/<#{tag}/i, "$$" + tag).gsub(/<\/#{tag}/i, "||" + tag) } + content = %x[echo '#{content.gsub("'", "''")}' | html2text] + preserve.each { |tag| content = content.gsub("$$" + tag, "<" + tag).gsub("||" + tag, " "post", "title" => title, "tags" => post["tags"]} f.puts header.to_yaml + "---\n" + content end # End file