Skip to content

Commit

Permalink
fonctions d'échappement améliorées
Browse files Browse the repository at this point in the history
  • Loading branch information
cherifVN committed Jun 12, 2024
1 parent 9a79cb9 commit 60e7c71
Showing 1 changed file with 16 additions and 40 deletions.
56 changes: 16 additions & 40 deletions translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,36 +40,21 @@ def escape_simple_quotes():
global spaces_at_start
global spaces_at_end

if dialogue_filtered.startswith(" "):
while dialogue_filtered.startswith(" "):
spaces_at_start += 1
escape_simple_quotes()
return
else:
dialogue_filtered = dialogue_filtered[spaces_at_start:]
spaces_at_start = 0
dialogue_filtered = dialogue_filtered[1:]

if dialogue_filtered.startswith("\\'"):
dialogue_filtered = dialogue_filtered[2:]
while dialogue_filtered.startswith("\\'"):
slash_quote_start += 1
escape_simple_quotes()
return


if dialogue_filtered.endswith(" "):
dialogue_filtered = dialogue_filtered[2:]

while dialogue_filtered.endswith(" "):
spaces_at_end += 1
escape_simple_quotes()
return
elif spaces_at_end > 0:
dialogue_filtered = dialogue_filtered[:-spaces_at_end]
spaces_at_end = 0
dialogue_filtered = dialogue_filtered[:-1]



if dialogue_filtered.endswith("\\'"):
dialogue_filtered = dialogue_filtered[:-2]
while dialogue_filtered.endswith("\\'"):
slash_quote_end += 1
escape_simple_quotes()
return
dialogue_filtered = dialogue_filtered[:-2]

#dialogue_filtered = dialogue_filtered.replace("\\'", "'")
try:
Expand Down Expand Up @@ -103,27 +88,18 @@ def escape_double_quotes():
global spaces_at_start
global spaces_at_end

if dialogue_filtered.startswith(" "):
spaces_at_start += 1
escape_double_quotes()
return
else:
dialogue_filtered = dialogue_filtered[spaces_at_start:]
spaces_at_start = 0

if dialogue_filtered.startswith('\\"'):
while dialogue_filtered.startswith(" "):
spaces_at_start += 1
dialogue_filtered = dialogue_filtered[1:]

while dialogue_filtered.startswith('\\"'):
dialogue_filtered = dialogue_filtered[2:]
slash_quote_start += 1
escape_double_quotes()
return

if dialogue_filtered.endswith(" "):
while dialogue_filtered.endswith(" "):
spaces_at_end += 1
escape_double_quotes()
return
elif spaces_at_end > 0:
dialogue_filtered = dialogue_filtered[:-spaces_at_end]
spaces_at_end = 0
dialogue_filtered = dialogue_filtered[:-1]


if dialogue_filtered.endswith('\\"'):
Expand Down

0 comments on commit 60e7c71

Please sign in to comment.