Closed SeanTAllen closed 8 months ago
@manuzhang should the linting errors be fixed as part of this PR?
Yes, please fix it
@manuzhang this particular implementation apparently has an issue with windows. I'm guessing that is a path separator issue. I'll look at it later.
I think I know what the windows issue is. Testing that out now.
@manuzhang all set. with the optimization, all the old tests continued to work unchanged. It ends up being a better change.
I tested this locally as well with a site that uses the blog as an extra level of verification.
Prior to this commit, certain assumptions were made about the files seen in
on_files
that are not true when the mkdocs-material blog plugin is used.The url seen at the time
on_files
is called is not guaranteed to be the final url that will appear in html. With the blog plugin, at the timeon_files
is called, the value will be something like:blog/posts/foo.md
but at the time we are trying to get a mapping, the url will be something like:
blog/2024/01/foo.html
Due to this change, htmlproofer would fail to validate the url despite it being valid.
To address this, instead of looking up pages from a Dict where the key is set at the time of
on_files
, we know store a list of Files and check for thesearch_path
for a url against theurl
attribute of each File to try to find the mapping.