Remove some more references to the authors field

This commit is contained in:
Aaran Xu 2022-01-08 03:08:16 +08:00
parent 3cbe20944a
commit 4c2ca525bc

View File

@ -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###"[users forum](the users forum)"###.to_string();
let target =
r###"users forum at *the users forum*"###.to_string();
let target = r###"users forum at *the users 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]
```