Method: SectionParser#parse

Defined in:
lib/ribit/contentparser.rb

#parse(text, contentDoc) ⇒ Object



658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
# File 'lib/ribit/contentparser.rb', line 658

def parse( text, contentDoc )
  newContainers = Array.new
  sections = text.scan(  /\n----[^\n]*/ )
  str = text
  sections.each do |section|
    firstIndex = str.index( section )
    newContainers.push( SectionContainer.new( str[0, firstIndex] ) )
    
    # take the rest of the string
    str = str[ firstIndex + section.size, str.size]
  end
  
  # take tail
  if ( str != nil and str.size() > 0 and newContainers.size > 0 )
    #puts "*** adding the tail : " + str
    newContainers.push( SectionContainer.new( str ) )
  elsif ( newContainers.size == 0 )
    # no sections, (if only one then don't use it) 
    return [TextContainer.new( text )]
  end
  
  #      newContainers.each do |i|
  #        puts "### i = " + i.to_s
  #      end
  return newContainers    
end