Skip to content

Instantly share code, notes, and snippets.

@BrentonEarl
Created June 10, 2017 18:59
Show Gist options
  • Save BrentonEarl/3b38e8a8404dd2d56170ee502590dcef to your computer and use it in GitHub Desktop.
Save BrentonEarl/3b38e8a8404dd2d56170ee502590dcef to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'redcarpet'
md_file = File.read(ARGV.first)
html_filename = File.basename(ARGV.first, ".md") + ".html"
File.open(html_filename, 'w') do |file|
file.write(Redcarpet::Markdown.new(Redcarpet::Render::HTML.new).render(md_file))
end
@BrentonEarl
Copy link
Author

BrentonEarl commented Jun 10, 2017

To use this on Slackware, run as root:

gem install redcarpet

Then log out of the root account and run the script as a normal user with:

ruby md_to_html.rb Markdown_file.md

It will save the converted markdown text to an html formatted file within the same directory as the script.

"Markdown_file.md" will output "Markdown_file.html"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment