Last active
December 18, 2015 10:39
-
-
Save iskernel/5769759 to your computer and use it in GitHub Desktop.
A simple script for extracting the unicodes and the icon names from the Font Awesome cheat-sheet page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'net/http' | |
#Reads the HTML page | |
fontAwesomeUri = URI('http://fortawesome.github.io/Font-Awesome/cheatsheet/') | |
htmlSourceArray = Net::HTTP.get(fontAwesomeUri).split(/\r?\n/) | |
outputArray = Array.new() | |
tempString = String.new() | |
#Extracts the lines containing the unicodes and the icon names | |
htmlSourceArray.each_with_index do |line,index| | |
line = line.strip | |
if(line =~ /<i class="icon-fixed-width">&#x(....)<\/i>/ ) | |
tempString = "0x"+ $1 + " , " + htmlSourceArray[index+1].strip + "\n" | |
outputArray.push(tempString) | |
end | |
end | |
#Prints to output.txt the results | |
outputFile = File.open("output.txt","w") | |
outputArray.each do |line| | |
outputFile.write(line) | |
end | |
puts("Extracted " + outputArray.size().to_s() + | |
" items from the Font-Awesome cheatsheet. Hurray!") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment