From 5191b596f305f6e4a71642fe72f30882d32a41a4 Mon Sep 17 00:00:00 2001 From: Denis Kasak Date: Sun, 31 May 2020 14:23:19 +0200 Subject: [PATCH] Allow mixing of code and colours with other attrs when outputting HTML. --- matrix/colors.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/matrix/colors.py b/matrix/colors.py index 86f7faf..a1222f4 100644 --- a/matrix/colors.py +++ b/matrix/colors.py @@ -328,15 +328,21 @@ class Formatted(object): text = add_attribute(text, "code", True) attributes.pop("code") - elif attributes["fgcolor"] or attributes["bgcolor"]: + if attributes["fgcolor"] or attributes["bgcolor"]: text = add_color( text, attributes["fgcolor"], attributes["bgcolor"] ) - else: - for key, value in attributes.items(): - text = add_attribute(text, key, value) + + if attributes["fgcolor"]: + attributes.pop("fgcolor") + + if attributes["bgcolor"]: + attributes.pop("bgcolor") + + for key, value in attributes.items(): + text = add_attribute(text, key, value) return text