forked from LiveCarta/BookConverter
LAW-6649 | Add strong as tag with style
This commit is contained in:
@@ -134,7 +134,7 @@ class InlineStyleProcessor:
|
|||||||
self.inline_styled_tag.append(correspond_tag)
|
self.inline_styled_tag.append(correspond_tag)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def wrap_span_in_tag_to_save_style_attrs(initial_tag: Tag) -> Tag:
|
def wrap_tag_in_span_to_save_style_attrs(initial_tag: Tag) -> Tag:
|
||||||
"""Function designed to save style attrs that cannot be in tag.name -> span"""
|
"""Function designed to save style attrs that cannot be in tag.name -> span"""
|
||||||
# Compile a regex pattern to match tag names that can have certain style attributes
|
# Compile a regex pattern to match tag names that can have certain style attributes
|
||||||
dictkeys_pattern = re.compile("|".join(LiveCartaConfig.TAGS_TO_STYLE_ATTRS_CAN_BE_IN_TAG))
|
dictkeys_pattern = re.compile("|".join(LiveCartaConfig.TAGS_TO_STYLE_ATTRS_CAN_BE_IN_TAG))
|
||||||
@@ -183,7 +183,7 @@ class InlineStyleProcessor:
|
|||||||
|
|
||||||
def convert_initial_tag(self) -> Tag:
|
def convert_initial_tag(self) -> Tag:
|
||||||
self.change_attrs_with_corresponding_tags()
|
self.change_attrs_with_corresponding_tags()
|
||||||
self.inline_styled_tag = self.wrap_span_in_tag_to_save_style_attrs(self.inline_styled_tag)
|
self.inline_styled_tag = self.wrap_tag_in_span_to_save_style_attrs(self.inline_styled_tag)
|
||||||
return self.inline_styled_tag
|
return self.inline_styled_tag
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ class LiveCartaConfig:
|
|||||||
|
|
||||||
# Regular expression to match HTML tags that can have a style attribute
|
# Regular expression to match HTML tags that can have a style attribute
|
||||||
REGEX_TAGS_WITH_STYLE_ATTR = re.compile(
|
REGEX_TAGS_WITH_STYLE_ATTR = re.compile(
|
||||||
"(^div$)|(^p$)|(^span$)|(^code$)|(^kbd$)|(^var$)|(^li$)|(^ul$)|(^ol$)|(^td$)|(^th$)|(^h[1-9]$)"
|
"(^div$)|(^p$)|(^strong$)|(^span$)|(^code$)|(^kbd$)|(^var$)|(^li$)|(^ul$)|(^ol$)|(^td$)|(^th$)|(^h[1-9]$)"
|
||||||
)
|
)
|
||||||
|
|
||||||
# Dictionary mapping CSS style attribute-value pairs to HTML tags
|
# Dictionary mapping CSS style attribute-value pairs to HTML tags
|
||||||
@@ -31,7 +31,8 @@ class LiveCartaConfig:
|
|||||||
TAGS_TO_STYLE_ATTRS_CAN_BE_IN_TAG = {
|
TAGS_TO_STYLE_ATTRS_CAN_BE_IN_TAG = {
|
||||||
"^p$": ["text-align", "text-indent", "border-bottom", "border-top", "border-left", "border-right",
|
"^p$": ["text-align", "text-indent", "border-bottom", "border-top", "border-left", "border-right",
|
||||||
"background-color", "background"],
|
"background-color", "background"],
|
||||||
r"(^h[1-9]$)": ["list-style-type", "border-bottom", "border-top", "border-left", "border-right",
|
"^strong$": [],
|
||||||
|
"(^h[1-9]$)": ["list-style-type", "border-bottom", "border-top", "border-left", "border-right",
|
||||||
"background-color", "background"],
|
"background-color", "background"],
|
||||||
"^li$": ["text-align", "list-style-type", "value"],
|
"^li$": ["text-align", "list-style-type", "value"],
|
||||||
"^ul$": ["list-style-type"],
|
"^ul$": ["list-style-type"],
|
||||||
|
|||||||
Reference in New Issue
Block a user