diff --git a/src/utils/textstyleparser.go b/src/utils/textstyleparser.go index 0b50a77..e368bba 100644 --- a/src/utils/textstyleparser.go +++ b/src/utils/textstyleparser.go @@ -67,6 +67,7 @@ func ParseMarkdownMessage(message string) (string, []string) { textFormat = Bold textFormatBegin = i - numOfControlChars + additionalCharacterCount textFormatLength = 0 + additionalCharacterCount = 0 } else { state = ItalicEnd } diff --git a/src/utils/textstyleparser_test.go b/src/utils/textstyleparser_test.go index 697b20a..9aceb39 100644 --- a/src/utils/textstyleparser_test.go +++ b/src/utils/textstyleparser_test.go @@ -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) {