improve link detection logic slightly
This commit is contained in:
parent
df2613d083
commit
57acbc62c3
1 changed files with 5 additions and 4 deletions
|
@ -215,11 +215,12 @@ fn preprocess(string: String) -> String {
|
||||||
let result_vec = Vec::from(result.as_str());
|
let result_vec = Vec::from(result.as_str());
|
||||||
let start_delims = vec![b'(', b'<'];
|
let start_delims = vec![b'(', b'<'];
|
||||||
let end_delims = vec![b')', b'>'];
|
let end_delims = vec![b')', b'>'];
|
||||||
let links = finder.links(result.as_str()).filter(|link| {
|
|
||||||
// link.end() is the first char AFTER the link!
|
// link.end() is the first char AFTER the link!
|
||||||
(link.start() == 0 || link.end() == result.len())
|
let links = finder.links(result.as_str()).filter(|link| {
|
||||||
|| (!start_delims.contains(&result_vec[link.start() - 1])
|
link.start() == 0
|
||||||
&& !end_delims.contains(&result_vec[link.end()]))
|
|| link.end() == result.len()
|
||||||
|
|| !start_delims.contains(&result_vec[link.start() - 1])
|
||||||
|
|| !end_delims.contains(&result_vec[link.end()])
|
||||||
});
|
});
|
||||||
|
|
||||||
let mut offset = 0;
|
let mut offset = 0;
|
||||||
|
|
Loading…
Reference in a new issue