From f2807779aad0dd0d463d396d7ae7e2de48a83c3b Mon Sep 17 00:00:00 2001 From: Bohdan Horbeshko Date: Thu, 16 Nov 2023 08:44:26 -0500 Subject: [PATCH] Fix ending braces for PreCode --- telegram/formatter/formatter.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/telegram/formatter/formatter.go b/telegram/formatter/formatter.go index 6da8256..a8c94a0 100644 --- a/telegram/formatter/formatter.go +++ b/telegram/formatter/formatter.go @@ -40,8 +40,8 @@ var italicRunes = []rune("_") var strikeRunesMarkdown = []rune("~~") var strikeRunesXEP0393 = []rune("~") var codeRunes = []rune("`") -var preRuneStart = []rune("```\n") -var preRuneEnd = []rune("\n```") +var preRunesStart = []rune("```\n") +var preRunesEnd = []rune("\n```") var quoteRunes = []rune("> ") var newlineRunes = []rune("\n") var doubleNewlineRunes = []rune("\n\n") @@ -270,10 +270,10 @@ func entityToMarkdown(entity *client.TextEntity, doubledRunes []rune, markupMode case client.TypeTextEntityTypeCode: return markupBraces(entity, codeRunes, codeRunes) case client.TypeTextEntityTypePre: - return markupBraces(entity, preRuneStart, preRuneEnd) + return markupBraces(entity, preRunesStart, preRunesEnd) case client.TypeTextEntityTypePreCode: preCode, _ := entity.Type.(*client.TextEntityTypePreCode) - return markupBraces(entity, []rune("\n```"+preCode.Language+"\n"), codeRunes) + return markupBraces(entity, []rune("\n```"+preCode.Language+"\n"), preRunesEnd) case client.TypeTextEntityTypeBlockQuote: return quotePrependNewlines(entity, doubledRunes, MarkupModeMarkdown) case client.TypeTextEntityTypeTextUrl: @@ -300,10 +300,10 @@ func entityToXEP0393(entity *client.TextEntity, doubledRunes []rune, markupMode case client.TypeTextEntityTypeCode: return markupBraces(entity, codeRunes, codeRunes) case client.TypeTextEntityTypePre: - return markupBraces(entity, preRuneStart, preRuneEnd) + return markupBraces(entity, preRunesStart, preRunesEnd) case client.TypeTextEntityTypePreCode: preCode, _ := entity.Type.(*client.TextEntityTypePreCode) - return markupBraces(entity, []rune("\n```"+preCode.Language+"\n"), codeRunes) + return markupBraces(entity, []rune("\n```"+preCode.Language+"\n"), preRunesEnd) case client.TypeTextEntityTypeBlockQuote: return quotePrependNewlines(entity, doubledRunes, MarkupModeXEP0393) case client.TypeTextEntityTypeTextUrl: