From cbef2d00b12ea4b72b382508ff9b044e96f44f4a Mon Sep 17 00:00:00 2001 From: Trygve Aaberge Date: Sun, 15 Oct 2023 12:48:47 +0200 Subject: Apply code block styles first It looks better to have the `` characters around the other styles when there's styling inside code blocks. It makes it look a bit worse when theres code blocks inside styled text though. It should really remember the order the styles are opened to close them in the correct order. --- slack/slack_message.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'slack') diff --git a/slack/slack_message.py b/slack/slack_message.py index 39d6e57..4301560 100644 --- a/slack/slack_message.py +++ b/slack/slack_message.py @@ -926,6 +926,11 @@ class SlackMessage: characters_remove: List[str] = [] prev_style = prev_element.get("style", {}) cur_style = element.get("style", {}) + if cur_style.get("code", False) != prev_style.get("code", False): + if cur_style.get("code"): + characters_apply.append("`") + else: + characters_remove.append("`") if cur_style.get("bold", False) != prev_style.get("bold", False): if cur_style.get("bold"): colors_apply.append(weechat.color("bold")) @@ -945,11 +950,6 @@ class SlackMessage: characters_apply.append("~") else: characters_remove.append("~") - if cur_style.get("code", False) != prev_style.get("code", False): - if cur_style.get("code"): - characters_apply.append("`") - else: - characters_remove.append("`") prepend = "".join( characters_remove[::-1] -- cgit