Update functions.py
All checks were successful
Publish Docker image / Push Docker image to Docker Hub (push) Successful in -3s

This commit is contained in:
2025-09-26 10:06:11 +02:00
parent 8467b4ed53
commit 00855c3ce1

View File

@@ -50,7 +50,12 @@ def convert_text(text: str, format_indents: bool = True):
for line in seperate(text): for line in seperate(text):
# add anki field into line and count the number of changes # add anki field into line and count the number of changes
if as_indent and re.search(r"^\W+.+", line) is not None: if as_indent and re.search(r"^\W+.+", line) is not None:
newLine, _ = re.subn(r"(^\W+)(.+)", r"\1 {{{{c1::\2}}}}", line) if re.search(r"^\t+", line) is not None:
newLine = match_and_replace(line, format_indents)
else:
newLine, _ = re.subn(
r"(?!^\t|^.+:$)^(\W+)(.+)$", r"\1 {{c1::\2}}", line
)
else: else:
as_indent = False as_indent = False
newLine = match_and_replace(line, format_indents) newLine = match_and_replace(line, format_indents)
@@ -66,10 +71,10 @@ def match_and_replace(line: str, format_indents: bool = True):
if re.search(":$", line) is not None: if re.search(":$", line) is not None:
return True return True
if format_indents: if format_indents:
line, num = re.subn("(\t+.)(..*)", r"\1 {{{{c1::\2}}}}", line) line, num = re.subn("(\t+.)(..*)", r"\1 {{c1::\2}}", line)
if num > 0: if num > 0:
return line return line
line, num = re.subn("(:)(..+)", r"\1 {{{{c1::\2}}}}", line) line, num = re.subn("(:)(..+)", r"\1 {{c1::\2}}", line)
return line return line