class Object
Public Instance Methods
mdtohtml(file)
click to toggle source
# File bin/mdtohtml, line 6 def mdtohtml(file) markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, fenced_code_blocks: true, autolink: true, tables: true) out_file_content = markdown.render(File.read(file)) basename = File.basename(file, '.*') out_file = basename + '.html' fp = File.open(out_file, "w") css_url = 'https://raw.githubusercontent.com/githubutilities/mdtohtml/master/css/github-markdown.css' css_style = open(css_url).read fp.write(' <html> <head> <title>' + basename + '</title> <style> ' + css_style + ' </style> </head> <body> <article class="markdown-body">' ) fp.write(out_file_content) fp.write(' </article> </body> </html>' ) # close the file to save the changes fp.close end