Skip to content

Commit 7d77edb

Browse files
committed
links.php: TAdd a TODO about badges, and fragment search
1 parent 0fe6da3 commit 7d77edb

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

tools/links/links.config.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@ function (string $url, string $location, string $file = null): bool {
113113
},
114114
],
115115
'fragment' => [
116-
function (string $url, string $file = null): bool {
116+
/*function (string $url, string $file = null): bool {
117117
return str_ends_with($file, '.md') && (
118118
// ## Commerce [[% include 'snippets/commerce_badge.md' %]]
119119
str_ends_with($url, '/permission_use_cases.md#commerce')
120120
// ### Ensure proper Captcha behavior [[% include 'snippets/experience_badge.md' %]] [[% include 'snippets/commerce_badge.md' %]]
121121
|| str_ends_with($url, '/reverse_proxy.md#ensure-proper-captcha-behavior')
122122
);
123-
},
123+
},*/
124124
function (string $url, string $file = null): bool {
125125
return str_starts_with($url, 'https://classic.yarnpkg.com/en/docs/')
126126
|| str_starts_with($url, 'https://ddev.readthedocs.io/');

tools/links/links.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,11 @@ public static function testUrl(string $url, bool $external = null, bool $testFra
316316
$fragmentFound = $contents && 1 === preg_match("@(id|name)=\"$fragment\"@", $contents);
317317
if (!$fragmentFound && !self::isExternalUrl($url)) {
318318
if ('md' === pathinfo(TestableUrl::getUrlWithoutFragment($url), PATHINFO_EXTENSION)) {
319-
$pattern = '@^#+\W*' . str_replace('-', '\W+', $fragment) . '\W*$@mi';
319+
//TODO: MarkDown fragment search pattern should be a config.
320+
//$pattern = '@^#+\W*' . str_replace('-', '\W+', $fragment) . '\W*$@mi';
321+
$pattern = '@^#+\W*' . str_replace('-', '\W+', $fragment) . '\W*( \[\[% include \'.+_badge.md\' %\]\])*$@mi';
320322
$fragmentFound = (bool)preg_match($pattern, $contents);
323+
//TODO: Alternatively, Markdown headers could extracted, converted to anchors, and then compared
321324
}
322325
}
323326
}

0 commit comments

Comments
 (0)