mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-13 05:38:46 +00:00
Fix: correct markdown link form.
This commit is contained in:
parent
097d527cbd
commit
74396d27c0
2 changed files with 11 additions and 3 deletions
|
@ -1290,6 +1290,8 @@ mod tests {
|
||||||
schema.push_str(",\n");
|
schema.push_str(",\n");
|
||||||
|
|
||||||
// Transform the asciidoc form link to markdown style.
|
// Transform the asciidoc form link to markdown style.
|
||||||
|
//
|
||||||
|
// https://link[text] => [text](https://link)
|
||||||
let url_matches = schema.match_indices("https://");
|
let url_matches = schema.match_indices("https://");
|
||||||
let mut url_offsets = url_matches.map(|(idx, _)| idx).collect::<Vec<usize>>();
|
let mut url_offsets = url_matches.map(|(idx, _)| idx).collect::<Vec<usize>>();
|
||||||
url_offsets.reverse();
|
url_offsets.reverse();
|
||||||
|
@ -1298,8 +1300,14 @@ mod tests {
|
||||||
// matching on whitespace to ignore normal links
|
// matching on whitespace to ignore normal links
|
||||||
if let Some(link_end) = link.find(|c| c == ' ' || c == '[') {
|
if let Some(link_end) = link.find(|c| c == ' ' || c == '[') {
|
||||||
if link.chars().nth(link_end) == Some('[') {
|
if link.chars().nth(link_end) == Some('[') {
|
||||||
schema.insert(idx, '(');
|
if let Some(link_text_end) = link.find(']') {
|
||||||
schema.insert(idx + link_end + 1, ')');
|
let link_text = link[link_end..(link_text_end + 1)].to_string();
|
||||||
|
|
||||||
|
schema.replace_range((idx + link_end)..(idx + link_text_end + 1), "");
|
||||||
|
schema.insert(idx, '(');
|
||||||
|
schema.insert(idx + link_end + 1, ')');
|
||||||
|
schema.insert_str(idx, &link_text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -436,7 +436,7 @@
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"rust-analyzer.assist.importGroup": {
|
"rust-analyzer.assist.importGroup": {
|
||||||
"markdownDescription": "Group inserted imports by the (https://rust-analyzer.github.io/manual.html#auto-import)[following order]. Groups are separated by newlines.",
|
"markdownDescription": "Group inserted imports by the [following order](https://rust-analyzer.github.io/manual.html#auto-import). Groups are separated by newlines.",
|
||||||
"default": true,
|
"default": true,
|
||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue