module Mongoid::Markdown::InstanceMethods

Public Instance Methods

markdown!() click to toggle source
# File lib/mongoid-markdown/mongoid_old.rb, line 63
def markdown!
  self.class.markdown_attributes.each { |attr| __send__(attr) }
end
marked_down() click to toggle source
# File lib/mongoid-markdown/mongoid_old.rb, line 51
def marked_down
  marked_down? ? (@marked_down ||= {}) : @attributes.dup
end
marked_down=(value) click to toggle source
# File lib/mongoid-markdown/mongoid_old.rb, line 59
def marked_down=(value)
  @is_marked_down = !!value
end
marked_down?() click to toggle source
# File lib/mongoid-markdown/mongoid_old.rb, line 55
def marked_down?
  @is_marked_down != false
end
reload() click to toggle source
Calls superclass method
# File lib/mongoid-markdown/mongoid_old.rb, line 67
def reload
  marked_down.clear
  super
end
write_attribute(attr_name, value) click to toggle source
Calls superclass method
# File lib/mongoid-markdown/mongoid_old.rb, line 72
def write_attribute(attr_name, value)
  marked_down[attr_name.to_s] = nil
  super
end

Private Instance Methods

html_regexp() click to toggle source
# File lib/mongoid-markdown/mongoid_new.rb, line 98
def html_regexp
  %r{<(?:[^>"']+|"(?:\\.|[^\\"]+)*"|'(?:\\.|[^\\']+)*')*>}xm
end
markdown_glyphs() click to toggle source
# File lib/mongoid-markdown/mongoid_new.rb, line 81
def markdown_glyphs
  [[ '&#8217;', "'" ], 
   [ '&#8216;', "'" ],
   [ '&lt;', '<' ], 
   [ '&gt;', '>' ], 
   [ '&#8221;', '"' ],
   [ '&#8220;', '"' ],            
   [ '&#8230;', '...' ],
   [ '\1&#8212;', '--' ], 
   [ ' &rarr; ', '->' ], 
   [ ' &#8211; ', '-' ], 
   [ '&#215;', 'x' ], 
   [ '&#8482;', '(TM)' ], 
   [ '&#174;', '(R)' ],
   [ '&#169;', '(C)' ]]
end
strip_markdown_html(html) click to toggle source
# File lib/mongoid-markdown/mongoid_new.rb, line 72
def strip_markdown_html(html)
  returning html.dup.gsub(html_regexp, '') do |h|
    markdown_glyphs.each do |(entity, char)|
      sub = [ :gsub!, entity, char ]
      @textiled_unicode ? h.chars.send(*sub) : h.send(*sub)
    end
  end
end