Do not escape sequences inside of code blocks

Reviewed-by: Goncharov, Artem <artem.goncharov@t-systems.com>
Co-authored-by: gtema <artem.goncharov@gmail.com>
Co-committed-by: gtema <artem.goncharov@gmail.com>
This commit is contained in:
2022-11-10 15:42:20 +00:00
committed by zuul
parent 3336ba8df7
commit 5dd6d4fb44

View File

@ -312,14 +312,11 @@ class OTCDocConvertor:
escape_asterisk_re = r"\((\*)[\.,]"
for p in soup.body.find_all(string=re.compile(escape_asterisk_re)):
if p.string:
if p.string and p.parent.name not in ["b", "strong", "pre"]:
curr = p.string
part = re.search(escape_asterisk_re, curr)
# If we have `<b> all files (*.*)</b>` - no need to escape
if (
len(part.groups()) > 0
and p.parent.name not in ["b", "strong"]
):
if len(part.groups()) > 0:
logging.debug(
"Found asterisks to escape: %s", part.group(1)
)
@ -351,16 +348,13 @@ class OTCDocConvertor:
]
for to_rawize in rawize_strings:
for p in soup.body.find_all(string=re.compile(to_rawize)):
if p.string:
if p.string and p.parent.name not in ["b", "strong", "pre"]:
curr = p.string
part = re.search(to_rawize, curr)
# We should not escape inside of bold - this is wrong
if (
len(part.groups()) > 0
and p.parent.name not in ["b", "strong"]
):
if len(part.groups()) > 0:
logging.debug(
"Found element to rawize: %s", part.group(1)
"Found element to rawize %s", part.group(1)
)
new = curr.replace(
part.group(1), f"<code>{part.group(1)}</code>"
@ -372,7 +366,6 @@ class OTCDocConvertor:
logging.error(
"Cannot find string for rawization anymore"
)
logging.error(f"String with star: {p}")
# Drop parent link at the bottom of the page
for parent in soup.body.find_all("p", class_="familylinks"):