Skip to content

Instantly share code, notes, and snippets.

@tiennou
Last active September 25, 2020 11:52
Show Gist options
  • Save tiennou/d58a30307fd45eb7b889b2dbc3a10e06 to your computer and use it in GitHub Desktop.
Save tiennou/d58a30307fd45eb7b889b2dbc3a10e06 to your computer and use it in GitHub Desktop.
Quick-'n-dirty TextExpander to espanso converter
#!/usr/bin/env ruby
require 'plist'
require 'optimist'
require 'yaml'
opts = Optimist::options do
version "0.1.0"
banner <<-EOS
espando-convert converts a TextExpander snippet file to espando's YML syntax
Usage:
espando-convert <filename>
EOS
end
file = ARGV.shift
raise ArgumentError.new "missing input file" unless file
data = Plist.parse_xml(file)
package = {}
package['name'] = data['groupInfo']['groupName']
package['name'] ||= "untitled"
package['matches'] = []
data['snippetsTE3'].each do |snippet|
match = {}
match['trigger'] = snippet['abbreviation']
match['replace'] = snippet['plainText']
next if match['trigger'].empty? or match['replace'].empty?
package['matches'] << match
end
puts YAML.dump(package)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment