Fix internal links involving README files resulting in 404 errors#3013
Open
CCJK123 wants to merge 2 commits intorust-lang:masterfrom
Open
Fix internal links involving README files resulting in 404 errors#3013CCJK123 wants to merge 2 commits intorust-lang:masterfrom
README files resulting in 404 errors#3013CCJK123 wants to merge 2 commits intorust-lang:masterfrom
Conversation
`README` files Previously, the `index` preprocessor only changed the file names of `README` to `index.md`, but did not modify internal links pointing to said files to point to the renamed file instead. This resulted in internal links to `README` files being broken and giving 404 errors. This commit rectifies this by using the `mdbook-markdown`/`pulldown-cmark` to find links within the book, and the `url` crate to filter out internal links to `README` files, which are then adjusted accordingly. Fixes rust-lang#984.
Author
|
Realised that this approach seems to be lossy due to the current way
Perhaps regex is still a viable approach, though it'll need to account for the various types of links. Tolerating some information loss is also an option. Otherwise, the issue will continue to be unresolved due to being blocked by Would appreciate input on how best to proceed, thanks! |
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.
Fixes #984.
Did my best to address the concerns mentioned in #1921, by opting to:
mdbook-markdown/pulldown-cmarkandurlcrates instead of regex to identify and correct the relevant links (comment advising against regex usage)indexpreprocessor instead offix_linkinmdbook-html(previouslyadjust_links) to maintain clear separation between the preprocessor and the rest of the codebase (comment mentioning this consideration)Also duplicated some code from
HtmlRenderOptionsto get the markdown options for creating a parser viamdbook-markdown, not sure whether this should be abstracted out elsewhere. The testcases I wrote just use the default options.Hopefully this sufficiently addresses the issue, but do lmk if there's any changes/improvements I shd make!