@@ -944,9 +944,10 @@ fn preprocess_link(
944
944
// certain link kinds cannot have their path be urls,
945
945
// so they should not be ignored, no matter how much they look like urls.
946
946
// e.g. [https://example.com/] is not a link to example.com.
947
- let can_be_url = ori_link. kind != LinkType :: ShortcutUnknown
948
- && ori_link. kind != LinkType :: CollapsedUnknown
949
- && ori_link. kind != LinkType :: ReferenceUnknown ;
947
+ let can_be_url = !matches ! (
948
+ ori_link. kind,
949
+ LinkType :: ShortcutUnknown | LinkType :: CollapsedUnknown | LinkType :: ReferenceUnknown
950
+ ) ;
950
951
951
952
// [] is mostly likely not supposed to be a link
952
953
if ori_link. link . is_empty ( ) {
@@ -996,9 +997,25 @@ fn preprocess_link(
996
997
}
997
998
} ;
998
999
999
- // If there's no backticks, be lenient revert to old behavior.
1000
+ // If there's no backticks, be lenient and revert to the old behavior.
1000
1001
// This is to prevent churn by linting on stuff that isn't meant to be a link.
1001
- if ( can_be_url || !ori_link. link . contains ( '`' ) ) && should_ignore_link ( path_str) {
1002
+ // only shortcut links have simple enough syntax that they
1003
+ // are likely to be written accidentally, collapsed and reference links
1004
+ // need 4 metachars, and reference links will not usually use
1005
+ // backticks in the reference name.
1006
+ // therefore, only shortcut syntax gets the lenient behavior.
1007
+ //
1008
+ // here's a truth table for how link kinds that cannot be urls are handled:
1009
+ //
1010
+ // |-------------------------------------------------------|
1011
+ // | | is shortcut link | not shortcut link |
1012
+ // |--------------|--------------------|-------------------|
1013
+ // | has backtick | never ignore | never ignore |
1014
+ // | no backtick | ignore if url-like | never ignore |
1015
+ // |-------------------------------------------------------|
1016
+ let ignore_urllike =
1017
+ can_be_url || ( ori_link. kind == LinkType :: ShortcutUnknown && !ori_link. link . contains ( '`' ) ) ;
1018
+ if ignore_urllike && should_ignore_link ( path_str) {
1002
1019
return None ;
1003
1020
}
1004
1021
0 commit comments