diff options
author | Volker Krause <vkrause@kde.org> | 2021-05-11 17:42:43 +0200 |
---|---|---|
committer | Volker Krause <vkrause@kde.org> | 2021-05-16 07:37:34 +0000 |
commit | bba49c3924a84cf64cda84bd2a27ed26ae796687 (patch) | |
tree | b93c5faac2c8c8d69512f85952982e28659cfdaa /toolchain | |
parent | c28008a109cdd23c3de4a3fdceb12629431b03f1 (diff) | |
download | extra-cmake-modules-bba49c3924a84cf64cda84bd2a27ed26ae796687.tar.gz extra-cmake-modules-bba49c3924a84cf64cda84bd2a27ed26ae796687.tar.bz2 |
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.
Diffstat (limited to 'toolchain')
-rwxr-xr-x | toolchain/generate-fastlane-metadata.py | 37 |
1 files changed, 22 insertions, 15 deletions
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] += '</' + elem.tag + '>' + else: + for l in allLanguages: + found[l] += '</' + elem.tag + '>' # 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': |