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.
|
// FIXME: currently doesn't handle "title" in following line.
|
||||||
let re = Regex::new(r###"(?m)\n?^ {0,3}\[([^]]+)\]:[[:blank:]]*(.*)$"###)
|
let re = Regex::new(r###"(?m)\n?^ {0,3}\[([^]]+)\]:[[:blank:]]*(.*)$"###)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let output = re.replace_all(&buffer, |caps: &Captures<'_>| {
|
let output = re
|
||||||
let key = caps.get(1).unwrap().as_str().to_uppercase();
|
.replace_all(&buffer, |caps: &Captures<'_>| {
|
||||||
let val = caps.get(2).unwrap().as_str().to_string();
|
let key = caps.get(1).unwrap().as_str().to_uppercase();
|
||||||
if ref_map.insert(key, val).is_some() {
|
let val = caps.get(2).unwrap().as_str().to_string();
|
||||||
panic!("Did not expect markdown page to have duplicate reference");
|
if ref_map.insert(key, val).is_some() {
|
||||||
}
|
panic!(
|
||||||
"".to_string()
|
"Did not expect markdown page to have duplicate reference"
|
||||||
}).to_string();
|
);
|
||||||
|
}
|
||||||
|
"".to_string()
|
||||||
|
})
|
||||||
|
.to_string();
|
||||||
(output, ref_map)
|
(output, ref_map)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,8 +200,7 @@ more text"
|
|||||||
#[test]
|
#[test]
|
||||||
fn parses_name_with_utf8() {
|
fn parses_name_with_utf8() {
|
||||||
let source = r###"[user’s forum](the user’s forum)"###.to_string();
|
let source = r###"[user’s forum](the user’s forum)"###.to_string();
|
||||||
let target =
|
let target = r###"user’s forum at *the user’s forum*"###.to_string();
|
||||||
r###"user’s forum at *the user’s forum*"###.to_string();
|
|
||||||
assert_eq!(parse(source), target);
|
assert_eq!(parse(source), target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,7 +254,6 @@ more text"
|
|||||||
[package]
|
[package]
|
||||||
name = "hello_cargo"
|
name = "hello_cargo"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Your Name <you@example.com>"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
```
|
```
|
||||||
@ -284,7 +286,6 @@ is still here` link at *ref*"
|
|||||||
[package]
|
[package]
|
||||||
name = "hello_cargo"
|
name = "hello_cargo"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Your Name <you@example.com>"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
```
|
```
|
||||||
@ -297,7 +298,6 @@ more text
|
|||||||
[package]
|
[package]
|
||||||
name = "hello_cargo"
|
name = "hello_cargo"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Your Name <you@example.com>"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user