diff --git a/resources/lib/twitch_addon/addon/utils.py b/resources/lib/twitch_addon/addon/utils.py index 85431754..7273b606 100644 --- a/resources/lib/twitch_addon/addon/utils.py +++ b/resources/lib/twitch_addon/addon/utils.py @@ -791,18 +791,20 @@ def convert_duration(duration): u'\U0000FE00-\U0000FE0F' # variation selectors (emoji presentation) u'\U0000200D' # zero width joiner (emoji sequences) u'\U000020E3' # combining enclosing keycap - u']' + u']+' ) def strip_tofu(text): - # Remove non-renderable emoji/symbols (would show as tofu boxes). Only collapse - # horizontal double spaces -- line breaks are kept (matters for plots). + # Replace non-renderable emoji/symbols (would show as tofu boxes) with a single space -- + # dropping them glues words together ("WEEKENDType" -> "WEEKENDType"). Only + # horizontal whitespace is collapsed, line breaks are kept (matters for plots). if not isinstance(text, str): return text - text = _TOFU_RE.sub(u'', text) + text = _TOFU_RE.sub(u' ', text) text = re.sub(u'[ \\t]{2,}', u' ', text) - return text + text = re.sub(u'[ \\t]*\\n[ \\t]*', u'\n', text) + return text.strip() class TitleBuilder(object):