use markdown2pdf::markdown::*;
use super::common::parse;
fn link_url_of(input: &str) -> String {
let tokens = parse(input);
let Some(Token::Link { url, .. }) = tokens.iter().find(|t| matches!(t, Token::Link { .. }))
else {
panic!("expected a link in {:?}", tokens);
};
url.clone()
}
#[test]
fn ascii_case_fold() {
assert_eq!(link_url_of("[FOO]\n\n[foo]: /a\n"), "/a");
assert_eq!(link_url_of("[foo]\n\n[FOO]: /a\n"), "/a");
}
#[test]
fn internal_whitespace_collapsed() {
assert_eq!(link_url_of("[foo bar]\n\n[foo bar]: /a\n"), "/a");
}
#[test]
fn leading_trailing_whitespace_trimmed_via_collapse() {
assert_eq!(link_url_of("[ foo ]\n\n[foo]: /a\n"), "/a");
}
#[test]
fn tab_folds_to_single_space() {
assert_eq!(link_url_of("[a\tb]\n\n[a b]: /a\n"), "/a");
}
#[test]
fn newline_folds_to_single_space() {
assert_eq!(link_url_of("[a\nb]\n\n[a b]: /a\n"), "/a");
}
#[test]
fn sharp_s_folds_to_ss() {
assert_eq!(link_url_of("[Straße]\n\n[strasse]: /a\n"), "/a");
}
#[test]
fn capital_sharp_s_folds_to_ss() {
assert_eq!(link_url_of("[GROẞ]\n\n[gross]: /a\n"), "/a");
}
#[test]
fn cjk_left_alone() {
assert_eq!(link_url_of("[日本語]\n\n[日本語]: /a\n"), "/a");
}
#[test]
fn mixed_case_with_unicode_punctuation() {
assert_eq!(link_url_of("[Hello, World!]\n\n[hello, world!]: /a\n"), "/a");
}
#[test]
fn label_with_only_internal_spacing_difference() {
assert_eq!(link_url_of("[a b c]\n\n[a b c]: /a\n"), "/a");
}