Skip to content

`tbot::markup`

Artem Starikov requested to merge markup into master

The tbot::markup module makes it easier to work with markup correctly. At its top-level, it provides basic formatters like bold, italic and link. These formatters are then passed to a markup formatter html or markdown_v2, which may be displayed, and so converted to a string:

use tbot::markup::{bold, italic, markdown_v2};
let message = markdown_v2(bold((
    "*This is <b>old, ",
    italic("and this is bold and italic!"),
))).to_string();
println!("{}", message); // *\*This is <b\>old, _and this is bold and italic\!_*

Being planned for v0.5.2, this feature does not integrate with parameters::Text, because integration would require support for owned values, which is not here yet and will be a breaking change. Once tbot allows owned values, the markup API should integrate with parameters::Text to allow this:

bot.send_message(id, markdown_v2((..)).call().await;

Closes #25 (closed).

Merge request reports