fixed bug in textstyleparser

* handle multi-character emojis correctly

see #544
This commit is contained in:
Bernhard B
2024-06-17 20:33:26 +02:00
parent db4554d5ff
commit 05225a27ee
2 changed files with 9 additions and 2 deletions

View File

@@ -67,6 +67,7 @@ func ParseMarkdownMessage(message string) (string, []string) {
textFormat = Bold
textFormatBegin = i - numOfControlChars + additionalCharacterCount
textFormatLength = 0
additionalCharacterCount = 0
} else {
state = ItalicEnd
}

View File

@@ -60,7 +60,7 @@ func TestMulticharacterEmoji(t *testing.T) {
func TestMulticharacterEmojiWithBoldText(t *testing.T) {
message, signalCliFormatStrings := ParseMarkdownMessage("👋**abcdefg**")
expectMessageEqual(t, message, "👋abcdefg")
expectFormatStringsEqual(t, signalCliFormatStrings, []string{"2:8:BOLD"})
expectFormatStringsEqual(t, signalCliFormatStrings, []string{"2:7:BOLD"})
}
func TestMultipleMulticharacterEmoji(t *testing.T) {
@@ -72,7 +72,13 @@ func TestMultipleMulticharacterEmoji(t *testing.T) {
func TestMultipleMulticharacterEmojiWithBoldText(t *testing.T) {
message, signalCliFormatStrings := ParseMarkdownMessage("👋🏾**abcdefg**")
expectMessageEqual(t, message, "👋🏾abcdefg")
expectFormatStringsEqual(t, signalCliFormatStrings, []string{"4:9:BOLD"})
expectFormatStringsEqual(t, signalCliFormatStrings, []string{"4:7:BOLD"})
}
func TestMulticharacterEmojiWithBoldText2(t *testing.T) {
message, signalCliFormatStrings := ParseMarkdownMessage("Test 👦🏿 via **signal** API")
expectMessageEqual(t, message, "Test 👦🏿 via signal API")
expectFormatStringsEqual(t, signalCliFormatStrings, []string{"14:6:BOLD"})
}
func TestSpoiler(t *testing.T) {