LAW-6649 | Add strong as tag with style

This commit is contained in:
Kibzik
2023-04-20 17:07:24 +03:00
parent 11bca250ab
commit c636413b05
2 changed files with 5 additions and 4 deletions

View File

@@ -134,7 +134,7 @@ class InlineStyleProcessor:
self.inline_styled_tag.append(correspond_tag)
@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"""
# 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))
@@ -183,7 +183,7 @@ class InlineStyleProcessor:
def convert_initial_tag(self) -> Tag:
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

View File

@@ -9,7 +9,7 @@ class LiveCartaConfig:
# Regular expression to match HTML tags that can have a style attribute
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
@@ -31,7 +31,8 @@ class LiveCartaConfig:
TAGS_TO_STYLE_ATTRS_CAN_BE_IN_TAG = {
"^p$": ["text-align", "text-indent", "border-bottom", "border-top", "border-left", "border-right",
"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"],
"^li$": ["text-align", "list-style-type", "value"],
"^ul$": ["list-style-type"],