forked from LiveCarta/BookConverter
Add style to <code> tags without
This commit is contained in:
@@ -209,7 +209,7 @@ def _preprocess_code_tags(chapter_tag: BeautifulSoup):
|
|||||||
"""
|
"""
|
||||||
Function
|
Function
|
||||||
- transform <code>, <kdb>, <var> tags into span
|
- transform <code>, <kdb>, <var> tags into span
|
||||||
- add code style to this tags
|
- add code style to this tags (if there is no)
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
chapter_tag: Tag, soup object
|
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")):
|
for code in chapter_tag.find_all(re.compile("code|kbd|var")):
|
||||||
if not code.parent.name == "pre":
|
if not code.parent.name == "pre":
|
||||||
code.name = "span"
|
code.name = "span"
|
||||||
continue
|
|
||||||
# if tag isn"t in pre and doesn"t have style
|
|
||||||
if not code.attrs.get("style"):
|
if not code.attrs.get("style"):
|
||||||
code.attrs["style"] = "font-size: 14px; font-family: courier new,courier,monospace;"
|
code.attrs["style"] = "font-size: 14px; font-family: courier new,courier,monospace;"
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def _preprocess_pre_tags(chapter_tag: BeautifulSoup):
|
def _preprocess_pre_tags(chapter_tag: BeautifulSoup):
|
||||||
|
|||||||
Reference in New Issue
Block a user