extern crate html2md; use html2md::parse_html; use pretty_assertions::assert_eq; #[test] fn test_dumb() { let md = parse_html("

CARTHAPHILUS

"); assert_eq!(md, "CARTHAPHILUS") } #[test] fn test_anchor() { let md = parse_html(r#"

APOSIMZ

"#); assert_eq!(md, "[APOSIMZ](http://ya.ru)") } #[test] fn test_anchor2() { let md = parse_html(r#"

APOSIMZSIDONIA

"#); assert_eq!(md, "[APOSIMZ](http://ya.ru)[SIDONIA](http://yandex.ru)") } #[test] fn test_anchor3() { let md = parse_html(r#"

APOSIMZ

SIDONIA

"#); assert_eq!(md, "\ [APOSIMZ](http://ya.ru) [SIDONIA](http://yandex.ru)") } #[test] fn test_image() { let md = parse_html(r#"

Gitter
"#); assert_eq!(md, "[![Gitter](https://img.shields.io/gitter/room/MARC-FS/MARC-FS.svg)](https://gitter.im/MARC-FS/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)") } #[test] fn test_escaping() { let md = parse_html(r#"

*god*'s in his **heaven** - all is right with the __world__

"#); assert_eq!(md, "\\*god\\*\'s in his \\*\\*heaven\\*\\* - all is right with the \\_\\_world\\_\\_") } #[test] fn test_escaping_mid_hyphens() { let md = parse_html(r#"

This is a header with-hyphen!

"#); assert_eq!(md, "This is a header with-hyphen!\n==========") } #[test] fn test_escaping_start_hyphens() { let md = parse_html(r#"

- This is a header with starting hyphen!

"#); assert_eq!(md, "\\- This is a header with starting hyphen!\n==========") } #[test] fn test_escaping_start_sharp() { let md = parse_html("# nothing to worry about"); assert_eq!(md, "\\# nothing to worry about") } /// Note: Also strips multiple spaces #[test] fn test_escaping_start_hyphens_space() { let md = parse_html(r#"

- This is a header with starting hyphen!

"#); assert_eq!(md, " \\- This is a header with starting hyphen!\n==========") } #[test] fn test_escaping_html_tags() { let md = parse_html(r#"xxxxxxx xx xxxxxxxxxxx: <iframe src="xxxxxx_xx_xxxxxxxxxxx/embed/" allowfullscreen="" height="725" width="450"></iframe>"#); assert_eq!(md, r#"xxxxxxx xx xxxxxxxxxxx: \