Skip to content

Instantly share code, notes, and snippets.

@itspriddle
Created January 24, 2013 15:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itspriddle/4623692 to your computer and use it in GitHub Desktop.
Save itspriddle/4623692 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Usage:
# gfm <files>
#
# Examples:
#
# gfm README.markdown
# echo "# Test" | gfm
# echo "# Test" | gfm - README.markdown
# gfm
# # Hi
# ^d
require 'net/http'
require 'json'
url = URI.parse("https://api.github.com/markdown")
request = Net::HTTP::Post.new("#{url.path}")
request.body = { "mode" => "gfm", "text" => ARGF.read }.to_json
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
response = http.start { |http| http.request(request) }
puts response.body
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment