Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions lib/saxlsx/shared_string_collection_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,31 @@ def self.parse(file_system, &block)

def initialize(&block)
@block = block
@extract = false
end

def start_element(name)
@current_string = String.new if name == :si
case name
when :si then @current_string = nil
when :t then @extract = true
end
end

def end_element(name)
if name == :si
@block.call @current_string
@current_string = nil
case name
when :si then @block.call(@current_string)
when :t then @extract = false
end
end

def text(value)
@current_string << CGI.unescapeHTML(value) if @current_string
if @extract
if @current_string
@current_string << CGI.unescapeHTML(value)
else
@current_string = CGI.unescapeHTML(value)
end
end
end

end
end