From 5b2ddf313560e32fe656f79f85e789551a6ff8c9 Mon Sep 17 00:00:00 2001 From: Sebastian Ludwig Date: Mon, 21 May 2018 14:26:30 +0200 Subject: [PATCH] Fixes a regression introduced in ea58bd1: child HTML tags in strings like were ignored when consuming strings. Closes #244. --- lib/twine/formatters/android.rb | 3 ++- test/test_formatters.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/twine/formatters/android.rb b/lib/twine/formatters/android.rb index 55c735c..37d512e 100644 --- a/lib/twine/formatters/android.rb +++ b/lib/twine/formatters/android.rb @@ -67,7 +67,8 @@ module Twine key = child.attributes['name'] - set_translation_for_key(key, lang, child.text) + content = child.children.map(&:to_s).join + set_translation_for_key(key, lang, content) set_comment_for_key(key, comment) if comment comment = nil diff --git a/test/test_formatters.rb b/test/test_formatters.rb index 51d3c51..a9cb2e9 100644 --- a/test/test_formatters.rb +++ b/test/test_formatters.rb @@ -101,6 +101,21 @@ class TestAndroidFormatter < FormatterTest assert_equal 'This is\n a string', @empty_twine_file.definitions_by_key["foo"].translations['en'] end + def test_read_html_tags + content = <<-EOCONTENT + + + Hello, BOLD + + EOCONTENT + + io = StringIO.new(content) + + @formatter.read io, 'en' + + assert_equal 'Hello, BOLD', @empty_twine_file.definitions_by_key["foo"].translations['en'] + end + def test_set_translation_converts_leading_spaces @formatter.set_translation_for_key 'key1', 'en', "\u0020value" assert_equal ' value', @empty_twine_file.definitions_by_key['key1'].translations['en']