lib/quesadilla/extractor.rb in quesadilla-0.1.1 vs lib/quesadilla/extractor.rb in quesadilla-0.1.2
- old
+ new
@@ -22,10 +22,11 @@
markdown_triple_emphasis: true,
markdown_double_emphasis: true,
markdown_emphasis: true,
markdown_strikethrough: true,
hashtags: true,
+ hashtag_validator: nil,
autolinks: true,
emoji: true,
users: false,
user_validator: nil,
html: true,
@@ -40,25 +41,26 @@
# @option options markdown_triple_emphasis [Boolean] Should extract Markdown triple emphasis (bold italic). Defaults to `true`.
# @option options markdown_double_emphasis [Boolean] Should extract Markdown double emphasis (bold). Defaults to `true`.
# @option options markdown_emphasis [Boolean] Should extract Markdown emphasis (italic). Defaults to `true`.
# @option options markdown_strikethrough [Boolean] Should extract Markdown strikethrough. Defaults to `true`.
# @option options hashtags [Boolean] Should extract hashtags. Defaults to `true`.
+ # @option options hashtag_validator A callable object to validate a hashtag. This should return `true` or `false`. Invalid hashtags will be left as plain text. If the validator is `nil`, all hashtags will be extracted. Defaults to `nil`.
# @option options autolinks [Boolean] Should automatically detect links. Defaults to `true`.
# @option options emoji [Boolean] Should extract named emoji. Defaults to `true`.
# @option options users [Boolean] Should extract user mentions. Defaults to `false`.
- # @option options user_validator A callable object to validate a username. This should return the user ID of the user or nil if it is invalid. Invalid users will be left as plain text. If the validator is nil, all usernames will be extracted. Defaults to `nil`.
+ # @option options user_validator A callable object to validate a username. This should return the user ID of the user or nil if it is invalid. Invalid users will be left as plain text. If the validator is `nil`, all usernames will be extracted. Defaults to `nil`.
# @option options html [Boolean] Should generate HTML. Defaults to `true`.
# @option options html_renderer [Class] class to use as HTML renderer. Defaults to `Quesadilla::HTMLRenderer`.
def initialize(options = {})
@options = self.class.default_options.merge(options)
@renderer = @options[:html_renderer].new if @options[:html]
end
# Extract entities from text
- # @param original_text the text to extract from
+ # @param text [String] the text to extract from
# @return [Hash] hash containing the display text, html text, and entities
- def extract(original_text)
- @original_text = original_text.dup
+ def extract(text)
+ @original_text = text.dup
# Emoji colon-syntax
replace_emoji if @options[:emoji]
@working_text = @original_text.dup