Class HTML::Pipeline::EmojiFilter
In: lib/html/pipeline/emoji_filter.rb
Parent: Filter

HTML filter that replaces :emoji: with images.

Context:

  :asset_root (required) - base url to link to emoji sprite
  :asset_path (optional) - url path to link to emoji sprite. :file_name can be used as a placeholder for the sprite file name. If no asset_path is set "emoji/:file_name" is used.
  :ignored_ancestor_tags (optional) - Tags to stop the emojification. Node has matched ancestor HTML tags will not be emojified. Default to pre, code, and tt tags. Extra tags please pass in the form of array, e.g., %w(blockquote summary).
  :img_attrs (optional) - Attributes for generated img tag. E.g. Pass { "draggble" => true, "height" => nil } to set draggable attribute to "true" and clear height attribute of generated img tag.

Methods

Constants

DEFAULT_IGNORED_ANCESTOR_TAGS = %w[pre code tt].freeze

Public Instance methods

The url path to link emoji sprites

:file_name can be used in the asset_path as a placeholder for the sprite file name. If no asset_path is set in the context "emoji/:file_name" is used. Returns the context‘s asset_path or the default path if no context asset_path is given.

The base url to link emoji sprites

Raises ArgumentError if context option has not been provided. Returns the context‘s asset_root.

Replace :emoji: with corresponding images.

text - String text to replace :emoji: in.

Returns a String with :emoji: replaced with images.

Implementation of validate hook. Errors should raise exceptions or use an existing validator.

[Validate]