Skip to content

Commit cea98f9

Browse files
committed
Modify index preprocessor to also fix internal links pointing to
`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 #984.
1 parent dc151e1 commit cea98f9

File tree

4 files changed

+416
-1
lines changed

4 files changed

+416
-1
lines changed

Cargo.lock

Lines changed: 258 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ topological-sort = "0.2.2"
6868
tower-http = "0.6.8"
6969
tracing = "0.1.44"
7070
tracing-subscriber = { version = "0.3.22", features = ["env-filter"] }
71+
url = "2.5.8"
7172
walkdir = "2.5.0"
7273

7374
[package]

crates/mdbook-driver/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ mdbook-markdown.workspace = true
1616
mdbook-preprocessor.workspace = true
1717
mdbook-renderer.workspace = true
1818
mdbook-summary.workspace = true
19+
pulldown-cmark-to-cmark.workspace = true
1920
regex.workspace = true
2021
serde.workspace = true
2122
serde_json.workspace = true
@@ -24,6 +25,7 @@ tempfile.workspace = true
2425
toml.workspace = true
2526
topological-sort.workspace = true
2627
tracing.workspace = true
28+
url.workspace = true
2729

2830
[lints]
2931
workspace = true

0 commit comments

Comments
 (0)