Skip to content

Instantly share code, notes, and snippets.

@takuya
Created Aug 17, 2012
Embed
What would you like to do?
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