use discord_markdown::{convertor::*, parser::{parse, parse_with_md_hyperlinks}};
#[test]
fn convertor_basic() {
assert_eq!(to_html(
parse("foo > _foo bar_ *foo bar* **foo bar** __foo bar__\n> `foo bar` ``foo bar`` ||foo bar||\n> \n> test"),
), "foo > foo bar foo bar foo bar foo bar
foo bar foo bar foo bar
test
");
}
#[test]
fn convertor_nested() {
assert_eq!(to_html(
parse("foo _> foo_ _bar\n> foo_ ||***__~~foo\nbar~~__***||"),
), "foo > foo bar
foo
foo
bar");
}
#[test]
fn convertor_regex() {
assert_eq!(to_html_with_callbacks(
parse("<#1234567890><@&1234567890><@1234567890><@!1234567890><:foo:1234567890>"),
|filename| (filename.to_string(), None),
|id| (id.to_string(), None),
|x| (x.to_string(), Some(String::from("#ff00ff"))),
|id| (id.to_string(), None),
), "#1234567890@1234567890
@1234567890@1234567890");
}
#[test]
fn convertor_hyperlinks() {
assert_eq!(to_html(
parse(" https://example.com [foo](https://example.com/) [foo]()"),
), "https://www.example.com/ https://example.com [foo](https://example.com/) [foo](http://example.com)");
assert_eq!(to_html(
parse_with_md_hyperlinks(" https://example.com [foo](https://example.com/) [foo]()"),
), "https://www.example.com/ https://example.com foo foo");
}