From 167f44442ef15d947552653cbd739813eebd96a9 Mon Sep 17 00:00:00 2001 From: YouKnow Date: Sun, 17 Nov 2024 16:39:22 +0330 Subject: [PATCH] updated bold in render to use MarkdownV2 style updated `Renderer::as_markdown` comment to explicitly say the output is in MarkdownV2 style --- crates/teloxide/src/utils/render.rs | 10 +++++----- crates/teloxide/src/utils/render/markdown.rs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crates/teloxide/src/utils/render.rs b/crates/teloxide/src/utils/render.rs index a609b233..f1ea6baa 100644 --- a/crates/teloxide/src/utils/render.rs +++ b/crates/teloxide/src/utils/render.rs @@ -140,7 +140,7 @@ impl<'a> Renderer<'a> { self.format(&html::HTML) } - /// Renders and returns the text as a **Markdown-formatted** string. + /// Renders and returns the text as a **MarkdownV2-formatted** string. #[must_use] #[inline] pub fn as_markdown(&self) -> String { @@ -164,7 +164,7 @@ mod test { let render = Renderer::new(text, &entities); assert_eq!(render.as_html(), "Bold italic <underline_"); - assert_eq!(render.as_markdown(), "**Bold** _\ritalic_\r __\rbold both italics"); - assert_eq!(render.as_markdown(), "Some **bold _\rboth** italics_\r"); + assert_eq!(render.as_markdown(), "Some *bold _\rboth* italics_\r"); } #[test] @@ -243,8 +243,8 @@ mod test { ); assert_eq!( render.as_markdown(), - "**Hi** _\rhow_\r __\rare__\r ~you~?\n**n****__\r~este~__\rd** [entities](https://t.me/) \ - [are](tg://user?id=1234567) `cool`\n>Im in a Blockquote\\!" + "*Hi* _\rhow_\r __\rare__\r ~you~?\n*n**__\r~este~__\rd* [entities](https://t.me/) \ + [are](tg://user?id=1234567) `cool`\n>Im in a Blockquote\\!" ); } } diff --git a/crates/teloxide/src/utils/render/markdown.rs b/crates/teloxide/src/utils/render/markdown.rs index 822274fb..4a046ce9 100644 --- a/crates/teloxide/src/utils/render/markdown.rs +++ b/crates/teloxide/src/utils/render/markdown.rs @@ -5,7 +5,7 @@ use crate::utils::markdown::ESCAPE_CHARS; use super::{ComplexTag, Kind, Place, SimpleTag, Tag, TagWriter}; pub static MARKDOWN: TagWriter = TagWriter { - bold: SimpleTag::new("**", "**"), + bold: SimpleTag::new("*", "*"), blockquote: SimpleTag::new(">", ""), italic: SimpleTag::new("_\r", "_\r"), underline: SimpleTag::new("__\r", "__\r"),