extern crate rhtml2md; use rhtml2md::parse_html; use pretty_assertions::assert_eq; #[test] fn test_tables() { let md = parse_html(r#"
Minor1 Minor2 Minor3 Minor4
col1 col2 col3 col4
"#); assert_eq!(md, "\ |Minor1|Minor2|Minor3|Minor4| |------|------|------|------| | col1 | col2 | col3 | col4 |"); } #[test] fn test_tables_invalid_more_headers() { let md = parse_html(r#"
Minor1 Minor2 Minor3 Minor4 Minor5 Minor6
col1 col2 col3 col4
"#); assert_eq!(md, "\ |Minor1|Minor2|Minor3|Minor4|Minor5|Minor6| |------|------|------|------|------|------| | col1 | col2 | col3 | col4 | | |"); } #[test] fn test_tables_invalid_more_rows() { let md = parse_html(r#"
Minor1 Minor2
col1 col2 col3 col4
"#); assert_eq!(md, "\ |Minor1|Minor2| | | |------|------|----|----| | col1 | col2 |col3|col4|"); } #[test] fn test_tables_odd_column_width() { let md = parse_html(r#"
Minor Major
col1 col2
"#); assert_eq!(md, "\ |Minor|Major| |-----|-----| |col1 |col2 |"); } #[test] fn test_tables_alignment() { let md = parse_html(r#"
Minor1 Minor2 Minor3 Minor4
col1 col2 col3 col4
"#); assert_eq!(md, "\ |Minor1|Minor2|Minor3|Minor4| |-----:|:----:|-----:|:-----| | col1 | col2 | col3 | col4 |"); } #[test] fn test_tables_wild_example() { let md = parse_html(r#"
One ring
Patterns
Titanic



One ring to rule them all
There's one for the sorrow
Roll on, Titanic, roll



One ring to find them
And two for the joy
You're the pride of White Star Line



One ring to bring them all
And three for the girls
Roll on, Titanic, roll



And in the darkness bind them
And four for the boys
Into the mists of time



"#); assert_eq!(md, "\ | One ring | Patterns | Titanic | | | | |-----------------------------|--------------------------|-----------------------------------|---|---|---| | One ring to rule them all |There's one for the sorrow| Roll on, Titanic, roll | | | | | One ring to find them | And two for the joy |You're the pride of White Star Line| | | | | One ring to bring them all | And three for the girls | Roll on, Titanic, roll | | | | |And in the darkness bind them| And four for the boys | Into the mists of time | | | |"); }