Skip to content

Commit eea394a

Browse files
fix:split at the second | if multiple | (#19)
1 parent fb4ea03 commit eea394a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

app.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,9 +424,23 @@ def process_double_brackets(text, tvar_id=0):
424424
if not (text.startswith("[[") and text.endswith("]]")):
425425
print(f"Input >{text}< must be wrapped in double brackets [[ ]]")
426426
sys.exit(1)
427+
428+
if '<tvar' in text:
429+
return text, double_brackets_types.wikilink
427430

428431
inner_wl = text[2:-2].strip()
429-
parts = inner_wl.split('|')
432+
s = inner_wl
433+
434+
first = s.find('|')
435+
if first == -1:
436+
parts = [s]
437+
else:
438+
second = s.find('|', first + 1)
439+
if second != -1:
440+
parts = [s[:second], s[second + 1:]]
441+
else:
442+
parts = [s[:first], s[first + 1:]]
443+
430444

431445
category_aliases = ['Category:', 'category:', 'Cat:', 'cat:']
432446
file_aliases = ['File:', 'file:', 'Image:', 'image:']
@@ -862,3 +876,4 @@ def api_convert():
862876

863877
if __name__ == '__main__':
864878
app.run(debug=True)
879+

0 commit comments

Comments
 (0)