class Md2key::Highlight

Constants

DEFAULT_EXTENSION

Public Class Methods

pbcopy_highlighted_code(code) click to toggle source
# File lib/md2key/highlight.rb, line 5
def pbcopy_highlighted_code(code)
  ensure_highlight_availability

  extension = code.extension || DEFAULT_EXTENSION

  IO.popen("highlight -O rtf -K 28 -s rdark -k Monaco -S #{extension} -u utf-8 | pbcopy", 'w+') do |highlight|
    highlight.write(code.source)
    highlight.close
  end
end

Private Class Methods

ensure_highlight_availability() click to toggle source
# File lib/md2key/highlight.rb, line 18
def ensure_highlight_availability
  return if system('which -s highlight')

  abort "`highlight` is not available. Try `brew install highlight`."
end