Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion lib/creek/shared_strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def self.parse_shared_string_from_document(xml)
dictionary = Hash.new

xml.css('si').each_with_index do |si, idx|
text_nodes = si.css('t')
text_nodes = si.css('>t, r t')
if text_nodes.count == 1 # plain text node
dictionary[idx] = Creek::Styles::Converter.unescape_string(text_nodes.first.content)
else # rich text nodes with text fragments
Expand Down
10 changes: 10 additions & 0 deletions spec/fixtures/sst.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,14 @@
<si>
<t>Cell with_x000D_escaped_x000D_characters</t>
</si>
<si>
<t>吉田兼好</t>
<rPh sb="0" eb="2">
<t xml:space="preserve">ヨシダ </t>
</rPh>
<rPh sb="2" eb="4">
<t xml:space="preserve">ケンコウ </t>
</rPh>
<phoneticPr fontId="1"/>
</si>
</sst>
3 changes: 2 additions & 1 deletion spec/shared_string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@
doc = Nokogiri::XML(shared_strings_xml_file)
dictionary = Creek::SharedStrings.parse_shared_string_from_document(doc)

expect(dictionary.keys.size).to eq(6)
expect(dictionary.keys.size).to eq(7)
expect(dictionary[0]).to eq('Cell A1')
expect(dictionary[1]).to eq('Cell B1')
expect(dictionary[2]).to eq('My Cell')
expect(dictionary[3]).to eq('Cell A2')
expect(dictionary[4]).to eq('Cell B2')
expect(dictionary[5]).to eq("Cell with\rescaped\rcharacters")
expect(dictionary[6]).to eq('吉田兼好')
end

end