Sha256: 7e3953c94ef0eec18c59834d54239895d62f4d58bfaeb047adc44fe67e3c3638
Contents?: true
Size: 1.63 KB
Versions: 2
Compression:
Stored size: 1.63 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("aipim/markdown/"+filename+".md")) end def self.init(filename) system("mkdir -p aipim/html") output = File.open("aipim/html/"+filename+".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.41 | lib/aipim-rails/convert_to_html.rb |
aipim-rails-0.0.40 | lib/aipim-rails/convert_to_html.rb |