mirror of
https://github.com/aljazceru/signal-cli-rest-api.git
synced 2026-01-19 23:04:34 +01:00
fixed bug in textstyleparser
* handle multi-character emojis correctly see #544
This commit is contained in:
@@ -67,6 +67,7 @@ func ParseMarkdownMessage(message string) (string, []string) {
|
||||
textFormat = Bold
|
||||
textFormatBegin = i - numOfControlChars + additionalCharacterCount
|
||||
textFormatLength = 0
|
||||
additionalCharacterCount = 0
|
||||
} else {
|
||||
state = ItalicEnd
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user