Class: Redcarpet::Socialable

Inherits:
Render::HTML
  • Object
show all
Includes:
Hashtags, Mentions
Defined in:
lib/redcarpet/socialable.rb

Defined Under Namespace

Modules: Hashtags, Mentions

Constant Summary collapse

BASE_REGEXP =
'(<\/?[^>]*>)?' +
# There should be a whitespace or beginning of line
'(^|[\s\>])+' +
# Placeholder for what we want to match
'%s' +
# This is where match ends
'(\b|\-|\.|,|:|;|\?|!|\(|\)|$)?' +
# Closing HTML tag if any
'(<\/?[^>]*>)?'

Instance Method Summary collapse

Methods included from Hashtags

#postprocess

Methods included from Mentions

#postprocess

Instance Method Details

#header(text, level) ⇒ Object



31
32
33
# File 'lib/redcarpet/socialable.rb', line 31

def header(text, level)
  "<h#{level}>#{safe_replace(text)}</h#{level}>"
end

#list_item(text, list_type) ⇒ Object



27
28
29
# File 'lib/redcarpet/socialable.rb', line 27

def list_item(text, list_type)
  "<li>#{safe_replace(text)}</li>"
end

#paragraph(text) ⇒ Object



23
24
25
# File 'lib/redcarpet/socialable.rb', line 23

def paragraph(text)
  "<p>#{safe_replace(text)}</p>"
end

#safe_replace(text) ⇒ Object



35
36
37
38
# File 'lib/redcarpet/socialable.rb', line 35

def safe_replace(text)
  text = process_mentions(text)
  process_hashtags(text)
end