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

\n

d e f

"); assert_eq!("a b c\n\nd e f", result); } #[test] fn ending_space_is_trimmed() { let result = convert_string("a b c
\n
d e f"); assert_eq!("a b c\nd e f", result); } #[test] fn bold() { let result = convert_string("My little car."); assert_eq!("My **little** car.", result); let result = convert_string("My little car."); assert_eq!("My **little** car.", result); } #[test] fn emphasize() { let result = convert_string("My little car."); assert_eq!("My *little* car.", result); let result = convert_string("My little car."); assert_eq!("My *little* car.", result); } #[test] fn paragraph() { 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("

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); } #[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
quote should give \ double
lines
", ); assert_eq!( "> a nested >> quote should give double > lines\n", result ); let result = convert_string( "

And he said:

Quote me
and 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 text
which you \ can find in the quote
and 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 \"image\""); 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( "I AM HEADshould ignore \ head tag", ); assert_eq!("should ignore head tag", result); } #[test] fn unordered_list() { let expected = "Here's a list: * first * second Wasn't it good?"; let result = convert_string( "Here's a list: Wasn't it \ good?", ); assert_eq!(expected, result); let result = convert_string( "

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: Wasn't it good?", ); assert_eq!(expected, result); } #[test] fn ordered_list() { let expected = "Here's a list: 1. first 2. second Wasn't it good?"; let result = convert_string( "Here's a list:
  1. first
  2. second
Wasn't it \ good?", ); assert_eq!(expected, result); let result = convert_string( "

Here's a list:

  1. first
  2. second
\

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:
  1. A paragraph
    with two lines.

    With a blank line in between.


  2. second item
    with three\n

    lines
  3. as well as
    1. a nested
      list
    2. of two

    and the nested list ended
Wasn't it good?", ); assert_eq!(expected, result); } #[test] fn ordered_and_unordered_mixed() { let expected = "Here's a list: 1. A paragraph with two lines. With a blank line in between. 2. as well as * a nested list 1. Even more nested list 2. Inside of that * of two and the nested list ended 3. But then a third item followed Wasn't it good?"; let result = convert_string( "Here's a list:
  1. A paragraph
    with two lines.

    With a blank line in between.

  2. as well as and the nested list ended
  3. But then a third item followed
Wasn't it good?", ); assert_eq!(expected, result); }