mirror of
https://github.com/youwen5/iamb.git
synced 2025-06-19 21:29:52 -07:00
Enable autolinking when rendering Markdown (#226)
This commit is contained in:
parent
d3b717d1be
commit
db9cb92737
1 changed files with 28 additions and 0 deletions
|
@ -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,
|
||||
"<p><a href=\"http://example.com\">http://example.com</a></p>\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,
|
||||
"<p><a href=\"http://www.example.com\">www.example.com</a></p>\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,
|
||||
"<p>See docs (they're at <a href=\"https://iamb.chat\">https://iamb.chat</a>)</p>\n"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_markdown_message() {
|
||||
let input = "**bold**\n";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue