mirror of
https://github.com/rust-lang/mdBook
synced 2024-12-14 23:02:34 +00:00
(test) validate id from non ascii headings
This commit is contained in:
parent
48c97dadd0
commit
43b3d157d9
1 changed files with 30 additions and 7 deletions
|
@ -328,28 +328,51 @@ more text with spaces
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_generates_anchors() {
|
fn it_generates_anchors() {
|
||||||
assert_eq!(
|
|
||||||
id_from_content("## `--passes`: add more rustdoc passes"),
|
|
||||||
"a--passes-add-more-rustdoc-passes"
|
|
||||||
);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
id_from_content("## Method-call expressions"),
|
id_from_content("## Method-call expressions"),
|
||||||
"method-call-expressions"
|
"method-call-expressions"
|
||||||
);
|
);
|
||||||
|
assert_eq!(
|
||||||
|
id_from_content("## **Bold** title"),
|
||||||
|
"bold-title"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
id_from_content("## `Code` title"),
|
||||||
|
"code-title"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn it_generates_anchors_from_non_ascii_initial() {
|
||||||
|
assert_eq!(
|
||||||
|
id_from_content("## `--passes`: add more rustdoc passes"),
|
||||||
|
"--passes-add-more-rustdoc-passes"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
id_from_content("## 中文標題 CJK title"),
|
||||||
|
"中文標題-cjk-title"
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
id_from_content("## Über"),
|
||||||
|
"Über"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn it_normalizes_ids() {
|
fn it_normalizes_ids() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
normalize_id("`--passes`: add more rustdoc passes"),
|
normalize_id("`--passes`: add more rustdoc passes"),
|
||||||
"a--passes-add-more-rustdoc-passes"
|
"--passes-add-more-rustdoc-passes"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
normalize_id("Method-call 🐙 expressions \u{1f47c}"),
|
normalize_id("Method-call 🐙 expressions \u{1f47c}"),
|
||||||
"method-call--expressions-"
|
"method-call--expressions-"
|
||||||
);
|
);
|
||||||
assert_eq!(normalize_id("_-_12345"), "a_-_12345");
|
assert_eq!(normalize_id("_-_12345"), "_-_12345");
|
||||||
assert_eq!(normalize_id("12345"), "a12345");
|
assert_eq!(normalize_id("12345"), "12345");
|
||||||
|
assert_eq!(normalize_id("中文"), "中文");
|
||||||
|
assert_eq!(normalize_id("にほんご"), "にほんご");
|
||||||
|
assert_eq!(normalize_id("한국어"), "한국어");
|
||||||
assert_eq!(normalize_id(""), "");
|
assert_eq!(normalize_id(""), "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue