From 91b1b8445c0dee2f8e68681a1beb0c44da3db646 Mon Sep 17 00:00:00 2001 From: Charles Haley Date: Tue, 22 Jul 2025 12:36:54 +0100 Subject: [PATCH] Two small optimizations in the FFML transifex processor. It is possible that using the ternary expressions will be faster, and it looks better. --- src/calibre/utils/ffml_processor.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/calibre/utils/ffml_processor.py b/src/calibre/utils/ffml_processor.py index 267e8775f8..d231e39aa4 100644 --- a/src/calibre/utils/ffml_processor.py +++ b/src/calibre/utils/ffml_processor.py @@ -389,8 +389,7 @@ class FFMLProcessor: result += '\\' + tree.text() elif tree.node_kind() == NodeKinds.CODE_TEXT: t = tree.text() - if t.endswith('`'): - t = t + ' ' + t = t + ' ' if t.endswith('`') else t result += f'``{t}``' elif tree.node_kind() == NodeKinds.CODE_BLOCK: result += '\n[CODE]\n' + tree.text().replace('[/CODE]', r'[\/CODE]') + '[/CODE]\n' @@ -407,9 +406,7 @@ class FFMLProcessor: for child in tree.children(): result += '[*]' t = self.tree_to_transifex(child, depth=depth+1) - if t.endswith('\n\n'): - t = t[0:-1] - result += t + result += t[0:-1] if t.endswith('\n\n') else t result += '[/LIST]\n' elif tree.node_kind() == NodeKinds.REF: result += f':ref:`{tree.text()}`'