Open theunrepentantgeek opened 1 year ago
@theunrepentantgeek Nice, thanks for the PR. Will take a look at this
Hi @wjdp! I hate comment-bumping, but I was wondering if you had a chance to take a look at this PR. I just encountered a need for this.
@wjdp Is there anything I can do (as the PR author) to make this easier for you to review and merge?
And while I'm here - many thanks for htmltest. I know that often it's a thankless job doing the hard work maintaining an open source tool, and that it can be difficult to find the time it deserves. So, once again, thanks.
All our documentation for the Azure Service Operator project gets published into the subfolder
azure-service-operator
and we'd like to usehtmltest
to catch our broken links.This PR adds support for this scenario, allowing verification of websites that aren't published to the root of a server.
New configuration
BaseURL
allows specifying the final URL to which the site will be published.Any trailing folder that is a part of this URL will be trimmed from absolute URLs before checking to see if the file exists. For example, given
BaseURL: http://www.example.com/blog
, an absolute reference to/blog/post/2023-05-24.html
will have/blog/
trimmed from the start, leaving the filepathpost/2023-05-24.html
for testing.New configuration
CheckSelfReferencesAsInternal
(default:false
) allows checking of self-external references as though they are internal.If you have
BaseURL: http://www.example.com/blog
and a reference tohttp://www.example.com/blog/post/2023-05-24.html
, instead of failing as a broken link (since the file hasn't yet been published), it will now be converted into the internal reference/blog/post/2023-05-24.html
and checked.Full tests are included.
Closes #45 Closes #47 Closes #184
Some background: We've previously been using different tools to try and verify our markdown prior to rendering by Hugo, but we've had multiple issues with broken links making it through to our live website.