Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions pkg/channels/telegram.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,8 +470,11 @@ func extractCodeBlocks(text string) codeBlockMatch {
codes = append(codes, match[1])
}

i := 0
text = re.ReplaceAllStringFunc(text, func(m string) string {
return fmt.Sprintf("\x00CB%d\x00", len(codes)-1)
placeholder := fmt.Sprintf("\x00CB%d\x00", i)
i++
return placeholder
})

return codeBlockMatch{text: text, codes: codes}
Expand All @@ -491,8 +494,11 @@ func extractInlineCodes(text string) inlineCodeMatch {
codes = append(codes, match[1])
}

i := 0
text = re.ReplaceAllStringFunc(text, func(m string) string {
return fmt.Sprintf("\x00IC%d\x00", len(codes)-1)
placeholder := fmt.Sprintf("\x00IC%d\x00", i)
i++
return placeholder
})

return inlineCodeMatch{text: text, codes: codes}
Expand Down