Module: Convert

Extended by:
Converters
Defined in:
lib/convert.rb,
lib/converters/ted.rb,
lib/converters/gist.rb,
lib/converters/vimeo.rb,
lib/converters/decode.rb,
lib/converters/encode.rb,
lib/converters/flickr.rb,
lib/converters/hashtag.rb,
lib/converters/twitter.rb,
lib/converters/youtube.rb,
lib/converters/kramdown.rb,
lib/converters/liveleak.rb,
lib/converters/markdown.rb,
lib/converters/metacafe.rb,
lib/converters/nokogiri.rb,
lib/converters/sanitize.rb,
lib/converters/auto_link.rb,
lib/converters/image_tag.rb,
lib/converters/instagram.rb,
lib/converters/redcarpet.rb,
lib/converters/simpleidn.rb,
lib/converters/worldstar.rb,
lib/converters/soundcloud.rb,
lib/converters/dailymotion.rb,
lib/converters/google_maps.rb,
lib/converters/html_escape.rb,
lib/converters/video_embed.rb,
lib/converters/vimeo_embed.rb,
lib/converters/email_escape.rb,
lib/converters/iframe_embed.rb,
lib/converters/strip_params.rb,
lib/converters/simple_format.rb,
lib/converters/unescape_html.rb,
lib/converters/youtube_embed.rb,
lib/converters/youtube_image.rb,
lib/converters/youtube_js_api.rb

Overview

Convert strings and HTML from a long list of converters @homepage: github.com/fugroup/convert @author: Vidar <[email protected]>, Fugroup Ltd. @license: MIT, contributions are welcome.

Defined Under Namespace

Modules: Converters

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, :scan, :to_ascii, :to_unicode]
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, to_ascii, to_unicode, 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



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

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