Skip to content

Commit efd84b9

Browse files
ledsunpythonicrubyist
authored andcommitted
Ignore runs of phonetic that appears in Japanese (#77)
1 parent 4e1b1b4 commit efd84b9

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

lib/creek/shared_strings.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def self.parse_shared_string_from_document(xml)
2929
dictionary = Hash.new
3030

3131
xml.css('si').each_with_index do |si, idx|
32-
text_nodes = si.css('t')
32+
text_nodes = si.css('>t, r t')
3333
if text_nodes.count == 1 # plain text node
3434
dictionary[idx] = Creek::Styles::Converter.unescape_string(text_nodes.first.content)
3535
else # rich text nodes with text fragments

spec/fixtures/sst.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,14 @@
7878
<si>
7979
<t>Cell with_x000D_escaped_x000D_characters</t>
8080
</si>
81+
<si>
82+
<t>吉田兼好</t>
83+
<rPh sb="0" eb="2">
84+
<t xml:space="preserve">ヨシダ </t>
85+
</rPh>
86+
<rPh sb="2" eb="4">
87+
<t xml:space="preserve">ケンコウ </t>
88+
</rPh>
89+
<phoneticPr fontId="1"/>
90+
</si>
8191
</sst>

spec/shared_string_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77
doc = Nokogiri::XML(shared_strings_xml_file)
88
dictionary = Creek::SharedStrings.parse_shared_string_from_document(doc)
99

10-
expect(dictionary.keys.size).to eq(6)
10+
expect(dictionary.keys.size).to eq(7)
1111
expect(dictionary[0]).to eq('Cell A1')
1212
expect(dictionary[1]).to eq('Cell B1')
1313
expect(dictionary[2]).to eq('My Cell')
1414
expect(dictionary[3]).to eq('Cell A2')
1515
expect(dictionary[4]).to eq('Cell B2')
1616
expect(dictionary[5]).to eq("Cell with\rescaped\rcharacters")
17+
expect(dictionary[6]).to eq('吉田兼好')
1718
end
1819

1920
end

0 commit comments

Comments
 (0)