Class: Convert

Inherits:
Object
  • Object
show all
Extended by:
Converters
Defined in:
lib/convert.rb

Overview

# # # # # The Convert module is responsible for converting strings

Constant Summary collapse

CONVERTERS =

Some of the matchers are taken from github.com/dejan/auto_html

[:iframe_embed, :dailymotion, :email_escape, :flickr, :gist, :google_maps, :hashtag, :escape_html, :image_tag, :instagram, :liveleak, :markdown, :metacafe, :redcarpet, :soundcloud, :ted, :twitter, :video_embed, :vimeo, :vimeo_embed, :worldstar, :youtube, :youtube_embed, :youtube_js_api, :auto_link, :encode, :decode, :strip_params, :sanitize, :nokogiri]
DEFAULT =
[:dailymotion, :flickr, :gist, :google_maps, :instagram, :liveleak, :metacafe, :soundcloud, :ted, :twitter, :vimeo, :worldstar, :youtube, :auto_link]

Constants included from Converters

Converters::CONFIGS, Converters::SKIP

Class Method Summary collapse

Methods included from Converters

auto_link, convert, convertable?, dailymotion, decode, email_escape, encode, escape_html, flickr, gist, google_maps, hashtag, iframe_embed, image_tag, instagram, kramdown, liveleak, markdown, metacafe, redcarpet, sanitize, scan, simple_format, soundcloud, strip_params, ted, twitter, unescape_html, video_embed, vimeo, vimeo_embed, worldstar, youtube, youtube_embed, youtube_image, youtube_js_api

Class Method Details

.run(string, options = {}) ⇒ Object

Run all the converters or the ones you sent to the initializers



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/convert.rb', line 39

def self.run(string, options = {})
  return '' if !string

  # Setup
  options = {:markdown => true, :config => :custom, :converters => DEFAULT}.merge(options)

  # Include
  options[:converters] += options[:include] if options[:include]

  # Exclude
  options[:converters] -= options[:exclude] if options[:exclude]

  # Markdown
  string = markdown(string, :autolink => false) if options[:markdown]

  # Scan
  string = scan(string, options)

  # Sanitize
  string = sanitize(string, :config => options[:config])

  string
end