Preserve HTML tables as per markdown's support for tables.

This commit is contained in:
Stephen McDonald 2011-11-25 06:10:47 +11:00
parent ab85c82356
commit bc20ba9be9
1 changed files with 6 additions and 1 deletions

View File

@ -60,7 +60,12 @@ module Jekyll
name = "#{Date.parse(post['date']).to_s}-#{title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.#{format}" name = "#{Date.parse(post['date']).to_s}-#{title.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '')}.#{format}"
File.open("_posts/tumblr/#{name}", "w") do |f| 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, "</" + tag) }
end
header = {"layout" => "post", "title" => title, "tags" => post["tags"]} header = {"layout" => "post", "title" => title, "tags" => post["tags"]}
f.puts header.to_yaml + "---\n" + content f.puts header.to_yaml + "---\n" + content
end # End file end # End file