Add style to <code> tags without

This commit is contained in:
Kiryl
2022-06-23 18:48:50 +03:00
parent ffa6e90ad5
commit 66e03c98e3

View File

@@ -209,7 +209,7 @@ def _preprocess_code_tags(chapter_tag: BeautifulSoup):
"""
Function
- transform <code>, <kdb>, <var> tags into span
- add code style to this tags
- add code style to this tags (if there is no)
Parameters
----------
chapter_tag: Tag, soup object
@@ -222,10 +222,10 @@ def _preprocess_code_tags(chapter_tag: BeautifulSoup):
for code in chapter_tag.find_all(re.compile("code|kbd|var")):
if not code.parent.name == "pre":
code.name = "span"
if not code.attrs.get("style"):
code.attrs["style"] = "font-size: 14px; font-family: courier new,courier,monospace;"
continue
# if tag isn"t in pre and doesn"t have style
if not code.attrs.get("style"):
code.attrs["style"] = "font-size: 14px; font-family: courier new,courier,monospace;"
def _preprocess_pre_tags(chapter_tag: BeautifulSoup):