diff options
author | Trygve Aaberge <trygveaa@gmail.com> | 2023-09-29 22:17:41 +0200 |
---|---|---|
committer | Trygve Aaberge <trygveaa@gmail.com> | 2023-09-29 22:38:15 +0200 |
commit | ddac981011d945c77cd95c86f46f91e51b4761d7 (patch) | |
tree | 75cc9423b0ea248a7aaa511dbc0b2fbf469ce415 | |
parent | 3e7c754837afc7df87143f69f74a8130b033e812 (diff) | |
download | wee-slack-ddac981011d945c77cd95c86f46f91e51b4761d7.tar.gz |
Fix rendering of text styles for certain messages
This fixes a regression in commit 74da303 which caused certain messages
to include the bold/italic/strikethrough characters (but not the color
attributes) even though the style should not be active.
-rw-r--r-- | wee_slack.py | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/wee_slack.py b/wee_slack.py index 2825114..d99d2a7 100644 --- a/wee_slack.py +++ b/wee_slack.py @@ -4729,35 +4729,29 @@ def unfurl_rich_text_section(block): colors_remove = [] characters_apply = [] characters_remove = [] - if element.get("style", {}).get("bold") != prev_element.get("style", {}).get( - "bold" - ): - if element.get("style", {}).get("bold"): + prev_style = prev_element.get("style", {}) + cur_style = element.get("style", {}) + if cur_style.get("bold", False) != prev_style.get("bold", False): + if cur_style.get("bold"): colors_apply.append(w.color(config.render_bold_as)) characters_apply.append("*") else: colors_remove.append(w.color("-" + config.render_bold_as)) characters_remove.append("*") - if element.get("style", {}).get("italic") != prev_element.get("style", {}).get( - "italic" - ): - if element.get("style", {}).get("italic"): + if cur_style.get("italic", False) != prev_style.get("italic", False): + if cur_style.get("italic"): colors_apply.append(w.color(config.render_italic_as)) characters_apply.append("_") else: colors_remove.append(w.color("-" + config.render_italic_as)) characters_remove.append("_") - if element.get("style", {}).get("strike") != prev_element.get("style", {}).get( - "strike" - ): - if element.get("style", {}).get("strike"): + if cur_style.get("strike", False) != prev_style.get("strike", False): + if cur_style.get("strike"): characters_apply.append("~") else: characters_remove.append("~") - if element.get("style", {}).get("code") != prev_element.get("style", {}).get( - "code" - ): - if element.get("style", {}).get("code"): + if cur_style.get("code", False) != prev_style.get("code", False): + if cur_style.get("code"): characters_apply.append("`") else: characters_remove.append("`") |