lib/rfeedparser/better_sgmlparser.rb
# Replaced Tagfind and Charref Regexps with the ones in feedparser.py
# This makes things work. 
Replaced Tagfind and Charref Regexps with the ones in feedparser.py
This makes things work.
Replaced Tagfind and Charref Regexps with the ones in feedparser . py This makes things work .
def parse_starttag(i)
    @_starttag_text = nil
    start_pos = i
    rawdata = @rawdata
    ni,match = index_match(rawdata,Shorttagopen,i)
    if ni == i 
      k,match = index_match(rawdata,Shorttag,i)
      return nil unless match
      tag, data = match[1], match[2]
      @_starttag_text = "<#{tag}/"
      tag.downcase!
      second_end = rawdata.index(Shorttagopen,k)
      finish_shorttag(tag, data)
      @_starttag_text = rawdata[start_pos...second_end+1]
      return k
    end
    j = rawdata.index(Endbracket, i+1)
    return nil unless j
    attrsd = []
    if rawdata[i...i+2] == '<>'
      k = j
      tag = @lasttag
    else
      ni,match = index_match(rawdata,Tagfind,i+1)
      unless match
        error('unexpected call to parse_starttag')
      end
      k = ni+match[0].length+1
      tag = match[0].downcase
      @lasttag = tag
    end
    while k < j
      break if rawdata.index(Endtagfind, k) == k
      ni,match = index_match(rawdata,Attrfind,k)
      break unless ni
      matched_length = match[0].length
      attrname, rest, attrvalue = match[1],match[2],match[3]
      if rest.nil? || rest.empty?
        attrvalue = '' 
      elsif [?',?'] == [attrvalue[0..0], attrvalue[-1..-1]] || [?",?"] == [attrvalue[0],attrvalue[-1]]
        attrvalue = attrvalue[1...-1]
      end
      attrsd << [attrname.downcase, attrvalue]
      k += matched_length
    end
    if rawdata[j..j] == ">"
      j += 1
    end
    @_starttag_text = rawdata[start_pos...j]
    finish_starttag(tag, attrsd)
    return j
  end
def parse_starttag ( i ) @_starttag_text = nil start_pos = i rawdata = @rawdata ni , match = index_match ( rawdata , Shorttagopen , i ) if ni == i k , match = index_match ( rawdata , Shorttag , i ) return nil unless match tag , data = match [ 1 ] , match [ 2 ] @_starttag_text = "<#{tag}/" tag . downcase! second_end = rawdata . index ( Shorttagopen , k ) finish_shorttag ( tag , data ) @_starttag_text = rawdata [ start_pos ... second_end + 1 ] return k end j = rawdata . index ( Endbracket , i + 1 ) return nil unless j attrsd = [ ] if rawdata [ i ... i + 2 ] == '<>' k = j tag = @lasttag else ni , match = index_match ( rawdata , Tagfind , i + 1 ) unless match error ( 'unexpected call to parse_starttag' ) end k = ni + match [ 0 ] . length + 1 tag = match [ 0 ] . downcase @lasttag = tag end while k < j break if rawdata . index ( Endtagfind , k ) == k ni , match = index_match ( rawdata , Attrfind , k ) break unless ni matched_length = match [ 0 ] . length attrname , rest , attrvalue = match [ 1 ] , match [ 2 ] , match [ 3 ] if rest . nil? || rest . empty? attrvalue = '' elsif [ ?' , ?' ] == [ attrvalue [ 0 .. 0 ] , attrvalue [ - 1 .. - 1 ] ] || [ ?" , ?" ] == [ attrvalue [ 0 ] , attrvalue [ - 1 ] ] attrvalue = attrvalue [ 1 ... - 1 ] end attrsd << [ attrname . downcase , attrvalue ] k += matched_length end if rawdata [ j .. j ] == ">" j += 1 end @_starttag_text = rawdata [ start_pos ... j ] finish_starttag ( tag , attrsd ) return j end
Replaced Tagfind and Charref Regexps with the ones in feedparser.py
This makes things work.
Replaced Tagfind and Charref Regexps with the ones in feedparser . py This makes things work .
# SGML shorthand: <tag/data/ == <tag>data</tag> # XXX Can data contain &... (entity or char refs)? # XXX Can data contain < or > (tag characters)? # XXX Can there be whitespace before the first /? # SGML shorthand: <> == <last open tag seen> # was: = attrname # Why the change?
i