Skip to content

Commit

Permalink
themes/boxes: Add msg_heading style to themes & render message headings.
Browse files Browse the repository at this point in the history
New test cases added under test_soup2markup.

Fixes zulip#1095.
  • Loading branch information
mounilKshah authored and Dishti-Oberai committed Feb 2, 2022
1 parent 7914a41 commit 9e14bbe
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 0 deletions.
6 changes: 6 additions & 0 deletions tests/ui/test_ui_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1358,6 +1358,12 @@ def test_private_message_to_self(self, mocker):
[("msg_mention", "@Bob Smith")],
id="user-mention",
),
case("<h1>heading1</h1>", [("msg_heading", "heading1")], id="h1"),
case("<h2>heading2</h2>", [("msg_heading", "heading2")], id="h2"),
case("<h3>heading3</h3>", [("msg_heading", "heading3")], id="h3"),
case("<h4>heading4</h4>", [("msg_heading", "heading4")], id="h4"),
case("<h5>heading5</h5>", [("msg_heading", "heading5")], id="h5"),
case("<h6>heading6</h6>", [("msg_heading", "heading6")], id="h6"),
case(
'<span class="user-group-mention">@A Group',
[("msg_mention", "@A Group")],
Expand Down
1 change: 1 addition & 0 deletions zulipterminal/config/themes.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
'msg_emoji' : 'bold',
'reaction' : 'bold',
'reaction_mine' : 'standout',
'msg_heading' : 'bold',
'msg_math' : 'standout',
'msg_mention' : 'bold',
'msg_link' : '',
Expand Down
1 change: 1 addition & 0 deletions zulipterminal/themes/gruvbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class GruvBoxColor(Enum):
'msg_emoji' : (Color.NEUTRAL_PURPLE, Color.DARK0_HARD),
'reaction' : (Color.NEUTRAL_PURPLE__BOLD, Color.DARK0_HARD),
'reaction_mine' : (Color.DARK0_HARD, Color.NEUTRAL_PURPLE),
'msg_heading' : (Color.DARK0_HARD__BOLD, Color.BRIGHT_GREEN),
'msg_math' : (Color.DARK0_HARD, Color.GRAY_244),
'msg_mention' : (Color.BRIGHT_RED__BOLD, Color.DARK0_HARD),
'msg_link' : (Color.BRIGHT_BLUE, Color.DARK0_HARD),
Expand Down
1 change: 1 addition & 0 deletions zulipterminal/themes/zt_blue.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'msg_emoji' : (Color.DARK_MAGENTA, Color.LIGHT_BLUE),
'reaction' : (Color.DARK_MAGENTA__BOLD, Color.LIGHT_BLUE),
'reaction_mine' : (Color.LIGHT_BLUE, Color.DARK_MAGENTA),
'msg_heading' : (Color.WHITE__BOLD, Color.BLACK),
'msg_math' : (Color.LIGHT_GRAY, Color.DARK_GRAY),
'msg_mention' : (Color.LIGHT_RED__BOLD, Color.LIGHT_BLUE),
'msg_link' : (Color.DARK_BLUE, Color.LIGHT_GRAY),
Expand Down
1 change: 1 addition & 0 deletions zulipterminal/themes/zt_dark.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'msg_emoji' : (Color.LIGHT_MAGENTA, Color.BLACK),
'reaction' : (Color.LIGHT_MAGENTA__BOLD, Color.BLACK),
'reaction_mine' : (Color.BLACK, Color.LIGHT_MAGENTA),
'msg_heading' : (Color.LIGHT_CYAN__BOLD, Color.DARK_MAGENTA),
'msg_math' : (Color.LIGHT_GRAY, Color.DARK_GRAY),
'msg_mention' : (Color.LIGHT_RED__BOLD, Color.BLACK),
'msg_link' : (Color.LIGHT_BLUE, Color.BLACK),
Expand Down
1 change: 1 addition & 0 deletions zulipterminal/themes/zt_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
'msg_emoji' : (Color.LIGHT_MAGENTA, Color.WHITE),
'reaction' : (Color.LIGHT_MAGENTA__BOLD, Color.WHITE),
'reaction_mine' : (Color.WHITE, Color.LIGHT_MAGENTA),
'msg_heading' : (Color.WHITE__BOLD, Color.DARK_RED),
'msg_math' : (Color.DARK_GRAY, Color.LIGHT_GRAY),
'msg_mention' : (Color.LIGHT_RED__BOLD, Color.WHITE),
'msg_link' : (Color.DARK_BLUE, Color.WHITE),
Expand Down
3 changes: 3 additions & 0 deletions zulipterminal/ui_tools/boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,6 +1236,9 @@ def soup2markup(
text = unrendered_tags[tag]
if text:
markup.append(unrendered_template.format(text))
elif tag in ("h1", "h2", "h3", "h4", "h5", "h6"):
# HEADING STYLE (h1 to h6)
markup.append(("msg_heading", tag_text))
elif tag in ("p", "del"):
# PARAGRAPH, STRIKE-THROUGH
markup.extend(cls.soup2markup(element, metadata)[0])
Expand Down

0 comments on commit 9e14bbe

Please sign in to comment.