From bba49c3924a84cf64cda84bd2a27ed26ae796687 Mon Sep 17 00:00:00 2001 From: Volker Krause Date: Tue, 11 May 2021 17:42:43 +0200 Subject: Handle text-less tags Contrary to the comment those exist (e.g. ul, ol), this just wasn't noticed as due to the script-enforced formatting those always contain some spaces. This resulted in different structures between English and translated description texts. With this change all language variants show the same structure. --- toolchain/generate-fastlane-metadata.py | 37 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'toolchain') diff --git a/toolchain/generate-fastlane-metadata.py b/toolchain/generate-fastlane-metadata.py index e6f377a1..e917484e 100755 --- a/toolchain/generate-fastlane-metadata.py +++ b/toolchain/generate-fastlane-metadata.py @@ -85,28 +85,35 @@ def readText(elem, found, allLanguages): # If there is text available, we'll want to extract it # Additionally, if this element has any children, make sure we read those as well - # It isn't clear if it is possible for an item to not have text, but to have children which do have text - # The code will currently skip these if they're encountered - if elem.text: - if elem.tag in supportedRichTextTags: + if elem.tag in supportedRichTextTags: + if (elem.text and elem.text.strip()) or lang: found[lang] += '<' + elem.tag + '>' + else: + for l in allLanguages: + found[l] += '<' + elem.tag + '>' + + if elem.text and elem.text.strip(): found[lang] += elem.text - subOutput = {} - for child in elem: - if not child.get('{http://www.w3.org/XML/1998/namespace}lang') and len(subOutput) > 0: - applyLanguageFallback(subOutput, allLanguages) - for l in allLanguages: - found[l] += subOutput[l] - subOutput = {} - readText(child, subOutput, allLanguages) - if len(subOutput) > 0: + subOutput = {} + for child in elem: + if not child.get('{http://www.w3.org/XML/1998/namespace}lang') and len(subOutput) > 0: applyLanguageFallback(subOutput, allLanguages) for l in allLanguages: found[l] += subOutput[l] - - if elem.tag in supportedRichTextTags: + subOutput = {} + readText(child, subOutput, allLanguages) + if len(subOutput) > 0: + applyLanguageFallback(subOutput, allLanguages) + for l in allLanguages: + found[l] += subOutput[l] + + if elem.tag in supportedRichTextTags: + if (elem.text and elem.text.strip()) or lang: found[lang] += '' + else: + for l in allLanguages: + found[l] += '' # Finally, if this element is a HTML Paragraph (p) or HTML List Item (li) make sure we add a new line for presentation purposes if elem.tag == 'li' or elem.tag == 'p': -- cgit v1.2.1