extern crate html2runes; use html2runes::markdown::*; #[test] fn plaintext() { let result = convert_string("My little car."); assert_eq!("My little car.", result); } #[test] fn newlines_are_ignored() { let result = convert_string( "My little car.", ); assert_eq!("My little car.", result); } #[test] fn lines_with_empty_spaces_are_killed() { let result = convert_string("
a b c
\nd e f
"); assert_eq!("a b c\n\nd e f", result); } #[test] fn ending_space_is_trimmed() { let result = convert_string("a b cA piece of text
Another piece
"); assert_eq!("A piece of text\n\nAnother piece", result); let result = convert_string( "A piece of text
Another piece
", ); assert_eq!("A piece of text\n\nAnother piece", result); let result = convert_string("A piece of text
Another piece"); assert_eq!("A piece of text\n\nAnother piece", result); let result = convert_string("
Another piece");
assert_eq!("A piece of text\n\nAnother piece", result);
}
#[test]
fn newline() {
let result = convert_string("one
two
three
four");
assert_eq!("one\ntwo\nthree\nfour", result);
let result = convert_string("one
two");
assert_eq!("one\ntwo", result);
let result = convert_string("
none");
assert_eq!("none", result);
}
#[test]
fn blockquote() {
let result = convert_string("
just a quote"); assert_eq!("> just a quote\n", result); let result = convert_string( "
a nested", ); assert_eq!( "> a nested >> quote should give double > lines\n", result ); let result = convert_string( "quote should give \ doublelines
And he said:
Quote meand all was \ good.", ); assert_eq!( "And he said: > Quote me and all was good.", result ); let result = convert_string( "And he said:
A long long piece of textand all was good.", ); assert_eq!( "And he said: > A long long piece of text > which you can find in the quote and all was good.", result ); } #[test] fn link() { let result = convert_string("here is a link to google"); assert_eq!("here is a [link](http://google.com) to google", result); } #[test] fn image() { let result = convert_string("here is an "); assert_eq!("here is an ![image](bla.png)", result); } #[test] fn ignoring_styles() { let result = convert_string("should ignore style tag"); assert_eq!("should ignore style tag", result); } #[test] fn ignoring_scripts() { let result = convert_string("should ignore script tag"); assert_eq!("should ignore script tag", result); } #[test] fn ignoring_head() { let result = convert_string( "
which you \ can find in the quote
Here's a list:
Wasn't it good?
", ); assert_eq!(expected, result); } #[test] fn unordered_more_complex_list() { let expected = "Here's a list: * A paragraph with two lines. With a blank line in between. * second item with three lines * as well as * a nested list * of two and the nested list ended Wasn't it good?"; let result = convert_string( "Here's a list:A paragraph
with two lines.
With a blank line in between.
of two
Here's a list:
Wasn't it good?
", ); assert_eq!(expected, result); } #[test] fn ordered_more_complex_list() { let expected = "Here's a list: 1. A paragraph with two lines. With a blank line in between. 2. second item with three lines 3. as well as 1. a nested list 2. of two and the nested list ended Wasn't it good?"; let result = convert_string( "Here's a list:A paragraph
with two lines.
With a blank line in between.
of two
A paragraph
with two lines.
With a blank line in between.
of two