Created
January 2, 2020 14:11
-
-
Save thbwd/28388bc3cb60f59dbc2b1a0df599da7a to your computer and use it in GitHub Desktop.
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
def i(str) | |
return '' if str.nil? || (stripped = str.strip).empty? | |
"π§²#{stripped}π§²" | |
end | |
def convert(input) | |
input.gsub(/πͺ([^π€πͺ]+)?((π€([^π€πͺ]+)π€([^π€πͺ]+)?)+)πͺ/) do | |
m = Regexp.last_match | |
s = "π€#{i m[1]}" | |
m[2].scan(/π€([^π€πͺ]+)π€([^π€πͺ]+)?/).each { |l, e| s << l << i(e) } | |
s << 'π€' | |
end | |
end | |
Dir['*.emojic'].each do |file_name| | |
puts file_name | |
converted = convert(File.read(file_name)) | |
File.open(file_name, 'w') { |file| file.puts converted } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment