Skip to content

Instantly share code, notes, and snippets.

@syohex
Created May 19, 2014 09:06
Show Gist options
  • Save syohex/136e1b965bab98db3620 to your computer and use it in GitHub Desktop.
Save syohex/136e1b965bab98db3620 to your computer and use it in GitHub Desktop.
Script for updating auto-complete CSS dictionary
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
require 'set'
old_url = 'https://raw.githubusercontent.com/auto-complete/auto-complete/master/dict/css-mode'
old_properties = SortedSet.new
open(old_url).read.each_line do |line|
old_properties.add(line.strip)
end
doc = Nokogiri::parse(open('http://www.w3schools.com/cssref/default.asp'))
new_properties = SortedSet.new
doc.css('table.reference > tr').each do |e|
td = e.css('td')
next if td.nil?
next if td.first.nil?
property = td.first.text
property.strip!
new_properties.add(property)
end
merged = old_properties | new_properties
merged.each do |property|
puts property
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment