class Minidown::ParagraphElement
Constants
- ExcludeSchemeRegexp
- StringSymbolRegexp
Attributes
contents[R]
extra[RW]
Public Class Methods
new(*_)
click to toggle source
Calls superclass method
Minidown::Element::new
# File lib/minidown/elements/paragraph_element.rb, line 9 def initialize *_ super @contents = [raw_content] @extra = false end
Public Instance Methods
parse()
click to toggle source
# File lib/minidown/elements/paragraph_element.rb, line 15 def parse if ParagraphElement === nodes.last nodes.last.contents << raw_content else nodes << self end end
text()
click to toggle source
# File lib/minidown/elements/paragraph_element.rb, line 23 def text build_element raw_content end
to_html()
click to toggle source
# File lib/minidown/elements/paragraph_element.rb, line 27 def to_html if @extra contents.map{|content| ParagraphElement.new(doc, content).to_html }.join ''.freeze else contents.map! do |line| build_element line end build_tag 'p'.freeze do |content| pre_elem = contents.shift content << pre_elem.to_html while elem = contents.shift content << br_tag if TextElement === pre_elem && TextElement === elem content << elem.to_html pre_elem = elem end end end end
Private Instance Methods
build_element(content_str)
click to toggle source
# File lib/minidown/elements/paragraph_element.rb, line 48 def build_element content_str if Utils::Regexp[:raw_html] =~ content_str && (raw = $1) && (ExcludeSchemeRegexp =~ raw || StringSymbolRegexp =~ raw) RawHtmlElement.new doc, raw else TextElement.new doc, content_str end end