updated bold in render to use MarkdownV2 style

updated `Renderer::as_markdown` comment to explicitly say the output is in MarkdownV2 style
This commit is contained in:
YouKnow 2024-11-17 16:39:22 +03:30
parent 94db1757dc
commit 167f44442e
2 changed files with 6 additions and 6 deletions

View file

@ -140,7 +140,7 @@ impl<'a> Renderer<'a> {
self.format(&html::HTML) 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] #[must_use]
#[inline] #[inline]
pub fn as_markdown(&self) -> String { pub fn as_markdown(&self) -> String {
@ -164,7 +164,7 @@ mod test {
let render = Renderer::new(text, &entities); let render = Renderer::new(text, &entities);
assert_eq!(render.as_html(), "<b>Bold</b> <i>italic</i> <u>&lt;underline</u>_"); assert_eq!(render.as_html(), "<b>Bold</b> <i>italic</i> <u>&lt;underline</u>_");
assert_eq!(render.as_markdown(), "**Bold** _\ritalic_\r __\r<underline__\r\\_"); assert_eq!(render.as_markdown(), "*Bold* _\ritalic_\r __\r<underline__\r\\_");
} }
#[test] #[test]
@ -204,7 +204,7 @@ mod test {
let render = Renderer::new(text, &entities); let render = Renderer::new(text, &entities);
assert_eq!(render.as_html(), "Some <b>bold <i>both</b> italics</i>"); assert_eq!(render.as_html(), "Some <b>bold <i>both</b> italics</i>");
assert_eq!(render.as_markdown(), "Some **bold _\rboth** italics_\r"); assert_eq!(render.as_markdown(), "Some *bold _\rboth* italics_\r");
} }
#[test] #[test]
@ -243,7 +243,7 @@ mod test {
); );
assert_eq!( assert_eq!(
render.as_markdown(), render.as_markdown(),
"**Hi** _\rhow_\r __\rare__\r ~you~?\n**n****__\r~este~__\rd** [entities](https://t.me/) \ "*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\\!" [are](tg://user?id=1234567) `cool`\n>Im in a Blockquote\\!"
); );
} }

View file

@ -5,7 +5,7 @@ use crate::utils::markdown::ESCAPE_CHARS;
use super::{ComplexTag, Kind, Place, SimpleTag, Tag, TagWriter}; use super::{ComplexTag, Kind, Place, SimpleTag, Tag, TagWriter};
pub static MARKDOWN: TagWriter = TagWriter { pub static MARKDOWN: TagWriter = TagWriter {
bold: SimpleTag::new("**", "**"), bold: SimpleTag::new("*", "*"),
blockquote: SimpleTag::new(">", ""), blockquote: SimpleTag::new(">", ""),
italic: SimpleTag::new("_\r", "_\r"), italic: SimpleTag::new("_\r", "_\r"),
underline: SimpleTag::new("__\r", "__\r"), underline: SimpleTag::new("__\r", "__\r"),