Commit db9cb92737
Unregistered key
Layout: unified · split
src/message/mod.rs +28
| @@ -129,6 +129,7 @@ const TIME_GUTTER_EMPTY_SPAN: Span<'static> = span_static(TIME_GUTTER_EMPTY); | |||
| 129 | 129 | ||
| 130 | fn text_to_message_content(input: String) -> TextMessageEventContent { | 130 | fn text_to_message_content(input: String) -> TextMessageEventContent { |
| 131 | let mut options = ComrakOptions::default(); | 131 | let mut options = ComrakOptions::default(); |
| 132 | options.extension.autolink = true; | ||
| 132 | options.extension.shortcodes = true; | 133 | options.extension.shortcodes = true; |
| 133 | options.extension.strikethrough = true; | 134 | options.extension.strikethrough = true; |
| 134 | options.render.hardbreaks = true; | 135 | options.render.hardbreaks = true; |
| @@ -1235,6 +1236,33 @@ pub mod tests { | |||
| 1235 | assert_eq!(identity(&mc6), mc1); | 1236 | assert_eq!(identity(&mc6), mc1); |
| 1236 | } | 1237 | } |
| 1237 | 1238 | ||
| 1239 | #[test] | ||
| 1240 | fn test_markdown_autolink() { | ||
| 1241 | let input = "http://example.com\n"; | ||
| 1242 | let content = text_to_message_content(input.into()); | ||
| 1243 | assert_eq!(content.body, input); | ||
| 1244 | assert_eq!( | ||
| 1245 | content.formatted.unwrap().body, | ||
| 1246 | "<p><a href=\"http://example.com\">http://example.com</a></p>\n" | ||
| 1247 | ); | ||
| 1248 | |||
| 1249 | let input = "www.example.com\n"; | ||
| 1250 | let content = text_to_message_content(input.into()); | ||
| 1251 | assert_eq!(content.body, input); | ||
| 1252 | assert_eq!( | ||
| 1253 | content.formatted.unwrap().body, | ||
| 1254 | "<p><a href=\"http://www.example.com\">www.example.com</a></p>\n" | ||
| 1255 | ); | ||
| 1256 | |||
| 1257 | let input = "See docs (they're at https://iamb.chat)\n"; | ||
| 1258 | let content = text_to_message_content(input.into()); | ||
| 1259 | assert_eq!(content.body, input); | ||
| 1260 | assert_eq!( | ||
| 1261 | content.formatted.unwrap().body, | ||
| 1262 | "<p>See docs (they're at <a href=\"https://iamb.chat\">https://iamb.chat</a>)</p>\n" | ||
| 1263 | ); | ||
| 1264 | } | ||
| 1265 | |||
| 1238 | #[test] | 1266 | #[test] |
| 1239 | fn test_markdown_message() { | 1267 | fn test_markdown_message() { |
| 1240 | let input = "**bold**\n"; | 1268 | let input = "**bold**\n"; |