Fixed a bug with labels

This commit is contained in:
Darks 2021-02-10 22:44:07 +01:00
parent d622e4e3fb
commit f07634c6ac
Signed by: Darks
GPG Key ID: 7515644268BE1433
1 changed files with 8 additions and 5 deletions

View File

@ -50,7 +50,8 @@ for line in markdown:
n_h3 = 0
header = res.group(1)
index = f"{n_h1}"
table_of_contents += f"[target={index}]{index}{header}[/target]\n"
label = index.replace(".", "_")
table_of_contents += f"[target={label}]{index}{header}[/target]\n"
output.append(f"[big][brown][b]{index}{header}[/b][/brown][/big]"
f"[label={index}]")
elif (res := r_h2.search(line)):
@ -58,16 +59,18 @@ for line in markdown:
n_h3 = 0
header = res.group(1)
index = f"{n_h1}.{n_h2}"
table_of_contents += f"[target={index}]{index}{header}[/target]\n"
label = index.replace(".", "_")
table_of_contents += f"[target={label}]{index}{header}[/target]\n"
output.append(f"[brown][b]{index}{header}[/b][/brown]"
f"[label={index}]")
f"[label={label}]")
elif (res := r_h3.search(line)):
n_h3 += 1
header = res.group(1)
index = f"{n_h1}.{n_h2}.{n_h3}"
table_of_contents += f"[target={index}]{index}{header}[/target]\n"
label = index.replace(".", "_")
table_of_contents += f"[target={label}]{index}{header}[/target]\n"
output.append(f"[b]{index}{header}[/b]"
f"[label={index}]")
f"[label={label}]")
else:
res = r_link.sub(
lambda m: f"{m.group(1)}[url={m.group(3)}]{m.group(2)}[/url]{m.group(4)}", line)