-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
In one of my books, I'd like to distribute a copy of a PDF. To make sure the document in my book doesn't get out of sync with the original I'm using a symlink.
I'm on a windows computer, so I created the symlink with the following:
$ mklink "../../../Install Files/Documentation/some-document.pdf" "some-document.pdf"My directory structure looks something like this:
docs/book.tomlsrc/SUMMARY.mdoverview.mdsome-document.pdf->../../../Install Files/Documentation/some-document.pdf
Now when I run the build server mdbook serve --open go to http://localhost:3000/overview.html, and click the link to some-document.pdf it will serve up a zero byte file... Which is kinda not helpful.
I believe what's happened is the HTML renderer copied the symlink as-is, meaning the output directory now contains a broken symlink. Because the output directory is meant to be copied around and standalone, we should be copying the actual file contents to the output directory.
One solution would be for the HTML renderer to run std::fs::canonicalize() first when copying files across (e.g. to resolve any symlinks), probably in mdbook::utils::copy_files_except_ext(). I'm not sure how much code depends on this function though.