improving the conversion based on A.G. feedback

This commit is contained in:
2023-03-20 11:29:12 +00:00
committed by Gitea
parent fc5fc91867
commit 410ad07a68

View File

@ -439,17 +439,17 @@ class OTCDocConvertor:
# Special case for multiple asterisks and colons like ecs:*:*
re_escape = re.compile(r"([:])(\*+)")
re_escape_new = re.compile(r"([:])(\*)[^$]")
for p in soup.body.find_all(string=re_escape):
if p.string and (p.parent.name == "p" or p.parent.name == "li"):
p.string.replace_with(
re.sub(re_escape, r"\1``\2``", p.string))
string=p.string
while re.search(re_escape, string):
if re.search(re_escape_new, string):
string=re.sub(re_escape, r"\1``\2``", string, count=1)
else:
p.string.replace_with(string)
break
# Additional loop fixing false positives from previous loop
re_escape = re.compile(r":``\*``$")
for p in soup.body.find_all(string=re_escape):
if p.string and (p.parent.name == "p" or p.parent.name == "li"):
p.string.replace_with(
re.sub(re_escape, r":*", p.string))
# Drop parent link at the bottom of the page
for parent in soup.body.find_all("p", class_="familylinks"):