Support sending and completing Emoji shortcodes in the message bar (#100)

This commit is contained in:
Ulyssa 2023-05-24 21:14:13 -07:00
parent 529073f4d4
commit 8d22b83d85
No known key found for this signature in database
GPG key ID: 1B3965A3D18B9B64
5 changed files with 83 additions and 5 deletions

View file

@ -97,6 +97,7 @@ const TIME_GUTTER_EMPTY_SPAN: Span<'static> = span_static(TIME_GUTTER_EMPTY);
fn text_to_message_content(input: String) -> TextMessageEventContent {
let mut options = ComrakOptions::default();
options.extension.shortcodes = true;
options.render.hardbreaks = true;
let html = markdown_to_html(input.as_str(), &options);
@ -1013,6 +1014,11 @@ pub mod tests {
"<pre><code class=\"language-rust\">const A: usize = 1;\n</code></pre>\n"
);
let input = ":heart:\n";
let content = text_to_message_content(input.into());
assert_eq!(content.body, input);
assert_eq!(content.formatted.unwrap().body, "<p>\u{2764}\u{FE0F}</p>\n");
let input = "para 1\n\npara 2\n";
let content = text_to_message_content(input.into());
assert_eq!(content.body, input);