colors: Add markdown style italics support.

This commit is contained in:
poljar (Damir Jelić) 2018-03-06 22:57:57 +01:00
parent 16a2215cfc
commit 207fb44bdc

View file

@ -73,6 +73,33 @@ class Formatted():
attributes["bold"] = not attributes["bold"]
i = i + 1
# Markdown bold
elif line[i] == "*":
if attributes["italic"] and not line[i-1].isspace():
if text:
substrings.append(FormattedString(
text, attributes.copy()))
text = ""
attributes["italic"] = not attributes["italic"]
i = i + 1
continue
elif attributes["italic"] and line[i-1].isspace():
text = text + line[i]
i = i + 1
continue
elif i+1 > len(line) or line[i+1].isspace():
text = text + line[i]
i = i + 1
continue
if text:
substrings.append(FormattedString(text, attributes.copy()))
text = ""
attributes["italic"] = not attributes["italic"]
i = i + 1
# Color
elif line[i] == "\x03":
if text: