mirror of
https://github.com/rust-lang-cn/book-cn.git
synced 2025-01-22 23:10:20 +08:00
Remove some more references to the authors field
This commit is contained in:
parent
3cbe20944a
commit
4c2ca525bc
@ -27,14 +27,18 @@ fn parse_references(buffer: String) -> (String, HashMap<String, String>) {
|
||||
// FIXME: currently doesn't handle "title" in following line.
|
||||
let re = Regex::new(r###"(?m)\n?^ {0,3}\[([^]]+)\]:[[:blank:]]*(.*)$"###)
|
||||
.unwrap();
|
||||
let output = re.replace_all(&buffer, |caps: &Captures<'_>| {
|
||||
let key = caps.get(1).unwrap().as_str().to_uppercase();
|
||||
let val = caps.get(2).unwrap().as_str().to_string();
|
||||
if ref_map.insert(key, val).is_some() {
|
||||
panic!("Did not expect markdown page to have duplicate reference");
|
||||
}
|
||||
"".to_string()
|
||||
}).to_string();
|
||||
let output = re
|
||||
.replace_all(&buffer, |caps: &Captures<'_>| {
|
||||
let key = caps.get(1).unwrap().as_str().to_uppercase();
|
||||
let val = caps.get(2).unwrap().as_str().to_string();
|
||||
if ref_map.insert(key, val).is_some() {
|
||||
panic!(
|
||||
"Did not expect markdown page to have duplicate reference"
|
||||
);
|
||||
}
|
||||
"".to_string()
|
||||
})
|
||||
.to_string();
|
||||
(output, ref_map)
|
||||
}
|
||||
|
||||
@ -196,8 +200,7 @@ more text"
|
||||
#[test]
|
||||
fn parses_name_with_utf8() {
|
||||
let source = r###"[user’s forum](the user’s forum)"###.to_string();
|
||||
let target =
|
||||
r###"user’s forum at *the user’s forum*"###.to_string();
|
||||
let target = r###"user’s forum at *the user’s forum*"###.to_string();
|
||||
assert_eq!(parse(source), target);
|
||||
}
|
||||
|
||||
@ -251,7 +254,6 @@ more text"
|
||||
[package]
|
||||
name = "hello_cargo"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
|
||||
[dependencies]
|
||||
```
|
||||
@ -284,7 +286,6 @@ is still here` link at *ref*"
|
||||
[package]
|
||||
name = "hello_cargo"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
|
||||
[dependencies]
|
||||
```
|
||||
@ -297,7 +298,6 @@ more text
|
||||
[package]
|
||||
name = "hello_cargo"
|
||||
version = "0.1.0"
|
||||
authors = ["Your Name <you@example.com>"]
|
||||
|
||||
[dependencies]
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user