Fix regex

This commit is contained in:
Darks 2021-02-11 09:34:25 +01:00
parent 2b59ee7a4c
commit 598d08b326
Signed by: Darks
GPG Key ID: 7515644268BE1433
1 changed files with 4 additions and 4 deletions

View File

@ -29,8 +29,8 @@ r_h1 = re.compile("^# (.+)$", re.I|re.M)
r_h2 = re.compile("^## (.+)$", re.I|re.M)
r_h3 = re.compile("^### (.+)$", re.I|re.M)
r_link = re.compile("(\W)\[(.+?)\]\((.+?)\)(\W)", re.I|re.M)
r_em = re.compile("(\s)\*(\w.+\w)\*(\s)", re.I|re.M)
r_strong = re.compile("(\s)\*\*(\w.+\w)\*\*(\s)", re.I|re.M)
r_em = re.compile("([^\w*])\*(\w.+?\w)\*([^\w*])", re.I|re.M)
r_strong = re.compile("(\W)\*{2}(\w.+?\w)\*{2}(\W)", re.I|re.M)
# Open and extract document
markdown = args.input.read().splitlines()
@ -60,7 +60,7 @@ for line in markdown:
header = res.group(1)
index = f"{n_h1}.{n_h2}"
label = index.replace(".", "_")
table_of_contents += f"[target={label}]{index} {header}[/target]\n"
table_of_contents += f"    [target={label}]{index} {header}[/target]\n"
output.append(f"[brown][b]{index} {header}[/b][/brown]"
f"[label={label}]")
elif (res := r_h3.search(line)):
@ -68,7 +68,7 @@ for line in markdown:
header = res.group(1)
index = f"{n_h1}.{n_h2}.{n_h3}"
label = index.replace(".", "_")
table_of_contents += f"[target={label}]{index} {header}[/target]\n"
table_of_contents += f"        [target={label}]{index} {header}[/target]\n"
output.append(f"[b]{index} {header}[/b]"
f"[label={label}]")
else: