Clean up extraneous newlines left by html2text.

This commit is contained in:
Stephen McDonald 2011-11-21 05:49:49 +11:00
parent b762a1d5c5
commit 1b3abb61d8
1 changed files with 7 additions and 1 deletions

View File

@ -75,7 +75,13 @@ 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}"
if title != nil || content != nil && name != nil if title != nil || content != nil && name != nil
content = %x[echo '#{content.gsub("'", "''")}' | html2text] if format == "md" if format == "md"
content = %x[echo '#{content.gsub("'", "''")}' | html2text]
# html2text leaves extra blank lines in code blocks - clean them up.
begin
content.gsub!("\n \n", "\n")
end until !content.include? "\n \n"
end
File.open("_posts/tumblr/#{name}", "w") do |f| File.open("_posts/tumblr/#{name}", "w") do |f|
f.puts <<-HEADER f.puts <<-HEADER