Skip to content

Commit

Permalink
fix: Handle the placeholder correctly while the engine adds spaces to…
Browse files Browse the repository at this point in the history
… it.
  • Loading branch information
bookfere committed Oct 4, 2023
1 parent f68dff1 commit 9b78a09
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def add_translation(self, translation, placeholder, position=None,
count = 0
for reserve in self.reserve_elements:
# Escape the markups (<m id=1 />) to replace escaped markups.
pattern = placeholder[1].format(format(count, '05'))
pattern = placeholder[1].format(r'\s*'.join(format(count, '05')))
# Prevent potential invalid escapes from affecting the replacement.
translation = re.sub(
xml_escape(pattern), lambda _: get_string(reserve),
Expand Down
2 changes: 1 addition & 1 deletion tests/test_element.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def test_add_translation(self):
self.element.get_content(Base.placeholder)
translation = ('{{id_00000}} A {{id_00001}} B C {{id_00002}} D E '
'{{id_00003}} F G {{id_00004}} H {{id_00005}} I '
'{{id_00006}} {{id_00007}} K{{id_00008}}L')
'{{id_00006}} {{id_00007}} K{ { id _ 0 00 08 } }L')
new = self.element.add_translation(translation, Base.placeholder)
translation = ('<p xmlns="http://www.w3.org/1999/xhtml" class="abc">'
'<img src="icon.jpg"/> A <img src="w1.jpg"/> '
Expand Down

0 comments on commit 9b78a09

Please sign in to comment.