Skip to content

Commit

Permalink
fix PageContent::title_links
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Nov 20, 2021
1 parent bfb38c6 commit 5c8c9b0
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 28 deletions.
23 changes: 0 additions & 23 deletions crates/application/src/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,26 +123,3 @@ pub fn is_obsoleted(
) -> bool {
obsoleted_map.get(page_id).is_some()
}

#[test]
fn cmark_test() {
let md = "
[inline](/titles/bouzuya)
[ref][ref]
[ref_unknown][ref_unknown]
[collapsed][]
[collapsed_unknown][]
[shortcut]
[shortcut_unknown]
</titles/%E3%81%BC%E3%81%86%E3%81%9A%E3%82%844>
[ref]: /titles/%E3%81%BC%E3%81%86%E3%81%9A%E3%82%841
[collapsed]: /titles/%E3%81%BC%E3%81%86%E3%81%9A%E3%82%842
[shortcut]: /titles/%E3%81%BC%E3%81%86%E3%81%9A%E3%82%843
";
let links = read_links_impl(md);
assert_eq!(
links,
vec!["bouzuya", "ぼうずや1", "ぼうずや2", "ぼうずや3"]
);
}
31 changes: 26 additions & 5 deletions crates/entity/src/entity/page_content.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,19 @@ mod tests {
"",
"[20210203T040506Z]",
"",
"[inline](/titles/bouzuya)",
"[ref][ref]",
"[ref_unknown][ref_unknown]",
"[collapsed][]",
"[collapsed_unknown][]",
"[shortcut]",
"[shortcut_unknown]",
"</titles/%E3%81%BC%E3%81%86%E3%81%9A%E3%82%844>",
"",
"[ref]: /titles/%E3%81%BC%E3%81%86%E3%81%9A%E3%82%841",
"[collapsed]: /titles/%E3%81%BC%E3%81%86%E3%81%9A%E3%82%842",
"[shortcut]: /titles/%E3%81%BC%E3%81%86%E3%81%9A%E3%82%843",
"",
"[title1]: /titles/title1",
"[title2]: /titles/title2",
"[title3]: /titles/title3",
Expand All @@ -251,11 +264,19 @@ mod tests {
);
assert_eq!(
page_content.title_links(),
vec!["title1", "title2", "title3"]
.iter()
.map(|s| s.to_string())
.map(PageTitle::from)
.collect::<Vec<PageTitle>>()
vec![
"title1",
"title2",
"title3",
"bouzuya",
"ぼうずや1",
"ぼうずや2",
"ぼうずや3"
]
.iter()
.map(|s| s.to_string())
.map(PageTitle::from)
.collect::<Vec<PageTitle>>()
);
}

Expand Down

0 comments on commit 5c8c9b0

Please sign in to comment.