Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow space in SUMMARY.md's link destination #1293

Merged
merged 2 commits into from
Aug 8, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
delete '+' replacement and use cargo fmt to format
  • Loading branch information
Evian-Zhang committed Aug 8, 2020
commit 9d5c454e47f03c61baf3856e4564c4cccf3d10b1
14 changes: 4 additions & 10 deletions src/book/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ impl<'a> SummaryParser<'a> {

/// Finishes parsing a link once the `Event::Start(Tag::Link(..))` has been opened.
fn parse_link(&mut self, href: String) -> Link {
let href = href.replace("%20", " ").replace("+", " ");
let href = href.replace("%20", " ");
let link_content = collect_events!(self.stream, end Tag::Link(..));
let name = stringify_events(link_content);

Expand Down Expand Up @@ -948,10 +948,10 @@ mod tests {

assert_eq!(got, should_be);
}

#[test]
fn allow_space_in_link_destination() {
let src = "- [test1](./test%20link1.md)\n- [test2](./test+link2.md)\n- [test3](<./test link3.md>)";
let src = "- [test1](./test%20link1.md)\n- [test2](<./test link2.md>)";
let should_be = vec![
SummaryItem::Link(Link {
name: String::from("test1"),
Expand All @@ -965,18 +965,12 @@ mod tests {
number: Some(SectionNumber(vec![2])),
nested_items: Vec::new(),
}),
SummaryItem::Link(Link {
name: String::from("test3"),
location: Some(PathBuf::from("./test link3.md")),
number: Some(SectionNumber(vec![3])),
nested_items: Vec::new(),
}),
];
let mut parser = SummaryParser::new(src);
let got = parser
.parse_numbered(&mut 0, &mut SectionNumber::default())
.unwrap();

assert_eq!(got, should_be);
}
}