// change the rest of the reply.
func telegramMarkdownEntities(markdown string) (string, []TelegramEntity) {
var out TelegramMarkdownText
+
lines := strings.Split(markdown, "\n")
for index := 0; index < len(lines); index++ {
if index > 0 {
// add appends text.
func (m *TelegramMarkdownText) add(text string) {
m.text.WriteString(text)
+
m.units += telegramUTF16Units(text)
}
for index < len(line) {
if line[index] == '\\' && index+1 < len(line) && strings.IndexByte(telegramMarkdownPunctuation, line[index+1]) >= 0 {
m.add(line[plain:index])
+
plain = index + 1
index += 2
}
m.add(line[plain:index])
+
start := m.units
if span.kind == "code" {
m.add(span.content)
// close runs to the end, as in Markdown.
func telegramRewriteProse(markdown string, rewrite func(string) string) string {
var out strings.Builder
+
lines := strings.Split(markdown, "\n")
for index := 0; index < len(lines); index++ {
if index > 0 {
_, fence := telegramCodeFence(line)
if fence == "" {
telegramRewriteLineProse(&out, line, rewrite)
+
continue
}
}
out.WriteString(strings.Join(lines[index:end+1], "\n"))
+
index = end
}
out.WriteString(rewrite(line[prose:index]))
out.WriteString(line[index:end])
+
index = end
prose = end