diff --git a/src/message/mod.rs b/src/message/mod.rs index c039a01..48b149a 100644 --- a/src/message/mod.rs +++ b/src/message/mod.rs @@ -129,6 +129,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.autolink = true; options.extension.shortcodes = true; options.extension.strikethrough = true; options.render.hardbreaks = true; @@ -1235,6 +1236,33 @@ pub mod tests { assert_eq!(identity(&mc6), mc1); } + #[test] + fn test_markdown_autolink() { + let input = "http://example.com\n"; + let content = text_to_message_content(input.into()); + assert_eq!(content.body, input); + assert_eq!( + content.formatted.unwrap().body, + "
\n" + ); + + let input = "www.example.com\n"; + let content = text_to_message_content(input.into()); + assert_eq!(content.body, input); + assert_eq!( + content.formatted.unwrap().body, + "\n" + ); + + let input = "See docs (they're at https://iamb.chat)\n"; + let content = text_to_message_content(input.into()); + assert_eq!(content.body, input); + assert_eq!( + content.formatted.unwrap().body, + "See docs (they're at https://iamb.chat)
\n" + ); + } + #[test] fn test_markdown_message() { let input = "**bold**\n";