Skip to content

Commit

Permalink
ToMarkdown: fix escaping of '`'
Browse files Browse the repository at this point in the history
  • Loading branch information
wiz0u committed Jul 20, 2024
1 parent dd9b6a8 commit 3eb6353
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Telegram.Bot/Extensions/FormatExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,12 @@ public static string ToMarkdown(string message, MessageEntity[]? entities)
}
switch (lastCh = sb[i])
{
case '_': case '*': case '~': case '`': case '#': case '+': case '-': case '=': case '.': case '!':
case '_': case '*': case '~': case '#': case '+': case '-': case '=': case '.': case '!':
case '[': case ']': case '(': case ')': case '{': case '}': case '>': case '|': case '\\':
if (closings.Count == 0 || closings[0].md[0] != '`')
sb.Insert(i++, '\\');
if (closings.Count != 0 && closings[0].md[0] == '`') break;
goto case '`';
case '`':
sb.Insert(i++, '\\');
break;
}
}
Expand Down

0 comments on commit 3eb6353

Please sign in to comment.