Correctly handle if a link starts with a whitespace
This commit is contained in:
parent
9a7cc6c32f
commit
fd62036caa
2 changed files with 4 additions and 2 deletions
|
@ -340,6 +340,7 @@ pub fn inner_docs(attrs: &[ast::Attribute]) -> bool {
|
|||
fn preprocess_link(link: &str) -> String {
|
||||
let link = link.replace('`', "");
|
||||
let link = link.split('#').next().unwrap();
|
||||
let link = link.trim();
|
||||
let link = link.rsplit('@').next().unwrap();
|
||||
let link = link.strip_suffix("()").unwrap_or(link);
|
||||
let link = link.strip_suffix("{}").unwrap_or(link);
|
||||
|
|
|
@ -884,7 +884,8 @@ fn preprocess_link(
|
|||
let mut parts = stripped.split('#');
|
||||
|
||||
let link = parts.next().unwrap();
|
||||
if link.trim().is_empty() {
|
||||
let link = link.trim();
|
||||
if link.is_empty() {
|
||||
// This is an anchor to an element of the current page, nothing to do in here!
|
||||
return None;
|
||||
}
|
||||
|
@ -897,7 +898,7 @@ fn preprocess_link(
|
|||
// Parse and strip the disambiguator from the link, if present.
|
||||
let (disambiguator, path_str, link_text) = match Disambiguator::from_str(link) {
|
||||
Ok(Some((d, path, link_text))) => (Some(d), path.trim(), link_text.trim()),
|
||||
Ok(None) => (None, link.trim(), link.trim()),
|
||||
Ok(None) => (None, link, link),
|
||||
Err((err_msg, relative_range)) => {
|
||||
// Only report error if we would not have ignored this link. See issue #83859.
|
||||
if !should_ignore_link_with_disambiguators(link) {
|
||||
|
|
Loading…
Add table
Reference in a new issue