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
#!/usr/bin/env ruby -wU | |
require 'erb' | |
require 'fileutils' | |
require 'shellwords' | |
# extension to String to extract colours into rgb array | |
class String | |
# hex to array | |
def h2a |
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
#!/usr/bin/env ruby -wU | |
require 'erb' | |
# extension to String to extract colours into rgb array | |
class String | |
# hex to array | |
def h2a | |
if self.length == 4 | |
self.scan(/[0-9A-Fa-f]/). |
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
#!/usr/bin/env ruby18 -wKU | |
line = ENV['TM_CURRENT_LINE'] || ENV['TM_SELECTED_TEXT'] | |
color = '' | |
line.scan(/(#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})(?=[^0-9A-Fa-f])|rgba{0,1}\([0-9]{1,3}[, ]+?[0-9]{1,3}[, ]+?[0-9]{1,3}[, 0-9\.]*?\))/) { |c| | |
color = color+"<div style='font-size:8px;display:inline-block;height:3em;margin:0;padding:0 0.5em 0 0;height:3em;background:#{c[0]}'><span style='background:#000;color:#FFF'>#{c[0]}</span></div>" | |
} | |
color = '<div style=\\"background:\\#000;color:\\#FFF;padding:2px\\">No color found</div>' unless color.length > 0 |