Skip to content

Instantly share code, notes, and snippets.

@takuya
Created August 17, 2012 12:00
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 takuya/3378320 to your computer and use it in GitHub Desktop.
Save takuya/3378320 to your computer and use it in GitHub Desktop.
gistの貼り付けタグのScriptからHTMLにする。 ref: http://qiita.com/items/333e7d9c9b16ab566665
#!/usr/bin/env ruby
require 'openssl'
require 'open-uri'
require 'rubygems'
require 'json'
if ARGV.size < 1 || ! (/([0-9]+)/ =~ ARGV[0])
puts "Usage : Gist のIDを指定。"
puts "以下のように指定"
puts " #{__FILE__} https://gist.github.com/3033059 "
puts " #{__FILE__} https://gist.github.com/3033059.js "
puts " #{__FILE__} https://gist.github.com/3033059.json "
puts " #{__FILE__} 3033059 "
exit
end
id = $1
json = open("https://gist.github.com/#{id}.json").read
data = JSON.load json
puts '<style>'
puts 'div.highlight{ background-color: #FFFFFF !important;}' #はてなダイアリーとかぶるので。
puts open('https://gist.github.com/stylesheets/gist/embed.css').read
puts '</style>'
puts data["div"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment