Fix naive handling of relative links when proofing#75
Merged
manuzhang merged 1 commit intomanuzhang:mainfrom Feb 27, 2024
Merged
Fix naive handling of relative links when proofing#75manuzhang merged 1 commit intomanuzhang:mainfrom
manuzhang merged 1 commit intomanuzhang:mainfrom
Conversation
6b1e373 to
bb16cc7
Compare
bb16cc7 to
ba6b4f2
Compare
Contributor
Author
|
There appears to be a bit more than needs to be done to this. It works on our site, but not the integration tests. Will look into. |
This commit fixes naive handling of relative links when proofing. The problem here was the assumption that a relative link of foo.html that was coming from a file at bar/fubar.md in the filesystem would always appear at bar/foo.html. That is not always true. If directory_urls was on, then it wasn't true. Thus, manuzhang#46. It was also not true when using relative links between blog posts when using the mkdocs material blog plugin. This commit changes the relative url lookup logic to be more robust and in the process make the proofer work with both the mkdocs material blog plugin and with directory_urls on. It does this by storing additional information in the lookup files that we use to find information about pages. We can now look up a file by its src_uri entry, for example blog/posts/index.md and then use that to get the dest_uri like blog/12/10/some-post/ and then use that dest_uri value to robustly handle figuring out where a relative link is pointing. Closes manuzhang#46 Closes manuzhang#70
ba6b4f2 to
e58fc13
Compare
SeanTAllen
commented
Feb 27, 2024
|
|
||
| ## Image Link absolute/relative | ||
|
|
||
| <a href="../assets/hello-world.drawio.svg"></a> |
Contributor
Author
There was a problem hiding this comment.
This needed to be changed as it isn't a valid test with directory urls on. mkdocs won't change the link in the raw href to be correct. only those in markdown.
SeanTAllen
commented
Feb 27, 2024
| * [Main Page](../index.md) | ||
| * [Sub-Page](./page2.md) | ||
| * <figure markdown> | ||
| <a href="../assets/hello-world.drawio.svg"> |
Contributor
Author
There was a problem hiding this comment.
This needed to be changed as it isn't a valid test with directory urls on. mkdocs won't change the link in the raw href to be correct. only those in markdown.
manuzhang
approved these changes
Feb 27, 2024
Owner
|
LGTM. Merged. Nice work! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This commit fixes naive handling of relative links when proofing. The problem here was the assumption that a relative link of
foo.htmlthat was coming from a file atbar/fubar.mdin the filesystem would always appear atbar/foo.html.That is not always true. If directory_urls was on, then it wasn't true. Thus, #46.
It was also not true when using relative links between blog posts when using the mkdocs material blog plugin.
This commit changes the relative url lookup logic to be more robust and in the process make the proofer work with both the mkdocs material blog plugin and with directory_urls on.
It does this by storing additional information in the lookup files that we use to find information about pages. We can now look up a file by its src_uri entry, for example
blog/posts/index.mdand then use that to get thedest_urilikeblog/12/10/some-post/and then use thatdest_urivalue to robustly handle figuring out where a relative link is pointing.Closes #46
Closes #70