]> git.giacomolli.uk - onechat/blobdiff - telegram_markdown.go
Check spacing between Go statement blocks
[onechat] / telegram_markdown.go
index 8738bcdb38f57e673bd195e11d630505bbee0074..712cf2802c43a5b7c2c054048ca783ac995d75a3 100644 (file)
@@ -31,6 +31,7 @@ var (
 // change the rest of the reply.
 func telegramMarkdownEntities(markdown string) (string, []TelegramEntity) {
        var out TelegramMarkdownText
 // 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 {
        lines := strings.Split(markdown, "\n")
        for index := 0; index < len(lines); index++ {
                if index > 0 {
@@ -144,6 +145,7 @@ type TelegramMarkdownText struct {
 // add appends text.
 func (m *TelegramMarkdownText) add(text string) {
        m.text.WriteString(text)
 // add appends text.
 func (m *TelegramMarkdownText) add(text string) {
        m.text.WriteString(text)
+
        m.units += telegramUTF16Units(text)
 }
 
        m.units += telegramUTF16Units(text)
 }
 
@@ -164,6 +166,7 @@ func (m *TelegramMarkdownText) inline(line string) {
        for index < len(line) {
                if line[index] == '\\' && index+1 < len(line) && strings.IndexByte(telegramMarkdownPunctuation, line[index+1]) >= 0 {
                        m.add(line[plain:index])
        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
 
                        plain = index + 1
                        index += 2
 
@@ -177,6 +180,7 @@ func (m *TelegramMarkdownText) inline(line string) {
                }
 
                m.add(line[plain:index])
                }
 
                m.add(line[plain:index])
+
                start := m.units
                if span.kind == "code" {
                        m.add(span.content)
                start := m.units
                if span.kind == "code" {
                        m.add(span.content)
@@ -256,6 +260,7 @@ func telegramHeadingText(line string) string {
 // close runs to the end, as in Markdown.
 func telegramRewriteProse(markdown string, rewrite func(string) string) string {
        var out strings.Builder
 // 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 {
        lines := strings.Split(markdown, "\n")
        for index := 0; index < len(lines); index++ {
                if index > 0 {
@@ -266,6 +271,7 @@ func telegramRewriteProse(markdown string, rewrite func(string) string) string {
                _, fence := telegramCodeFence(line)
                if fence == "" {
                        telegramRewriteLineProse(&out, line, rewrite)
                _, fence := telegramCodeFence(line)
                if fence == "" {
                        telegramRewriteLineProse(&out, line, rewrite)
+
                        continue
                }
 
                        continue
                }
 
@@ -275,6 +281,7 @@ func telegramRewriteProse(markdown string, rewrite func(string) string) string {
                }
 
                out.WriteString(strings.Join(lines[index:end+1], "\n"))
                }
 
                out.WriteString(strings.Join(lines[index:end+1], "\n"))
+
                index = end
        }
 
                index = end
        }
 
@@ -302,6 +309,7 @@ func telegramRewriteLineProse(out *strings.Builder, line string, rewrite func(st
 
                        out.WriteString(rewrite(line[prose:index]))
                        out.WriteString(line[index:end])
 
                        out.WriteString(rewrite(line[prose:index]))
                        out.WriteString(line[index:end])
+
                        index = end
                        prose = end
 
                        index = end
                        prose = end