Sha256: e51dc17750468c563ee0b62c7172d93ff6ebc2fb3b8f272122aebfcb5811f838

Contents?: true

Size: 1.57 KB

Versions: 2

Compression:

Stored size: 1.57 KB

Contents

require 'redcarpet'

module ConvertToHtml

	def self.md_to_html(filename)
		markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true)
		markdown.render(File.read(filename))
	end

	def self.init(filename)
		output = File.open("aipim/relatorio.html", "w")
		output.puts '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'
		output.puts '<html>'
		output.puts '	<head>'
		output.puts '	<META http-equiv="Content-Type" content="text/html; charset=utf-8">'
		output.puts '	<link href="bootstrap.min.css" rel="stylesheet">'
		output.puts '	<script src="jquery-1.9.1.js"></script>'
		output.puts '	<script type="text/javascript">'
		output.puts '		$(document).ready(function(){'
		output.puts '			$(\'a\').click(function(){'
		output.puts '	    		var titulo = $(this).html();'
		output.puts '		    	$(\'html, body\').animate({'
		output.puts '					scrollTop: $(\'h2\').filter(\':contains("\'+titulo+\'")\').offset().top'
		output.puts '				}, 1000);'
		output.puts '			});'
		output.puts '		});'
		output.puts '	</script>'
		output.puts '	<style>'
		output.puts '		img {'
		output.puts '			width: 100%;'
		output.puts '		}'
		output.puts '		blockquote p {'
		output.puts '			text-align: center;'
		output.puts '		}'
		output.puts '		body {'
		output.puts '			padding-left:25%;'
		output.puts '			padding-right:25%;'
		output.puts '			align:center'
		output.puts '		}'
		output.puts '	</style>'
		output.puts '</head>'
		output.puts '<body>'
		output.puts md_to_html(filename)
		output.puts '</body>'
		output.puts '</html>'
		output.close
	end
	
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
aipim-rails-0.0.23 lib/aipim-rails/convert_to_html.rb
aipim-rails-0.0.22 lib/aipim-rails/convert_to_html.rb