diff --git a/src/lib/page_functions.py b/src/lib/page_functions.py index 3c00723..0fd1825 100644 --- a/src/lib/page_functions.py +++ b/src/lib/page_functions.py @@ -333,7 +333,7 @@ def replace_parameter_if_double(page_content, p, v): print('\nreplace_parameter_if_double()') regex = r'\| *' + p + r' *=' - if '}}' not in page_content or not re.search(regex, page_content): + if '}}' not in page_content or re.search(regex, page_content) is None: return '' if re.search(regex, page_content).start() > page_content.find('}}'): diff --git a/src/wiktionary/fr_wiktionary_format.py b/src/wiktionary/fr_wiktionary_format.py index c225e75..e59152e 100644 --- a/src/wiktionary/fr_wiktionary_format.py +++ b/src/wiktionary/fr_wiktionary_format.py @@ -558,7 +558,7 @@ def treat_page(page): else: line_end = page_content2[:page_content2.find('\n')] new_line_end = replace_parameter_if_double(line_end, 'lang', language_code) - if line_end != new_line_end: + if new_line_end != '' and line_end != new_line_end: # Fix doubles new_page_content2 = page_content2.replace(line_end, new_line_end) page_content = page_content.replace(page_content2, new_page_content2)